documentation.d.ts 3.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675
  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. /**
  6067. * Gets the byte stride.
  6068. */
  6069. readonly byteStride: number;
  6070. /**
  6071. * Constructor
  6072. * @param engine the engine
  6073. * @param data the data to use for this buffer
  6074. * @param updatable whether the data is updatable
  6075. * @param stride the stride (optional)
  6076. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6077. * @param instanced whether the buffer is instanced (optional)
  6078. * @param useBytes set to true if the stride in in bytes (optional)
  6079. */
  6080. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6081. /**
  6082. * Create a new VertexBuffer based on the current buffer
  6083. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6084. * @param offset defines offset in the buffer (0 by default)
  6085. * @param size defines the size in floats of attributes (position is 3 for instance)
  6086. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6087. * @param instanced defines if the vertex buffer contains indexed data
  6088. * @param useBytes defines if the offset and stride are in bytes
  6089. * @returns the new vertex buffer
  6090. */
  6091. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6092. /**
  6093. * Gets a boolean indicating if the Buffer is updatable?
  6094. * @returns true if the buffer is updatable
  6095. */
  6096. isUpdatable(): boolean;
  6097. /**
  6098. * Gets current buffer's data
  6099. * @returns a DataArray or null
  6100. */
  6101. getData(): Nullable<DataArray>;
  6102. /**
  6103. * Gets underlying native buffer
  6104. * @returns underlying native buffer
  6105. */
  6106. getBuffer(): Nullable<DataBuffer>;
  6107. /**
  6108. * Gets the stride in float32 units (i.e. byte stride / 4).
  6109. * May not be an integer if the byte stride is not divisible by 4.
  6110. * DEPRECATED. Use byteStride instead.
  6111. * @returns the stride in float32 units
  6112. */
  6113. getStrideSize(): number;
  6114. /**
  6115. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6116. * @param data defines the data to store
  6117. */
  6118. create(data?: Nullable<DataArray>): void;
  6119. /** @hidden */
  6120. _rebuild(): void;
  6121. /**
  6122. * Update current buffer data
  6123. * @param data defines the data to store
  6124. */
  6125. update(data: DataArray): void;
  6126. /**
  6127. * Updates the data directly.
  6128. * @param data the new data
  6129. * @param offset the new offset
  6130. * @param vertexCount the vertex count (optional)
  6131. * @param useBytes set to true if the offset is in bytes
  6132. */
  6133. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6134. /**
  6135. * Release all resources
  6136. */
  6137. dispose(): void;
  6138. }
  6139. /**
  6140. * Specialized buffer used to store vertex data
  6141. */
  6142. export class VertexBuffer {
  6143. /** @hidden */
  6144. _buffer: Buffer;
  6145. private _kind;
  6146. private _size;
  6147. private _ownsBuffer;
  6148. private _instanced;
  6149. private _instanceDivisor;
  6150. /**
  6151. * The byte type.
  6152. */
  6153. static readonly BYTE: number;
  6154. /**
  6155. * The unsigned byte type.
  6156. */
  6157. static readonly UNSIGNED_BYTE: number;
  6158. /**
  6159. * The short type.
  6160. */
  6161. static readonly SHORT: number;
  6162. /**
  6163. * The unsigned short type.
  6164. */
  6165. static readonly UNSIGNED_SHORT: number;
  6166. /**
  6167. * The integer type.
  6168. */
  6169. static readonly INT: number;
  6170. /**
  6171. * The unsigned integer type.
  6172. */
  6173. static readonly UNSIGNED_INT: number;
  6174. /**
  6175. * The float type.
  6176. */
  6177. static readonly FLOAT: number;
  6178. /**
  6179. * Gets or sets the instance divisor when in instanced mode
  6180. */
  6181. instanceDivisor: number;
  6182. /**
  6183. * Gets the byte stride.
  6184. */
  6185. readonly byteStride: number;
  6186. /**
  6187. * Gets the byte offset.
  6188. */
  6189. readonly byteOffset: number;
  6190. /**
  6191. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6192. */
  6193. readonly normalized: boolean;
  6194. /**
  6195. * Gets the data type of each component in the array.
  6196. */
  6197. readonly type: number;
  6198. /**
  6199. * Constructor
  6200. * @param engine the engine
  6201. * @param data the data to use for this vertex buffer
  6202. * @param kind the vertex buffer kind
  6203. * @param updatable whether the data is updatable
  6204. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6205. * @param stride the stride (optional)
  6206. * @param instanced whether the buffer is instanced (optional)
  6207. * @param offset the offset of the data (optional)
  6208. * @param size the number of components (optional)
  6209. * @param type the type of the component (optional)
  6210. * @param normalized whether the data contains normalized data (optional)
  6211. * @param useBytes set to true if stride and offset are in bytes (optional)
  6212. */
  6213. 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);
  6214. /** @hidden */
  6215. _rebuild(): void;
  6216. /**
  6217. * Returns the kind of the VertexBuffer (string)
  6218. * @returns a string
  6219. */
  6220. getKind(): string;
  6221. /**
  6222. * Gets a boolean indicating if the VertexBuffer is updatable?
  6223. * @returns true if the buffer is updatable
  6224. */
  6225. isUpdatable(): boolean;
  6226. /**
  6227. * Gets current buffer's data
  6228. * @returns a DataArray or null
  6229. */
  6230. getData(): Nullable<DataArray>;
  6231. /**
  6232. * Gets underlying native buffer
  6233. * @returns underlying native buffer
  6234. */
  6235. getBuffer(): Nullable<DataBuffer>;
  6236. /**
  6237. * Gets the stride in float32 units (i.e. byte stride / 4).
  6238. * May not be an integer if the byte stride is not divisible by 4.
  6239. * DEPRECATED. Use byteStride instead.
  6240. * @returns the stride in float32 units
  6241. */
  6242. getStrideSize(): number;
  6243. /**
  6244. * Returns the offset as a multiple of the type byte length.
  6245. * DEPRECATED. Use byteOffset instead.
  6246. * @returns the offset in bytes
  6247. */
  6248. getOffset(): number;
  6249. /**
  6250. * Returns the number of components per vertex attribute (integer)
  6251. * @returns the size in float
  6252. */
  6253. getSize(): number;
  6254. /**
  6255. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6256. * @returns true if this buffer is instanced
  6257. */
  6258. getIsInstanced(): boolean;
  6259. /**
  6260. * Returns the instancing divisor, zero for non-instanced (integer).
  6261. * @returns a number
  6262. */
  6263. getInstanceDivisor(): number;
  6264. /**
  6265. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6266. * @param data defines the data to store
  6267. */
  6268. create(data?: DataArray): void;
  6269. /**
  6270. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6271. * This function will create a new buffer if the current one is not updatable
  6272. * @param data defines the data to store
  6273. */
  6274. update(data: DataArray): void;
  6275. /**
  6276. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6277. * Returns the directly updated WebGLBuffer.
  6278. * @param data the new data
  6279. * @param offset the new offset
  6280. * @param useBytes set to true if the offset is in bytes
  6281. */
  6282. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6283. /**
  6284. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6285. */
  6286. dispose(): void;
  6287. /**
  6288. * Enumerates each value of this vertex buffer as numbers.
  6289. * @param count the number of values to enumerate
  6290. * @param callback the callback function called for each value
  6291. */
  6292. forEach(count: number, callback: (value: number, index: number) => void): void;
  6293. /**
  6294. * Positions
  6295. */
  6296. static readonly PositionKind: string;
  6297. /**
  6298. * Normals
  6299. */
  6300. static readonly NormalKind: string;
  6301. /**
  6302. * Tangents
  6303. */
  6304. static readonly TangentKind: string;
  6305. /**
  6306. * Texture coordinates
  6307. */
  6308. static readonly UVKind: string;
  6309. /**
  6310. * Texture coordinates 2
  6311. */
  6312. static readonly UV2Kind: string;
  6313. /**
  6314. * Texture coordinates 3
  6315. */
  6316. static readonly UV3Kind: string;
  6317. /**
  6318. * Texture coordinates 4
  6319. */
  6320. static readonly UV4Kind: string;
  6321. /**
  6322. * Texture coordinates 5
  6323. */
  6324. static readonly UV5Kind: string;
  6325. /**
  6326. * Texture coordinates 6
  6327. */
  6328. static readonly UV6Kind: string;
  6329. /**
  6330. * Colors
  6331. */
  6332. static readonly ColorKind: string;
  6333. /**
  6334. * Matrix indices (for bones)
  6335. */
  6336. static readonly MatricesIndicesKind: string;
  6337. /**
  6338. * Matrix weights (for bones)
  6339. */
  6340. static readonly MatricesWeightsKind: string;
  6341. /**
  6342. * Additional matrix indices (for bones)
  6343. */
  6344. static readonly MatricesIndicesExtraKind: string;
  6345. /**
  6346. * Additional matrix weights (for bones)
  6347. */
  6348. static readonly MatricesWeightsExtraKind: string;
  6349. /**
  6350. * Deduces the stride given a kind.
  6351. * @param kind The kind string to deduce
  6352. * @returns The deduced stride
  6353. */
  6354. static DeduceStride(kind: string): number;
  6355. /**
  6356. * Gets the byte length of the given type.
  6357. * @param type the type
  6358. * @returns the number of bytes
  6359. */
  6360. static GetTypeByteLength(type: number): number;
  6361. /**
  6362. * Enumerates each value of the given parameters as numbers.
  6363. * @param data the data to enumerate
  6364. * @param byteOffset the byte offset of the data
  6365. * @param byteStride the byte stride of the data
  6366. * @param componentCount the number of components per element
  6367. * @param componentType the type of the component
  6368. * @param count the number of values to enumerate
  6369. * @param normalized whether the data is normalized
  6370. * @param callback the callback function called for each value
  6371. */
  6372. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6373. private static _GetFloatValue;
  6374. }
  6375. }
  6376. declare module BABYLON {
  6377. /**
  6378. * @hidden
  6379. */
  6380. export class IntersectionInfo {
  6381. bu: Nullable<number>;
  6382. bv: Nullable<number>;
  6383. distance: number;
  6384. faceId: number;
  6385. subMeshId: number;
  6386. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6387. }
  6388. }
  6389. declare module BABYLON {
  6390. /**
  6391. * Represens a plane by the equation ax + by + cz + d = 0
  6392. */
  6393. export class Plane {
  6394. private static _TmpMatrix;
  6395. /**
  6396. * Normal of the plane (a,b,c)
  6397. */
  6398. normal: Vector3;
  6399. /**
  6400. * d component of the plane
  6401. */
  6402. d: number;
  6403. /**
  6404. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6405. * @param a a component of the plane
  6406. * @param b b component of the plane
  6407. * @param c c component of the plane
  6408. * @param d d component of the plane
  6409. */
  6410. constructor(a: number, b: number, c: number, d: number);
  6411. /**
  6412. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6413. */
  6414. asArray(): number[];
  6415. /**
  6416. * @returns a new plane copied from the current Plane.
  6417. */
  6418. clone(): Plane;
  6419. /**
  6420. * @returns the string "Plane".
  6421. */
  6422. getClassName(): string;
  6423. /**
  6424. * @returns the Plane hash code.
  6425. */
  6426. getHashCode(): number;
  6427. /**
  6428. * Normalize the current Plane in place.
  6429. * @returns the updated Plane.
  6430. */
  6431. normalize(): Plane;
  6432. /**
  6433. * Applies a transformation the plane and returns the result
  6434. * @param transformation the transformation matrix to be applied to the plane
  6435. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6436. */
  6437. transform(transformation: DeepImmutable<Matrix>): Plane;
  6438. /**
  6439. * Calcualtte the dot product between the point and the plane normal
  6440. * @param point point to calculate the dot product with
  6441. * @returns the dot product (float) of the point coordinates and the plane normal.
  6442. */
  6443. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6444. /**
  6445. * Updates the current Plane from the plane defined by the three given points.
  6446. * @param point1 one of the points used to contruct the plane
  6447. * @param point2 one of the points used to contruct the plane
  6448. * @param point3 one of the points used to contruct the plane
  6449. * @returns the updated Plane.
  6450. */
  6451. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6452. /**
  6453. * Checks if the plane is facing a given direction
  6454. * @param direction the direction to check if the plane is facing
  6455. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6456. * @returns True is the vector "direction" is the same side than the plane normal.
  6457. */
  6458. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6459. /**
  6460. * Calculates the distance to a point
  6461. * @param point point to calculate distance to
  6462. * @returns the signed distance (float) from the given point to the Plane.
  6463. */
  6464. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6465. /**
  6466. * Creates a plane from an array
  6467. * @param array the array to create a plane from
  6468. * @returns a new Plane from the given array.
  6469. */
  6470. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6471. /**
  6472. * Creates a plane from three points
  6473. * @param point1 point used to create the plane
  6474. * @param point2 point used to create the plane
  6475. * @param point3 point used to create the plane
  6476. * @returns a new Plane defined by the three given points.
  6477. */
  6478. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6479. /**
  6480. * Creates a plane from an origin point and a normal
  6481. * @param origin origin of the plane to be constructed
  6482. * @param normal normal of the plane to be constructed
  6483. * @returns a new Plane the normal vector to this plane at the given origin point.
  6484. * Note : the vector "normal" is updated because normalized.
  6485. */
  6486. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6487. /**
  6488. * Calculates the distance from a plane and a point
  6489. * @param origin origin of the plane to be constructed
  6490. * @param normal normal of the plane to be constructed
  6491. * @param point point to calculate distance to
  6492. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6493. */
  6494. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6495. }
  6496. }
  6497. declare module BABYLON {
  6498. /**
  6499. * Class used to store bounding sphere information
  6500. */
  6501. export class BoundingSphere {
  6502. /**
  6503. * Gets the center of the bounding sphere in local space
  6504. */
  6505. readonly center: Vector3;
  6506. /**
  6507. * Radius of the bounding sphere in local space
  6508. */
  6509. radius: number;
  6510. /**
  6511. * Gets the center of the bounding sphere in world space
  6512. */
  6513. readonly centerWorld: Vector3;
  6514. /**
  6515. * Radius of the bounding sphere in world space
  6516. */
  6517. radiusWorld: number;
  6518. /**
  6519. * Gets the minimum vector in local space
  6520. */
  6521. readonly minimum: Vector3;
  6522. /**
  6523. * Gets the maximum vector in local space
  6524. */
  6525. readonly maximum: Vector3;
  6526. private _worldMatrix;
  6527. private static readonly TmpVector3;
  6528. /**
  6529. * Creates a new bounding sphere
  6530. * @param min defines the minimum vector (in local space)
  6531. * @param max defines the maximum vector (in local space)
  6532. * @param worldMatrix defines the new world matrix
  6533. */
  6534. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6535. /**
  6536. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6537. * @param min defines the new minimum vector (in local space)
  6538. * @param max defines the new maximum vector (in local space)
  6539. * @param worldMatrix defines the new world matrix
  6540. */
  6541. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6542. /**
  6543. * Scale the current bounding sphere by applying a scale factor
  6544. * @param factor defines the scale factor to apply
  6545. * @returns the current bounding box
  6546. */
  6547. scale(factor: number): BoundingSphere;
  6548. /**
  6549. * Gets the world matrix of the bounding box
  6550. * @returns a matrix
  6551. */
  6552. getWorldMatrix(): DeepImmutable<Matrix>;
  6553. /** @hidden */
  6554. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6555. /**
  6556. * Tests if the bounding sphere is intersecting the frustum planes
  6557. * @param frustumPlanes defines the frustum planes to test
  6558. * @returns true if there is an intersection
  6559. */
  6560. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6561. /**
  6562. * Tests if the bounding sphere center is in between the frustum planes.
  6563. * Used for optimistic fast inclusion.
  6564. * @param frustumPlanes defines the frustum planes to test
  6565. * @returns true if the sphere center is in between the frustum planes
  6566. */
  6567. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6568. /**
  6569. * Tests if a point is inside the bounding sphere
  6570. * @param point defines the point to test
  6571. * @returns true if the point is inside the bounding sphere
  6572. */
  6573. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6574. /**
  6575. * Checks if two sphere intersct
  6576. * @param sphere0 sphere 0
  6577. * @param sphere1 sphere 1
  6578. * @returns true if the speres intersect
  6579. */
  6580. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6581. }
  6582. }
  6583. declare module BABYLON {
  6584. /**
  6585. * Class used to store bounding box information
  6586. */
  6587. export class BoundingBox implements ICullable {
  6588. /**
  6589. * Gets the 8 vectors representing the bounding box in local space
  6590. */
  6591. readonly vectors: Vector3[];
  6592. /**
  6593. * Gets the center of the bounding box in local space
  6594. */
  6595. readonly center: Vector3;
  6596. /**
  6597. * Gets the center of the bounding box in world space
  6598. */
  6599. readonly centerWorld: Vector3;
  6600. /**
  6601. * Gets the extend size in local space
  6602. */
  6603. readonly extendSize: Vector3;
  6604. /**
  6605. * Gets the extend size in world space
  6606. */
  6607. readonly extendSizeWorld: Vector3;
  6608. /**
  6609. * Gets the OBB (object bounding box) directions
  6610. */
  6611. readonly directions: Vector3[];
  6612. /**
  6613. * Gets the 8 vectors representing the bounding box in world space
  6614. */
  6615. readonly vectorsWorld: Vector3[];
  6616. /**
  6617. * Gets the minimum vector in world space
  6618. */
  6619. readonly minimumWorld: Vector3;
  6620. /**
  6621. * Gets the maximum vector in world space
  6622. */
  6623. readonly maximumWorld: Vector3;
  6624. /**
  6625. * Gets the minimum vector in local space
  6626. */
  6627. readonly minimum: Vector3;
  6628. /**
  6629. * Gets the maximum vector in local space
  6630. */
  6631. readonly maximum: Vector3;
  6632. private _worldMatrix;
  6633. private static readonly TmpVector3;
  6634. /**
  6635. * @hidden
  6636. */
  6637. _tag: number;
  6638. /**
  6639. * Creates a new bounding box
  6640. * @param min defines the minimum vector (in local space)
  6641. * @param max defines the maximum vector (in local space)
  6642. * @param worldMatrix defines the new world matrix
  6643. */
  6644. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6645. /**
  6646. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6647. * @param min defines the new minimum vector (in local space)
  6648. * @param max defines the new maximum vector (in local space)
  6649. * @param worldMatrix defines the new world matrix
  6650. */
  6651. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6652. /**
  6653. * Scale the current bounding box by applying a scale factor
  6654. * @param factor defines the scale factor to apply
  6655. * @returns the current bounding box
  6656. */
  6657. scale(factor: number): BoundingBox;
  6658. /**
  6659. * Gets the world matrix of the bounding box
  6660. * @returns a matrix
  6661. */
  6662. getWorldMatrix(): DeepImmutable<Matrix>;
  6663. /** @hidden */
  6664. _update(world: DeepImmutable<Matrix>): void;
  6665. /**
  6666. * Tests if the bounding box is intersecting the frustum planes
  6667. * @param frustumPlanes defines the frustum planes to test
  6668. * @returns true if there is an intersection
  6669. */
  6670. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6671. /**
  6672. * Tests if the bounding box is entirely inside the frustum planes
  6673. * @param frustumPlanes defines the frustum planes to test
  6674. * @returns true if there is an inclusion
  6675. */
  6676. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6677. /**
  6678. * Tests if a point is inside the bounding box
  6679. * @param point defines the point to test
  6680. * @returns true if the point is inside the bounding box
  6681. */
  6682. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6683. /**
  6684. * Tests if the bounding box intersects with a bounding sphere
  6685. * @param sphere defines the sphere to test
  6686. * @returns true if there is an intersection
  6687. */
  6688. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6689. /**
  6690. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6691. * @param min defines the min vector to use
  6692. * @param max defines the max vector to use
  6693. * @returns true if there is an intersection
  6694. */
  6695. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6696. /**
  6697. * Tests if two bounding boxes are intersections
  6698. * @param box0 defines the first box to test
  6699. * @param box1 defines the second box to test
  6700. * @returns true if there is an intersection
  6701. */
  6702. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6703. /**
  6704. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6705. * @param minPoint defines the minimum vector of the bounding box
  6706. * @param maxPoint defines the maximum vector of the bounding box
  6707. * @param sphereCenter defines the sphere center
  6708. * @param sphereRadius defines the sphere radius
  6709. * @returns true if there is an intersection
  6710. */
  6711. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6712. /**
  6713. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6714. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6715. * @param frustumPlanes defines the frustum planes to test
  6716. * @return true if there is an inclusion
  6717. */
  6718. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6719. /**
  6720. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6721. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6722. * @param frustumPlanes defines the frustum planes to test
  6723. * @return true if there is an intersection
  6724. */
  6725. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6726. }
  6727. }
  6728. declare module BABYLON {
  6729. /** @hidden */
  6730. export class Collider {
  6731. /** Define if a collision was found */
  6732. collisionFound: boolean;
  6733. /**
  6734. * Define last intersection point in local space
  6735. */
  6736. intersectionPoint: Vector3;
  6737. /**
  6738. * Define last collided mesh
  6739. */
  6740. collidedMesh: Nullable<AbstractMesh>;
  6741. private _collisionPoint;
  6742. private _planeIntersectionPoint;
  6743. private _tempVector;
  6744. private _tempVector2;
  6745. private _tempVector3;
  6746. private _tempVector4;
  6747. private _edge;
  6748. private _baseToVertex;
  6749. private _destinationPoint;
  6750. private _slidePlaneNormal;
  6751. private _displacementVector;
  6752. /** @hidden */
  6753. _radius: Vector3;
  6754. /** @hidden */
  6755. _retry: number;
  6756. private _velocity;
  6757. private _basePoint;
  6758. private _epsilon;
  6759. /** @hidden */
  6760. _velocityWorldLength: number;
  6761. /** @hidden */
  6762. _basePointWorld: Vector3;
  6763. private _velocityWorld;
  6764. private _normalizedVelocity;
  6765. /** @hidden */
  6766. _initialVelocity: Vector3;
  6767. /** @hidden */
  6768. _initialPosition: Vector3;
  6769. private _nearestDistance;
  6770. private _collisionMask;
  6771. collisionMask: number;
  6772. /**
  6773. * Gets the plane normal used to compute the sliding response (in local space)
  6774. */
  6775. readonly slidePlaneNormal: Vector3;
  6776. /** @hidden */
  6777. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6778. /** @hidden */
  6779. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6780. /** @hidden */
  6781. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6782. /** @hidden */
  6783. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6784. /** @hidden */
  6785. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6786. /** @hidden */
  6787. _getResponse(pos: Vector3, vel: Vector3): void;
  6788. }
  6789. }
  6790. declare module BABYLON {
  6791. /**
  6792. * Interface for cullable objects
  6793. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6794. */
  6795. export interface ICullable {
  6796. /**
  6797. * Checks if the object or part of the object is in the frustum
  6798. * @param frustumPlanes Camera near/planes
  6799. * @returns true if the object is in frustum otherwise false
  6800. */
  6801. isInFrustum(frustumPlanes: Plane[]): boolean;
  6802. /**
  6803. * Checks if a cullable object (mesh...) is in the camera frustum
  6804. * Unlike isInFrustum this cheks the full bounding box
  6805. * @param frustumPlanes Camera near/planes
  6806. * @returns true if the object is in frustum otherwise false
  6807. */
  6808. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6809. }
  6810. /**
  6811. * Info for a bounding data of a mesh
  6812. */
  6813. export class BoundingInfo implements ICullable {
  6814. /**
  6815. * Bounding box for the mesh
  6816. */
  6817. readonly boundingBox: BoundingBox;
  6818. /**
  6819. * Bounding sphere for the mesh
  6820. */
  6821. readonly boundingSphere: BoundingSphere;
  6822. private _isLocked;
  6823. private static readonly TmpVector3;
  6824. /**
  6825. * Constructs bounding info
  6826. * @param minimum min vector of the bounding box/sphere
  6827. * @param maximum max vector of the bounding box/sphere
  6828. * @param worldMatrix defines the new world matrix
  6829. */
  6830. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6831. /**
  6832. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6833. * @param min defines the new minimum vector (in local space)
  6834. * @param max defines the new maximum vector (in local space)
  6835. * @param worldMatrix defines the new world matrix
  6836. */
  6837. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6838. /**
  6839. * min vector of the bounding box/sphere
  6840. */
  6841. readonly minimum: Vector3;
  6842. /**
  6843. * max vector of the bounding box/sphere
  6844. */
  6845. readonly maximum: Vector3;
  6846. /**
  6847. * If the info is locked and won't be updated to avoid perf overhead
  6848. */
  6849. isLocked: boolean;
  6850. /**
  6851. * Updates the bounding sphere and box
  6852. * @param world world matrix to be used to update
  6853. */
  6854. update(world: DeepImmutable<Matrix>): void;
  6855. /**
  6856. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6857. * @param center New center of the bounding info
  6858. * @param extend New extend of the bounding info
  6859. * @returns the current bounding info
  6860. */
  6861. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6862. /**
  6863. * Scale the current bounding info by applying a scale factor
  6864. * @param factor defines the scale factor to apply
  6865. * @returns the current bounding info
  6866. */
  6867. scale(factor: number): BoundingInfo;
  6868. /**
  6869. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6870. * @param frustumPlanes defines the frustum to test
  6871. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6872. * @returns true if the bounding info is in the frustum planes
  6873. */
  6874. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6875. /**
  6876. * Gets the world distance between the min and max points of the bounding box
  6877. */
  6878. readonly diagonalLength: number;
  6879. /**
  6880. * Checks if a cullable object (mesh...) is in the camera frustum
  6881. * Unlike isInFrustum this cheks the full bounding box
  6882. * @param frustumPlanes Camera near/planes
  6883. * @returns true if the object is in frustum otherwise false
  6884. */
  6885. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /** @hidden */
  6887. _checkCollision(collider: Collider): boolean;
  6888. /**
  6889. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6890. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6891. * @param point the point to check intersection with
  6892. * @returns if the point intersects
  6893. */
  6894. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6895. /**
  6896. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6897. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6898. * @param boundingInfo the bounding info to check intersection with
  6899. * @param precise if the intersection should be done using OBB
  6900. * @returns if the bounding info intersects
  6901. */
  6902. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6903. }
  6904. }
  6905. declare module BABYLON {
  6906. /**
  6907. * Extracts minimum and maximum values from a list of indexed positions
  6908. * @param positions defines the positions to use
  6909. * @param indices defines the indices to the positions
  6910. * @param indexStart defines the start index
  6911. * @param indexCount defines the end index
  6912. * @param bias defines bias value to add to the result
  6913. * @return minimum and maximum values
  6914. */
  6915. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6916. minimum: Vector3;
  6917. maximum: Vector3;
  6918. };
  6919. /**
  6920. * Extracts minimum and maximum values from a list of positions
  6921. * @param positions defines the positions to use
  6922. * @param start defines the start index in the positions array
  6923. * @param count defines the number of positions to handle
  6924. * @param bias defines bias value to add to the result
  6925. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6926. * @return minimum and maximum values
  6927. */
  6928. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6929. minimum: Vector3;
  6930. maximum: Vector3;
  6931. };
  6932. }
  6933. declare module BABYLON {
  6934. /** @hidden */
  6935. export class WebGLDataBuffer extends DataBuffer {
  6936. private _buffer;
  6937. constructor(resource: WebGLBuffer);
  6938. readonly underlyingResource: any;
  6939. }
  6940. }
  6941. declare module BABYLON {
  6942. /** @hidden */
  6943. export class WebGLPipelineContext implements IPipelineContext {
  6944. engine: ThinEngine;
  6945. program: Nullable<WebGLProgram>;
  6946. context?: WebGLRenderingContext;
  6947. vertexShader?: WebGLShader;
  6948. fragmentShader?: WebGLShader;
  6949. isParallelCompiled: boolean;
  6950. onCompiled?: () => void;
  6951. transformFeedback?: WebGLTransformFeedback | null;
  6952. readonly isAsync: boolean;
  6953. readonly isReady: boolean;
  6954. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  6955. }
  6956. }
  6957. declare module BABYLON {
  6958. interface ThinEngine {
  6959. /**
  6960. * Create an uniform buffer
  6961. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6962. * @param elements defines the content of the uniform buffer
  6963. * @returns the webGL uniform buffer
  6964. */
  6965. createUniformBuffer(elements: FloatArray): DataBuffer;
  6966. /**
  6967. * Create a dynamic uniform buffer
  6968. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6969. * @param elements defines the content of the uniform buffer
  6970. * @returns the webGL uniform buffer
  6971. */
  6972. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  6973. /**
  6974. * Update an existing uniform buffer
  6975. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6976. * @param uniformBuffer defines the target uniform buffer
  6977. * @param elements defines the content to update
  6978. * @param offset defines the offset in the uniform buffer where update should start
  6979. * @param count defines the size of the data to update
  6980. */
  6981. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  6982. /**
  6983. * Bind an uniform buffer to the current webGL context
  6984. * @param buffer defines the buffer to bind
  6985. */
  6986. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  6987. /**
  6988. * Bind a buffer to the current webGL context at a given location
  6989. * @param buffer defines the buffer to bind
  6990. * @param location defines the index where to bind the buffer
  6991. */
  6992. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  6993. /**
  6994. * Bind a specific block at a given index in a specific shader program
  6995. * @param pipelineContext defines the pipeline context to use
  6996. * @param blockName defines the block name
  6997. * @param index defines the index where to bind the block
  6998. */
  6999. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7000. }
  7001. }
  7002. declare module BABYLON {
  7003. /**
  7004. * Uniform buffer objects.
  7005. *
  7006. * Handles blocks of uniform on the GPU.
  7007. *
  7008. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7009. *
  7010. * For more information, please refer to :
  7011. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7012. */
  7013. export class UniformBuffer {
  7014. private _engine;
  7015. private _buffer;
  7016. private _data;
  7017. private _bufferData;
  7018. private _dynamic?;
  7019. private _uniformLocations;
  7020. private _uniformSizes;
  7021. private _uniformLocationPointer;
  7022. private _needSync;
  7023. private _noUBO;
  7024. private _currentEffect;
  7025. private static _MAX_UNIFORM_SIZE;
  7026. private static _tempBuffer;
  7027. /**
  7028. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7029. * This is dynamic to allow compat with webgl 1 and 2.
  7030. * You will need to pass the name of the uniform as well as the value.
  7031. */
  7032. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7033. /**
  7034. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7035. * This is dynamic to allow compat with webgl 1 and 2.
  7036. * You will need to pass the name of the uniform as well as the value.
  7037. */
  7038. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7039. /**
  7040. * Lambda to Update a single float in a uniform buffer.
  7041. * This is dynamic to allow compat with webgl 1 and 2.
  7042. * You will need to pass the name of the uniform as well as the value.
  7043. */
  7044. updateFloat: (name: string, x: number) => void;
  7045. /**
  7046. * Lambda to Update a vec2 of float in a uniform buffer.
  7047. * This is dynamic to allow compat with webgl 1 and 2.
  7048. * You will need to pass the name of the uniform as well as the value.
  7049. */
  7050. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7051. /**
  7052. * Lambda to Update a vec3 of float in a uniform buffer.
  7053. * This is dynamic to allow compat with webgl 1 and 2.
  7054. * You will need to pass the name of the uniform as well as the value.
  7055. */
  7056. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7057. /**
  7058. * Lambda to Update a vec4 of float in a uniform buffer.
  7059. * This is dynamic to allow compat with webgl 1 and 2.
  7060. * You will need to pass the name of the uniform as well as the value.
  7061. */
  7062. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7063. /**
  7064. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7065. * This is dynamic to allow compat with webgl 1 and 2.
  7066. * You will need to pass the name of the uniform as well as the value.
  7067. */
  7068. updateMatrix: (name: string, mat: Matrix) => void;
  7069. /**
  7070. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7071. * This is dynamic to allow compat with webgl 1 and 2.
  7072. * You will need to pass the name of the uniform as well as the value.
  7073. */
  7074. updateVector3: (name: string, vector: Vector3) => void;
  7075. /**
  7076. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7077. * This is dynamic to allow compat with webgl 1 and 2.
  7078. * You will need to pass the name of the uniform as well as the value.
  7079. */
  7080. updateVector4: (name: string, vector: Vector4) => void;
  7081. /**
  7082. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7083. * This is dynamic to allow compat with webgl 1 and 2.
  7084. * You will need to pass the name of the uniform as well as the value.
  7085. */
  7086. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7087. /**
  7088. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7089. * This is dynamic to allow compat with webgl 1 and 2.
  7090. * You will need to pass the name of the uniform as well as the value.
  7091. */
  7092. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7093. /**
  7094. * Instantiates a new Uniform buffer objects.
  7095. *
  7096. * Handles blocks of uniform on the GPU.
  7097. *
  7098. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7099. *
  7100. * For more information, please refer to :
  7101. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7102. * @param engine Define the engine the buffer is associated with
  7103. * @param data Define the data contained in the buffer
  7104. * @param dynamic Define if the buffer is updatable
  7105. */
  7106. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7107. /**
  7108. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7109. * or just falling back on setUniformXXX calls.
  7110. */
  7111. readonly useUbo: boolean;
  7112. /**
  7113. * Indicates if the WebGL underlying uniform buffer is in sync
  7114. * with the javascript cache data.
  7115. */
  7116. readonly isSync: boolean;
  7117. /**
  7118. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7119. * Also, a dynamic UniformBuffer will disable cache verification and always
  7120. * update the underlying WebGL uniform buffer to the GPU.
  7121. * @returns if Dynamic, otherwise false
  7122. */
  7123. isDynamic(): boolean;
  7124. /**
  7125. * The data cache on JS side.
  7126. * @returns the underlying data as a float array
  7127. */
  7128. getData(): Float32Array;
  7129. /**
  7130. * The underlying WebGL Uniform buffer.
  7131. * @returns the webgl buffer
  7132. */
  7133. getBuffer(): Nullable<DataBuffer>;
  7134. /**
  7135. * std140 layout specifies how to align data within an UBO structure.
  7136. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7137. * for specs.
  7138. */
  7139. private _fillAlignment;
  7140. /**
  7141. * Adds an uniform in the buffer.
  7142. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7143. * for the layout to be correct !
  7144. * @param name Name of the uniform, as used in the uniform block in the shader.
  7145. * @param size Data size, or data directly.
  7146. */
  7147. addUniform(name: string, size: number | number[]): void;
  7148. /**
  7149. * Adds a Matrix 4x4 to the uniform buffer.
  7150. * @param name Name of the uniform, as used in the uniform block in the shader.
  7151. * @param mat A 4x4 matrix.
  7152. */
  7153. addMatrix(name: string, mat: Matrix): void;
  7154. /**
  7155. * Adds a vec2 to the uniform buffer.
  7156. * @param name Name of the uniform, as used in the uniform block in the shader.
  7157. * @param x Define the x component value of the vec2
  7158. * @param y Define the y component value of the vec2
  7159. */
  7160. addFloat2(name: string, x: number, y: number): void;
  7161. /**
  7162. * Adds a vec3 to the uniform buffer.
  7163. * @param name Name of the uniform, as used in the uniform block in the shader.
  7164. * @param x Define the x component value of the vec3
  7165. * @param y Define the y component value of the vec3
  7166. * @param z Define the z component value of the vec3
  7167. */
  7168. addFloat3(name: string, x: number, y: number, z: number): void;
  7169. /**
  7170. * Adds a vec3 to the uniform buffer.
  7171. * @param name Name of the uniform, as used in the uniform block in the shader.
  7172. * @param color Define the vec3 from a Color
  7173. */
  7174. addColor3(name: string, color: Color3): void;
  7175. /**
  7176. * Adds a vec4 to the uniform buffer.
  7177. * @param name Name of the uniform, as used in the uniform block in the shader.
  7178. * @param color Define the rgb components from a Color
  7179. * @param alpha Define the a component of the vec4
  7180. */
  7181. addColor4(name: string, color: Color3, alpha: number): void;
  7182. /**
  7183. * Adds a vec3 to the uniform buffer.
  7184. * @param name Name of the uniform, as used in the uniform block in the shader.
  7185. * @param vector Define the vec3 components from a Vector
  7186. */
  7187. addVector3(name: string, vector: Vector3): void;
  7188. /**
  7189. * Adds a Matrix 3x3 to the uniform buffer.
  7190. * @param name Name of the uniform, as used in the uniform block in the shader.
  7191. */
  7192. addMatrix3x3(name: string): void;
  7193. /**
  7194. * Adds a Matrix 2x2 to the uniform buffer.
  7195. * @param name Name of the uniform, as used in the uniform block in the shader.
  7196. */
  7197. addMatrix2x2(name: string): void;
  7198. /**
  7199. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7200. */
  7201. create(): void;
  7202. /** @hidden */
  7203. _rebuild(): void;
  7204. /**
  7205. * Updates the WebGL Uniform Buffer on the GPU.
  7206. * If the `dynamic` flag is set to true, no cache comparison is done.
  7207. * Otherwise, the buffer will be updated only if the cache differs.
  7208. */
  7209. update(): void;
  7210. /**
  7211. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7212. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7213. * @param data Define the flattened data
  7214. * @param size Define the size of the data.
  7215. */
  7216. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7217. private _valueCache;
  7218. private _cacheMatrix;
  7219. private _updateMatrix3x3ForUniform;
  7220. private _updateMatrix3x3ForEffect;
  7221. private _updateMatrix2x2ForEffect;
  7222. private _updateMatrix2x2ForUniform;
  7223. private _updateFloatForEffect;
  7224. private _updateFloatForUniform;
  7225. private _updateFloat2ForEffect;
  7226. private _updateFloat2ForUniform;
  7227. private _updateFloat3ForEffect;
  7228. private _updateFloat3ForUniform;
  7229. private _updateFloat4ForEffect;
  7230. private _updateFloat4ForUniform;
  7231. private _updateMatrixForEffect;
  7232. private _updateMatrixForUniform;
  7233. private _updateVector3ForEffect;
  7234. private _updateVector3ForUniform;
  7235. private _updateVector4ForEffect;
  7236. private _updateVector4ForUniform;
  7237. private _updateColor3ForEffect;
  7238. private _updateColor3ForUniform;
  7239. private _updateColor4ForEffect;
  7240. private _updateColor4ForUniform;
  7241. /**
  7242. * Sets a sampler uniform on the effect.
  7243. * @param name Define the name of the sampler.
  7244. * @param texture Define the texture to set in the sampler
  7245. */
  7246. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7247. /**
  7248. * Directly updates the value of the uniform in the cache AND on the GPU.
  7249. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7250. * @param data Define the flattened data
  7251. */
  7252. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7253. /**
  7254. * Binds this uniform buffer to an effect.
  7255. * @param effect Define the effect to bind the buffer to
  7256. * @param name Name of the uniform block in the shader.
  7257. */
  7258. bindToEffect(effect: Effect, name: string): void;
  7259. /**
  7260. * Disposes the uniform buffer.
  7261. */
  7262. dispose(): void;
  7263. }
  7264. }
  7265. declare module BABYLON {
  7266. /**
  7267. * Enum that determines the text-wrapping mode to use.
  7268. */
  7269. export enum InspectableType {
  7270. /**
  7271. * Checkbox for booleans
  7272. */
  7273. Checkbox = 0,
  7274. /**
  7275. * Sliders for numbers
  7276. */
  7277. Slider = 1,
  7278. /**
  7279. * Vector3
  7280. */
  7281. Vector3 = 2,
  7282. /**
  7283. * Quaternions
  7284. */
  7285. Quaternion = 3,
  7286. /**
  7287. * Color3
  7288. */
  7289. Color3 = 4,
  7290. /**
  7291. * String
  7292. */
  7293. String = 5
  7294. }
  7295. /**
  7296. * Interface used to define custom inspectable properties.
  7297. * This interface is used by the inspector to display custom property grids
  7298. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7299. */
  7300. export interface IInspectable {
  7301. /**
  7302. * Gets the label to display
  7303. */
  7304. label: string;
  7305. /**
  7306. * Gets the name of the property to edit
  7307. */
  7308. propertyName: string;
  7309. /**
  7310. * Gets the type of the editor to use
  7311. */
  7312. type: InspectableType;
  7313. /**
  7314. * Gets the minimum value of the property when using in "slider" mode
  7315. */
  7316. min?: number;
  7317. /**
  7318. * Gets the maximum value of the property when using in "slider" mode
  7319. */
  7320. max?: number;
  7321. /**
  7322. * Gets the setp to use when using in "slider" mode
  7323. */
  7324. step?: number;
  7325. }
  7326. }
  7327. declare module BABYLON {
  7328. /**
  7329. * Class used to provide helper for timing
  7330. */
  7331. export class TimingTools {
  7332. /**
  7333. * Polyfill for setImmediate
  7334. * @param action defines the action to execute after the current execution block
  7335. */
  7336. static SetImmediate(action: () => void): void;
  7337. }
  7338. }
  7339. declare module BABYLON {
  7340. /**
  7341. * Class used to enable instatition of objects by class name
  7342. */
  7343. export class InstantiationTools {
  7344. /**
  7345. * Use this object to register external classes like custom textures or material
  7346. * to allow the laoders to instantiate them
  7347. */
  7348. static RegisteredExternalClasses: {
  7349. [key: string]: Object;
  7350. };
  7351. /**
  7352. * Tries to instantiate a new object from a given class name
  7353. * @param className defines the class name to instantiate
  7354. * @returns the new object or null if the system was not able to do the instantiation
  7355. */
  7356. static Instantiate(className: string): any;
  7357. }
  7358. }
  7359. declare module BABYLON {
  7360. /**
  7361. * Define options used to create a depth texture
  7362. */
  7363. export class DepthTextureCreationOptions {
  7364. /** Specifies whether or not a stencil should be allocated in the texture */
  7365. generateStencil?: boolean;
  7366. /** Specifies whether or not bilinear filtering is enable on the texture */
  7367. bilinearFiltering?: boolean;
  7368. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7369. comparisonFunction?: number;
  7370. /** Specifies if the created texture is a cube texture */
  7371. isCube?: boolean;
  7372. }
  7373. }
  7374. declare module BABYLON {
  7375. interface ThinEngine {
  7376. /**
  7377. * Creates a depth stencil cube texture.
  7378. * This is only available in WebGL 2.
  7379. * @param size The size of face edge in the cube texture.
  7380. * @param options The options defining the cube texture.
  7381. * @returns The cube texture
  7382. */
  7383. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7384. /**
  7385. * Creates a cube texture
  7386. * @param rootUrl defines the url where the files to load is located
  7387. * @param scene defines the current scene
  7388. * @param files defines the list of files to load (1 per face)
  7389. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7390. * @param onLoad defines an optional callback raised when the texture is loaded
  7391. * @param onError defines an optional callback raised if there is an issue to load the texture
  7392. * @param format defines the format of the data
  7393. * @param forcedExtension defines the extension to use to pick the right loader
  7394. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7395. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7396. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7397. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7398. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7399. * @returns the cube texture as an InternalTexture
  7400. */
  7401. 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;
  7402. /**
  7403. * Creates a cube texture
  7404. * @param rootUrl defines the url where the files to load is located
  7405. * @param scene defines the current scene
  7406. * @param files defines the list of files to load (1 per face)
  7407. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7408. * @param onLoad defines an optional callback raised when the texture is loaded
  7409. * @param onError defines an optional callback raised if there is an issue to load the texture
  7410. * @param format defines the format of the data
  7411. * @param forcedExtension defines the extension to use to pick the right loader
  7412. * @returns the cube texture as an InternalTexture
  7413. */
  7414. 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;
  7415. /**
  7416. * Creates a cube texture
  7417. * @param rootUrl defines the url where the files to load is located
  7418. * @param scene defines the current scene
  7419. * @param files defines the list of files to load (1 per face)
  7420. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7421. * @param onLoad defines an optional callback raised when the texture is loaded
  7422. * @param onError defines an optional callback raised if there is an issue to load the texture
  7423. * @param format defines the format of the data
  7424. * @param forcedExtension defines the extension to use to pick the right loader
  7425. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7426. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7427. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7428. * @returns the cube texture as an InternalTexture
  7429. */
  7430. 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;
  7431. /** @hidden */
  7432. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7433. /** @hidden */
  7434. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7435. /** @hidden */
  7436. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7437. /** @hidden */
  7438. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7439. }
  7440. }
  7441. declare module BABYLON {
  7442. /**
  7443. * Class for creating a cube texture
  7444. */
  7445. export class CubeTexture extends BaseTexture {
  7446. private _delayedOnLoad;
  7447. /**
  7448. * The url of the texture
  7449. */
  7450. url: string;
  7451. /**
  7452. * Gets or sets the center of the bounding box associated with the cube texture.
  7453. * It must define where the camera used to render the texture was set
  7454. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7455. */
  7456. boundingBoxPosition: Vector3;
  7457. private _boundingBoxSize;
  7458. /**
  7459. * Gets or sets the size of the bounding box associated with the cube texture
  7460. * When defined, the cubemap will switch to local mode
  7461. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7462. * @example https://www.babylonjs-playground.com/#RNASML
  7463. */
  7464. /**
  7465. * Returns the bounding box size
  7466. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7467. */
  7468. boundingBoxSize: Vector3;
  7469. protected _rotationY: number;
  7470. /**
  7471. * Sets texture matrix rotation angle around Y axis in radians.
  7472. */
  7473. /**
  7474. * Gets texture matrix rotation angle around Y axis radians.
  7475. */
  7476. rotationY: number;
  7477. /**
  7478. * Are mip maps generated for this texture or not.
  7479. */
  7480. readonly noMipmap: boolean;
  7481. private _noMipmap;
  7482. private _files;
  7483. protected _forcedExtension: Nullable<string>;
  7484. private _extensions;
  7485. private _textureMatrix;
  7486. private _format;
  7487. private _createPolynomials;
  7488. /** @hidden */
  7489. _prefiltered: boolean;
  7490. /**
  7491. * Creates a cube texture from an array of image urls
  7492. * @param files defines an array of image urls
  7493. * @param scene defines the hosting scene
  7494. * @param noMipmap specifies if mip maps are not used
  7495. * @returns a cube texture
  7496. */
  7497. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7498. /**
  7499. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7500. * @param url defines the url of the prefiltered texture
  7501. * @param scene defines the scene the texture is attached to
  7502. * @param forcedExtension defines the extension of the file if different from the url
  7503. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7504. * @return the prefiltered texture
  7505. */
  7506. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7507. /**
  7508. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7509. * as prefiltered data.
  7510. * @param rootUrl defines the url of the texture or the root name of the six images
  7511. * @param scene defines the scene the texture is attached to
  7512. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7513. * @param noMipmap defines if mipmaps should be created or not
  7514. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7515. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7516. * @param onError defines a callback triggered in case of error during load
  7517. * @param format defines the internal format to use for the texture once loaded
  7518. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7519. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7520. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7521. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7522. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7523. * @return the cube texture
  7524. */
  7525. 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);
  7526. /**
  7527. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7528. */
  7529. readonly isPrefiltered: boolean;
  7530. /**
  7531. * Get the current class name of the texture useful for serialization or dynamic coding.
  7532. * @returns "CubeTexture"
  7533. */
  7534. getClassName(): string;
  7535. /**
  7536. * Update the url (and optional buffer) of this texture if url was null during construction.
  7537. * @param url the url of the texture
  7538. * @param forcedExtension defines the extension to use
  7539. * @param onLoad callback called when the texture is loaded (defaults to null)
  7540. */
  7541. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7542. /**
  7543. * Delays loading of the cube texture
  7544. * @param forcedExtension defines the extension to use
  7545. */
  7546. delayLoad(forcedExtension?: string): void;
  7547. /**
  7548. * Returns the reflection texture matrix
  7549. * @returns the reflection texture matrix
  7550. */
  7551. getReflectionTextureMatrix(): Matrix;
  7552. /**
  7553. * Sets the reflection texture matrix
  7554. * @param value Reflection texture matrix
  7555. */
  7556. setReflectionTextureMatrix(value: Matrix): void;
  7557. /**
  7558. * Parses text to create a cube texture
  7559. * @param parsedTexture define the serialized text to read from
  7560. * @param scene defines the hosting scene
  7561. * @param rootUrl defines the root url of the cube texture
  7562. * @returns a cube texture
  7563. */
  7564. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7565. /**
  7566. * Makes a clone, or deep copy, of the cube texture
  7567. * @returns a new cube texture
  7568. */
  7569. clone(): CubeTexture;
  7570. }
  7571. }
  7572. declare module BABYLON {
  7573. /**
  7574. * Manages the defines for the Material
  7575. */
  7576. export class MaterialDefines {
  7577. /** @hidden */
  7578. protected _keys: string[];
  7579. private _isDirty;
  7580. /** @hidden */
  7581. _renderId: number;
  7582. /** @hidden */
  7583. _areLightsDirty: boolean;
  7584. /** @hidden */
  7585. _areLightsDisposed: boolean;
  7586. /** @hidden */
  7587. _areAttributesDirty: boolean;
  7588. /** @hidden */
  7589. _areTexturesDirty: boolean;
  7590. /** @hidden */
  7591. _areFresnelDirty: boolean;
  7592. /** @hidden */
  7593. _areMiscDirty: boolean;
  7594. /** @hidden */
  7595. _areImageProcessingDirty: boolean;
  7596. /** @hidden */
  7597. _normals: boolean;
  7598. /** @hidden */
  7599. _uvs: boolean;
  7600. /** @hidden */
  7601. _needNormals: boolean;
  7602. /** @hidden */
  7603. _needUVs: boolean;
  7604. [id: string]: any;
  7605. /**
  7606. * Specifies if the material needs to be re-calculated
  7607. */
  7608. readonly isDirty: boolean;
  7609. /**
  7610. * Marks the material to indicate that it has been re-calculated
  7611. */
  7612. markAsProcessed(): void;
  7613. /**
  7614. * Marks the material to indicate that it needs to be re-calculated
  7615. */
  7616. markAsUnprocessed(): void;
  7617. /**
  7618. * Marks the material to indicate all of its defines need to be re-calculated
  7619. */
  7620. markAllAsDirty(): void;
  7621. /**
  7622. * Marks the material to indicate that image processing needs to be re-calculated
  7623. */
  7624. markAsImageProcessingDirty(): void;
  7625. /**
  7626. * Marks the material to indicate the lights need to be re-calculated
  7627. * @param disposed Defines whether the light is dirty due to dispose or not
  7628. */
  7629. markAsLightDirty(disposed?: boolean): void;
  7630. /**
  7631. * Marks the attribute state as changed
  7632. */
  7633. markAsAttributesDirty(): void;
  7634. /**
  7635. * Marks the texture state as changed
  7636. */
  7637. markAsTexturesDirty(): void;
  7638. /**
  7639. * Marks the fresnel state as changed
  7640. */
  7641. markAsFresnelDirty(): void;
  7642. /**
  7643. * Marks the misc state as changed
  7644. */
  7645. markAsMiscDirty(): void;
  7646. /**
  7647. * Rebuilds the material defines
  7648. */
  7649. rebuild(): void;
  7650. /**
  7651. * Specifies if two material defines are equal
  7652. * @param other - A material define instance to compare to
  7653. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7654. */
  7655. isEqual(other: MaterialDefines): boolean;
  7656. /**
  7657. * Clones this instance's defines to another instance
  7658. * @param other - material defines to clone values to
  7659. */
  7660. cloneTo(other: MaterialDefines): void;
  7661. /**
  7662. * Resets the material define values
  7663. */
  7664. reset(): void;
  7665. /**
  7666. * Converts the material define values to a string
  7667. * @returns - String of material define information
  7668. */
  7669. toString(): string;
  7670. }
  7671. }
  7672. declare module BABYLON {
  7673. /**
  7674. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7675. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7676. * 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;
  7677. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7678. */
  7679. export class ColorCurves {
  7680. private _dirty;
  7681. private _tempColor;
  7682. private _globalCurve;
  7683. private _highlightsCurve;
  7684. private _midtonesCurve;
  7685. private _shadowsCurve;
  7686. private _positiveCurve;
  7687. private _negativeCurve;
  7688. private _globalHue;
  7689. private _globalDensity;
  7690. private _globalSaturation;
  7691. private _globalExposure;
  7692. /**
  7693. * Gets the global Hue value.
  7694. * 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).
  7695. */
  7696. /**
  7697. * Sets 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. globalHue: number;
  7701. /**
  7702. * Gets the global Density value.
  7703. * 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.
  7704. * Values less than zero provide a filter of opposite hue.
  7705. */
  7706. /**
  7707. * Sets the global Density value.
  7708. * 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.
  7709. * Values less than zero provide a filter of opposite hue.
  7710. */
  7711. globalDensity: number;
  7712. /**
  7713. * Gets the global Saturation value.
  7714. * 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.
  7715. */
  7716. /**
  7717. * Sets 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. globalSaturation: number;
  7721. /**
  7722. * Gets the global Exposure value.
  7723. * 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.
  7724. */
  7725. /**
  7726. * Sets 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. globalExposure: number;
  7730. private _highlightsHue;
  7731. private _highlightsDensity;
  7732. private _highlightsSaturation;
  7733. private _highlightsExposure;
  7734. /**
  7735. * Gets the highlights Hue value.
  7736. * 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).
  7737. */
  7738. /**
  7739. * Sets 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. highlightsHue: number;
  7743. /**
  7744. * Gets the highlights Density value.
  7745. * 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.
  7746. * Values less than zero provide a filter of opposite hue.
  7747. */
  7748. /**
  7749. * Sets the highlights Density value.
  7750. * 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.
  7751. * Values less than zero provide a filter of opposite hue.
  7752. */
  7753. highlightsDensity: number;
  7754. /**
  7755. * Gets the highlights Saturation value.
  7756. * 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.
  7757. */
  7758. /**
  7759. * Sets 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. highlightsSaturation: number;
  7763. /**
  7764. * Gets the highlights Exposure value.
  7765. * 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.
  7766. */
  7767. /**
  7768. * Sets 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. highlightsExposure: number;
  7772. private _midtonesHue;
  7773. private _midtonesDensity;
  7774. private _midtonesSaturation;
  7775. private _midtonesExposure;
  7776. /**
  7777. * Gets the midtones Hue value.
  7778. * 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).
  7779. */
  7780. /**
  7781. * Sets 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. midtonesHue: number;
  7785. /**
  7786. * Gets the midtones Density value.
  7787. * 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.
  7788. * Values less than zero provide a filter of opposite hue.
  7789. */
  7790. /**
  7791. * Sets the midtones Density value.
  7792. * 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.
  7793. * Values less than zero provide a filter of opposite hue.
  7794. */
  7795. midtonesDensity: number;
  7796. /**
  7797. * Gets the midtones Saturation value.
  7798. * 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.
  7799. */
  7800. /**
  7801. * Sets 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. midtonesSaturation: number;
  7805. /**
  7806. * Gets the midtones Exposure value.
  7807. * 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.
  7808. */
  7809. /**
  7810. * Sets 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. midtonesExposure: number;
  7814. private _shadowsHue;
  7815. private _shadowsDensity;
  7816. private _shadowsSaturation;
  7817. private _shadowsExposure;
  7818. /**
  7819. * Gets the shadows Hue value.
  7820. * 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).
  7821. */
  7822. /**
  7823. * Sets 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. shadowsHue: number;
  7827. /**
  7828. * Gets the shadows Density value.
  7829. * 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.
  7830. * Values less than zero provide a filter of opposite hue.
  7831. */
  7832. /**
  7833. * Sets the shadows Density value.
  7834. * 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.
  7835. * Values less than zero provide a filter of opposite hue.
  7836. */
  7837. shadowsDensity: number;
  7838. /**
  7839. * Gets the shadows Saturation value.
  7840. * 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.
  7841. */
  7842. /**
  7843. * Sets 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. shadowsSaturation: number;
  7847. /**
  7848. * Gets the shadows Exposure value.
  7849. * 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.
  7850. */
  7851. /**
  7852. * Sets 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. shadowsExposure: number;
  7856. /**
  7857. * Returns the class name
  7858. * @returns The class name
  7859. */
  7860. getClassName(): string;
  7861. /**
  7862. * Binds the color curves to the shader.
  7863. * @param colorCurves The color curve to bind
  7864. * @param effect The effect to bind to
  7865. * @param positiveUniform The positive uniform shader parameter
  7866. * @param neutralUniform The neutral uniform shader parameter
  7867. * @param negativeUniform The negative uniform shader parameter
  7868. */
  7869. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7870. /**
  7871. * Prepare the list of uniforms associated with the ColorCurves effects.
  7872. * @param uniformsList The list of uniforms used in the effect
  7873. */
  7874. static PrepareUniforms(uniformsList: string[]): void;
  7875. /**
  7876. * Returns color grading data based on a hue, density, saturation and exposure value.
  7877. * @param filterHue The hue of the color filter.
  7878. * @param filterDensity The density of the color filter.
  7879. * @param saturation The saturation.
  7880. * @param exposure The exposure.
  7881. * @param result The result data container.
  7882. */
  7883. private getColorGradingDataToRef;
  7884. /**
  7885. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7886. * @param value The input slider value in range [-100,100].
  7887. * @returns Adjusted value.
  7888. */
  7889. private static applyColorGradingSliderNonlinear;
  7890. /**
  7891. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7892. * @param hue The hue (H) input.
  7893. * @param saturation The saturation (S) input.
  7894. * @param brightness The brightness (B) input.
  7895. * @result An RGBA color represented as Vector4.
  7896. */
  7897. private static fromHSBToRef;
  7898. /**
  7899. * Returns a value clamped between min and max
  7900. * @param value The value to clamp
  7901. * @param min The minimum of value
  7902. * @param max The maximum of value
  7903. * @returns The clamped value.
  7904. */
  7905. private static clamp;
  7906. /**
  7907. * Clones the current color curve instance.
  7908. * @return The cloned curves
  7909. */
  7910. clone(): ColorCurves;
  7911. /**
  7912. * Serializes the current color curve instance to a json representation.
  7913. * @return a JSON representation
  7914. */
  7915. serialize(): any;
  7916. /**
  7917. * Parses the color curve from a json representation.
  7918. * @param source the JSON source to parse
  7919. * @return The parsed curves
  7920. */
  7921. static Parse(source: any): ColorCurves;
  7922. }
  7923. }
  7924. declare module BABYLON {
  7925. /**
  7926. * Interface to follow in your material defines to integrate easily the
  7927. * Image proccessing functions.
  7928. * @hidden
  7929. */
  7930. export interface IImageProcessingConfigurationDefines {
  7931. IMAGEPROCESSING: boolean;
  7932. VIGNETTE: boolean;
  7933. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7934. VIGNETTEBLENDMODEOPAQUE: boolean;
  7935. TONEMAPPING: boolean;
  7936. TONEMAPPING_ACES: boolean;
  7937. CONTRAST: boolean;
  7938. EXPOSURE: boolean;
  7939. COLORCURVES: boolean;
  7940. COLORGRADING: boolean;
  7941. COLORGRADING3D: boolean;
  7942. SAMPLER3DGREENDEPTH: boolean;
  7943. SAMPLER3DBGRMAP: boolean;
  7944. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7945. }
  7946. /**
  7947. * @hidden
  7948. */
  7949. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7950. IMAGEPROCESSING: boolean;
  7951. VIGNETTE: boolean;
  7952. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7953. VIGNETTEBLENDMODEOPAQUE: boolean;
  7954. TONEMAPPING: boolean;
  7955. TONEMAPPING_ACES: boolean;
  7956. CONTRAST: boolean;
  7957. COLORCURVES: boolean;
  7958. COLORGRADING: boolean;
  7959. COLORGRADING3D: boolean;
  7960. SAMPLER3DGREENDEPTH: boolean;
  7961. SAMPLER3DBGRMAP: boolean;
  7962. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7963. EXPOSURE: boolean;
  7964. constructor();
  7965. }
  7966. /**
  7967. * This groups together the common properties used for image processing either in direct forward pass
  7968. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7969. * or not.
  7970. */
  7971. export class ImageProcessingConfiguration {
  7972. /**
  7973. * Default tone mapping applied in BabylonJS.
  7974. */
  7975. static readonly TONEMAPPING_STANDARD: number;
  7976. /**
  7977. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7978. * to other engines rendering to increase portability.
  7979. */
  7980. static readonly TONEMAPPING_ACES: number;
  7981. /**
  7982. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7983. */
  7984. colorCurves: Nullable<ColorCurves>;
  7985. private _colorCurvesEnabled;
  7986. /**
  7987. * Gets wether the color curves effect is enabled.
  7988. */
  7989. /**
  7990. * Sets wether the color curves effect is enabled.
  7991. */
  7992. colorCurvesEnabled: boolean;
  7993. private _colorGradingTexture;
  7994. /**
  7995. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7996. */
  7997. /**
  7998. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7999. */
  8000. colorGradingTexture: Nullable<BaseTexture>;
  8001. private _colorGradingEnabled;
  8002. /**
  8003. * Gets wether the color grading effect is enabled.
  8004. */
  8005. /**
  8006. * Sets wether the color grading effect is enabled.
  8007. */
  8008. colorGradingEnabled: boolean;
  8009. private _colorGradingWithGreenDepth;
  8010. /**
  8011. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8012. */
  8013. /**
  8014. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8015. */
  8016. colorGradingWithGreenDepth: boolean;
  8017. private _colorGradingBGR;
  8018. /**
  8019. * Gets wether the color grading texture contains BGR values.
  8020. */
  8021. /**
  8022. * Sets wether the color grading texture contains BGR values.
  8023. */
  8024. colorGradingBGR: boolean;
  8025. /** @hidden */
  8026. _exposure: number;
  8027. /**
  8028. * Gets the Exposure used in the effect.
  8029. */
  8030. /**
  8031. * Sets the Exposure used in the effect.
  8032. */
  8033. exposure: number;
  8034. private _toneMappingEnabled;
  8035. /**
  8036. * Gets wether the tone mapping effect is enabled.
  8037. */
  8038. /**
  8039. * Sets wether the tone mapping effect is enabled.
  8040. */
  8041. toneMappingEnabled: boolean;
  8042. private _toneMappingType;
  8043. /**
  8044. * Gets the type of tone mapping effect.
  8045. */
  8046. /**
  8047. * Sets the type of tone mapping effect used in BabylonJS.
  8048. */
  8049. toneMappingType: number;
  8050. protected _contrast: number;
  8051. /**
  8052. * Gets the contrast used in the effect.
  8053. */
  8054. /**
  8055. * Sets the contrast used in the effect.
  8056. */
  8057. contrast: number;
  8058. /**
  8059. * Vignette stretch size.
  8060. */
  8061. vignetteStretch: number;
  8062. /**
  8063. * Vignette centre X Offset.
  8064. */
  8065. vignetteCentreX: number;
  8066. /**
  8067. * Vignette centre Y Offset.
  8068. */
  8069. vignetteCentreY: number;
  8070. /**
  8071. * Vignette weight or intensity of the vignette effect.
  8072. */
  8073. vignetteWeight: number;
  8074. /**
  8075. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8076. * if vignetteEnabled is set to true.
  8077. */
  8078. vignetteColor: Color4;
  8079. /**
  8080. * Camera field of view used by the Vignette effect.
  8081. */
  8082. vignetteCameraFov: number;
  8083. private _vignetteBlendMode;
  8084. /**
  8085. * Gets the vignette blend mode allowing different kind of effect.
  8086. */
  8087. /**
  8088. * Sets the vignette blend mode allowing different kind of effect.
  8089. */
  8090. vignetteBlendMode: number;
  8091. private _vignetteEnabled;
  8092. /**
  8093. * Gets wether the vignette effect is enabled.
  8094. */
  8095. /**
  8096. * Sets wether the vignette effect is enabled.
  8097. */
  8098. vignetteEnabled: boolean;
  8099. private _applyByPostProcess;
  8100. /**
  8101. * Gets wether the image processing is applied through a post process or not.
  8102. */
  8103. /**
  8104. * Sets wether the image processing is applied through a post process or not.
  8105. */
  8106. applyByPostProcess: boolean;
  8107. private _isEnabled;
  8108. /**
  8109. * Gets wether the image processing is enabled or not.
  8110. */
  8111. /**
  8112. * Sets wether the image processing is enabled or not.
  8113. */
  8114. isEnabled: boolean;
  8115. /**
  8116. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8117. */
  8118. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8119. /**
  8120. * Method called each time the image processing information changes requires to recompile the effect.
  8121. */
  8122. protected _updateParameters(): void;
  8123. /**
  8124. * Gets the current class name.
  8125. * @return "ImageProcessingConfiguration"
  8126. */
  8127. getClassName(): string;
  8128. /**
  8129. * Prepare the list of uniforms associated with the Image Processing effects.
  8130. * @param uniforms The list of uniforms used in the effect
  8131. * @param defines the list of defines currently in use
  8132. */
  8133. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8134. /**
  8135. * Prepare the list of samplers associated with the Image Processing effects.
  8136. * @param samplersList The list of uniforms used in the effect
  8137. * @param defines the list of defines currently in use
  8138. */
  8139. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8140. /**
  8141. * Prepare the list of defines associated to the shader.
  8142. * @param defines the list of defines to complete
  8143. * @param forPostProcess Define if we are currently in post process mode or not
  8144. */
  8145. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8146. /**
  8147. * Returns true if all the image processing information are ready.
  8148. * @returns True if ready, otherwise, false
  8149. */
  8150. isReady(): boolean;
  8151. /**
  8152. * Binds the image processing to the shader.
  8153. * @param effect The effect to bind to
  8154. * @param aspectRatio Define the current aspect ratio of the effect
  8155. */
  8156. bind(effect: Effect, aspectRatio?: number): void;
  8157. /**
  8158. * Clones the current image processing instance.
  8159. * @return The cloned image processing
  8160. */
  8161. clone(): ImageProcessingConfiguration;
  8162. /**
  8163. * Serializes the current image processing instance to a json representation.
  8164. * @return a JSON representation
  8165. */
  8166. serialize(): any;
  8167. /**
  8168. * Parses the image processing from a json representation.
  8169. * @param source the JSON source to parse
  8170. * @return The parsed image processing
  8171. */
  8172. static Parse(source: any): ImageProcessingConfiguration;
  8173. private static _VIGNETTEMODE_MULTIPLY;
  8174. private static _VIGNETTEMODE_OPAQUE;
  8175. /**
  8176. * Used to apply the vignette as a mix with the pixel color.
  8177. */
  8178. static readonly VIGNETTEMODE_MULTIPLY: number;
  8179. /**
  8180. * Used to apply the vignette as a replacement of the pixel color.
  8181. */
  8182. static readonly VIGNETTEMODE_OPAQUE: number;
  8183. }
  8184. }
  8185. declare module BABYLON {
  8186. /** @hidden */
  8187. export var postprocessVertexShader: {
  8188. name: string;
  8189. shader: string;
  8190. };
  8191. }
  8192. declare module BABYLON {
  8193. interface ThinEngine {
  8194. /**
  8195. * Creates a new render target texture
  8196. * @param size defines the size of the texture
  8197. * @param options defines the options used to create the texture
  8198. * @returns a new render target texture stored in an InternalTexture
  8199. */
  8200. createRenderTargetTexture(size: number | {
  8201. width: number;
  8202. height: number;
  8203. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8204. }
  8205. }
  8206. declare module BABYLON {
  8207. /** Defines supported spaces */
  8208. export enum Space {
  8209. /** Local (object) space */
  8210. LOCAL = 0,
  8211. /** World space */
  8212. WORLD = 1,
  8213. /** Bone space */
  8214. BONE = 2
  8215. }
  8216. /** Defines the 3 main axes */
  8217. export class Axis {
  8218. /** X axis */
  8219. static X: Vector3;
  8220. /** Y axis */
  8221. static Y: Vector3;
  8222. /** Z axis */
  8223. static Z: Vector3;
  8224. }
  8225. }
  8226. declare module BABYLON {
  8227. /**
  8228. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8229. * This is the base of the follow, arc rotate cameras and Free camera
  8230. * @see http://doc.babylonjs.com/features/cameras
  8231. */
  8232. export class TargetCamera extends Camera {
  8233. private static _RigCamTransformMatrix;
  8234. private static _TargetTransformMatrix;
  8235. private static _TargetFocalPoint;
  8236. /**
  8237. * Define the current direction the camera is moving to
  8238. */
  8239. cameraDirection: Vector3;
  8240. /**
  8241. * Define the current rotation the camera is rotating to
  8242. */
  8243. cameraRotation: Vector2;
  8244. /**
  8245. * When set, the up vector of the camera will be updated by the rotation of the camera
  8246. */
  8247. updateUpVectorFromRotation: boolean;
  8248. private _tmpQuaternion;
  8249. /**
  8250. * Define the current rotation of the camera
  8251. */
  8252. rotation: Vector3;
  8253. /**
  8254. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8255. */
  8256. rotationQuaternion: Quaternion;
  8257. /**
  8258. * Define the current speed of the camera
  8259. */
  8260. speed: number;
  8261. /**
  8262. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8263. * around all axis.
  8264. */
  8265. noRotationConstraint: boolean;
  8266. /**
  8267. * Define the current target of the camera as an object or a position.
  8268. */
  8269. lockedTarget: any;
  8270. /** @hidden */
  8271. _currentTarget: Vector3;
  8272. /** @hidden */
  8273. _initialFocalDistance: number;
  8274. /** @hidden */
  8275. _viewMatrix: Matrix;
  8276. /** @hidden */
  8277. _camMatrix: Matrix;
  8278. /** @hidden */
  8279. _cameraTransformMatrix: Matrix;
  8280. /** @hidden */
  8281. _cameraRotationMatrix: Matrix;
  8282. /** @hidden */
  8283. _referencePoint: Vector3;
  8284. /** @hidden */
  8285. _transformedReferencePoint: Vector3;
  8286. protected _globalCurrentTarget: Vector3;
  8287. protected _globalCurrentUpVector: Vector3;
  8288. /** @hidden */
  8289. _reset: () => void;
  8290. private _defaultUp;
  8291. /**
  8292. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8293. * This is the base of the follow, arc rotate cameras and Free camera
  8294. * @see http://doc.babylonjs.com/features/cameras
  8295. * @param name Defines the name of the camera in the scene
  8296. * @param position Defines the start position of the camera in the scene
  8297. * @param scene Defines the scene the camera belongs to
  8298. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8299. */
  8300. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8301. /**
  8302. * Gets the position in front of the camera at a given distance.
  8303. * @param distance The distance from the camera we want the position to be
  8304. * @returns the position
  8305. */
  8306. getFrontPosition(distance: number): Vector3;
  8307. /** @hidden */
  8308. _getLockedTargetPosition(): Nullable<Vector3>;
  8309. private _storedPosition;
  8310. private _storedRotation;
  8311. private _storedRotationQuaternion;
  8312. /**
  8313. * Store current camera state of the camera (fov, position, rotation, etc..)
  8314. * @returns the camera
  8315. */
  8316. storeState(): Camera;
  8317. /**
  8318. * Restored camera state. You must call storeState() first
  8319. * @returns whether it was successful or not
  8320. * @hidden
  8321. */
  8322. _restoreStateValues(): boolean;
  8323. /** @hidden */
  8324. _initCache(): void;
  8325. /** @hidden */
  8326. _updateCache(ignoreParentClass?: boolean): void;
  8327. /** @hidden */
  8328. _isSynchronizedViewMatrix(): boolean;
  8329. /** @hidden */
  8330. _computeLocalCameraSpeed(): number;
  8331. /**
  8332. * Defines the target the camera should look at.
  8333. * @param target Defines the new target as a Vector or a mesh
  8334. */
  8335. setTarget(target: Vector3): void;
  8336. /**
  8337. * Return the current target position of the camera. This value is expressed in local space.
  8338. * @returns the target position
  8339. */
  8340. getTarget(): Vector3;
  8341. /** @hidden */
  8342. _decideIfNeedsToMove(): boolean;
  8343. /** @hidden */
  8344. _updatePosition(): void;
  8345. /** @hidden */
  8346. _checkInputs(): void;
  8347. protected _updateCameraRotationMatrix(): void;
  8348. /**
  8349. * 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)
  8350. * @returns the current camera
  8351. */
  8352. private _rotateUpVectorWithCameraRotationMatrix;
  8353. private _cachedRotationZ;
  8354. private _cachedQuaternionRotationZ;
  8355. /** @hidden */
  8356. _getViewMatrix(): Matrix;
  8357. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8358. /**
  8359. * @hidden
  8360. */
  8361. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8362. /**
  8363. * @hidden
  8364. */
  8365. _updateRigCameras(): void;
  8366. private _getRigCamPositionAndTarget;
  8367. /**
  8368. * Gets the current object class name.
  8369. * @return the class name
  8370. */
  8371. getClassName(): string;
  8372. }
  8373. }
  8374. declare module BABYLON {
  8375. /**
  8376. * Gather the list of keyboard event types as constants.
  8377. */
  8378. export class KeyboardEventTypes {
  8379. /**
  8380. * The keydown event is fired when a key becomes active (pressed).
  8381. */
  8382. static readonly KEYDOWN: number;
  8383. /**
  8384. * The keyup event is fired when a key has been released.
  8385. */
  8386. static readonly KEYUP: number;
  8387. }
  8388. /**
  8389. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8390. */
  8391. export class KeyboardInfo {
  8392. /**
  8393. * Defines the type of event (KeyboardEventTypes)
  8394. */
  8395. type: number;
  8396. /**
  8397. * Defines the related dom event
  8398. */
  8399. event: KeyboardEvent;
  8400. /**
  8401. * Instantiates a new keyboard info.
  8402. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8403. * @param type Defines the type of event (KeyboardEventTypes)
  8404. * @param event Defines the related dom event
  8405. */
  8406. constructor(
  8407. /**
  8408. * Defines the type of event (KeyboardEventTypes)
  8409. */
  8410. type: number,
  8411. /**
  8412. * Defines the related dom event
  8413. */
  8414. event: KeyboardEvent);
  8415. }
  8416. /**
  8417. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8418. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8419. */
  8420. export class KeyboardInfoPre extends KeyboardInfo {
  8421. /**
  8422. * Defines the type of event (KeyboardEventTypes)
  8423. */
  8424. type: number;
  8425. /**
  8426. * Defines the related dom event
  8427. */
  8428. event: KeyboardEvent;
  8429. /**
  8430. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8431. */
  8432. skipOnPointerObservable: boolean;
  8433. /**
  8434. * Instantiates a new keyboard pre info.
  8435. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8436. * @param type Defines the type of event (KeyboardEventTypes)
  8437. * @param event Defines the related dom event
  8438. */
  8439. constructor(
  8440. /**
  8441. * Defines the type of event (KeyboardEventTypes)
  8442. */
  8443. type: number,
  8444. /**
  8445. * Defines the related dom event
  8446. */
  8447. event: KeyboardEvent);
  8448. }
  8449. }
  8450. declare module BABYLON {
  8451. /**
  8452. * Manage the keyboard inputs to control the movement of a free camera.
  8453. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8454. */
  8455. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8456. /**
  8457. * Defines the camera the input is attached to.
  8458. */
  8459. camera: FreeCamera;
  8460. /**
  8461. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8462. */
  8463. keysUp: number[];
  8464. /**
  8465. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8466. */
  8467. keysDown: number[];
  8468. /**
  8469. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8470. */
  8471. keysLeft: number[];
  8472. /**
  8473. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8474. */
  8475. keysRight: number[];
  8476. private _keys;
  8477. private _onCanvasBlurObserver;
  8478. private _onKeyboardObserver;
  8479. private _engine;
  8480. private _scene;
  8481. /**
  8482. * Attach the input controls to a specific dom element to get the input from.
  8483. * @param element Defines the element the controls should be listened from
  8484. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8485. */
  8486. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8487. /**
  8488. * Detach the current controls from the specified dom element.
  8489. * @param element Defines the element to stop listening the inputs from
  8490. */
  8491. detachControl(element: Nullable<HTMLElement>): void;
  8492. /**
  8493. * Update the current camera state depending on the inputs that have been used this frame.
  8494. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8495. */
  8496. checkInputs(): void;
  8497. /**
  8498. * Gets the class name of the current intput.
  8499. * @returns the class name
  8500. */
  8501. getClassName(): string;
  8502. /** @hidden */
  8503. _onLostFocus(): void;
  8504. /**
  8505. * Get the friendly name associated with the input class.
  8506. * @returns the input friendly name
  8507. */
  8508. getSimpleName(): string;
  8509. }
  8510. }
  8511. declare module BABYLON {
  8512. /**
  8513. * Interface describing all the common properties and methods a shadow light needs to implement.
  8514. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8515. * as well as binding the different shadow properties to the effects.
  8516. */
  8517. export interface IShadowLight extends Light {
  8518. /**
  8519. * The light id in the scene (used in scene.findLighById for instance)
  8520. */
  8521. id: string;
  8522. /**
  8523. * The position the shdow will be casted from.
  8524. */
  8525. position: Vector3;
  8526. /**
  8527. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8528. */
  8529. direction: Vector3;
  8530. /**
  8531. * The transformed position. Position of the light in world space taking parenting in account.
  8532. */
  8533. transformedPosition: Vector3;
  8534. /**
  8535. * The transformed direction. Direction of the light in world space taking parenting in account.
  8536. */
  8537. transformedDirection: Vector3;
  8538. /**
  8539. * The friendly name of the light in the scene.
  8540. */
  8541. name: string;
  8542. /**
  8543. * Defines the shadow projection clipping minimum z value.
  8544. */
  8545. shadowMinZ: number;
  8546. /**
  8547. * Defines the shadow projection clipping maximum z value.
  8548. */
  8549. shadowMaxZ: number;
  8550. /**
  8551. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8552. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8553. */
  8554. computeTransformedInformation(): boolean;
  8555. /**
  8556. * Gets the scene the light belongs to.
  8557. * @returns The scene
  8558. */
  8559. getScene(): Scene;
  8560. /**
  8561. * Callback defining a custom Projection Matrix Builder.
  8562. * This can be used to override the default projection matrix computation.
  8563. */
  8564. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8565. /**
  8566. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8567. * @param matrix The materix to updated with the projection information
  8568. * @param viewMatrix The transform matrix of the light
  8569. * @param renderList The list of mesh to render in the map
  8570. * @returns The current light
  8571. */
  8572. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8573. /**
  8574. * Gets the current depth scale used in ESM.
  8575. * @returns The scale
  8576. */
  8577. getDepthScale(): number;
  8578. /**
  8579. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8580. * @returns true if a cube texture needs to be use
  8581. */
  8582. needCube(): boolean;
  8583. /**
  8584. * Detects if the projection matrix requires to be recomputed this frame.
  8585. * @returns true if it requires to be recomputed otherwise, false.
  8586. */
  8587. needProjectionMatrixCompute(): boolean;
  8588. /**
  8589. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8590. */
  8591. forceProjectionMatrixCompute(): void;
  8592. /**
  8593. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8594. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8595. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8596. */
  8597. getShadowDirection(faceIndex?: number): Vector3;
  8598. /**
  8599. * Gets the minZ used for shadow according to both the scene and the light.
  8600. * @param activeCamera The camera we are returning the min for
  8601. * @returns the depth min z
  8602. */
  8603. getDepthMinZ(activeCamera: Camera): number;
  8604. /**
  8605. * Gets the maxZ used for shadow according to both the scene and the light.
  8606. * @param activeCamera The camera we are returning the max for
  8607. * @returns the depth max z
  8608. */
  8609. getDepthMaxZ(activeCamera: Camera): number;
  8610. }
  8611. /**
  8612. * Base implementation IShadowLight
  8613. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8614. */
  8615. export abstract class ShadowLight extends Light implements IShadowLight {
  8616. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8617. protected _position: Vector3;
  8618. protected _setPosition(value: Vector3): void;
  8619. /**
  8620. * Sets the position the shadow will be casted from. Also use as the light position for both
  8621. * point and spot lights.
  8622. */
  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. position: Vector3;
  8628. protected _direction: Vector3;
  8629. protected _setDirection(value: Vector3): void;
  8630. /**
  8631. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8632. * Also use as the light direction on spot and directional lights.
  8633. */
  8634. /**
  8635. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8636. * Also use as the light direction on spot and directional lights.
  8637. */
  8638. direction: Vector3;
  8639. private _shadowMinZ;
  8640. /**
  8641. * Gets the shadow projection clipping minimum z value.
  8642. */
  8643. /**
  8644. * Sets the shadow projection clipping minimum z value.
  8645. */
  8646. shadowMinZ: number;
  8647. private _shadowMaxZ;
  8648. /**
  8649. * Sets the shadow projection clipping maximum z value.
  8650. */
  8651. /**
  8652. * Gets the shadow projection clipping maximum z value.
  8653. */
  8654. shadowMaxZ: number;
  8655. /**
  8656. * Callback defining a custom Projection Matrix Builder.
  8657. * This can be used to override the default projection matrix computation.
  8658. */
  8659. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8660. /**
  8661. * The transformed position. Position of the light in world space taking parenting in account.
  8662. */
  8663. transformedPosition: Vector3;
  8664. /**
  8665. * The transformed direction. Direction of the light in world space taking parenting in account.
  8666. */
  8667. transformedDirection: Vector3;
  8668. private _needProjectionMatrixCompute;
  8669. /**
  8670. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8671. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8672. */
  8673. computeTransformedInformation(): boolean;
  8674. /**
  8675. * Return the depth scale used for the shadow map.
  8676. * @returns the depth scale.
  8677. */
  8678. getDepthScale(): number;
  8679. /**
  8680. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8681. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8682. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8683. */
  8684. getShadowDirection(faceIndex?: number): Vector3;
  8685. /**
  8686. * Returns the ShadowLight absolute position in the World.
  8687. * @returns the position vector in world space
  8688. */
  8689. getAbsolutePosition(): Vector3;
  8690. /**
  8691. * Sets the ShadowLight direction toward the passed target.
  8692. * @param target The point to target in local space
  8693. * @returns the updated ShadowLight direction
  8694. */
  8695. setDirectionToTarget(target: Vector3): Vector3;
  8696. /**
  8697. * Returns the light rotation in euler definition.
  8698. * @returns the x y z rotation in local space.
  8699. */
  8700. getRotation(): Vector3;
  8701. /**
  8702. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8703. * @returns true if a cube texture needs to be use
  8704. */
  8705. needCube(): boolean;
  8706. /**
  8707. * Detects if the projection matrix requires to be recomputed this frame.
  8708. * @returns true if it requires to be recomputed otherwise, false.
  8709. */
  8710. needProjectionMatrixCompute(): boolean;
  8711. /**
  8712. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8713. */
  8714. forceProjectionMatrixCompute(): void;
  8715. /** @hidden */
  8716. _initCache(): void;
  8717. /** @hidden */
  8718. _isSynchronized(): boolean;
  8719. /**
  8720. * Computes the world matrix of the node
  8721. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8722. * @returns the world matrix
  8723. */
  8724. computeWorldMatrix(force?: boolean): Matrix;
  8725. /**
  8726. * Gets the minZ used for shadow according to both the scene and the light.
  8727. * @param activeCamera The camera we are returning the min for
  8728. * @returns the depth min z
  8729. */
  8730. getDepthMinZ(activeCamera: Camera): number;
  8731. /**
  8732. * Gets the maxZ used for shadow according to both the scene and the light.
  8733. * @param activeCamera The camera we are returning the max for
  8734. * @returns the depth max z
  8735. */
  8736. getDepthMaxZ(activeCamera: Camera): number;
  8737. /**
  8738. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8739. * @param matrix The materix to updated with the projection information
  8740. * @param viewMatrix The transform matrix of the light
  8741. * @param renderList The list of mesh to render in the map
  8742. * @returns The current light
  8743. */
  8744. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8745. }
  8746. }
  8747. declare module BABYLON {
  8748. /**
  8749. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8750. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8751. */
  8752. export class EffectFallbacks implements IEffectFallbacks {
  8753. private _defines;
  8754. private _currentRank;
  8755. private _maxRank;
  8756. private _mesh;
  8757. /**
  8758. * Removes the fallback from the bound mesh.
  8759. */
  8760. unBindMesh(): void;
  8761. /**
  8762. * Adds a fallback on the specified property.
  8763. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8764. * @param define The name of the define in the shader
  8765. */
  8766. addFallback(rank: number, define: string): void;
  8767. /**
  8768. * Sets the mesh to use CPU skinning when needing to fallback.
  8769. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8770. * @param mesh The mesh to use the fallbacks.
  8771. */
  8772. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8773. /**
  8774. * Checks to see if more fallbacks are still availible.
  8775. */
  8776. readonly hasMoreFallbacks: boolean;
  8777. /**
  8778. * Removes the defines that should be removed when falling back.
  8779. * @param currentDefines defines the current define statements for the shader.
  8780. * @param effect defines the current effect we try to compile
  8781. * @returns The resulting defines with defines of the current rank removed.
  8782. */
  8783. reduce(currentDefines: string, effect: Effect): string;
  8784. }
  8785. }
  8786. declare module BABYLON {
  8787. /**
  8788. * "Static Class" containing the most commonly used helper while dealing with material for
  8789. * rendering purpose.
  8790. *
  8791. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8792. *
  8793. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8794. */
  8795. export class MaterialHelper {
  8796. /**
  8797. * Bind the current view position to an effect.
  8798. * @param effect The effect to be bound
  8799. * @param scene The scene the eyes position is used from
  8800. */
  8801. static BindEyePosition(effect: Effect, scene: Scene): void;
  8802. /**
  8803. * Helps preparing the defines values about the UVs in used in the effect.
  8804. * UVs are shared as much as we can accross channels in the shaders.
  8805. * @param texture The texture we are preparing the UVs for
  8806. * @param defines The defines to update
  8807. * @param key The channel key "diffuse", "specular"... used in the shader
  8808. */
  8809. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8810. /**
  8811. * Binds a texture matrix value to its corrsponding uniform
  8812. * @param texture The texture to bind the matrix for
  8813. * @param uniformBuffer The uniform buffer receivin the data
  8814. * @param key The channel key "diffuse", "specular"... used in the shader
  8815. */
  8816. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8817. /**
  8818. * Gets the current status of the fog (should it be enabled?)
  8819. * @param mesh defines the mesh to evaluate for fog support
  8820. * @param scene defines the hosting scene
  8821. * @returns true if fog must be enabled
  8822. */
  8823. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8824. /**
  8825. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8826. * @param mesh defines the current mesh
  8827. * @param scene defines the current scene
  8828. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8829. * @param pointsCloud defines if point cloud rendering has to be turned on
  8830. * @param fogEnabled defines if fog has to be turned on
  8831. * @param alphaTest defines if alpha testing has to be turned on
  8832. * @param defines defines the current list of defines
  8833. */
  8834. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8835. /**
  8836. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8837. * @param scene defines the current scene
  8838. * @param engine defines the current engine
  8839. * @param defines specifies the list of active defines
  8840. * @param useInstances defines if instances have to be turned on
  8841. * @param useClipPlane defines if clip plane have to be turned on
  8842. */
  8843. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8844. /**
  8845. * Prepares the defines for bones
  8846. * @param mesh The mesh containing the geometry data we will draw
  8847. * @param defines The defines to update
  8848. */
  8849. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8850. /**
  8851. * Prepares the defines for morph targets
  8852. * @param mesh The mesh containing the geometry data we will draw
  8853. * @param defines The defines to update
  8854. */
  8855. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8856. /**
  8857. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8858. * @param mesh The mesh containing the geometry data we will draw
  8859. * @param defines The defines to update
  8860. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8861. * @param useBones Precise whether bones should be used or not (override mesh info)
  8862. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8863. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8864. * @returns false if defines are considered not dirty and have not been checked
  8865. */
  8866. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8867. /**
  8868. * Prepares the defines related to multiview
  8869. * @param scene The scene we are intending to draw
  8870. * @param defines The defines to update
  8871. */
  8872. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8873. /**
  8874. * Prepares the defines related to the light information passed in parameter
  8875. * @param scene The scene we are intending to draw
  8876. * @param mesh The mesh the effect is compiling for
  8877. * @param light The light the effect is compiling for
  8878. * @param lightIndex The index of the light
  8879. * @param defines The defines to update
  8880. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8881. * @param state Defines the current state regarding what is needed (normals, etc...)
  8882. */
  8883. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8884. needNormals: boolean;
  8885. needRebuild: boolean;
  8886. shadowEnabled: boolean;
  8887. specularEnabled: boolean;
  8888. lightmapMode: boolean;
  8889. }): void;
  8890. /**
  8891. * Prepares the defines related to the light information passed in parameter
  8892. * @param scene The scene we are intending to draw
  8893. * @param mesh The mesh the effect is compiling for
  8894. * @param defines The defines to update
  8895. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8896. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8897. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8898. * @returns true if normals will be required for the rest of the effect
  8899. */
  8900. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8901. /**
  8902. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8903. * @param lightIndex defines the light index
  8904. * @param uniformsList The uniform list
  8905. * @param samplersList The sampler list
  8906. * @param projectedLightTexture defines if projected texture must be used
  8907. * @param uniformBuffersList defines an optional list of uniform buffers
  8908. */
  8909. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8910. /**
  8911. * Prepares the uniforms and samplers list to be used in the effect
  8912. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8913. * @param samplersList The sampler list
  8914. * @param defines The defines helping in the list generation
  8915. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8916. */
  8917. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8918. /**
  8919. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8920. * @param defines The defines to update while falling back
  8921. * @param fallbacks The authorized effect fallbacks
  8922. * @param maxSimultaneousLights The maximum number of lights allowed
  8923. * @param rank the current rank of the Effect
  8924. * @returns The newly affected rank
  8925. */
  8926. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8927. private static _TmpMorphInfluencers;
  8928. /**
  8929. * Prepares the list of attributes required for morph targets according to the effect defines.
  8930. * @param attribs The current list of supported attribs
  8931. * @param mesh The mesh to prepare the morph targets attributes for
  8932. * @param influencers The number of influencers
  8933. */
  8934. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8935. /**
  8936. * Prepares the list of attributes required for morph targets according to the effect defines.
  8937. * @param attribs The current list of supported attribs
  8938. * @param mesh The mesh to prepare the morph targets attributes for
  8939. * @param defines The current Defines of the effect
  8940. */
  8941. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8942. /**
  8943. * Prepares the list of attributes required for bones according to the effect defines.
  8944. * @param attribs The current list of supported attribs
  8945. * @param mesh The mesh to prepare the bones attributes for
  8946. * @param defines The current Defines of the effect
  8947. * @param fallbacks The current efffect fallback strategy
  8948. */
  8949. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8950. /**
  8951. * Check and prepare the list of attributes required for instances according to the effect defines.
  8952. * @param attribs The current list of supported attribs
  8953. * @param defines The current MaterialDefines of the effect
  8954. */
  8955. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8956. /**
  8957. * Add the list of attributes required for instances to the attribs array.
  8958. * @param attribs The current list of supported attribs
  8959. */
  8960. static PushAttributesForInstances(attribs: string[]): void;
  8961. /**
  8962. * Binds the light shadow information to the effect for the given mesh.
  8963. * @param light The light containing the generator
  8964. * @param scene The scene the lights belongs to
  8965. * @param mesh The mesh we are binding the information to render
  8966. * @param lightIndex The light index in the effect used to render the mesh
  8967. * @param effect The effect we are binding the data to
  8968. */
  8969. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8970. /**
  8971. * Binds the light information to the effect.
  8972. * @param light The light containing the generator
  8973. * @param effect The effect we are binding the data to
  8974. * @param lightIndex The light index in the effect used to render
  8975. */
  8976. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8977. /**
  8978. * Binds the lights information from the scene to the effect for the given mesh.
  8979. * @param light Light to bind
  8980. * @param lightIndex Light index
  8981. * @param scene The scene where the light belongs to
  8982. * @param mesh The mesh we are binding the information to render
  8983. * @param effect The effect we are binding the data to
  8984. * @param useSpecular Defines if specular is supported
  8985. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8986. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8987. */
  8988. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8989. /**
  8990. * Binds the lights information from the scene to the effect for the given mesh.
  8991. * @param scene The scene the lights belongs to
  8992. * @param mesh The mesh we are binding the information to render
  8993. * @param effect The effect we are binding the data to
  8994. * @param defines The generated defines for the effect
  8995. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8996. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8997. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8998. */
  8999. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9000. private static _tempFogColor;
  9001. /**
  9002. * Binds the fog information from the scene to the effect for the given mesh.
  9003. * @param scene The scene the lights belongs to
  9004. * @param mesh The mesh we are binding the information to render
  9005. * @param effect The effect we are binding the data to
  9006. * @param linearSpace Defines if the fog effect is applied in linear space
  9007. */
  9008. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9009. /**
  9010. * Binds the bones information from the mesh to the effect.
  9011. * @param mesh The mesh we are binding the information to render
  9012. * @param effect The effect we are binding the data to
  9013. */
  9014. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9015. /**
  9016. * Binds the morph targets information from the mesh to the effect.
  9017. * @param abstractMesh The mesh we are binding the information to render
  9018. * @param effect The effect we are binding the data to
  9019. */
  9020. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9021. /**
  9022. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9023. * @param defines The generated defines used in the effect
  9024. * @param effect The effect we are binding the data to
  9025. * @param scene The scene we are willing to render with logarithmic scale for
  9026. */
  9027. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9028. /**
  9029. * Binds the clip plane information from the scene to the effect.
  9030. * @param scene The scene the clip plane information are extracted from
  9031. * @param effect The effect we are binding the data to
  9032. */
  9033. static BindClipPlane(effect: Effect, scene: Scene): void;
  9034. }
  9035. }
  9036. declare module BABYLON {
  9037. /** @hidden */
  9038. export var packingFunctions: {
  9039. name: string;
  9040. shader: string;
  9041. };
  9042. }
  9043. declare module BABYLON {
  9044. /** @hidden */
  9045. export var shadowMapPixelShader: {
  9046. name: string;
  9047. shader: string;
  9048. };
  9049. }
  9050. declare module BABYLON {
  9051. /** @hidden */
  9052. export var bonesDeclaration: {
  9053. name: string;
  9054. shader: string;
  9055. };
  9056. }
  9057. declare module BABYLON {
  9058. /** @hidden */
  9059. export var morphTargetsVertexGlobalDeclaration: {
  9060. name: string;
  9061. shader: string;
  9062. };
  9063. }
  9064. declare module BABYLON {
  9065. /** @hidden */
  9066. export var morphTargetsVertexDeclaration: {
  9067. name: string;
  9068. shader: string;
  9069. };
  9070. }
  9071. declare module BABYLON {
  9072. /** @hidden */
  9073. export var instancesDeclaration: {
  9074. name: string;
  9075. shader: string;
  9076. };
  9077. }
  9078. declare module BABYLON {
  9079. /** @hidden */
  9080. export var helperFunctions: {
  9081. name: string;
  9082. shader: string;
  9083. };
  9084. }
  9085. declare module BABYLON {
  9086. /** @hidden */
  9087. export var morphTargetsVertex: {
  9088. name: string;
  9089. shader: string;
  9090. };
  9091. }
  9092. declare module BABYLON {
  9093. /** @hidden */
  9094. export var instancesVertex: {
  9095. name: string;
  9096. shader: string;
  9097. };
  9098. }
  9099. declare module BABYLON {
  9100. /** @hidden */
  9101. export var bonesVertex: {
  9102. name: string;
  9103. shader: string;
  9104. };
  9105. }
  9106. declare module BABYLON {
  9107. /** @hidden */
  9108. export var shadowMapVertexShader: {
  9109. name: string;
  9110. shader: string;
  9111. };
  9112. }
  9113. declare module BABYLON {
  9114. /** @hidden */
  9115. export var depthBoxBlurPixelShader: {
  9116. name: string;
  9117. shader: string;
  9118. };
  9119. }
  9120. declare module BABYLON {
  9121. /**
  9122. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9123. */
  9124. export interface ICustomShaderOptions {
  9125. /**
  9126. * Gets or sets the custom shader name to use
  9127. */
  9128. shaderName: string;
  9129. /**
  9130. * The list of attribute names used in the shader
  9131. */
  9132. attributes?: string[];
  9133. /**
  9134. * The list of unifrom names used in the shader
  9135. */
  9136. uniforms?: string[];
  9137. /**
  9138. * The list of sampler names used in the shader
  9139. */
  9140. samplers?: string[];
  9141. /**
  9142. * The list of defines used in the shader
  9143. */
  9144. defines?: string[];
  9145. }
  9146. /**
  9147. * Interface to implement to create a shadow generator compatible with BJS.
  9148. */
  9149. export interface IShadowGenerator {
  9150. /**
  9151. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9152. * @returns The render target texture if present otherwise, null
  9153. */
  9154. getShadowMap(): Nullable<RenderTargetTexture>;
  9155. /**
  9156. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9157. * @returns The render target texture if the shadow map is present otherwise, null
  9158. */
  9159. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9160. /**
  9161. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9162. * @param subMesh The submesh we want to render in the shadow map
  9163. * @param useInstances Defines wether will draw in the map using instances
  9164. * @returns true if ready otherwise, false
  9165. */
  9166. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9167. /**
  9168. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9169. * @param defines Defines of the material we want to update
  9170. * @param lightIndex Index of the light in the enabled light list of the material
  9171. */
  9172. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9173. /**
  9174. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9175. * defined in the generator but impacting the effect).
  9176. * It implies the unifroms available on the materials are the standard BJS ones.
  9177. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9178. * @param effect The effect we are binfing the information for
  9179. */
  9180. bindShadowLight(lightIndex: string, effect: Effect): void;
  9181. /**
  9182. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9183. * (eq to shadow prjection matrix * light transform matrix)
  9184. * @returns The transform matrix used to create the shadow map
  9185. */
  9186. getTransformMatrix(): Matrix;
  9187. /**
  9188. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9189. * Cube and 2D textures for instance.
  9190. */
  9191. recreateShadowMap(): void;
  9192. /**
  9193. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9194. * @param onCompiled Callback triggered at the and of the effects compilation
  9195. * @param options Sets of optional options forcing the compilation with different modes
  9196. */
  9197. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9198. useInstances: boolean;
  9199. }>): void;
  9200. /**
  9201. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9202. * @param options Sets of optional options forcing the compilation with different modes
  9203. * @returns A promise that resolves when the compilation completes
  9204. */
  9205. forceCompilationAsync(options?: Partial<{
  9206. useInstances: boolean;
  9207. }>): Promise<void>;
  9208. /**
  9209. * Serializes the shadow generator setup to a json object.
  9210. * @returns The serialized JSON object
  9211. */
  9212. serialize(): any;
  9213. /**
  9214. * Disposes the Shadow map and related Textures and effects.
  9215. */
  9216. dispose(): void;
  9217. }
  9218. /**
  9219. * Default implementation IShadowGenerator.
  9220. * This is the main object responsible of generating shadows in the framework.
  9221. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9222. */
  9223. export class ShadowGenerator implements IShadowGenerator {
  9224. /**
  9225. * Shadow generator mode None: no filtering applied.
  9226. */
  9227. static readonly FILTER_NONE: number;
  9228. /**
  9229. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9230. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9231. */
  9232. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9233. /**
  9234. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9235. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9236. */
  9237. static readonly FILTER_POISSONSAMPLING: number;
  9238. /**
  9239. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9240. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9241. */
  9242. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9243. /**
  9244. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9245. * edge artifacts on steep falloff.
  9246. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9247. */
  9248. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9249. /**
  9250. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9251. * edge artifacts on steep falloff.
  9252. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9253. */
  9254. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9255. /**
  9256. * Shadow generator mode PCF: Percentage Closer Filtering
  9257. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9258. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9259. */
  9260. static readonly FILTER_PCF: number;
  9261. /**
  9262. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9263. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9264. * Contact Hardening
  9265. */
  9266. static readonly FILTER_PCSS: number;
  9267. /**
  9268. * Reserved for PCF and PCSS
  9269. * Highest Quality.
  9270. *
  9271. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9272. *
  9273. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9274. */
  9275. static readonly QUALITY_HIGH: number;
  9276. /**
  9277. * Reserved for PCF and PCSS
  9278. * Good tradeoff for quality/perf cross devices
  9279. *
  9280. * Execute PCF on a 3*3 kernel.
  9281. *
  9282. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9283. */
  9284. static readonly QUALITY_MEDIUM: number;
  9285. /**
  9286. * Reserved for PCF and PCSS
  9287. * The lowest quality but the fastest.
  9288. *
  9289. * Execute PCF on a 1*1 kernel.
  9290. *
  9291. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9292. */
  9293. static readonly QUALITY_LOW: number;
  9294. /** Gets or sets the custom shader name to use */
  9295. customShaderOptions: ICustomShaderOptions;
  9296. /**
  9297. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9298. */
  9299. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9300. /**
  9301. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9302. */
  9303. onAfterShadowMapRenderObservable: Observable<Effect>;
  9304. /**
  9305. * Observable triggered before a mesh is rendered in the shadow map.
  9306. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9307. */
  9308. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9309. /**
  9310. * Observable triggered after a mesh is rendered in the shadow map.
  9311. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9312. */
  9313. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9314. private _bias;
  9315. /**
  9316. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9317. */
  9318. /**
  9319. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9320. */
  9321. bias: number;
  9322. private _normalBias;
  9323. /**
  9324. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9325. */
  9326. /**
  9327. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9328. */
  9329. normalBias: number;
  9330. private _blurBoxOffset;
  9331. /**
  9332. * Gets the blur box offset: offset applied during the blur pass.
  9333. * Only useful if useKernelBlur = false
  9334. */
  9335. /**
  9336. * Sets the blur box offset: offset applied during the blur pass.
  9337. * Only useful if useKernelBlur = false
  9338. */
  9339. blurBoxOffset: number;
  9340. private _blurScale;
  9341. /**
  9342. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9343. * 2 means half of the size.
  9344. */
  9345. /**
  9346. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9347. * 2 means half of the size.
  9348. */
  9349. blurScale: number;
  9350. private _blurKernel;
  9351. /**
  9352. * Gets the blur kernel: kernel size of the blur pass.
  9353. * Only useful if useKernelBlur = true
  9354. */
  9355. /**
  9356. * Sets the blur kernel: kernel size of the blur pass.
  9357. * Only useful if useKernelBlur = true
  9358. */
  9359. blurKernel: number;
  9360. private _useKernelBlur;
  9361. /**
  9362. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9363. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9364. */
  9365. /**
  9366. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9367. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9368. */
  9369. useKernelBlur: boolean;
  9370. private _depthScale;
  9371. /**
  9372. * Gets the depth scale used in ESM mode.
  9373. */
  9374. /**
  9375. * Sets the depth scale used in ESM mode.
  9376. * This can override the scale stored on the light.
  9377. */
  9378. depthScale: number;
  9379. private _filter;
  9380. /**
  9381. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9382. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9383. */
  9384. /**
  9385. * Sets 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. filter: number;
  9389. /**
  9390. * Gets if the current filter is set to Poisson Sampling.
  9391. */
  9392. /**
  9393. * Sets the current filter to Poisson Sampling.
  9394. */
  9395. usePoissonSampling: boolean;
  9396. /**
  9397. * Gets if the current filter is set to ESM.
  9398. */
  9399. /**
  9400. * Sets the current filter is to ESM.
  9401. */
  9402. useExponentialShadowMap: boolean;
  9403. /**
  9404. * Gets if the current filter is set to filtered ESM.
  9405. */
  9406. /**
  9407. * Gets if the current filter is set to filtered ESM.
  9408. */
  9409. useBlurExponentialShadowMap: boolean;
  9410. /**
  9411. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9412. * exponential to prevent steep falloff artifacts).
  9413. */
  9414. /**
  9415. * Sets the current filter to "close ESM" (using the inverse of the
  9416. * exponential to prevent steep falloff artifacts).
  9417. */
  9418. useCloseExponentialShadowMap: boolean;
  9419. /**
  9420. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9421. * exponential to prevent steep falloff artifacts).
  9422. */
  9423. /**
  9424. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9425. * exponential to prevent steep falloff artifacts).
  9426. */
  9427. useBlurCloseExponentialShadowMap: boolean;
  9428. /**
  9429. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9430. */
  9431. /**
  9432. * Sets the current filter to "PCF" (percentage closer filtering).
  9433. */
  9434. usePercentageCloserFiltering: boolean;
  9435. private _filteringQuality;
  9436. /**
  9437. * Gets the PCF or PCSS Quality.
  9438. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9439. */
  9440. /**
  9441. * Sets the PCF or PCSS Quality.
  9442. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9443. */
  9444. filteringQuality: number;
  9445. /**
  9446. * Gets if the current filter is set to "PCSS" (contact hardening).
  9447. */
  9448. /**
  9449. * Sets the current filter to "PCSS" (contact hardening).
  9450. */
  9451. useContactHardeningShadow: boolean;
  9452. private _contactHardeningLightSizeUVRatio;
  9453. /**
  9454. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9455. * Using a ratio helps keeping shape stability independently of the map size.
  9456. *
  9457. * It does not account for the light projection as it was having too much
  9458. * instability during the light setup or during light position changes.
  9459. *
  9460. * Only valid if useContactHardeningShadow is true.
  9461. */
  9462. /**
  9463. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9464. * Using a ratio helps keeping shape stability independently of the map size.
  9465. *
  9466. * It does not account for the light projection as it was having too much
  9467. * instability during the light setup or during light position changes.
  9468. *
  9469. * Only valid if useContactHardeningShadow is true.
  9470. */
  9471. contactHardeningLightSizeUVRatio: number;
  9472. private _darkness;
  9473. /** Gets or sets the actual darkness of a shadow */
  9474. darkness: number;
  9475. /**
  9476. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9477. * 0 means strongest and 1 would means no shadow.
  9478. * @returns the darkness.
  9479. */
  9480. getDarkness(): number;
  9481. /**
  9482. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9483. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9484. * @returns the shadow generator allowing fluent coding.
  9485. */
  9486. setDarkness(darkness: number): ShadowGenerator;
  9487. private _transparencyShadow;
  9488. /** Gets or sets the ability to have transparent shadow */
  9489. transparencyShadow: boolean;
  9490. /**
  9491. * Sets the ability to have transparent shadow (boolean).
  9492. * @param transparent True if transparent else False
  9493. * @returns the shadow generator allowing fluent coding
  9494. */
  9495. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9496. private _shadowMap;
  9497. private _shadowMap2;
  9498. /**
  9499. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9500. * @returns The render target texture if present otherwise, null
  9501. */
  9502. getShadowMap(): Nullable<RenderTargetTexture>;
  9503. /**
  9504. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9505. * @returns The render target texture if the shadow map is present otherwise, null
  9506. */
  9507. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9508. /**
  9509. * Gets the class name of that object
  9510. * @returns "ShadowGenerator"
  9511. */
  9512. getClassName(): string;
  9513. /**
  9514. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9515. * @param mesh Mesh to add
  9516. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9517. * @returns the Shadow Generator itself
  9518. */
  9519. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9520. /**
  9521. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9522. * @param mesh Mesh to remove
  9523. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9524. * @returns the Shadow Generator itself
  9525. */
  9526. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9527. /**
  9528. * Controls the extent to which the shadows fade out at the edge of the frustum
  9529. * Used only by directionals and spots
  9530. */
  9531. frustumEdgeFalloff: number;
  9532. private _light;
  9533. /**
  9534. * Returns the associated light object.
  9535. * @returns the light generating the shadow
  9536. */
  9537. getLight(): IShadowLight;
  9538. /**
  9539. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9540. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9541. * It might on the other hand introduce peter panning.
  9542. */
  9543. forceBackFacesOnly: boolean;
  9544. private _scene;
  9545. private _lightDirection;
  9546. private _effect;
  9547. private _viewMatrix;
  9548. private _projectionMatrix;
  9549. private _transformMatrix;
  9550. private _cachedPosition;
  9551. private _cachedDirection;
  9552. private _cachedDefines;
  9553. private _currentRenderID;
  9554. private _boxBlurPostprocess;
  9555. private _kernelBlurXPostprocess;
  9556. private _kernelBlurYPostprocess;
  9557. private _blurPostProcesses;
  9558. private _mapSize;
  9559. private _currentFaceIndex;
  9560. private _currentFaceIndexCache;
  9561. private _textureType;
  9562. private _defaultTextureMatrix;
  9563. private _storedUniqueId;
  9564. /** @hidden */
  9565. static _SceneComponentInitialization: (scene: Scene) => void;
  9566. /**
  9567. * Creates a ShadowGenerator object.
  9568. * A ShadowGenerator is the required tool to use the shadows.
  9569. * Each light casting shadows needs to use its own ShadowGenerator.
  9570. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9571. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9572. * @param light The light object generating the shadows.
  9573. * @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.
  9574. */
  9575. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9576. private _initializeGenerator;
  9577. private _initializeShadowMap;
  9578. private _initializeBlurRTTAndPostProcesses;
  9579. private _renderForShadowMap;
  9580. private _renderSubMeshForShadowMap;
  9581. private _applyFilterValues;
  9582. /**
  9583. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9584. * @param onCompiled Callback triggered at the and of the effects compilation
  9585. * @param options Sets of optional options forcing the compilation with different modes
  9586. */
  9587. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9588. useInstances: boolean;
  9589. }>): void;
  9590. /**
  9591. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9592. * @param options Sets of optional options forcing the compilation with different modes
  9593. * @returns A promise that resolves when the compilation completes
  9594. */
  9595. forceCompilationAsync(options?: Partial<{
  9596. useInstances: boolean;
  9597. }>): Promise<void>;
  9598. /**
  9599. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9600. * @param subMesh The submesh we want to render in the shadow map
  9601. * @param useInstances Defines wether will draw in the map using instances
  9602. * @returns true if ready otherwise, false
  9603. */
  9604. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9605. /**
  9606. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9607. * @param defines Defines of the material we want to update
  9608. * @param lightIndex Index of the light in the enabled light list of the material
  9609. */
  9610. prepareDefines(defines: any, lightIndex: number): void;
  9611. /**
  9612. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9613. * defined in the generator but impacting the effect).
  9614. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9615. * @param effect The effect we are binfing the information for
  9616. */
  9617. bindShadowLight(lightIndex: string, effect: Effect): void;
  9618. /**
  9619. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9620. * (eq to shadow prjection matrix * light transform matrix)
  9621. * @returns The transform matrix used to create the shadow map
  9622. */
  9623. getTransformMatrix(): Matrix;
  9624. /**
  9625. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9626. * Cube and 2D textures for instance.
  9627. */
  9628. recreateShadowMap(): void;
  9629. private _disposeBlurPostProcesses;
  9630. private _disposeRTTandPostProcesses;
  9631. /**
  9632. * Disposes the ShadowGenerator.
  9633. * Returns nothing.
  9634. */
  9635. dispose(): void;
  9636. /**
  9637. * Serializes the shadow generator setup to a json object.
  9638. * @returns The serialized JSON object
  9639. */
  9640. serialize(): any;
  9641. /**
  9642. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9643. * @param parsedShadowGenerator The JSON object to parse
  9644. * @param scene The scene to create the shadow map for
  9645. * @returns The parsed shadow generator
  9646. */
  9647. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9648. }
  9649. }
  9650. declare module BABYLON {
  9651. /**
  9652. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9653. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9654. * 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.
  9655. */
  9656. export abstract class Light extends Node {
  9657. /**
  9658. * Falloff Default: light is falling off following the material specification:
  9659. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9660. */
  9661. static readonly FALLOFF_DEFAULT: number;
  9662. /**
  9663. * Falloff Physical: light is falling off following the inverse squared distance law.
  9664. */
  9665. static readonly FALLOFF_PHYSICAL: number;
  9666. /**
  9667. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9668. * to enhance interoperability with other engines.
  9669. */
  9670. static readonly FALLOFF_GLTF: number;
  9671. /**
  9672. * Falloff Standard: light is falling off like in the standard material
  9673. * to enhance interoperability with other materials.
  9674. */
  9675. static readonly FALLOFF_STANDARD: number;
  9676. /**
  9677. * If every light affecting the material is in this lightmapMode,
  9678. * material.lightmapTexture adds or multiplies
  9679. * (depends on material.useLightmapAsShadowmap)
  9680. * after every other light calculations.
  9681. */
  9682. static readonly LIGHTMAP_DEFAULT: number;
  9683. /**
  9684. * material.lightmapTexture as only diffuse lighting from this light
  9685. * adds only specular lighting from this light
  9686. * adds dynamic shadows
  9687. */
  9688. static readonly LIGHTMAP_SPECULAR: number;
  9689. /**
  9690. * material.lightmapTexture as only lighting
  9691. * no light calculation from this light
  9692. * only adds dynamic shadows from this light
  9693. */
  9694. static readonly LIGHTMAP_SHADOWSONLY: number;
  9695. /**
  9696. * Each light type uses the default quantity according to its type:
  9697. * point/spot lights use luminous intensity
  9698. * directional lights use illuminance
  9699. */
  9700. static readonly INTENSITYMODE_AUTOMATIC: number;
  9701. /**
  9702. * lumen (lm)
  9703. */
  9704. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9705. /**
  9706. * candela (lm/sr)
  9707. */
  9708. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9709. /**
  9710. * lux (lm/m^2)
  9711. */
  9712. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9713. /**
  9714. * nit (cd/m^2)
  9715. */
  9716. static readonly INTENSITYMODE_LUMINANCE: number;
  9717. /**
  9718. * Light type const id of the point light.
  9719. */
  9720. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9721. /**
  9722. * Light type const id of the directional light.
  9723. */
  9724. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9725. /**
  9726. * Light type const id of the spot light.
  9727. */
  9728. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9729. /**
  9730. * Light type const id of the hemispheric light.
  9731. */
  9732. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9733. /**
  9734. * Diffuse gives the basic color to an object.
  9735. */
  9736. diffuse: Color3;
  9737. /**
  9738. * Specular produces a highlight color on an object.
  9739. * Note: This is note affecting PBR materials.
  9740. */
  9741. specular: Color3;
  9742. /**
  9743. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9744. * falling off base on range or angle.
  9745. * This can be set to any values in Light.FALLOFF_x.
  9746. *
  9747. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9748. * other types of materials.
  9749. */
  9750. falloffType: number;
  9751. /**
  9752. * Strength of the light.
  9753. * Note: By default it is define in the framework own unit.
  9754. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9755. */
  9756. intensity: number;
  9757. private _range;
  9758. protected _inverseSquaredRange: number;
  9759. /**
  9760. * Defines how far from the source the light is impacting in scene units.
  9761. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9762. */
  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. range: number;
  9768. /**
  9769. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9770. * of light.
  9771. */
  9772. private _photometricScale;
  9773. private _intensityMode;
  9774. /**
  9775. * Gets the photometric scale used to interpret the intensity.
  9776. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9777. */
  9778. /**
  9779. * Sets 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. intensityMode: number;
  9783. private _radius;
  9784. /**
  9785. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9786. */
  9787. /**
  9788. * sets the light radius used by PBR Materials to simulate soft area lights.
  9789. */
  9790. radius: number;
  9791. private _renderPriority;
  9792. /**
  9793. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9794. * exceeding the number allowed of the materials.
  9795. */
  9796. renderPriority: number;
  9797. private _shadowEnabled;
  9798. /**
  9799. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9800. * the current shadow generator.
  9801. */
  9802. /**
  9803. * Sets 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. shadowEnabled: boolean;
  9807. private _includedOnlyMeshes;
  9808. /**
  9809. * Gets the only meshes impacted by this light.
  9810. */
  9811. /**
  9812. * Sets the only meshes impacted by this light.
  9813. */
  9814. includedOnlyMeshes: AbstractMesh[];
  9815. private _excludedMeshes;
  9816. /**
  9817. * Gets the meshes not impacted by this light.
  9818. */
  9819. /**
  9820. * Sets the meshes not impacted by this light.
  9821. */
  9822. excludedMeshes: AbstractMesh[];
  9823. private _excludeWithLayerMask;
  9824. /**
  9825. * Gets the layer id use to find what meshes are not impacted by the light.
  9826. * Inactive if 0
  9827. */
  9828. /**
  9829. * Sets the layer id use to find what meshes are not impacted by the light.
  9830. * Inactive if 0
  9831. */
  9832. excludeWithLayerMask: number;
  9833. private _includeOnlyWithLayerMask;
  9834. /**
  9835. * Gets the layer id use to find what meshes are impacted by the light.
  9836. * Inactive if 0
  9837. */
  9838. /**
  9839. * Sets the layer id use to find what meshes are impacted by the light.
  9840. * Inactive if 0
  9841. */
  9842. includeOnlyWithLayerMask: number;
  9843. private _lightmapMode;
  9844. /**
  9845. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9846. */
  9847. /**
  9848. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9849. */
  9850. lightmapMode: number;
  9851. /**
  9852. * Shadow generator associted to the light.
  9853. * @hidden Internal use only.
  9854. */
  9855. _shadowGenerator: Nullable<IShadowGenerator>;
  9856. /**
  9857. * @hidden Internal use only.
  9858. */
  9859. _excludedMeshesIds: string[];
  9860. /**
  9861. * @hidden Internal use only.
  9862. */
  9863. _includedOnlyMeshesIds: string[];
  9864. /**
  9865. * The current light unifom buffer.
  9866. * @hidden Internal use only.
  9867. */
  9868. _uniformBuffer: UniformBuffer;
  9869. /**
  9870. * Creates a Light object in the scene.
  9871. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9872. * @param name The firendly name of the light
  9873. * @param scene The scene the light belongs too
  9874. */
  9875. constructor(name: string, scene: Scene);
  9876. protected abstract _buildUniformLayout(): void;
  9877. /**
  9878. * Sets the passed Effect "effect" with the Light information.
  9879. * @param effect The effect to update
  9880. * @param lightIndex The index of the light in the effect to update
  9881. * @returns The light
  9882. */
  9883. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9884. /**
  9885. * Sets the passed Effect "effect" with the Light information.
  9886. * @param effect The effect to update
  9887. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9888. * @returns The light
  9889. */
  9890. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9891. /**
  9892. * Returns the string "Light".
  9893. * @returns the class name
  9894. */
  9895. getClassName(): string;
  9896. /** @hidden */
  9897. readonly _isLight: boolean;
  9898. /**
  9899. * Converts the light information to a readable string for debug purpose.
  9900. * @param fullDetails Supports for multiple levels of logging within scene loading
  9901. * @returns the human readable light info
  9902. */
  9903. toString(fullDetails?: boolean): string;
  9904. /** @hidden */
  9905. protected _syncParentEnabledState(): void;
  9906. /**
  9907. * Set the enabled state of this node.
  9908. * @param value - the new enabled state
  9909. */
  9910. setEnabled(value: boolean): void;
  9911. /**
  9912. * Returns the Light associated shadow generator if any.
  9913. * @return the associated shadow generator.
  9914. */
  9915. getShadowGenerator(): Nullable<IShadowGenerator>;
  9916. /**
  9917. * Returns a Vector3, the absolute light position in the World.
  9918. * @returns the world space position of the light
  9919. */
  9920. getAbsolutePosition(): Vector3;
  9921. /**
  9922. * Specifies if the light will affect the passed mesh.
  9923. * @param mesh The mesh to test against the light
  9924. * @return true the mesh is affected otherwise, false.
  9925. */
  9926. canAffectMesh(mesh: AbstractMesh): boolean;
  9927. /**
  9928. * Sort function to order lights for rendering.
  9929. * @param a First Light object to compare to second.
  9930. * @param b Second Light object to compare first.
  9931. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9932. */
  9933. static CompareLightsPriority(a: Light, b: Light): number;
  9934. /**
  9935. * Releases resources associated with this node.
  9936. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9937. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9938. */
  9939. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9940. /**
  9941. * Returns the light type ID (integer).
  9942. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9943. */
  9944. getTypeID(): number;
  9945. /**
  9946. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9947. * @returns the scaled intensity in intensity mode unit
  9948. */
  9949. getScaledIntensity(): number;
  9950. /**
  9951. * Returns a new Light object, named "name", from the current one.
  9952. * @param name The name of the cloned light
  9953. * @returns the new created light
  9954. */
  9955. clone(name: string): Nullable<Light>;
  9956. /**
  9957. * Serializes the current light into a Serialization object.
  9958. * @returns the serialized object.
  9959. */
  9960. serialize(): any;
  9961. /**
  9962. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9963. * This new light is named "name" and added to the passed scene.
  9964. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9965. * @param name The friendly name of the light
  9966. * @param scene The scene the new light will belong to
  9967. * @returns the constructor function
  9968. */
  9969. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9970. /**
  9971. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9972. * @param parsedLight The JSON representation of the light
  9973. * @param scene The scene to create the parsed light in
  9974. * @returns the created light after parsing
  9975. */
  9976. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9977. private _hookArrayForExcluded;
  9978. private _hookArrayForIncludedOnly;
  9979. private _resyncMeshes;
  9980. /**
  9981. * Forces the meshes to update their light related information in their rendering used effects
  9982. * @hidden Internal Use Only
  9983. */
  9984. _markMeshesAsLightDirty(): void;
  9985. /**
  9986. * Recomputes the cached photometric scale if needed.
  9987. */
  9988. private _computePhotometricScale;
  9989. /**
  9990. * Returns the Photometric Scale according to the light type and intensity mode.
  9991. */
  9992. private _getPhotometricScale;
  9993. /**
  9994. * Reorder the light in the scene according to their defined priority.
  9995. * @hidden Internal Use Only
  9996. */
  9997. _reorderLightsInScene(): void;
  9998. /**
  9999. * Prepares the list of defines specific to the light type.
  10000. * @param defines the list of defines
  10001. * @param lightIndex defines the index of the light for the effect
  10002. */
  10003. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10004. }
  10005. }
  10006. declare module BABYLON {
  10007. /**
  10008. * Interface used to define Action
  10009. */
  10010. export interface IAction {
  10011. /**
  10012. * Trigger for the action
  10013. */
  10014. trigger: number;
  10015. /** Options of the trigger */
  10016. triggerOptions: any;
  10017. /**
  10018. * Gets the trigger parameters
  10019. * @returns the trigger parameters
  10020. */
  10021. getTriggerParameter(): any;
  10022. /**
  10023. * Internal only - executes current action event
  10024. * @hidden
  10025. */
  10026. _executeCurrent(evt?: ActionEvent): void;
  10027. /**
  10028. * Serialize placeholder for child classes
  10029. * @param parent of child
  10030. * @returns the serialized object
  10031. */
  10032. serialize(parent: any): any;
  10033. /**
  10034. * Internal only
  10035. * @hidden
  10036. */
  10037. _prepare(): void;
  10038. /**
  10039. * Internal only - manager for action
  10040. * @hidden
  10041. */
  10042. _actionManager: AbstractActionManager;
  10043. /**
  10044. * Adds action to chain of actions, may be a DoNothingAction
  10045. * @param action defines the next action to execute
  10046. * @returns The action passed in
  10047. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10048. */
  10049. then(action: IAction): IAction;
  10050. }
  10051. /**
  10052. * The action to be carried out following a trigger
  10053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10054. */
  10055. export class Action implements IAction {
  10056. /** the trigger, with or without parameters, for the action */
  10057. triggerOptions: any;
  10058. /**
  10059. * Trigger for the action
  10060. */
  10061. trigger: number;
  10062. /**
  10063. * Internal only - manager for action
  10064. * @hidden
  10065. */
  10066. _actionManager: ActionManager;
  10067. private _nextActiveAction;
  10068. private _child;
  10069. private _condition?;
  10070. private _triggerParameter;
  10071. /**
  10072. * An event triggered prior to action being executed.
  10073. */
  10074. onBeforeExecuteObservable: Observable<Action>;
  10075. /**
  10076. * Creates a new Action
  10077. * @param triggerOptions the trigger, with or without parameters, for the action
  10078. * @param condition an optional determinant of action
  10079. */
  10080. constructor(
  10081. /** the trigger, with or without parameters, for the action */
  10082. triggerOptions: any, condition?: Condition);
  10083. /**
  10084. * Internal only
  10085. * @hidden
  10086. */
  10087. _prepare(): void;
  10088. /**
  10089. * Gets the trigger parameters
  10090. * @returns the trigger parameters
  10091. */
  10092. getTriggerParameter(): any;
  10093. /**
  10094. * Internal only - executes current action event
  10095. * @hidden
  10096. */
  10097. _executeCurrent(evt?: ActionEvent): void;
  10098. /**
  10099. * Execute placeholder for child classes
  10100. * @param evt optional action event
  10101. */
  10102. execute(evt?: ActionEvent): void;
  10103. /**
  10104. * Skips to next active action
  10105. */
  10106. skipToNextActiveAction(): void;
  10107. /**
  10108. * Adds action to chain of actions, may be a DoNothingAction
  10109. * @param action defines the next action to execute
  10110. * @returns The action passed in
  10111. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10112. */
  10113. then(action: Action): Action;
  10114. /**
  10115. * Internal only
  10116. * @hidden
  10117. */
  10118. _getProperty(propertyPath: string): string;
  10119. /**
  10120. * Internal only
  10121. * @hidden
  10122. */
  10123. _getEffectiveTarget(target: any, propertyPath: string): any;
  10124. /**
  10125. * Serialize placeholder for child classes
  10126. * @param parent of child
  10127. * @returns the serialized object
  10128. */
  10129. serialize(parent: any): any;
  10130. /**
  10131. * Internal only called by serialize
  10132. * @hidden
  10133. */
  10134. protected _serialize(serializedAction: any, parent?: any): any;
  10135. /**
  10136. * Internal only
  10137. * @hidden
  10138. */
  10139. static _SerializeValueAsString: (value: any) => string;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. static _GetTargetProperty: (target: Node | Scene) => {
  10145. name: string;
  10146. targetType: string;
  10147. value: string;
  10148. };
  10149. }
  10150. }
  10151. declare module BABYLON {
  10152. /**
  10153. * A Condition applied to an Action
  10154. */
  10155. export class Condition {
  10156. /**
  10157. * Internal only - manager for action
  10158. * @hidden
  10159. */
  10160. _actionManager: ActionManager;
  10161. /**
  10162. * Internal only
  10163. * @hidden
  10164. */
  10165. _evaluationId: number;
  10166. /**
  10167. * Internal only
  10168. * @hidden
  10169. */
  10170. _currentResult: boolean;
  10171. /**
  10172. * Creates a new Condition
  10173. * @param actionManager the manager of the action the condition is applied to
  10174. */
  10175. constructor(actionManager: ActionManager);
  10176. /**
  10177. * Check if the current condition is valid
  10178. * @returns a boolean
  10179. */
  10180. isValid(): boolean;
  10181. /**
  10182. * Internal only
  10183. * @hidden
  10184. */
  10185. _getProperty(propertyPath: string): string;
  10186. /**
  10187. * Internal only
  10188. * @hidden
  10189. */
  10190. _getEffectiveTarget(target: any, propertyPath: string): any;
  10191. /**
  10192. * Serialize placeholder for child classes
  10193. * @returns the serialized object
  10194. */
  10195. serialize(): any;
  10196. /**
  10197. * Internal only
  10198. * @hidden
  10199. */
  10200. protected _serialize(serializedCondition: any): any;
  10201. }
  10202. /**
  10203. * Defines specific conditional operators as extensions of Condition
  10204. */
  10205. export class ValueCondition extends Condition {
  10206. /** path to specify the property of the target the conditional operator uses */
  10207. propertyPath: string;
  10208. /** the value compared by the conditional operator against the current value of the property */
  10209. value: any;
  10210. /** the conditional operator, default ValueCondition.IsEqual */
  10211. operator: number;
  10212. /**
  10213. * Internal only
  10214. * @hidden
  10215. */
  10216. private static _IsEqual;
  10217. /**
  10218. * Internal only
  10219. * @hidden
  10220. */
  10221. private static _IsDifferent;
  10222. /**
  10223. * Internal only
  10224. * @hidden
  10225. */
  10226. private static _IsGreater;
  10227. /**
  10228. * Internal only
  10229. * @hidden
  10230. */
  10231. private static _IsLesser;
  10232. /**
  10233. * returns the number for IsEqual
  10234. */
  10235. static readonly IsEqual: number;
  10236. /**
  10237. * Returns the number for IsDifferent
  10238. */
  10239. static readonly IsDifferent: number;
  10240. /**
  10241. * Returns the number for IsGreater
  10242. */
  10243. static readonly IsGreater: number;
  10244. /**
  10245. * Returns the number for IsLesser
  10246. */
  10247. static readonly IsLesser: number;
  10248. /**
  10249. * Internal only The action manager for the condition
  10250. * @hidden
  10251. */
  10252. _actionManager: ActionManager;
  10253. /**
  10254. * Internal only
  10255. * @hidden
  10256. */
  10257. private _target;
  10258. /**
  10259. * Internal only
  10260. * @hidden
  10261. */
  10262. private _effectiveTarget;
  10263. /**
  10264. * Internal only
  10265. * @hidden
  10266. */
  10267. private _property;
  10268. /**
  10269. * Creates a new ValueCondition
  10270. * @param actionManager manager for the action the condition applies to
  10271. * @param target for the action
  10272. * @param propertyPath path to specify the property of the target the conditional operator uses
  10273. * @param value the value compared by the conditional operator against the current value of the property
  10274. * @param operator the conditional operator, default ValueCondition.IsEqual
  10275. */
  10276. constructor(actionManager: ActionManager, target: any,
  10277. /** path to specify the property of the target the conditional operator uses */
  10278. propertyPath: string,
  10279. /** the value compared by the conditional operator against the current value of the property */
  10280. value: any,
  10281. /** the conditional operator, default ValueCondition.IsEqual */
  10282. operator?: number);
  10283. /**
  10284. * Compares the given value with the property value for the specified conditional operator
  10285. * @returns the result of the comparison
  10286. */
  10287. isValid(): boolean;
  10288. /**
  10289. * Serialize the ValueCondition into a JSON compatible object
  10290. * @returns serialization object
  10291. */
  10292. serialize(): any;
  10293. /**
  10294. * Gets the name of the conditional operator for the ValueCondition
  10295. * @param operator the conditional operator
  10296. * @returns the name
  10297. */
  10298. static GetOperatorName(operator: number): string;
  10299. }
  10300. /**
  10301. * Defines a predicate condition as an extension of Condition
  10302. */
  10303. export class PredicateCondition extends Condition {
  10304. /** defines the predicate function used to validate the condition */
  10305. predicate: () => boolean;
  10306. /**
  10307. * Internal only - manager for action
  10308. * @hidden
  10309. */
  10310. _actionManager: ActionManager;
  10311. /**
  10312. * Creates a new PredicateCondition
  10313. * @param actionManager manager for the action the condition applies to
  10314. * @param predicate defines the predicate function used to validate the condition
  10315. */
  10316. constructor(actionManager: ActionManager,
  10317. /** defines the predicate function used to validate the condition */
  10318. predicate: () => boolean);
  10319. /**
  10320. * @returns the validity of the predicate condition
  10321. */
  10322. isValid(): boolean;
  10323. }
  10324. /**
  10325. * Defines a state condition as an extension of Condition
  10326. */
  10327. export class StateCondition extends Condition {
  10328. /** Value to compare with target state */
  10329. value: string;
  10330. /**
  10331. * Internal only - manager for action
  10332. * @hidden
  10333. */
  10334. _actionManager: ActionManager;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private _target;
  10340. /**
  10341. * Creates a new StateCondition
  10342. * @param actionManager manager for the action the condition applies to
  10343. * @param target of the condition
  10344. * @param value to compare with target state
  10345. */
  10346. constructor(actionManager: ActionManager, target: any,
  10347. /** Value to compare with target state */
  10348. value: string);
  10349. /**
  10350. * Gets a boolean indicating if the current condition is met
  10351. * @returns the validity of the state
  10352. */
  10353. isValid(): boolean;
  10354. /**
  10355. * Serialize the StateCondition into a JSON compatible object
  10356. * @returns serialization object
  10357. */
  10358. serialize(): any;
  10359. }
  10360. }
  10361. declare module BABYLON {
  10362. /**
  10363. * This defines an action responsible to toggle a boolean once triggered.
  10364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10365. */
  10366. export class SwitchBooleanAction extends Action {
  10367. /**
  10368. * The path to the boolean property in the target object
  10369. */
  10370. propertyPath: string;
  10371. private _target;
  10372. private _effectiveTarget;
  10373. private _property;
  10374. /**
  10375. * Instantiate the action
  10376. * @param triggerOptions defines the trigger options
  10377. * @param target defines the object containing the boolean
  10378. * @param propertyPath defines the path to the boolean property in the target object
  10379. * @param condition defines the trigger related conditions
  10380. */
  10381. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10382. /** @hidden */
  10383. _prepare(): void;
  10384. /**
  10385. * Execute the action toggle the boolean value.
  10386. */
  10387. execute(): void;
  10388. /**
  10389. * Serializes the actions and its related information.
  10390. * @param parent defines the object to serialize in
  10391. * @returns the serialized object
  10392. */
  10393. serialize(parent: any): any;
  10394. }
  10395. /**
  10396. * This defines an action responsible to set a the state field of the target
  10397. * to a desired value once triggered.
  10398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10399. */
  10400. export class SetStateAction extends Action {
  10401. /**
  10402. * The value to store in the state field.
  10403. */
  10404. value: string;
  10405. private _target;
  10406. /**
  10407. * Instantiate the action
  10408. * @param triggerOptions defines the trigger options
  10409. * @param target defines the object containing the state property
  10410. * @param value defines the value to store in the state field
  10411. * @param condition defines the trigger related conditions
  10412. */
  10413. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10414. /**
  10415. * Execute the action and store the value on the target state property.
  10416. */
  10417. execute(): void;
  10418. /**
  10419. * Serializes the actions and its related information.
  10420. * @param parent defines the object to serialize in
  10421. * @returns the serialized object
  10422. */
  10423. serialize(parent: any): any;
  10424. }
  10425. /**
  10426. * This defines an action responsible to set a property of the target
  10427. * to a desired value once triggered.
  10428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10429. */
  10430. export class SetValueAction extends Action {
  10431. /**
  10432. * The path of the property to set in the target.
  10433. */
  10434. propertyPath: string;
  10435. /**
  10436. * The value to set in the property
  10437. */
  10438. value: any;
  10439. private _target;
  10440. private _effectiveTarget;
  10441. private _property;
  10442. /**
  10443. * Instantiate the action
  10444. * @param triggerOptions defines the trigger options
  10445. * @param target defines the object containing the property
  10446. * @param propertyPath defines the path of the property to set in the target
  10447. * @param value defines the value to set in the property
  10448. * @param condition defines the trigger related conditions
  10449. */
  10450. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10451. /** @hidden */
  10452. _prepare(): void;
  10453. /**
  10454. * Execute the action and set the targetted property to the desired value.
  10455. */
  10456. execute(): void;
  10457. /**
  10458. * Serializes the actions and its related information.
  10459. * @param parent defines the object to serialize in
  10460. * @returns the serialized object
  10461. */
  10462. serialize(parent: any): any;
  10463. }
  10464. /**
  10465. * This defines an action responsible to increment the target value
  10466. * to a desired value once triggered.
  10467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10468. */
  10469. export class IncrementValueAction extends Action {
  10470. /**
  10471. * The path of the property to increment in the target.
  10472. */
  10473. propertyPath: string;
  10474. /**
  10475. * The value we should increment the property by.
  10476. */
  10477. value: any;
  10478. private _target;
  10479. private _effectiveTarget;
  10480. private _property;
  10481. /**
  10482. * Instantiate the action
  10483. * @param triggerOptions defines the trigger options
  10484. * @param target defines the object containing the property
  10485. * @param propertyPath defines the path of the property to increment in the target
  10486. * @param value defines the value value we should increment the property by
  10487. * @param condition defines the trigger related conditions
  10488. */
  10489. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10490. /** @hidden */
  10491. _prepare(): void;
  10492. /**
  10493. * Execute the action and increment the target of the value amount.
  10494. */
  10495. execute(): void;
  10496. /**
  10497. * Serializes the actions and its related information.
  10498. * @param parent defines the object to serialize in
  10499. * @returns the serialized object
  10500. */
  10501. serialize(parent: any): any;
  10502. }
  10503. /**
  10504. * This defines an action responsible to start an animation once triggered.
  10505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10506. */
  10507. export class PlayAnimationAction extends Action {
  10508. /**
  10509. * Where the animation should start (animation frame)
  10510. */
  10511. from: number;
  10512. /**
  10513. * Where the animation should stop (animation frame)
  10514. */
  10515. to: number;
  10516. /**
  10517. * Define if the animation should loop or stop after the first play.
  10518. */
  10519. loop?: boolean;
  10520. private _target;
  10521. /**
  10522. * Instantiate the action
  10523. * @param triggerOptions defines the trigger options
  10524. * @param target defines the target animation or animation name
  10525. * @param from defines from where the animation should start (animation frame)
  10526. * @param end defines where the animation should stop (animation frame)
  10527. * @param loop defines if the animation should loop or stop after the first play
  10528. * @param condition defines the trigger related conditions
  10529. */
  10530. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10531. /** @hidden */
  10532. _prepare(): void;
  10533. /**
  10534. * Execute the action and play the animation.
  10535. */
  10536. execute(): void;
  10537. /**
  10538. * Serializes the actions and its related information.
  10539. * @param parent defines the object to serialize in
  10540. * @returns the serialized object
  10541. */
  10542. serialize(parent: any): any;
  10543. }
  10544. /**
  10545. * This defines an action responsible to stop an animation once triggered.
  10546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10547. */
  10548. export class StopAnimationAction extends Action {
  10549. private _target;
  10550. /**
  10551. * Instantiate the action
  10552. * @param triggerOptions defines the trigger options
  10553. * @param target defines the target animation or animation name
  10554. * @param condition defines the trigger related conditions
  10555. */
  10556. constructor(triggerOptions: any, target: any, condition?: Condition);
  10557. /** @hidden */
  10558. _prepare(): void;
  10559. /**
  10560. * Execute the action and stop the animation.
  10561. */
  10562. execute(): void;
  10563. /**
  10564. * Serializes the actions and its related information.
  10565. * @param parent defines the object to serialize in
  10566. * @returns the serialized object
  10567. */
  10568. serialize(parent: any): any;
  10569. }
  10570. /**
  10571. * This defines an action responsible that does nothing once triggered.
  10572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10573. */
  10574. export class DoNothingAction extends Action {
  10575. /**
  10576. * Instantiate the action
  10577. * @param triggerOptions defines the trigger options
  10578. * @param condition defines the trigger related conditions
  10579. */
  10580. constructor(triggerOptions?: any, condition?: Condition);
  10581. /**
  10582. * Execute the action and do nothing.
  10583. */
  10584. execute(): void;
  10585. /**
  10586. * Serializes the actions and its related information.
  10587. * @param parent defines the object to serialize in
  10588. * @returns the serialized object
  10589. */
  10590. serialize(parent: any): any;
  10591. }
  10592. /**
  10593. * This defines an action responsible to trigger several actions once triggered.
  10594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10595. */
  10596. export class CombineAction extends Action {
  10597. /**
  10598. * The list of aggregated animations to run.
  10599. */
  10600. children: Action[];
  10601. /**
  10602. * Instantiate the action
  10603. * @param triggerOptions defines the trigger options
  10604. * @param children defines the list of aggregated animations to run
  10605. * @param condition defines the trigger related conditions
  10606. */
  10607. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10608. /** @hidden */
  10609. _prepare(): void;
  10610. /**
  10611. * Execute the action and executes all the aggregated actions.
  10612. */
  10613. execute(evt: ActionEvent): void;
  10614. /**
  10615. * Serializes the actions and its related information.
  10616. * @param parent defines the object to serialize in
  10617. * @returns the serialized object
  10618. */
  10619. serialize(parent: any): any;
  10620. }
  10621. /**
  10622. * This defines an action responsible to run code (external event) once triggered.
  10623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10624. */
  10625. export class ExecuteCodeAction extends Action {
  10626. /**
  10627. * The callback function to run.
  10628. */
  10629. func: (evt: ActionEvent) => void;
  10630. /**
  10631. * Instantiate the action
  10632. * @param triggerOptions defines the trigger options
  10633. * @param func defines the callback function to run
  10634. * @param condition defines the trigger related conditions
  10635. */
  10636. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10637. /**
  10638. * Execute the action and run the attached code.
  10639. */
  10640. execute(evt: ActionEvent): void;
  10641. }
  10642. /**
  10643. * This defines an action responsible to set the parent property of the target once triggered.
  10644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10645. */
  10646. export class SetParentAction extends Action {
  10647. private _parent;
  10648. private _target;
  10649. /**
  10650. * Instantiate the action
  10651. * @param triggerOptions defines the trigger options
  10652. * @param target defines the target containing the parent property
  10653. * @param parent defines from where the animation should start (animation frame)
  10654. * @param condition defines the trigger related conditions
  10655. */
  10656. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10657. /** @hidden */
  10658. _prepare(): void;
  10659. /**
  10660. * Execute the action and set the parent property.
  10661. */
  10662. execute(): void;
  10663. /**
  10664. * Serializes the actions and its related information.
  10665. * @param parent defines the object to serialize in
  10666. * @returns the serialized object
  10667. */
  10668. serialize(parent: any): any;
  10669. }
  10670. }
  10671. declare module BABYLON {
  10672. /**
  10673. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10674. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10676. */
  10677. export class ActionManager extends AbstractActionManager {
  10678. /**
  10679. * Nothing
  10680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10681. */
  10682. static readonly NothingTrigger: number;
  10683. /**
  10684. * On pick
  10685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10686. */
  10687. static readonly OnPickTrigger: number;
  10688. /**
  10689. * On left pick
  10690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10691. */
  10692. static readonly OnLeftPickTrigger: number;
  10693. /**
  10694. * On right pick
  10695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10696. */
  10697. static readonly OnRightPickTrigger: number;
  10698. /**
  10699. * On center pick
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10701. */
  10702. static readonly OnCenterPickTrigger: number;
  10703. /**
  10704. * On pick down
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10706. */
  10707. static readonly OnPickDownTrigger: number;
  10708. /**
  10709. * On double pick
  10710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10711. */
  10712. static readonly OnDoublePickTrigger: number;
  10713. /**
  10714. * On pick up
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10716. */
  10717. static readonly OnPickUpTrigger: number;
  10718. /**
  10719. * On pick out.
  10720. * This trigger will only be raised if you also declared a OnPickDown
  10721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10722. */
  10723. static readonly OnPickOutTrigger: number;
  10724. /**
  10725. * On long press
  10726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10727. */
  10728. static readonly OnLongPressTrigger: number;
  10729. /**
  10730. * On pointer over
  10731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10732. */
  10733. static readonly OnPointerOverTrigger: number;
  10734. /**
  10735. * On pointer out
  10736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10737. */
  10738. static readonly OnPointerOutTrigger: number;
  10739. /**
  10740. * On every frame
  10741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10742. */
  10743. static readonly OnEveryFrameTrigger: number;
  10744. /**
  10745. * On intersection enter
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10747. */
  10748. static readonly OnIntersectionEnterTrigger: number;
  10749. /**
  10750. * On intersection exit
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10752. */
  10753. static readonly OnIntersectionExitTrigger: number;
  10754. /**
  10755. * On key down
  10756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10757. */
  10758. static readonly OnKeyDownTrigger: number;
  10759. /**
  10760. * On key up
  10761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10762. */
  10763. static readonly OnKeyUpTrigger: number;
  10764. private _scene;
  10765. /**
  10766. * Creates a new action manager
  10767. * @param scene defines the hosting scene
  10768. */
  10769. constructor(scene: Scene);
  10770. /**
  10771. * Releases all associated resources
  10772. */
  10773. dispose(): void;
  10774. /**
  10775. * Gets hosting scene
  10776. * @returns the hosting scene
  10777. */
  10778. getScene(): Scene;
  10779. /**
  10780. * Does this action manager handles actions of any of the given triggers
  10781. * @param triggers defines the triggers to be tested
  10782. * @return a boolean indicating whether one (or more) of the triggers is handled
  10783. */
  10784. hasSpecificTriggers(triggers: number[]): boolean;
  10785. /**
  10786. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10787. * speed.
  10788. * @param triggerA defines the trigger to be tested
  10789. * @param triggerB defines the trigger to be tested
  10790. * @return a boolean indicating whether one (or more) of the triggers is handled
  10791. */
  10792. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10793. /**
  10794. * Does this action manager handles actions of a given trigger
  10795. * @param trigger defines the trigger to be tested
  10796. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10797. * @return whether the trigger is handled
  10798. */
  10799. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10800. /**
  10801. * Does this action manager has pointer triggers
  10802. */
  10803. readonly hasPointerTriggers: boolean;
  10804. /**
  10805. * Does this action manager has pick triggers
  10806. */
  10807. readonly hasPickTriggers: boolean;
  10808. /**
  10809. * Registers an action to this action manager
  10810. * @param action defines the action to be registered
  10811. * @return the action amended (prepared) after registration
  10812. */
  10813. registerAction(action: IAction): Nullable<IAction>;
  10814. /**
  10815. * Unregisters an action to this action manager
  10816. * @param action defines the action to be unregistered
  10817. * @return a boolean indicating whether the action has been unregistered
  10818. */
  10819. unregisterAction(action: IAction): Boolean;
  10820. /**
  10821. * Process a specific trigger
  10822. * @param trigger defines the trigger to process
  10823. * @param evt defines the event details to be processed
  10824. */
  10825. processTrigger(trigger: number, evt?: IActionEvent): void;
  10826. /** @hidden */
  10827. _getEffectiveTarget(target: any, propertyPath: string): any;
  10828. /** @hidden */
  10829. _getProperty(propertyPath: string): string;
  10830. /**
  10831. * Serialize this manager to a JSON object
  10832. * @param name defines the property name to store this manager
  10833. * @returns a JSON representation of this manager
  10834. */
  10835. serialize(name: string): any;
  10836. /**
  10837. * Creates a new ActionManager from a JSON data
  10838. * @param parsedActions defines the JSON data to read from
  10839. * @param object defines the hosting mesh
  10840. * @param scene defines the hosting scene
  10841. */
  10842. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10843. /**
  10844. * Get a trigger name by index
  10845. * @param trigger defines the trigger index
  10846. * @returns a trigger name
  10847. */
  10848. static GetTriggerName(trigger: number): string;
  10849. }
  10850. }
  10851. declare module BABYLON {
  10852. /**
  10853. * Class representing a ray with position and direction
  10854. */
  10855. export class Ray {
  10856. /** origin point */
  10857. origin: Vector3;
  10858. /** direction */
  10859. direction: Vector3;
  10860. /** length of the ray */
  10861. length: number;
  10862. private static readonly TmpVector3;
  10863. private _tmpRay;
  10864. /**
  10865. * Creates a new ray
  10866. * @param origin origin point
  10867. * @param direction direction
  10868. * @param length length of the ray
  10869. */
  10870. constructor(
  10871. /** origin point */
  10872. origin: Vector3,
  10873. /** direction */
  10874. direction: Vector3,
  10875. /** length of the ray */
  10876. length?: number);
  10877. /**
  10878. * Checks if the ray intersects a box
  10879. * @param minimum bound of the box
  10880. * @param maximum bound of the box
  10881. * @param intersectionTreshold extra extend to be added to the box in all direction
  10882. * @returns if the box was hit
  10883. */
  10884. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10885. /**
  10886. * Checks if the ray intersects a box
  10887. * @param box the bounding box to check
  10888. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10889. * @returns if the box was hit
  10890. */
  10891. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10892. /**
  10893. * If the ray hits a sphere
  10894. * @param sphere the bounding sphere to check
  10895. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10896. * @returns true if it hits the sphere
  10897. */
  10898. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10899. /**
  10900. * If the ray hits a triange
  10901. * @param vertex0 triangle vertex
  10902. * @param vertex1 triangle vertex
  10903. * @param vertex2 triangle vertex
  10904. * @returns intersection information if hit
  10905. */
  10906. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10907. /**
  10908. * Checks if ray intersects a plane
  10909. * @param plane the plane to check
  10910. * @returns the distance away it was hit
  10911. */
  10912. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10913. /**
  10914. * Calculate the intercept of a ray on a given axis
  10915. * @param axis to check 'x' | 'y' | 'z'
  10916. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10917. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10918. */
  10919. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10920. /**
  10921. * Checks if ray intersects a mesh
  10922. * @param mesh the mesh to check
  10923. * @param fastCheck if only the bounding box should checked
  10924. * @returns picking info of the intersecton
  10925. */
  10926. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10927. /**
  10928. * Checks if ray intersects a mesh
  10929. * @param meshes the meshes to check
  10930. * @param fastCheck if only the bounding box should checked
  10931. * @param results array to store result in
  10932. * @returns Array of picking infos
  10933. */
  10934. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10935. private _comparePickingInfo;
  10936. private static smallnum;
  10937. private static rayl;
  10938. /**
  10939. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10940. * @param sega the first point of the segment to test the intersection against
  10941. * @param segb the second point of the segment to test the intersection against
  10942. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10943. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10944. */
  10945. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10946. /**
  10947. * Update the ray from viewport position
  10948. * @param x position
  10949. * @param y y position
  10950. * @param viewportWidth viewport width
  10951. * @param viewportHeight viewport height
  10952. * @param world world matrix
  10953. * @param view view matrix
  10954. * @param projection projection matrix
  10955. * @returns this ray updated
  10956. */
  10957. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10958. /**
  10959. * Creates a ray with origin and direction of 0,0,0
  10960. * @returns the new ray
  10961. */
  10962. static Zero(): Ray;
  10963. /**
  10964. * Creates a new ray from screen space and viewport
  10965. * @param x position
  10966. * @param y y position
  10967. * @param viewportWidth viewport width
  10968. * @param viewportHeight viewport height
  10969. * @param world world matrix
  10970. * @param view view matrix
  10971. * @param projection projection matrix
  10972. * @returns new ray
  10973. */
  10974. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10975. /**
  10976. * 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
  10977. * transformed to the given world matrix.
  10978. * @param origin The origin point
  10979. * @param end The end point
  10980. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10981. * @returns the new ray
  10982. */
  10983. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10984. /**
  10985. * Transforms a ray by a matrix
  10986. * @param ray ray to transform
  10987. * @param matrix matrix to apply
  10988. * @returns the resulting new ray
  10989. */
  10990. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10991. /**
  10992. * Transforms a ray by a matrix
  10993. * @param ray ray to transform
  10994. * @param matrix matrix to apply
  10995. * @param result ray to store result in
  10996. */
  10997. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10998. /**
  10999. * Unproject a ray from screen space to object space
  11000. * @param sourceX defines the screen space x coordinate to use
  11001. * @param sourceY defines the screen space y coordinate to use
  11002. * @param viewportWidth defines the current width of the viewport
  11003. * @param viewportHeight defines the current height of the viewport
  11004. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11005. * @param view defines the view matrix to use
  11006. * @param projection defines the projection matrix to use
  11007. */
  11008. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11009. }
  11010. /**
  11011. * Type used to define predicate used to select faces when a mesh intersection is detected
  11012. */
  11013. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11014. interface Scene {
  11015. /** @hidden */
  11016. _tempPickingRay: Nullable<Ray>;
  11017. /** @hidden */
  11018. _cachedRayForTransform: Ray;
  11019. /** @hidden */
  11020. _pickWithRayInverseMatrix: Matrix;
  11021. /** @hidden */
  11022. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11023. /** @hidden */
  11024. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11025. }
  11026. }
  11027. declare module BABYLON {
  11028. /**
  11029. * Groups all the scene component constants in one place to ease maintenance.
  11030. * @hidden
  11031. */
  11032. export class SceneComponentConstants {
  11033. static readonly NAME_EFFECTLAYER: string;
  11034. static readonly NAME_LAYER: string;
  11035. static readonly NAME_LENSFLARESYSTEM: string;
  11036. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11037. static readonly NAME_PARTICLESYSTEM: string;
  11038. static readonly NAME_GAMEPAD: string;
  11039. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11040. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11041. static readonly NAME_DEPTHRENDERER: string;
  11042. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11043. static readonly NAME_SPRITE: string;
  11044. static readonly NAME_OUTLINERENDERER: string;
  11045. static readonly NAME_PROCEDURALTEXTURE: string;
  11046. static readonly NAME_SHADOWGENERATOR: string;
  11047. static readonly NAME_OCTREE: string;
  11048. static readonly NAME_PHYSICSENGINE: string;
  11049. static readonly NAME_AUDIO: string;
  11050. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11051. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11052. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11053. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11054. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11055. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11056. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11057. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11058. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11059. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11060. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11061. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11062. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11063. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11064. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11065. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11066. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11067. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11068. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11069. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11070. static readonly STEP_AFTERRENDER_AUDIO: number;
  11071. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11072. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11073. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11074. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11075. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11076. static readonly STEP_POINTERMOVE_SPRITE: number;
  11077. static readonly STEP_POINTERDOWN_SPRITE: number;
  11078. static readonly STEP_POINTERUP_SPRITE: number;
  11079. }
  11080. /**
  11081. * This represents a scene component.
  11082. *
  11083. * This is used to decouple the dependency the scene is having on the different workloads like
  11084. * layers, post processes...
  11085. */
  11086. export interface ISceneComponent {
  11087. /**
  11088. * The name of the component. Each component must have a unique name.
  11089. */
  11090. name: string;
  11091. /**
  11092. * The scene the component belongs to.
  11093. */
  11094. scene: Scene;
  11095. /**
  11096. * Register the component to one instance of a scene.
  11097. */
  11098. register(): void;
  11099. /**
  11100. * Rebuilds the elements related to this component in case of
  11101. * context lost for instance.
  11102. */
  11103. rebuild(): void;
  11104. /**
  11105. * Disposes the component and the associated ressources.
  11106. */
  11107. dispose(): void;
  11108. }
  11109. /**
  11110. * This represents a SERIALIZABLE scene component.
  11111. *
  11112. * This extends Scene Component to add Serialization methods on top.
  11113. */
  11114. export interface ISceneSerializableComponent extends ISceneComponent {
  11115. /**
  11116. * Adds all the elements from the container to the scene
  11117. * @param container the container holding the elements
  11118. */
  11119. addFromContainer(container: AbstractScene): void;
  11120. /**
  11121. * Removes all the elements in the container from the scene
  11122. * @param container contains the elements to remove
  11123. * @param dispose if the removed element should be disposed (default: false)
  11124. */
  11125. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11126. /**
  11127. * Serializes the component data to the specified json object
  11128. * @param serializationObject The object to serialize to
  11129. */
  11130. serialize(serializationObject: any): void;
  11131. }
  11132. /**
  11133. * Strong typing of a Mesh related stage step action
  11134. */
  11135. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11136. /**
  11137. * Strong typing of a Evaluate Sub Mesh related stage step action
  11138. */
  11139. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11140. /**
  11141. * Strong typing of a Active Mesh related stage step action
  11142. */
  11143. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11144. /**
  11145. * Strong typing of a Camera related stage step action
  11146. */
  11147. export type CameraStageAction = (camera: Camera) => void;
  11148. /**
  11149. * Strong typing of a Camera Frame buffer related stage step action
  11150. */
  11151. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11152. /**
  11153. * Strong typing of a Render Target related stage step action
  11154. */
  11155. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11156. /**
  11157. * Strong typing of a RenderingGroup related stage step action
  11158. */
  11159. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11160. /**
  11161. * Strong typing of a Mesh Render related stage step action
  11162. */
  11163. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11164. /**
  11165. * Strong typing of a simple stage step action
  11166. */
  11167. export type SimpleStageAction = () => void;
  11168. /**
  11169. * Strong typing of a render target action.
  11170. */
  11171. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11172. /**
  11173. * Strong typing of a pointer move action.
  11174. */
  11175. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11176. /**
  11177. * Strong typing of a pointer up/down action.
  11178. */
  11179. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11180. /**
  11181. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11182. * @hidden
  11183. */
  11184. export class Stage<T extends Function> extends Array<{
  11185. index: number;
  11186. component: ISceneComponent;
  11187. action: T;
  11188. }> {
  11189. /**
  11190. * Hide ctor from the rest of the world.
  11191. * @param items The items to add.
  11192. */
  11193. private constructor();
  11194. /**
  11195. * Creates a new Stage.
  11196. * @returns A new instance of a Stage
  11197. */
  11198. static Create<T extends Function>(): Stage<T>;
  11199. /**
  11200. * Registers a step in an ordered way in the targeted stage.
  11201. * @param index Defines the position to register the step in
  11202. * @param component Defines the component attached to the step
  11203. * @param action Defines the action to launch during the step
  11204. */
  11205. registerStep(index: number, component: ISceneComponent, action: T): void;
  11206. /**
  11207. * Clears all the steps from the stage.
  11208. */
  11209. clear(): void;
  11210. }
  11211. }
  11212. declare module BABYLON {
  11213. interface Scene {
  11214. /** @hidden */
  11215. _pointerOverSprite: Nullable<Sprite>;
  11216. /** @hidden */
  11217. _pickedDownSprite: Nullable<Sprite>;
  11218. /** @hidden */
  11219. _tempSpritePickingRay: Nullable<Ray>;
  11220. /**
  11221. * All of the sprite managers added to this scene
  11222. * @see http://doc.babylonjs.com/babylon101/sprites
  11223. */
  11224. spriteManagers: Array<ISpriteManager>;
  11225. /**
  11226. * An event triggered when sprites rendering is about to start
  11227. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11228. */
  11229. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11230. /**
  11231. * An event triggered when sprites rendering is done
  11232. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11233. */
  11234. onAfterSpritesRenderingObservable: Observable<Scene>;
  11235. /** @hidden */
  11236. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11237. /** Launch a ray to try to pick a sprite in the scene
  11238. * @param x position on screen
  11239. * @param y position on screen
  11240. * @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
  11241. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11242. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11243. * @returns a PickingInfo
  11244. */
  11245. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11246. /** Use the given ray to pick a sprite in the scene
  11247. * @param ray The ray (in world space) to use to pick meshes
  11248. * @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
  11249. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11250. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11251. * @returns a PickingInfo
  11252. */
  11253. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11254. /** @hidden */
  11255. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11256. /** Launch a ray to try to pick sprites in the scene
  11257. * @param x position on screen
  11258. * @param y position on screen
  11259. * @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
  11260. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11261. * @returns a PickingInfo array
  11262. */
  11263. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11264. /** Use the given ray to pick sprites in the scene
  11265. * @param ray The ray (in world space) to use to pick meshes
  11266. * @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
  11267. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11268. * @returns a PickingInfo array
  11269. */
  11270. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11271. /**
  11272. * Force the sprite under the pointer
  11273. * @param sprite defines the sprite to use
  11274. */
  11275. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11276. /**
  11277. * Gets the sprite under the pointer
  11278. * @returns a Sprite or null if no sprite is under the pointer
  11279. */
  11280. getPointerOverSprite(): Nullable<Sprite>;
  11281. }
  11282. /**
  11283. * Defines the sprite scene component responsible to manage sprites
  11284. * in a given scene.
  11285. */
  11286. export class SpriteSceneComponent implements ISceneComponent {
  11287. /**
  11288. * The component name helpfull to identify the component in the list of scene components.
  11289. */
  11290. readonly name: string;
  11291. /**
  11292. * The scene the component belongs to.
  11293. */
  11294. scene: Scene;
  11295. /** @hidden */
  11296. private _spritePredicate;
  11297. /**
  11298. * Creates a new instance of the component for the given scene
  11299. * @param scene Defines the scene to register the component in
  11300. */
  11301. constructor(scene: Scene);
  11302. /**
  11303. * Registers the component in a given scene
  11304. */
  11305. register(): void;
  11306. /**
  11307. * Rebuilds the elements related to this component in case of
  11308. * context lost for instance.
  11309. */
  11310. rebuild(): void;
  11311. /**
  11312. * Disposes the component and the associated ressources.
  11313. */
  11314. dispose(): void;
  11315. private _pickSpriteButKeepRay;
  11316. private _pointerMove;
  11317. private _pointerDown;
  11318. private _pointerUp;
  11319. }
  11320. }
  11321. declare module BABYLON {
  11322. /** @hidden */
  11323. export var fogFragmentDeclaration: {
  11324. name: string;
  11325. shader: string;
  11326. };
  11327. }
  11328. declare module BABYLON {
  11329. /** @hidden */
  11330. export var fogFragment: {
  11331. name: string;
  11332. shader: string;
  11333. };
  11334. }
  11335. declare module BABYLON {
  11336. /** @hidden */
  11337. export var spritesPixelShader: {
  11338. name: string;
  11339. shader: string;
  11340. };
  11341. }
  11342. declare module BABYLON {
  11343. /** @hidden */
  11344. export var fogVertexDeclaration: {
  11345. name: string;
  11346. shader: string;
  11347. };
  11348. }
  11349. declare module BABYLON {
  11350. /** @hidden */
  11351. export var spritesVertexShader: {
  11352. name: string;
  11353. shader: string;
  11354. };
  11355. }
  11356. declare module BABYLON {
  11357. /**
  11358. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11359. */
  11360. export interface ISpriteManager extends IDisposable {
  11361. /**
  11362. * Restricts the camera to viewing objects with the same layerMask.
  11363. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11364. */
  11365. layerMask: number;
  11366. /**
  11367. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11368. */
  11369. isPickable: boolean;
  11370. /**
  11371. * Specifies the rendering group id for this mesh (0 by default)
  11372. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11373. */
  11374. renderingGroupId: number;
  11375. /**
  11376. * Defines the list of sprites managed by the manager.
  11377. */
  11378. sprites: Array<Sprite>;
  11379. /**
  11380. * Tests the intersection of a sprite with a specific ray.
  11381. * @param ray The ray we are sending to test the collision
  11382. * @param camera The camera space we are sending rays in
  11383. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11384. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11385. * @returns picking info or null.
  11386. */
  11387. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11388. /**
  11389. * Intersects the sprites with a ray
  11390. * @param ray defines the ray to intersect with
  11391. * @param camera defines the current active camera
  11392. * @param predicate defines a predicate used to select candidate sprites
  11393. * @returns null if no hit or a PickingInfo array
  11394. */
  11395. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11396. /**
  11397. * Renders the list of sprites on screen.
  11398. */
  11399. render(): void;
  11400. }
  11401. /**
  11402. * Class used to manage multiple sprites on the same spritesheet
  11403. * @see http://doc.babylonjs.com/babylon101/sprites
  11404. */
  11405. export class SpriteManager implements ISpriteManager {
  11406. /** defines the manager's name */
  11407. name: string;
  11408. /** Gets the list of sprites */
  11409. sprites: Sprite[];
  11410. /** Gets or sets the rendering group id (0 by default) */
  11411. renderingGroupId: number;
  11412. /** Gets or sets camera layer mask */
  11413. layerMask: number;
  11414. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11415. fogEnabled: boolean;
  11416. /** Gets or sets a boolean indicating if the sprites are pickable */
  11417. isPickable: boolean;
  11418. /** Defines the default width of a cell in the spritesheet */
  11419. cellWidth: number;
  11420. /** Defines the default height of a cell in the spritesheet */
  11421. cellHeight: number;
  11422. /** Associative array from JSON sprite data file */
  11423. private _cellData;
  11424. /** Array of sprite names from JSON sprite data file */
  11425. private _spriteMap;
  11426. /** True when packed cell data from JSON file is ready*/
  11427. private _packedAndReady;
  11428. /**
  11429. * An event triggered when the manager is disposed.
  11430. */
  11431. onDisposeObservable: Observable<SpriteManager>;
  11432. private _onDisposeObserver;
  11433. /**
  11434. * Callback called when the manager is disposed
  11435. */
  11436. onDispose: () => void;
  11437. private _capacity;
  11438. private _fromPacked;
  11439. private _spriteTexture;
  11440. private _epsilon;
  11441. private _scene;
  11442. private _vertexData;
  11443. private _buffer;
  11444. private _vertexBuffers;
  11445. private _indexBuffer;
  11446. private _effectBase;
  11447. private _effectFog;
  11448. /**
  11449. * Gets or sets the spritesheet texture
  11450. */
  11451. texture: Texture;
  11452. /**
  11453. * Creates a new sprite manager
  11454. * @param name defines the manager's name
  11455. * @param imgUrl defines the sprite sheet url
  11456. * @param capacity defines the maximum allowed number of sprites
  11457. * @param cellSize defines the size of a sprite cell
  11458. * @param scene defines the hosting scene
  11459. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11460. * @param samplingMode defines the smapling mode to use with spritesheet
  11461. * @param fromPacked set to false; do not alter
  11462. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11463. */
  11464. constructor(
  11465. /** defines the manager's name */
  11466. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11467. private _makePacked;
  11468. private _appendSpriteVertex;
  11469. /**
  11470. * Intersects the sprites with a ray
  11471. * @param ray defines the ray to intersect with
  11472. * @param camera defines the current active camera
  11473. * @param predicate defines a predicate used to select candidate sprites
  11474. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11475. * @returns null if no hit or a PickingInfo
  11476. */
  11477. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11478. /**
  11479. * Intersects the sprites with a ray
  11480. * @param ray defines the ray to intersect with
  11481. * @param camera defines the current active camera
  11482. * @param predicate defines a predicate used to select candidate sprites
  11483. * @returns null if no hit or a PickingInfo array
  11484. */
  11485. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11486. /**
  11487. * Render all child sprites
  11488. */
  11489. render(): void;
  11490. /**
  11491. * Release associated resources
  11492. */
  11493. dispose(): void;
  11494. }
  11495. }
  11496. declare module BABYLON {
  11497. /**
  11498. * Class used to represent a sprite
  11499. * @see http://doc.babylonjs.com/babylon101/sprites
  11500. */
  11501. export class Sprite {
  11502. /** defines the name */
  11503. name: string;
  11504. /** Gets or sets the current world position */
  11505. position: Vector3;
  11506. /** Gets or sets the main color */
  11507. color: Color4;
  11508. /** Gets or sets the width */
  11509. width: number;
  11510. /** Gets or sets the height */
  11511. height: number;
  11512. /** Gets or sets rotation angle */
  11513. angle: number;
  11514. /** Gets or sets the cell index in the sprite sheet */
  11515. cellIndex: number;
  11516. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11517. cellRef: string;
  11518. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11519. invertU: number;
  11520. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11521. invertV: number;
  11522. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11523. disposeWhenFinishedAnimating: boolean;
  11524. /** Gets the list of attached animations */
  11525. animations: Animation[];
  11526. /** Gets or sets a boolean indicating if the sprite can be picked */
  11527. isPickable: boolean;
  11528. /**
  11529. * Gets or sets the associated action manager
  11530. */
  11531. actionManager: Nullable<ActionManager>;
  11532. private _animationStarted;
  11533. private _loopAnimation;
  11534. private _fromIndex;
  11535. private _toIndex;
  11536. private _delay;
  11537. private _direction;
  11538. private _manager;
  11539. private _time;
  11540. private _onAnimationEnd;
  11541. /**
  11542. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11543. */
  11544. isVisible: boolean;
  11545. /**
  11546. * Gets or sets the sprite size
  11547. */
  11548. size: number;
  11549. /**
  11550. * Creates a new Sprite
  11551. * @param name defines the name
  11552. * @param manager defines the manager
  11553. */
  11554. constructor(
  11555. /** defines the name */
  11556. name: string, manager: ISpriteManager);
  11557. /**
  11558. * Starts an animation
  11559. * @param from defines the initial key
  11560. * @param to defines the end key
  11561. * @param loop defines if the animation must loop
  11562. * @param delay defines the start delay (in ms)
  11563. * @param onAnimationEnd defines a callback to call when animation ends
  11564. */
  11565. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11566. /** Stops current animation (if any) */
  11567. stopAnimation(): void;
  11568. /** @hidden */
  11569. _animate(deltaTime: number): void;
  11570. /** Release associated resources */
  11571. dispose(): void;
  11572. }
  11573. }
  11574. declare module BABYLON {
  11575. /**
  11576. * Information about the result of picking within a scene
  11577. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11578. */
  11579. export class PickingInfo {
  11580. /** @hidden */
  11581. _pickingUnavailable: boolean;
  11582. /**
  11583. * If the pick collided with an object
  11584. */
  11585. hit: boolean;
  11586. /**
  11587. * Distance away where the pick collided
  11588. */
  11589. distance: number;
  11590. /**
  11591. * The location of pick collision
  11592. */
  11593. pickedPoint: Nullable<Vector3>;
  11594. /**
  11595. * The mesh corresponding the the pick collision
  11596. */
  11597. pickedMesh: Nullable<AbstractMesh>;
  11598. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11599. bu: number;
  11600. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11601. bv: number;
  11602. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11603. faceId: number;
  11604. /** Id of the the submesh that was picked */
  11605. subMeshId: number;
  11606. /** If a sprite was picked, this will be the sprite the pick collided with */
  11607. pickedSprite: Nullable<Sprite>;
  11608. /**
  11609. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11610. */
  11611. originMesh: Nullable<AbstractMesh>;
  11612. /**
  11613. * The ray that was used to perform the picking.
  11614. */
  11615. ray: Nullable<Ray>;
  11616. /**
  11617. * Gets the normal correspodning to the face the pick collided with
  11618. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11619. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11620. * @returns The normal correspodning to the face the pick collided with
  11621. */
  11622. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11623. /**
  11624. * Gets the texture coordinates of where the pick occured
  11625. * @returns the vector containing the coordnates of the texture
  11626. */
  11627. getTextureCoordinates(): Nullable<Vector2>;
  11628. }
  11629. }
  11630. declare module BABYLON {
  11631. /**
  11632. * Gather the list of pointer event types as constants.
  11633. */
  11634. export class PointerEventTypes {
  11635. /**
  11636. * 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.
  11637. */
  11638. static readonly POINTERDOWN: number;
  11639. /**
  11640. * The pointerup event is fired when a pointer is no longer active.
  11641. */
  11642. static readonly POINTERUP: number;
  11643. /**
  11644. * The pointermove event is fired when a pointer changes coordinates.
  11645. */
  11646. static readonly POINTERMOVE: number;
  11647. /**
  11648. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11649. */
  11650. static readonly POINTERWHEEL: number;
  11651. /**
  11652. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11653. */
  11654. static readonly POINTERPICK: number;
  11655. /**
  11656. * The pointertap event is fired when a the object has been touched and released without drag.
  11657. */
  11658. static readonly POINTERTAP: number;
  11659. /**
  11660. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11661. */
  11662. static readonly POINTERDOUBLETAP: number;
  11663. }
  11664. /**
  11665. * Base class of pointer info types.
  11666. */
  11667. export class PointerInfoBase {
  11668. /**
  11669. * Defines the type of event (PointerEventTypes)
  11670. */
  11671. type: number;
  11672. /**
  11673. * Defines the related dom event
  11674. */
  11675. event: PointerEvent | MouseWheelEvent;
  11676. /**
  11677. * Instantiates the base class of pointers info.
  11678. * @param type Defines the type of event (PointerEventTypes)
  11679. * @param event Defines the related dom event
  11680. */
  11681. constructor(
  11682. /**
  11683. * Defines the type of event (PointerEventTypes)
  11684. */
  11685. type: number,
  11686. /**
  11687. * Defines the related dom event
  11688. */
  11689. event: PointerEvent | MouseWheelEvent);
  11690. }
  11691. /**
  11692. * This class is used to store pointer related info for the onPrePointerObservable event.
  11693. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11694. */
  11695. export class PointerInfoPre extends PointerInfoBase {
  11696. /**
  11697. * Ray from a pointer if availible (eg. 6dof controller)
  11698. */
  11699. ray: Nullable<Ray>;
  11700. /**
  11701. * Defines the local position of the pointer on the canvas.
  11702. */
  11703. localPosition: Vector2;
  11704. /**
  11705. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11706. */
  11707. skipOnPointerObservable: boolean;
  11708. /**
  11709. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11710. * @param type Defines the type of event (PointerEventTypes)
  11711. * @param event Defines the related dom event
  11712. * @param localX Defines the local x coordinates of the pointer when the event occured
  11713. * @param localY Defines the local y coordinates of the pointer when the event occured
  11714. */
  11715. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11716. }
  11717. /**
  11718. * This type contains all the data related to a pointer event in Babylon.js.
  11719. * 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.
  11720. */
  11721. export class PointerInfo extends PointerInfoBase {
  11722. /**
  11723. * Defines the picking info associated to the info (if any)\
  11724. */
  11725. pickInfo: Nullable<PickingInfo>;
  11726. /**
  11727. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11728. * @param type Defines the type of event (PointerEventTypes)
  11729. * @param event Defines the related dom event
  11730. * @param pickInfo Defines the picking info associated to the info (if any)\
  11731. */
  11732. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11733. /**
  11734. * Defines the picking info associated to the info (if any)\
  11735. */
  11736. pickInfo: Nullable<PickingInfo>);
  11737. }
  11738. /**
  11739. * Data relating to a touch event on the screen.
  11740. */
  11741. export interface PointerTouch {
  11742. /**
  11743. * X coordinate of touch.
  11744. */
  11745. x: number;
  11746. /**
  11747. * Y coordinate of touch.
  11748. */
  11749. y: number;
  11750. /**
  11751. * Id of touch. Unique for each finger.
  11752. */
  11753. pointerId: number;
  11754. /**
  11755. * Event type passed from DOM.
  11756. */
  11757. type: any;
  11758. }
  11759. }
  11760. declare module BABYLON {
  11761. /**
  11762. * Manage the mouse inputs to control the movement of a free camera.
  11763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11764. */
  11765. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11766. /**
  11767. * Define if touch is enabled in the mouse input
  11768. */
  11769. touchEnabled: boolean;
  11770. /**
  11771. * Defines the camera the input is attached to.
  11772. */
  11773. camera: FreeCamera;
  11774. /**
  11775. * Defines the buttons associated with the input to handle camera move.
  11776. */
  11777. buttons: number[];
  11778. /**
  11779. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11780. */
  11781. angularSensibility: number;
  11782. private _pointerInput;
  11783. private _onMouseMove;
  11784. private _observer;
  11785. private previousPosition;
  11786. /**
  11787. * Observable for when a pointer move event occurs containing the move offset
  11788. */
  11789. onPointerMovedObservable: Observable<{
  11790. offsetX: number;
  11791. offsetY: number;
  11792. }>;
  11793. /**
  11794. * @hidden
  11795. * If the camera should be rotated automatically based on pointer movement
  11796. */
  11797. _allowCameraRotation: boolean;
  11798. /**
  11799. * Manage the mouse inputs to control the movement of a free camera.
  11800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11801. * @param touchEnabled Defines if touch is enabled or not
  11802. */
  11803. constructor(
  11804. /**
  11805. * Define if touch is enabled in the mouse input
  11806. */
  11807. touchEnabled?: boolean);
  11808. /**
  11809. * Attach the input controls to a specific dom element to get the input from.
  11810. * @param element Defines the element the controls should be listened from
  11811. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11812. */
  11813. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11814. /**
  11815. * Called on JS contextmenu event.
  11816. * Override this method to provide functionality.
  11817. */
  11818. protected onContextMenu(evt: PointerEvent): void;
  11819. /**
  11820. * Detach the current controls from the specified dom element.
  11821. * @param element Defines the element to stop listening the inputs from
  11822. */
  11823. detachControl(element: Nullable<HTMLElement>): void;
  11824. /**
  11825. * Gets the class name of the current intput.
  11826. * @returns the class name
  11827. */
  11828. getClassName(): string;
  11829. /**
  11830. * Get the friendly name associated with the input class.
  11831. * @returns the input friendly name
  11832. */
  11833. getSimpleName(): string;
  11834. }
  11835. }
  11836. declare module BABYLON {
  11837. /**
  11838. * Manage the touch inputs to control the movement of a free camera.
  11839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11840. */
  11841. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11842. /**
  11843. * Defines the camera the input is attached to.
  11844. */
  11845. camera: FreeCamera;
  11846. /**
  11847. * Defines the touch sensibility for rotation.
  11848. * The higher the faster.
  11849. */
  11850. touchAngularSensibility: number;
  11851. /**
  11852. * Defines the touch sensibility for move.
  11853. * The higher the faster.
  11854. */
  11855. touchMoveSensibility: number;
  11856. private _offsetX;
  11857. private _offsetY;
  11858. private _pointerPressed;
  11859. private _pointerInput;
  11860. private _observer;
  11861. private _onLostFocus;
  11862. /**
  11863. * Attach the input controls to a specific dom element to get the input from.
  11864. * @param element Defines the element the controls should be listened from
  11865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11866. */
  11867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11868. /**
  11869. * Detach the current controls from the specified dom element.
  11870. * @param element Defines the element to stop listening the inputs from
  11871. */
  11872. detachControl(element: Nullable<HTMLElement>): void;
  11873. /**
  11874. * Update the current camera state depending on the inputs that have been used this frame.
  11875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11876. */
  11877. checkInputs(): void;
  11878. /**
  11879. * Gets the class name of the current intput.
  11880. * @returns the class name
  11881. */
  11882. getClassName(): string;
  11883. /**
  11884. * Get the friendly name associated with the input class.
  11885. * @returns the input friendly name
  11886. */
  11887. getSimpleName(): string;
  11888. }
  11889. }
  11890. declare module BABYLON {
  11891. /**
  11892. * Default Inputs manager for the FreeCamera.
  11893. * It groups all the default supported inputs for ease of use.
  11894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11895. */
  11896. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11897. /**
  11898. * @hidden
  11899. */
  11900. _mouseInput: Nullable<FreeCameraMouseInput>;
  11901. /**
  11902. * Instantiates a new FreeCameraInputsManager.
  11903. * @param camera Defines the camera the inputs belong to
  11904. */
  11905. constructor(camera: FreeCamera);
  11906. /**
  11907. * Add keyboard input support to the input manager.
  11908. * @returns the current input manager
  11909. */
  11910. addKeyboard(): FreeCameraInputsManager;
  11911. /**
  11912. * Add mouse input support to the input manager.
  11913. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11914. * @returns the current input manager
  11915. */
  11916. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11917. /**
  11918. * Removes the mouse input support from the manager
  11919. * @returns the current input manager
  11920. */
  11921. removeMouse(): FreeCameraInputsManager;
  11922. /**
  11923. * Add touch input support to the input manager.
  11924. * @returns the current input manager
  11925. */
  11926. addTouch(): FreeCameraInputsManager;
  11927. /**
  11928. * Remove all attached input methods from a camera
  11929. */
  11930. clear(): void;
  11931. }
  11932. }
  11933. declare module BABYLON {
  11934. /**
  11935. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11936. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11937. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11938. */
  11939. export class FreeCamera extends TargetCamera {
  11940. /**
  11941. * Define the collision ellipsoid of the camera.
  11942. * This is helpful to simulate a camera body like the player body around the camera
  11943. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11944. */
  11945. ellipsoid: Vector3;
  11946. /**
  11947. * Define an offset for the position of the ellipsoid around the camera.
  11948. * This can be helpful to determine the center of the body near the gravity center of the body
  11949. * instead of its head.
  11950. */
  11951. ellipsoidOffset: Vector3;
  11952. /**
  11953. * Enable or disable collisions of the camera with the rest of the scene objects.
  11954. */
  11955. checkCollisions: boolean;
  11956. /**
  11957. * Enable or disable gravity on the camera.
  11958. */
  11959. applyGravity: boolean;
  11960. /**
  11961. * Define the input manager associated to the camera.
  11962. */
  11963. inputs: FreeCameraInputsManager;
  11964. /**
  11965. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11966. * Higher values reduce sensitivity.
  11967. */
  11968. /**
  11969. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11970. * Higher values reduce sensitivity.
  11971. */
  11972. angularSensibility: number;
  11973. /**
  11974. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11975. */
  11976. keysUp: number[];
  11977. /**
  11978. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11979. */
  11980. keysDown: number[];
  11981. /**
  11982. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11983. */
  11984. keysLeft: number[];
  11985. /**
  11986. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11987. */
  11988. keysRight: number[];
  11989. /**
  11990. * Event raised when the camera collide with a mesh in the scene.
  11991. */
  11992. onCollide: (collidedMesh: AbstractMesh) => void;
  11993. private _collider;
  11994. private _needMoveForGravity;
  11995. private _oldPosition;
  11996. private _diffPosition;
  11997. private _newPosition;
  11998. /** @hidden */
  11999. _localDirection: Vector3;
  12000. /** @hidden */
  12001. _transformedDirection: Vector3;
  12002. /**
  12003. * Instantiates a Free Camera.
  12004. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12005. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12006. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12007. * @param name Define the name of the camera in the scene
  12008. * @param position Define the start position of the camera in the scene
  12009. * @param scene Define the scene the camera belongs to
  12010. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12011. */
  12012. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12013. /**
  12014. * Attached controls to the current camera.
  12015. * @param element Defines the element the controls should be listened from
  12016. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12017. */
  12018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12019. /**
  12020. * Detach the current controls from the camera.
  12021. * The camera will stop reacting to inputs.
  12022. * @param element Defines the element to stop listening the inputs from
  12023. */
  12024. detachControl(element: HTMLElement): void;
  12025. private _collisionMask;
  12026. /**
  12027. * Define a collision mask to limit the list of object the camera can collide with
  12028. */
  12029. collisionMask: number;
  12030. /** @hidden */
  12031. _collideWithWorld(displacement: Vector3): void;
  12032. private _onCollisionPositionChange;
  12033. /** @hidden */
  12034. _checkInputs(): void;
  12035. /** @hidden */
  12036. _decideIfNeedsToMove(): boolean;
  12037. /** @hidden */
  12038. _updatePosition(): void;
  12039. /**
  12040. * Destroy the camera and release the current resources hold by it.
  12041. */
  12042. dispose(): void;
  12043. /**
  12044. * Gets the current object class name.
  12045. * @return the class name
  12046. */
  12047. getClassName(): string;
  12048. }
  12049. }
  12050. declare module BABYLON {
  12051. /**
  12052. * Represents a gamepad control stick position
  12053. */
  12054. export class StickValues {
  12055. /**
  12056. * The x component of the control stick
  12057. */
  12058. x: number;
  12059. /**
  12060. * The y component of the control stick
  12061. */
  12062. y: number;
  12063. /**
  12064. * Initializes the gamepad x and y control stick values
  12065. * @param x The x component of the gamepad control stick value
  12066. * @param y The y component of the gamepad control stick value
  12067. */
  12068. constructor(
  12069. /**
  12070. * The x component of the control stick
  12071. */
  12072. x: number,
  12073. /**
  12074. * The y component of the control stick
  12075. */
  12076. y: number);
  12077. }
  12078. /**
  12079. * An interface which manages callbacks for gamepad button changes
  12080. */
  12081. export interface GamepadButtonChanges {
  12082. /**
  12083. * Called when a gamepad has been changed
  12084. */
  12085. changed: boolean;
  12086. /**
  12087. * Called when a gamepad press event has been triggered
  12088. */
  12089. pressChanged: boolean;
  12090. /**
  12091. * Called when a touch event has been triggered
  12092. */
  12093. touchChanged: boolean;
  12094. /**
  12095. * Called when a value has changed
  12096. */
  12097. valueChanged: boolean;
  12098. }
  12099. /**
  12100. * Represents a gamepad
  12101. */
  12102. export class Gamepad {
  12103. /**
  12104. * The id of the gamepad
  12105. */
  12106. id: string;
  12107. /**
  12108. * The index of the gamepad
  12109. */
  12110. index: number;
  12111. /**
  12112. * The browser gamepad
  12113. */
  12114. browserGamepad: any;
  12115. /**
  12116. * Specifies what type of gamepad this represents
  12117. */
  12118. type: number;
  12119. private _leftStick;
  12120. private _rightStick;
  12121. /** @hidden */
  12122. _isConnected: boolean;
  12123. private _leftStickAxisX;
  12124. private _leftStickAxisY;
  12125. private _rightStickAxisX;
  12126. private _rightStickAxisY;
  12127. /**
  12128. * Triggered when the left control stick has been changed
  12129. */
  12130. private _onleftstickchanged;
  12131. /**
  12132. * Triggered when the right control stick has been changed
  12133. */
  12134. private _onrightstickchanged;
  12135. /**
  12136. * Represents a gamepad controller
  12137. */
  12138. static GAMEPAD: number;
  12139. /**
  12140. * Represents a generic controller
  12141. */
  12142. static GENERIC: number;
  12143. /**
  12144. * Represents an XBox controller
  12145. */
  12146. static XBOX: number;
  12147. /**
  12148. * Represents a pose-enabled controller
  12149. */
  12150. static POSE_ENABLED: number;
  12151. /**
  12152. * Represents an Dual Shock controller
  12153. */
  12154. static DUALSHOCK: number;
  12155. /**
  12156. * Specifies whether the left control stick should be Y-inverted
  12157. */
  12158. protected _invertLeftStickY: boolean;
  12159. /**
  12160. * Specifies if the gamepad has been connected
  12161. */
  12162. readonly isConnected: boolean;
  12163. /**
  12164. * Initializes the gamepad
  12165. * @param id The id of the gamepad
  12166. * @param index The index of the gamepad
  12167. * @param browserGamepad The browser gamepad
  12168. * @param leftStickX The x component of the left joystick
  12169. * @param leftStickY The y component of the left joystick
  12170. * @param rightStickX The x component of the right joystick
  12171. * @param rightStickY The y component of the right joystick
  12172. */
  12173. constructor(
  12174. /**
  12175. * The id of the gamepad
  12176. */
  12177. id: string,
  12178. /**
  12179. * The index of the gamepad
  12180. */
  12181. index: number,
  12182. /**
  12183. * The browser gamepad
  12184. */
  12185. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12186. /**
  12187. * Callback triggered when the left joystick has changed
  12188. * @param callback
  12189. */
  12190. onleftstickchanged(callback: (values: StickValues) => void): void;
  12191. /**
  12192. * Callback triggered when the right joystick has changed
  12193. * @param callback
  12194. */
  12195. onrightstickchanged(callback: (values: StickValues) => void): void;
  12196. /**
  12197. * Gets the left joystick
  12198. */
  12199. /**
  12200. * Sets the left joystick values
  12201. */
  12202. leftStick: StickValues;
  12203. /**
  12204. * Gets the right joystick
  12205. */
  12206. /**
  12207. * Sets the right joystick value
  12208. */
  12209. rightStick: StickValues;
  12210. /**
  12211. * Updates the gamepad joystick positions
  12212. */
  12213. update(): void;
  12214. /**
  12215. * Disposes the gamepad
  12216. */
  12217. dispose(): void;
  12218. }
  12219. /**
  12220. * Represents a generic gamepad
  12221. */
  12222. export class GenericPad extends Gamepad {
  12223. private _buttons;
  12224. private _onbuttondown;
  12225. private _onbuttonup;
  12226. /**
  12227. * Observable triggered when a button has been pressed
  12228. */
  12229. onButtonDownObservable: Observable<number>;
  12230. /**
  12231. * Observable triggered when a button has been released
  12232. */
  12233. onButtonUpObservable: Observable<number>;
  12234. /**
  12235. * Callback triggered when a button has been pressed
  12236. * @param callback Called when a button has been pressed
  12237. */
  12238. onbuttondown(callback: (buttonPressed: number) => void): void;
  12239. /**
  12240. * Callback triggered when a button has been released
  12241. * @param callback Called when a button has been released
  12242. */
  12243. onbuttonup(callback: (buttonReleased: number) => void): void;
  12244. /**
  12245. * Initializes the generic gamepad
  12246. * @param id The id of the generic gamepad
  12247. * @param index The index of the generic gamepad
  12248. * @param browserGamepad The browser gamepad
  12249. */
  12250. constructor(id: string, index: number, browserGamepad: any);
  12251. private _setButtonValue;
  12252. /**
  12253. * Updates the generic gamepad
  12254. */
  12255. update(): void;
  12256. /**
  12257. * Disposes the generic gamepad
  12258. */
  12259. dispose(): void;
  12260. }
  12261. }
  12262. declare module BABYLON {
  12263. interface Engine {
  12264. /**
  12265. * Creates a raw texture
  12266. * @param data defines the data to store in the texture
  12267. * @param width defines the width of the texture
  12268. * @param height defines the height of the texture
  12269. * @param format defines the format of the data
  12270. * @param generateMipMaps defines if the engine should generate the mip levels
  12271. * @param invertY defines if data must be stored with Y axis inverted
  12272. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12273. * @param compression defines the compression used (null by default)
  12274. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12275. * @returns the raw texture inside an InternalTexture
  12276. */
  12277. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12278. /**
  12279. * Update a raw texture
  12280. * @param texture defines the texture to update
  12281. * @param data defines the data to store in the texture
  12282. * @param format defines the format of the data
  12283. * @param invertY defines if data must be stored with Y axis inverted
  12284. */
  12285. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12286. /**
  12287. * Update a raw texture
  12288. * @param texture defines the texture to update
  12289. * @param data defines the data to store in the texture
  12290. * @param format defines the format of the data
  12291. * @param invertY defines if data must be stored with Y axis inverted
  12292. * @param compression defines the compression used (null by default)
  12293. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12294. */
  12295. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12296. /**
  12297. * Creates a new raw cube texture
  12298. * @param data defines the array of data to use to create each face
  12299. * @param size defines the size of the textures
  12300. * @param format defines the format of the data
  12301. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12302. * @param generateMipMaps defines if the engine should generate the mip levels
  12303. * @param invertY defines if data must be stored with Y axis inverted
  12304. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12305. * @param compression defines the compression used (null by default)
  12306. * @returns the cube texture as an InternalTexture
  12307. */
  12308. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12309. /**
  12310. * Update a raw cube texture
  12311. * @param texture defines the texture to udpdate
  12312. * @param data defines the data to store
  12313. * @param format defines the data format
  12314. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12315. * @param invertY defines if data must be stored with Y axis inverted
  12316. */
  12317. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12318. /**
  12319. * Update a raw cube texture
  12320. * @param texture defines the texture to udpdate
  12321. * @param data defines the data to store
  12322. * @param format defines the data format
  12323. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12324. * @param invertY defines if data must be stored with Y axis inverted
  12325. * @param compression defines the compression used (null by default)
  12326. */
  12327. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12328. /**
  12329. * Update a raw cube texture
  12330. * @param texture defines the texture to udpdate
  12331. * @param data defines the data to store
  12332. * @param format defines the data format
  12333. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12334. * @param invertY defines if data must be stored with Y axis inverted
  12335. * @param compression defines the compression used (null by default)
  12336. * @param level defines which level of the texture to update
  12337. */
  12338. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12339. /**
  12340. * Creates a new raw cube texture from a specified url
  12341. * @param url defines the url where the data is located
  12342. * @param scene defines the current scene
  12343. * @param size defines the size of the textures
  12344. * @param format defines the format of the data
  12345. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12346. * @param noMipmap defines if the engine should avoid generating the mip levels
  12347. * @param callback defines a callback used to extract texture data from loaded data
  12348. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12349. * @param onLoad defines a callback called when texture is loaded
  12350. * @param onError defines a callback called if there is an error
  12351. * @returns the cube texture as an InternalTexture
  12352. */
  12353. 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;
  12354. /**
  12355. * Creates a new raw cube texture from a specified url
  12356. * @param url defines the url where the data is located
  12357. * @param scene defines the current scene
  12358. * @param size defines the size of the textures
  12359. * @param format defines the format of the data
  12360. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12361. * @param noMipmap defines if the engine should avoid generating the mip levels
  12362. * @param callback defines a callback used to extract texture data from loaded data
  12363. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12364. * @param onLoad defines a callback called when texture is loaded
  12365. * @param onError defines a callback called if there is an error
  12366. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12367. * @param invertY defines if data must be stored with Y axis inverted
  12368. * @returns the cube texture as an InternalTexture
  12369. */
  12370. 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;
  12371. /**
  12372. * Creates a new raw 3D texture
  12373. * @param data defines the data used to create the texture
  12374. * @param width defines the width of the texture
  12375. * @param height defines the height of the texture
  12376. * @param depth defines the depth of the texture
  12377. * @param format defines the format of the texture
  12378. * @param generateMipMaps defines if the engine must generate mip levels
  12379. * @param invertY defines if data must be stored with Y axis inverted
  12380. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12381. * @param compression defines the compressed used (can be null)
  12382. * @param textureType defines the compressed used (can be null)
  12383. * @returns a new raw 3D texture (stored in an InternalTexture)
  12384. */
  12385. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12386. /**
  12387. * Update a raw 3D texture
  12388. * @param texture defines the texture to update
  12389. * @param data defines the data to store
  12390. * @param format defines the data format
  12391. * @param invertY defines if data must be stored with Y axis inverted
  12392. */
  12393. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12394. /**
  12395. * Update a raw 3D texture
  12396. * @param texture defines the texture to update
  12397. * @param data defines the data to store
  12398. * @param format defines the data format
  12399. * @param invertY defines if data must be stored with Y axis inverted
  12400. * @param compression defines the used compression (can be null)
  12401. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12402. */
  12403. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12404. }
  12405. }
  12406. declare module BABYLON {
  12407. /**
  12408. * Raw texture can help creating a texture directly from an array of data.
  12409. * This can be super useful if you either get the data from an uncompressed source or
  12410. * if you wish to create your texture pixel by pixel.
  12411. */
  12412. export class RawTexture extends Texture {
  12413. /**
  12414. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12415. */
  12416. format: number;
  12417. private _engine;
  12418. /**
  12419. * Instantiates a new RawTexture.
  12420. * Raw texture can help creating a texture directly from an array of data.
  12421. * This can be super useful if you either get the data from an uncompressed source or
  12422. * if you wish to create your texture pixel by pixel.
  12423. * @param data define the array of data to use to create the texture
  12424. * @param width define the width of the texture
  12425. * @param height define the height of the texture
  12426. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12427. * @param scene define the scene the texture belongs to
  12428. * @param generateMipMaps define whether mip maps should be generated or not
  12429. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12430. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12431. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12432. */
  12433. constructor(data: ArrayBufferView, width: number, height: number,
  12434. /**
  12435. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12436. */
  12437. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12438. /**
  12439. * Updates the texture underlying data.
  12440. * @param data Define the new data of the texture
  12441. */
  12442. update(data: ArrayBufferView): void;
  12443. /**
  12444. * Creates a luminance texture from some data.
  12445. * @param data Define the texture data
  12446. * @param width Define the width of the texture
  12447. * @param height Define the height of the texture
  12448. * @param scene Define the scene the texture belongs to
  12449. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12450. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12451. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12452. * @returns the luminance texture
  12453. */
  12454. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12455. /**
  12456. * Creates a luminance alpha texture from some data.
  12457. * @param data Define the texture data
  12458. * @param width Define the width of the texture
  12459. * @param height Define the height of the texture
  12460. * @param scene Define the scene the texture belongs to
  12461. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12462. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12463. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12464. * @returns the luminance alpha texture
  12465. */
  12466. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12467. /**
  12468. * Creates an alpha texture from some data.
  12469. * @param data Define the texture data
  12470. * @param width Define the width of the texture
  12471. * @param height Define the height of the texture
  12472. * @param scene Define the scene the texture belongs to
  12473. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12474. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12475. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12476. * @returns the alpha texture
  12477. */
  12478. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12479. /**
  12480. * Creates a RGB texture from some data.
  12481. * @param data Define the texture data
  12482. * @param width Define the width of the texture
  12483. * @param height Define the height of the texture
  12484. * @param scene Define the scene the texture belongs to
  12485. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12486. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12487. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12488. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12489. * @returns the RGB alpha texture
  12490. */
  12491. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12492. /**
  12493. * Creates a RGBA texture from some data.
  12494. * @param data Define the texture data
  12495. * @param width Define the width of the texture
  12496. * @param height Define the height of the texture
  12497. * @param scene Define the scene the texture belongs to
  12498. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12499. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12500. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12501. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12502. * @returns the RGBA texture
  12503. */
  12504. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12505. /**
  12506. * Creates a R texture from some data.
  12507. * @param data Define the texture data
  12508. * @param width Define the width of the texture
  12509. * @param height Define the height of the texture
  12510. * @param scene Define the scene the texture belongs to
  12511. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12512. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12513. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12514. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12515. * @returns the R texture
  12516. */
  12517. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12518. }
  12519. }
  12520. declare module BABYLON {
  12521. /**
  12522. * Interface for the size containing width and height
  12523. */
  12524. export interface ISize {
  12525. /**
  12526. * Width
  12527. */
  12528. width: number;
  12529. /**
  12530. * Heighht
  12531. */
  12532. height: number;
  12533. }
  12534. /**
  12535. * Size containing widht and height
  12536. */
  12537. export class Size implements ISize {
  12538. /**
  12539. * Width
  12540. */
  12541. width: number;
  12542. /**
  12543. * Height
  12544. */
  12545. height: number;
  12546. /**
  12547. * Creates a Size object from the given width and height (floats).
  12548. * @param width width of the new size
  12549. * @param height height of the new size
  12550. */
  12551. constructor(width: number, height: number);
  12552. /**
  12553. * Returns a string with the Size width and height
  12554. * @returns a string with the Size width and height
  12555. */
  12556. toString(): string;
  12557. /**
  12558. * "Size"
  12559. * @returns the string "Size"
  12560. */
  12561. getClassName(): string;
  12562. /**
  12563. * Returns the Size hash code.
  12564. * @returns a hash code for a unique width and height
  12565. */
  12566. getHashCode(): number;
  12567. /**
  12568. * Updates the current size from the given one.
  12569. * @param src the given size
  12570. */
  12571. copyFrom(src: Size): void;
  12572. /**
  12573. * Updates in place the current Size from the given floats.
  12574. * @param width width of the new size
  12575. * @param height height of the new size
  12576. * @returns the updated Size.
  12577. */
  12578. copyFromFloats(width: number, height: number): Size;
  12579. /**
  12580. * Updates in place the current Size from the given floats.
  12581. * @param width width to set
  12582. * @param height height to set
  12583. * @returns the updated Size.
  12584. */
  12585. set(width: number, height: number): Size;
  12586. /**
  12587. * Multiplies the width and height by numbers
  12588. * @param w factor to multiple the width by
  12589. * @param h factor to multiple the height by
  12590. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12591. */
  12592. multiplyByFloats(w: number, h: number): Size;
  12593. /**
  12594. * Clones the size
  12595. * @returns a new Size copied from the given one.
  12596. */
  12597. clone(): Size;
  12598. /**
  12599. * True if the current Size and the given one width and height are strictly equal.
  12600. * @param other the other size to compare against
  12601. * @returns True if the current Size and the given one width and height are strictly equal.
  12602. */
  12603. equals(other: Size): boolean;
  12604. /**
  12605. * The surface of the Size : width * height (float).
  12606. */
  12607. readonly surface: number;
  12608. /**
  12609. * Create a new size of zero
  12610. * @returns a new Size set to (0.0, 0.0)
  12611. */
  12612. static Zero(): Size;
  12613. /**
  12614. * Sums the width and height of two sizes
  12615. * @param otherSize size to add to this size
  12616. * @returns a new Size set as the addition result of the current Size and the given one.
  12617. */
  12618. add(otherSize: Size): Size;
  12619. /**
  12620. * Subtracts the width and height of two
  12621. * @param otherSize size to subtract to this size
  12622. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12623. */
  12624. subtract(otherSize: Size): Size;
  12625. /**
  12626. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12627. * @param start starting size to lerp between
  12628. * @param end end size to lerp between
  12629. * @param amount amount to lerp between the start and end values
  12630. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12631. */
  12632. static Lerp(start: Size, end: Size, amount: number): Size;
  12633. }
  12634. }
  12635. declare module BABYLON {
  12636. /**
  12637. * Defines a runtime animation
  12638. */
  12639. export class RuntimeAnimation {
  12640. private _events;
  12641. /**
  12642. * The current frame of the runtime animation
  12643. */
  12644. private _currentFrame;
  12645. /**
  12646. * The animation used by the runtime animation
  12647. */
  12648. private _animation;
  12649. /**
  12650. * The target of the runtime animation
  12651. */
  12652. private _target;
  12653. /**
  12654. * The initiating animatable
  12655. */
  12656. private _host;
  12657. /**
  12658. * The original value of the runtime animation
  12659. */
  12660. private _originalValue;
  12661. /**
  12662. * The original blend value of the runtime animation
  12663. */
  12664. private _originalBlendValue;
  12665. /**
  12666. * The offsets cache of the runtime animation
  12667. */
  12668. private _offsetsCache;
  12669. /**
  12670. * The high limits cache of the runtime animation
  12671. */
  12672. private _highLimitsCache;
  12673. /**
  12674. * Specifies if the runtime animation has been stopped
  12675. */
  12676. private _stopped;
  12677. /**
  12678. * The blending factor of the runtime animation
  12679. */
  12680. private _blendingFactor;
  12681. /**
  12682. * The BabylonJS scene
  12683. */
  12684. private _scene;
  12685. /**
  12686. * The current value of the runtime animation
  12687. */
  12688. private _currentValue;
  12689. /** @hidden */
  12690. _animationState: _IAnimationState;
  12691. /**
  12692. * The active target of the runtime animation
  12693. */
  12694. private _activeTargets;
  12695. private _currentActiveTarget;
  12696. private _directTarget;
  12697. /**
  12698. * The target path of the runtime animation
  12699. */
  12700. private _targetPath;
  12701. /**
  12702. * The weight of the runtime animation
  12703. */
  12704. private _weight;
  12705. /**
  12706. * The ratio offset of the runtime animation
  12707. */
  12708. private _ratioOffset;
  12709. /**
  12710. * The previous delay of the runtime animation
  12711. */
  12712. private _previousDelay;
  12713. /**
  12714. * The previous ratio of the runtime animation
  12715. */
  12716. private _previousRatio;
  12717. private _enableBlending;
  12718. private _keys;
  12719. private _minFrame;
  12720. private _maxFrame;
  12721. private _minValue;
  12722. private _maxValue;
  12723. private _targetIsArray;
  12724. /**
  12725. * Gets the current frame of the runtime animation
  12726. */
  12727. readonly currentFrame: number;
  12728. /**
  12729. * Gets the weight of the runtime animation
  12730. */
  12731. readonly weight: number;
  12732. /**
  12733. * Gets the current value of the runtime animation
  12734. */
  12735. readonly currentValue: any;
  12736. /**
  12737. * Gets the target path of the runtime animation
  12738. */
  12739. readonly targetPath: string;
  12740. /**
  12741. * Gets the actual target of the runtime animation
  12742. */
  12743. readonly target: any;
  12744. /** @hidden */
  12745. _onLoop: () => void;
  12746. /**
  12747. * Create a new RuntimeAnimation object
  12748. * @param target defines the target of the animation
  12749. * @param animation defines the source animation object
  12750. * @param scene defines the hosting scene
  12751. * @param host defines the initiating Animatable
  12752. */
  12753. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12754. private _preparePath;
  12755. /**
  12756. * Gets the animation from the runtime animation
  12757. */
  12758. readonly animation: Animation;
  12759. /**
  12760. * Resets the runtime animation to the beginning
  12761. * @param restoreOriginal defines whether to restore the target property to the original value
  12762. */
  12763. reset(restoreOriginal?: boolean): void;
  12764. /**
  12765. * Specifies if the runtime animation is stopped
  12766. * @returns Boolean specifying if the runtime animation is stopped
  12767. */
  12768. isStopped(): boolean;
  12769. /**
  12770. * Disposes of the runtime animation
  12771. */
  12772. dispose(): void;
  12773. /**
  12774. * Apply the interpolated value to the target
  12775. * @param currentValue defines the value computed by the animation
  12776. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12777. */
  12778. setValue(currentValue: any, weight: number): void;
  12779. private _getOriginalValues;
  12780. private _setValue;
  12781. /**
  12782. * Gets the loop pmode of the runtime animation
  12783. * @returns Loop Mode
  12784. */
  12785. private _getCorrectLoopMode;
  12786. /**
  12787. * Move the current animation to a given frame
  12788. * @param frame defines the frame to move to
  12789. */
  12790. goToFrame(frame: number): void;
  12791. /**
  12792. * @hidden Internal use only
  12793. */
  12794. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12795. /**
  12796. * Execute the current animation
  12797. * @param delay defines the delay to add to the current frame
  12798. * @param from defines the lower bound of the animation range
  12799. * @param to defines the upper bound of the animation range
  12800. * @param loop defines if the current animation must loop
  12801. * @param speedRatio defines the current speed ratio
  12802. * @param weight defines the weight of the animation (default is -1 so no weight)
  12803. * @param onLoop optional callback called when animation loops
  12804. * @returns a boolean indicating if the animation is running
  12805. */
  12806. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12807. }
  12808. }
  12809. declare module BABYLON {
  12810. /**
  12811. * Class used to store an actual running animation
  12812. */
  12813. export class Animatable {
  12814. /** defines the target object */
  12815. target: any;
  12816. /** defines the starting frame number (default is 0) */
  12817. fromFrame: number;
  12818. /** defines the ending frame number (default is 100) */
  12819. toFrame: number;
  12820. /** defines if the animation must loop (default is false) */
  12821. loopAnimation: boolean;
  12822. /** defines a callback to call when animation ends if it is not looping */
  12823. onAnimationEnd?: (() => void) | null | undefined;
  12824. /** defines a callback to call when animation loops */
  12825. onAnimationLoop?: (() => void) | null | undefined;
  12826. private _localDelayOffset;
  12827. private _pausedDelay;
  12828. private _runtimeAnimations;
  12829. private _paused;
  12830. private _scene;
  12831. private _speedRatio;
  12832. private _weight;
  12833. private _syncRoot;
  12834. /**
  12835. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12836. * This will only apply for non looping animation (default is true)
  12837. */
  12838. disposeOnEnd: boolean;
  12839. /**
  12840. * Gets a boolean indicating if the animation has started
  12841. */
  12842. animationStarted: boolean;
  12843. /**
  12844. * Observer raised when the animation ends
  12845. */
  12846. onAnimationEndObservable: Observable<Animatable>;
  12847. /**
  12848. * Observer raised when the animation loops
  12849. */
  12850. onAnimationLoopObservable: Observable<Animatable>;
  12851. /**
  12852. * Gets the root Animatable used to synchronize and normalize animations
  12853. */
  12854. readonly syncRoot: Nullable<Animatable>;
  12855. /**
  12856. * Gets the current frame of the first RuntimeAnimation
  12857. * Used to synchronize Animatables
  12858. */
  12859. readonly masterFrame: number;
  12860. /**
  12861. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12862. */
  12863. weight: number;
  12864. /**
  12865. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12866. */
  12867. speedRatio: number;
  12868. /**
  12869. * Creates a new Animatable
  12870. * @param scene defines the hosting scene
  12871. * @param target defines the target object
  12872. * @param fromFrame defines the starting frame number (default is 0)
  12873. * @param toFrame defines the ending frame number (default is 100)
  12874. * @param loopAnimation defines if the animation must loop (default is false)
  12875. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12876. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12877. * @param animations defines a group of animation to add to the new Animatable
  12878. * @param onAnimationLoop defines a callback to call when animation loops
  12879. */
  12880. constructor(scene: Scene,
  12881. /** defines the target object */
  12882. target: any,
  12883. /** defines the starting frame number (default is 0) */
  12884. fromFrame?: number,
  12885. /** defines the ending frame number (default is 100) */
  12886. toFrame?: number,
  12887. /** defines if the animation must loop (default is false) */
  12888. loopAnimation?: boolean, speedRatio?: number,
  12889. /** defines a callback to call when animation ends if it is not looping */
  12890. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12891. /** defines a callback to call when animation loops */
  12892. onAnimationLoop?: (() => void) | null | undefined);
  12893. /**
  12894. * Synchronize and normalize current Animatable with a source Animatable
  12895. * This is useful when using animation weights and when animations are not of the same length
  12896. * @param root defines the root Animatable to synchronize with
  12897. * @returns the current Animatable
  12898. */
  12899. syncWith(root: Animatable): Animatable;
  12900. /**
  12901. * Gets the list of runtime animations
  12902. * @returns an array of RuntimeAnimation
  12903. */
  12904. getAnimations(): RuntimeAnimation[];
  12905. /**
  12906. * Adds more animations to the current animatable
  12907. * @param target defines the target of the animations
  12908. * @param animations defines the new animations to add
  12909. */
  12910. appendAnimations(target: any, animations: Animation[]): void;
  12911. /**
  12912. * Gets the source animation for a specific property
  12913. * @param property defines the propertyu to look for
  12914. * @returns null or the source animation for the given property
  12915. */
  12916. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12917. /**
  12918. * Gets the runtime animation for a specific property
  12919. * @param property defines the propertyu to look for
  12920. * @returns null or the runtime animation for the given property
  12921. */
  12922. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12923. /**
  12924. * Resets the animatable to its original state
  12925. */
  12926. reset(): void;
  12927. /**
  12928. * Allows the animatable to blend with current running animations
  12929. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12930. * @param blendingSpeed defines the blending speed to use
  12931. */
  12932. enableBlending(blendingSpeed: number): void;
  12933. /**
  12934. * Disable animation blending
  12935. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12936. */
  12937. disableBlending(): void;
  12938. /**
  12939. * Jump directly to a given frame
  12940. * @param frame defines the frame to jump to
  12941. */
  12942. goToFrame(frame: number): void;
  12943. /**
  12944. * Pause the animation
  12945. */
  12946. pause(): void;
  12947. /**
  12948. * Restart the animation
  12949. */
  12950. restart(): void;
  12951. private _raiseOnAnimationEnd;
  12952. /**
  12953. * Stop and delete the current animation
  12954. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12955. * @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)
  12956. */
  12957. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12958. /**
  12959. * Wait asynchronously for the animation to end
  12960. * @returns a promise which will be fullfilled when the animation ends
  12961. */
  12962. waitAsync(): Promise<Animatable>;
  12963. /** @hidden */
  12964. _animate(delay: number): boolean;
  12965. }
  12966. interface Scene {
  12967. /** @hidden */
  12968. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12969. /** @hidden */
  12970. _processLateAnimationBindingsForMatrices(holder: {
  12971. totalWeight: number;
  12972. animations: RuntimeAnimation[];
  12973. originalValue: Matrix;
  12974. }): any;
  12975. /** @hidden */
  12976. _processLateAnimationBindingsForQuaternions(holder: {
  12977. totalWeight: number;
  12978. animations: RuntimeAnimation[];
  12979. originalValue: Quaternion;
  12980. }, refQuaternion: Quaternion): Quaternion;
  12981. /** @hidden */
  12982. _processLateAnimationBindings(): void;
  12983. /**
  12984. * Will start the animation sequence of a given target
  12985. * @param target defines the target
  12986. * @param from defines from which frame should animation start
  12987. * @param to defines until which frame should animation run.
  12988. * @param weight defines the weight to apply to the animation (1.0 by default)
  12989. * @param loop defines if the animation loops
  12990. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12991. * @param onAnimationEnd defines the function to be executed when the animation ends
  12992. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12993. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12994. * @param onAnimationLoop defines the callback to call when an animation loops
  12995. * @returns the animatable object created for this animation
  12996. */
  12997. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12998. /**
  12999. * Will start the animation sequence of a given target
  13000. * @param target defines the target
  13001. * @param from defines from which frame should animation start
  13002. * @param to defines until which frame should animation run.
  13003. * @param loop defines if the animation loops
  13004. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13005. * @param onAnimationEnd defines the function to be executed when the animation ends
  13006. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13007. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13008. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13009. * @param onAnimationLoop defines the callback to call when an animation loops
  13010. * @returns the animatable object created for this animation
  13011. */
  13012. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13013. /**
  13014. * Will start the animation sequence of a given target and its hierarchy
  13015. * @param target defines the target
  13016. * @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.
  13017. * @param from defines from which frame should animation start
  13018. * @param to defines until which frame should animation run.
  13019. * @param loop defines if the animation loops
  13020. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13021. * @param onAnimationEnd defines the function to be executed when the animation ends
  13022. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13023. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13024. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13025. * @param onAnimationLoop defines the callback to call when an animation loops
  13026. * @returns the list of created animatables
  13027. */
  13028. 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[];
  13029. /**
  13030. * Begin a new animation on a given node
  13031. * @param target defines the target where the animation will take place
  13032. * @param animations defines the list of animations to start
  13033. * @param from defines the initial value
  13034. * @param to defines the final value
  13035. * @param loop defines if you want animation to loop (off by default)
  13036. * @param speedRatio defines the speed ratio to apply to all animations
  13037. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13038. * @param onAnimationLoop defines the callback to call when an animation loops
  13039. * @returns the list of created animatables
  13040. */
  13041. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13042. /**
  13043. * Begin a new animation on a given node and its hierarchy
  13044. * @param target defines the root node where the animation will take place
  13045. * @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.
  13046. * @param animations defines the list of animations to start
  13047. * @param from defines the initial value
  13048. * @param to defines the final value
  13049. * @param loop defines if you want animation to loop (off by default)
  13050. * @param speedRatio defines the speed ratio to apply to all animations
  13051. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13052. * @param onAnimationLoop defines the callback to call when an animation loops
  13053. * @returns the list of animatables created for all nodes
  13054. */
  13055. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13056. /**
  13057. * Gets the animatable associated with a specific target
  13058. * @param target defines the target of the animatable
  13059. * @returns the required animatable if found
  13060. */
  13061. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13062. /**
  13063. * Gets all animatables associated with a given target
  13064. * @param target defines the target to look animatables for
  13065. * @returns an array of Animatables
  13066. */
  13067. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13068. /**
  13069. * Stops and removes all animations that have been applied to the scene
  13070. */
  13071. stopAllAnimations(): void;
  13072. /**
  13073. * Gets the current delta time used by animation engine
  13074. */
  13075. deltaTime: number;
  13076. }
  13077. interface Bone {
  13078. /**
  13079. * Copy an animation range from another bone
  13080. * @param source defines the source bone
  13081. * @param rangeName defines the range name to copy
  13082. * @param frameOffset defines the frame offset
  13083. * @param rescaleAsRequired defines if rescaling must be applied if required
  13084. * @param skelDimensionsRatio defines the scaling ratio
  13085. * @returns true if operation was successful
  13086. */
  13087. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13088. }
  13089. }
  13090. declare module BABYLON {
  13091. /**
  13092. * Class used to override all child animations of a given target
  13093. */
  13094. export class AnimationPropertiesOverride {
  13095. /**
  13096. * Gets or sets a value indicating if animation blending must be used
  13097. */
  13098. enableBlending: boolean;
  13099. /**
  13100. * Gets or sets the blending speed to use when enableBlending is true
  13101. */
  13102. blendingSpeed: number;
  13103. /**
  13104. * Gets or sets the default loop mode to use
  13105. */
  13106. loopMode: number;
  13107. }
  13108. }
  13109. declare module BABYLON {
  13110. /**
  13111. * Class used to handle skinning animations
  13112. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13113. */
  13114. export class Skeleton implements IAnimatable {
  13115. /** defines the skeleton name */
  13116. name: string;
  13117. /** defines the skeleton Id */
  13118. id: string;
  13119. /**
  13120. * Defines the list of child bones
  13121. */
  13122. bones: Bone[];
  13123. /**
  13124. * Defines an estimate of the dimension of the skeleton at rest
  13125. */
  13126. dimensionsAtRest: Vector3;
  13127. /**
  13128. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13129. */
  13130. needInitialSkinMatrix: boolean;
  13131. /**
  13132. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13133. */
  13134. overrideMesh: Nullable<AbstractMesh>;
  13135. /**
  13136. * Gets the list of animations attached to this skeleton
  13137. */
  13138. animations: Array<Animation>;
  13139. private _scene;
  13140. private _isDirty;
  13141. private _transformMatrices;
  13142. private _transformMatrixTexture;
  13143. private _meshesWithPoseMatrix;
  13144. private _animatables;
  13145. private _identity;
  13146. private _synchronizedWithMesh;
  13147. private _ranges;
  13148. private _lastAbsoluteTransformsUpdateId;
  13149. private _canUseTextureForBones;
  13150. private _uniqueId;
  13151. /** @hidden */
  13152. _numBonesWithLinkedTransformNode: number;
  13153. /** @hidden */
  13154. _hasWaitingData: Nullable<boolean>;
  13155. /**
  13156. * Specifies if the skeleton should be serialized
  13157. */
  13158. doNotSerialize: boolean;
  13159. private _useTextureToStoreBoneMatrices;
  13160. /**
  13161. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13162. * Please note that this option is not available if the hardware does not support it
  13163. */
  13164. useTextureToStoreBoneMatrices: boolean;
  13165. private _animationPropertiesOverride;
  13166. /**
  13167. * Gets or sets the animation properties override
  13168. */
  13169. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13170. /**
  13171. * List of inspectable custom properties (used by the Inspector)
  13172. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13173. */
  13174. inspectableCustomProperties: IInspectable[];
  13175. /**
  13176. * An observable triggered before computing the skeleton's matrices
  13177. */
  13178. onBeforeComputeObservable: Observable<Skeleton>;
  13179. /**
  13180. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13181. */
  13182. readonly isUsingTextureForMatrices: boolean;
  13183. /**
  13184. * Gets the unique ID of this skeleton
  13185. */
  13186. readonly uniqueId: number;
  13187. /**
  13188. * Creates a new skeleton
  13189. * @param name defines the skeleton name
  13190. * @param id defines the skeleton Id
  13191. * @param scene defines the hosting scene
  13192. */
  13193. constructor(
  13194. /** defines the skeleton name */
  13195. name: string,
  13196. /** defines the skeleton Id */
  13197. id: string, scene: Scene);
  13198. /**
  13199. * Gets the current object class name.
  13200. * @return the class name
  13201. */
  13202. getClassName(): string;
  13203. /**
  13204. * Returns an array containing the root bones
  13205. * @returns an array containing the root bones
  13206. */
  13207. getChildren(): Array<Bone>;
  13208. /**
  13209. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13210. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13211. * @returns a Float32Array containing matrices data
  13212. */
  13213. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13214. /**
  13215. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13216. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13217. * @returns a raw texture containing the data
  13218. */
  13219. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13220. /**
  13221. * Gets the current hosting scene
  13222. * @returns a scene object
  13223. */
  13224. getScene(): Scene;
  13225. /**
  13226. * Gets a string representing the current skeleton data
  13227. * @param fullDetails defines a boolean indicating if we want a verbose version
  13228. * @returns a string representing the current skeleton data
  13229. */
  13230. toString(fullDetails?: boolean): string;
  13231. /**
  13232. * Get bone's index searching by name
  13233. * @param name defines bone's name to search for
  13234. * @return the indice of the bone. Returns -1 if not found
  13235. */
  13236. getBoneIndexByName(name: string): number;
  13237. /**
  13238. * Creater a new animation range
  13239. * @param name defines the name of the range
  13240. * @param from defines the start key
  13241. * @param to defines the end key
  13242. */
  13243. createAnimationRange(name: string, from: number, to: number): void;
  13244. /**
  13245. * Delete a specific animation range
  13246. * @param name defines the name of the range
  13247. * @param deleteFrames defines if frames must be removed as well
  13248. */
  13249. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13250. /**
  13251. * Gets a specific animation range
  13252. * @param name defines the name of the range to look for
  13253. * @returns the requested animation range or null if not found
  13254. */
  13255. getAnimationRange(name: string): Nullable<AnimationRange>;
  13256. /**
  13257. * Gets the list of all animation ranges defined on this skeleton
  13258. * @returns an array
  13259. */
  13260. getAnimationRanges(): Nullable<AnimationRange>[];
  13261. /**
  13262. * Copy animation range from a source skeleton.
  13263. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13264. * @param source defines the source skeleton
  13265. * @param name defines the name of the range to copy
  13266. * @param rescaleAsRequired defines if rescaling must be applied if required
  13267. * @returns true if operation was successful
  13268. */
  13269. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13270. /**
  13271. * Forces the skeleton to go to rest pose
  13272. */
  13273. returnToRest(): void;
  13274. private _getHighestAnimationFrame;
  13275. /**
  13276. * Begin a specific animation range
  13277. * @param name defines the name of the range to start
  13278. * @param loop defines if looping must be turned on (false by default)
  13279. * @param speedRatio defines the speed ratio to apply (1 by default)
  13280. * @param onAnimationEnd defines a callback which will be called when animation will end
  13281. * @returns a new animatable
  13282. */
  13283. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13284. /** @hidden */
  13285. _markAsDirty(): void;
  13286. /** @hidden */
  13287. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13288. /** @hidden */
  13289. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13290. private _computeTransformMatrices;
  13291. /**
  13292. * Build all resources required to render a skeleton
  13293. */
  13294. prepare(): void;
  13295. /**
  13296. * Gets the list of animatables currently running for this skeleton
  13297. * @returns an array of animatables
  13298. */
  13299. getAnimatables(): IAnimatable[];
  13300. /**
  13301. * Clone the current skeleton
  13302. * @param name defines the name of the new skeleton
  13303. * @param id defines the id of the new skeleton
  13304. * @returns the new skeleton
  13305. */
  13306. clone(name: string, id: string): Skeleton;
  13307. /**
  13308. * Enable animation blending for this skeleton
  13309. * @param blendingSpeed defines the blending speed to apply
  13310. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13311. */
  13312. enableBlending(blendingSpeed?: number): void;
  13313. /**
  13314. * Releases all resources associated with the current skeleton
  13315. */
  13316. dispose(): void;
  13317. /**
  13318. * Serialize the skeleton in a JSON object
  13319. * @returns a JSON object
  13320. */
  13321. serialize(): any;
  13322. /**
  13323. * Creates a new skeleton from serialized data
  13324. * @param parsedSkeleton defines the serialized data
  13325. * @param scene defines the hosting scene
  13326. * @returns a new skeleton
  13327. */
  13328. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13329. /**
  13330. * Compute all node absolute transforms
  13331. * @param forceUpdate defines if computation must be done even if cache is up to date
  13332. */
  13333. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13334. /**
  13335. * Gets the root pose matrix
  13336. * @returns a matrix
  13337. */
  13338. getPoseMatrix(): Nullable<Matrix>;
  13339. /**
  13340. * Sorts bones per internal index
  13341. */
  13342. sortBones(): void;
  13343. private _sortBones;
  13344. }
  13345. }
  13346. declare module BABYLON {
  13347. /**
  13348. * Class used to store bone information
  13349. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13350. */
  13351. export class Bone extends Node {
  13352. /**
  13353. * defines the bone name
  13354. */
  13355. name: string;
  13356. private static _tmpVecs;
  13357. private static _tmpQuat;
  13358. private static _tmpMats;
  13359. /**
  13360. * Gets the list of child bones
  13361. */
  13362. children: Bone[];
  13363. /** Gets the animations associated with this bone */
  13364. animations: Animation[];
  13365. /**
  13366. * Gets or sets bone length
  13367. */
  13368. length: number;
  13369. /**
  13370. * @hidden Internal only
  13371. * Set this value to map this bone to a different index in the transform matrices
  13372. * Set this value to -1 to exclude the bone from the transform matrices
  13373. */
  13374. _index: Nullable<number>;
  13375. private _skeleton;
  13376. private _localMatrix;
  13377. private _restPose;
  13378. private _baseMatrix;
  13379. private _absoluteTransform;
  13380. private _invertedAbsoluteTransform;
  13381. private _parent;
  13382. private _scalingDeterminant;
  13383. private _worldTransform;
  13384. private _localScaling;
  13385. private _localRotation;
  13386. private _localPosition;
  13387. private _needToDecompose;
  13388. private _needToCompose;
  13389. /** @hidden */
  13390. _linkedTransformNode: Nullable<TransformNode>;
  13391. /** @hidden */
  13392. _waitingTransformNodeId: Nullable<string>;
  13393. /** @hidden */
  13394. /** @hidden */
  13395. _matrix: Matrix;
  13396. /**
  13397. * Create a new bone
  13398. * @param name defines the bone name
  13399. * @param skeleton defines the parent skeleton
  13400. * @param parentBone defines the parent (can be null if the bone is the root)
  13401. * @param localMatrix defines the local matrix
  13402. * @param restPose defines the rest pose matrix
  13403. * @param baseMatrix defines the base matrix
  13404. * @param index defines index of the bone in the hiearchy
  13405. */
  13406. constructor(
  13407. /**
  13408. * defines the bone name
  13409. */
  13410. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13411. /**
  13412. * Gets the current object class name.
  13413. * @return the class name
  13414. */
  13415. getClassName(): string;
  13416. /**
  13417. * Gets the parent skeleton
  13418. * @returns a skeleton
  13419. */
  13420. getSkeleton(): Skeleton;
  13421. /**
  13422. * Gets parent bone
  13423. * @returns a bone or null if the bone is the root of the bone hierarchy
  13424. */
  13425. getParent(): Nullable<Bone>;
  13426. /**
  13427. * Returns an array containing the root bones
  13428. * @returns an array containing the root bones
  13429. */
  13430. getChildren(): Array<Bone>;
  13431. /**
  13432. * Sets the parent bone
  13433. * @param parent defines the parent (can be null if the bone is the root)
  13434. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13435. */
  13436. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13437. /**
  13438. * Gets the local matrix
  13439. * @returns a matrix
  13440. */
  13441. getLocalMatrix(): Matrix;
  13442. /**
  13443. * Gets the base matrix (initial matrix which remains unchanged)
  13444. * @returns a matrix
  13445. */
  13446. getBaseMatrix(): Matrix;
  13447. /**
  13448. * Gets the rest pose matrix
  13449. * @returns a matrix
  13450. */
  13451. getRestPose(): Matrix;
  13452. /**
  13453. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13454. */
  13455. getWorldMatrix(): Matrix;
  13456. /**
  13457. * Sets the local matrix to rest pose matrix
  13458. */
  13459. returnToRest(): void;
  13460. /**
  13461. * Gets the inverse of the absolute transform matrix.
  13462. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13463. * @returns a matrix
  13464. */
  13465. getInvertedAbsoluteTransform(): Matrix;
  13466. /**
  13467. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13468. * @returns a matrix
  13469. */
  13470. getAbsoluteTransform(): Matrix;
  13471. /**
  13472. * Links with the given transform node.
  13473. * The local matrix of this bone is copied from the transform node every frame.
  13474. * @param transformNode defines the transform node to link to
  13475. */
  13476. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13477. /**
  13478. * Gets the node used to drive the bone's transformation
  13479. * @returns a transform node or null
  13480. */
  13481. getTransformNode(): Nullable<TransformNode>;
  13482. /** Gets or sets current position (in local space) */
  13483. position: Vector3;
  13484. /** Gets or sets current rotation (in local space) */
  13485. rotation: Vector3;
  13486. /** Gets or sets current rotation quaternion (in local space) */
  13487. rotationQuaternion: Quaternion;
  13488. /** Gets or sets current scaling (in local space) */
  13489. scaling: Vector3;
  13490. /**
  13491. * Gets the animation properties override
  13492. */
  13493. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13494. private _decompose;
  13495. private _compose;
  13496. /**
  13497. * Update the base and local matrices
  13498. * @param matrix defines the new base or local matrix
  13499. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13500. * @param updateLocalMatrix defines if the local matrix should be updated
  13501. */
  13502. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13503. /** @hidden */
  13504. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13505. /**
  13506. * Flag the bone as dirty (Forcing it to update everything)
  13507. */
  13508. markAsDirty(): void;
  13509. /** @hidden */
  13510. _markAsDirtyAndCompose(): void;
  13511. private _markAsDirtyAndDecompose;
  13512. /**
  13513. * Translate the bone in local or world space
  13514. * @param vec The amount to translate the bone
  13515. * @param space The space that the translation is in
  13516. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13517. */
  13518. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13519. /**
  13520. * Set the postion of the bone in local or world space
  13521. * @param position The position to set the bone
  13522. * @param space The space that the position is in
  13523. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13524. */
  13525. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13526. /**
  13527. * Set the absolute position of the bone (world space)
  13528. * @param position The position to set the bone
  13529. * @param mesh The mesh that this bone is attached to
  13530. */
  13531. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13532. /**
  13533. * Scale the bone on the x, y and z axes (in local space)
  13534. * @param x The amount to scale the bone on the x axis
  13535. * @param y The amount to scale the bone on the y axis
  13536. * @param z The amount to scale the bone on the z axis
  13537. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13538. */
  13539. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13540. /**
  13541. * Set the bone scaling in local space
  13542. * @param scale defines the scaling vector
  13543. */
  13544. setScale(scale: Vector3): void;
  13545. /**
  13546. * Gets the current scaling in local space
  13547. * @returns the current scaling vector
  13548. */
  13549. getScale(): Vector3;
  13550. /**
  13551. * Gets the current scaling in local space and stores it in a target vector
  13552. * @param result defines the target vector
  13553. */
  13554. getScaleToRef(result: Vector3): void;
  13555. /**
  13556. * Set the yaw, pitch, and roll of the bone in local or world space
  13557. * @param yaw The rotation of the bone on the y axis
  13558. * @param pitch The rotation of the bone on the x axis
  13559. * @param roll The rotation of the bone on the z axis
  13560. * @param space The space that the axes of rotation are in
  13561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13562. */
  13563. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13564. /**
  13565. * Add a rotation to the bone on an axis in local or world space
  13566. * @param axis The axis to rotate the bone on
  13567. * @param amount The amount to rotate the bone
  13568. * @param space The space that the axis is in
  13569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13570. */
  13571. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13572. /**
  13573. * Set the rotation of the bone to a particular axis angle in local or world space
  13574. * @param axis The axis to rotate the bone on
  13575. * @param angle The angle that the bone should be rotated to
  13576. * @param space The space that the axis is in
  13577. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13578. */
  13579. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13580. /**
  13581. * Set the euler rotation of the bone in local of world space
  13582. * @param rotation The euler rotation that the bone should be set to
  13583. * @param space The space that the rotation is in
  13584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13585. */
  13586. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13587. /**
  13588. * Set the quaternion rotation of the bone in local of world space
  13589. * @param quat The quaternion rotation that the bone should be set to
  13590. * @param space The space that the rotation is in
  13591. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13592. */
  13593. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13594. /**
  13595. * Set the rotation matrix of the bone in local of world space
  13596. * @param rotMat The rotation matrix that the bone should be set to
  13597. * @param space The space that the rotation is in
  13598. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13599. */
  13600. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13601. private _rotateWithMatrix;
  13602. private _getNegativeRotationToRef;
  13603. /**
  13604. * Get the position of the bone in local or world space
  13605. * @param space The space that the returned position is in
  13606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13607. * @returns The position of the bone
  13608. */
  13609. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13610. /**
  13611. * Copy the position of the bone to a vector3 in local or world space
  13612. * @param space The space that the returned position is in
  13613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13614. * @param result The vector3 to copy the position to
  13615. */
  13616. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13617. /**
  13618. * Get the absolute position of the bone (world space)
  13619. * @param mesh The mesh that this bone is attached to
  13620. * @returns The absolute position of the bone
  13621. */
  13622. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13623. /**
  13624. * Copy the absolute position of the bone (world space) to the result param
  13625. * @param mesh The mesh that this bone is attached to
  13626. * @param result The vector3 to copy the absolute position to
  13627. */
  13628. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13629. /**
  13630. * Compute the absolute transforms of this bone and its children
  13631. */
  13632. computeAbsoluteTransforms(): void;
  13633. /**
  13634. * Get the world direction from an axis that is in the local space of the bone
  13635. * @param localAxis The local direction that is used to compute the world direction
  13636. * @param mesh The mesh that this bone is attached to
  13637. * @returns The world direction
  13638. */
  13639. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13640. /**
  13641. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13642. * @param localAxis The local direction that is used to compute the world direction
  13643. * @param mesh The mesh that this bone is attached to
  13644. * @param result The vector3 that the world direction will be copied to
  13645. */
  13646. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13647. /**
  13648. * Get the euler rotation of the bone in local or world space
  13649. * @param space The space that the rotation should be in
  13650. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13651. * @returns The euler rotation
  13652. */
  13653. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13654. /**
  13655. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13656. * @param space The space that the rotation should be in
  13657. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13658. * @param result The vector3 that the rotation should be copied to
  13659. */
  13660. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13661. /**
  13662. * Get the quaternion rotation of the bone in either local or world space
  13663. * @param space The space that the rotation should be in
  13664. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13665. * @returns The quaternion rotation
  13666. */
  13667. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13668. /**
  13669. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13670. * @param space The space that the rotation should be in
  13671. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13672. * @param result The quaternion that the rotation should be copied to
  13673. */
  13674. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13675. /**
  13676. * Get the rotation matrix of the bone in local or world space
  13677. * @param space The space that the rotation should be in
  13678. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13679. * @returns The rotation matrix
  13680. */
  13681. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13682. /**
  13683. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13684. * @param space The space that the rotation should be in
  13685. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13686. * @param result The quaternion that the rotation should be copied to
  13687. */
  13688. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13689. /**
  13690. * Get the world position of a point that is in the local space of the bone
  13691. * @param position The local position
  13692. * @param mesh The mesh that this bone is attached to
  13693. * @returns The world position
  13694. */
  13695. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13696. /**
  13697. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13698. * @param position The local position
  13699. * @param mesh The mesh that this bone is attached to
  13700. * @param result The vector3 that the world position should be copied to
  13701. */
  13702. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13703. /**
  13704. * Get the local position of a point that is in world space
  13705. * @param position The world position
  13706. * @param mesh The mesh that this bone is attached to
  13707. * @returns The local position
  13708. */
  13709. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13710. /**
  13711. * Get the local position of a point that is in world space and copy it to the result param
  13712. * @param position The world position
  13713. * @param mesh The mesh that this bone is attached to
  13714. * @param result The vector3 that the local position should be copied to
  13715. */
  13716. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13717. }
  13718. }
  13719. declare module BABYLON {
  13720. /**
  13721. * 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.
  13722. * @see https://doc.babylonjs.com/how_to/transformnode
  13723. */
  13724. export class TransformNode extends Node {
  13725. /**
  13726. * Object will not rotate to face the camera
  13727. */
  13728. static BILLBOARDMODE_NONE: number;
  13729. /**
  13730. * Object will rotate to face the camera but only on the x axis
  13731. */
  13732. static BILLBOARDMODE_X: number;
  13733. /**
  13734. * Object will rotate to face the camera but only on the y axis
  13735. */
  13736. static BILLBOARDMODE_Y: number;
  13737. /**
  13738. * Object will rotate to face the camera but only on the z axis
  13739. */
  13740. static BILLBOARDMODE_Z: number;
  13741. /**
  13742. * Object will rotate to face the camera
  13743. */
  13744. static BILLBOARDMODE_ALL: number;
  13745. /**
  13746. * Object will rotate to face the camera's position instead of orientation
  13747. */
  13748. static BILLBOARDMODE_USE_POSITION: number;
  13749. private _forward;
  13750. private _forwardInverted;
  13751. private _up;
  13752. private _right;
  13753. private _rightInverted;
  13754. private _position;
  13755. private _rotation;
  13756. private _rotationQuaternion;
  13757. protected _scaling: Vector3;
  13758. protected _isDirty: boolean;
  13759. private _transformToBoneReferal;
  13760. private _isAbsoluteSynced;
  13761. private _billboardMode;
  13762. /**
  13763. * Gets or sets the billboard mode. Default is 0.
  13764. *
  13765. * | Value | Type | Description |
  13766. * | --- | --- | --- |
  13767. * | 0 | BILLBOARDMODE_NONE | |
  13768. * | 1 | BILLBOARDMODE_X | |
  13769. * | 2 | BILLBOARDMODE_Y | |
  13770. * | 4 | BILLBOARDMODE_Z | |
  13771. * | 7 | BILLBOARDMODE_ALL | |
  13772. *
  13773. */
  13774. billboardMode: number;
  13775. private _preserveParentRotationForBillboard;
  13776. /**
  13777. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13778. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13779. */
  13780. preserveParentRotationForBillboard: boolean;
  13781. /**
  13782. * 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
  13783. */
  13784. scalingDeterminant: number;
  13785. private _infiniteDistance;
  13786. /**
  13787. * Gets or sets the distance of the object to max, often used by skybox
  13788. */
  13789. infiniteDistance: boolean;
  13790. /**
  13791. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13792. * By default the system will update normals to compensate
  13793. */
  13794. ignoreNonUniformScaling: boolean;
  13795. /**
  13796. * 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
  13797. */
  13798. reIntegrateRotationIntoRotationQuaternion: boolean;
  13799. /** @hidden */
  13800. _poseMatrix: Nullable<Matrix>;
  13801. /** @hidden */
  13802. _localMatrix: Matrix;
  13803. private _usePivotMatrix;
  13804. private _absolutePosition;
  13805. private _absoluteScaling;
  13806. private _absoluteRotationQuaternion;
  13807. private _pivotMatrix;
  13808. private _pivotMatrixInverse;
  13809. protected _postMultiplyPivotMatrix: boolean;
  13810. protected _isWorldMatrixFrozen: boolean;
  13811. /** @hidden */
  13812. _indexInSceneTransformNodesArray: number;
  13813. /**
  13814. * An event triggered after the world matrix is updated
  13815. */
  13816. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13817. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13818. /**
  13819. * Gets a string identifying the name of the class
  13820. * @returns "TransformNode" string
  13821. */
  13822. getClassName(): string;
  13823. /**
  13824. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13825. */
  13826. position: Vector3;
  13827. /**
  13828. * 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)).
  13829. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13830. */
  13831. rotation: Vector3;
  13832. /**
  13833. * 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)).
  13834. */
  13835. scaling: Vector3;
  13836. /**
  13837. * 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).
  13838. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13839. */
  13840. rotationQuaternion: Nullable<Quaternion>;
  13841. /**
  13842. * The forward direction of that transform in world space.
  13843. */
  13844. readonly forward: Vector3;
  13845. /**
  13846. * The up direction of that transform in world space.
  13847. */
  13848. readonly up: Vector3;
  13849. /**
  13850. * The right direction of that transform in world space.
  13851. */
  13852. readonly right: Vector3;
  13853. /**
  13854. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13855. * @param matrix the matrix to copy the pose from
  13856. * @returns this TransformNode.
  13857. */
  13858. updatePoseMatrix(matrix: Matrix): TransformNode;
  13859. /**
  13860. * Returns the mesh Pose matrix.
  13861. * @returns the pose matrix
  13862. */
  13863. getPoseMatrix(): Matrix;
  13864. /** @hidden */
  13865. _isSynchronized(): boolean;
  13866. /** @hidden */
  13867. _initCache(): void;
  13868. /**
  13869. * Flag the transform node as dirty (Forcing it to update everything)
  13870. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13871. * @returns this transform node
  13872. */
  13873. markAsDirty(property: string): TransformNode;
  13874. /**
  13875. * Returns the current mesh absolute position.
  13876. * Returns a Vector3.
  13877. */
  13878. readonly absolutePosition: Vector3;
  13879. /**
  13880. * Returns the current mesh absolute scaling.
  13881. * Returns a Vector3.
  13882. */
  13883. readonly absoluteScaling: Vector3;
  13884. /**
  13885. * Returns the current mesh absolute rotation.
  13886. * Returns a Quaternion.
  13887. */
  13888. readonly absoluteRotationQuaternion: Quaternion;
  13889. /**
  13890. * Sets a new matrix to apply before all other transformation
  13891. * @param matrix defines the transform matrix
  13892. * @returns the current TransformNode
  13893. */
  13894. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13895. /**
  13896. * Sets a new pivot matrix to the current node
  13897. * @param matrix defines the new pivot matrix to use
  13898. * @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
  13899. * @returns the current TransformNode
  13900. */
  13901. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13902. /**
  13903. * Returns the mesh pivot matrix.
  13904. * Default : Identity.
  13905. * @returns the matrix
  13906. */
  13907. getPivotMatrix(): Matrix;
  13908. /**
  13909. * Instantiate (when possible) or clone that node with its hierarchy
  13910. * @param newParent defines the new parent to use for the instance (or clone)
  13911. * @returns an instance (or a clone) of the current node with its hiearchy
  13912. */
  13913. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13914. /**
  13915. * Prevents the World matrix to be computed any longer
  13916. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13917. * @returns the TransformNode.
  13918. */
  13919. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13920. /**
  13921. * Allows back the World matrix computation.
  13922. * @returns the TransformNode.
  13923. */
  13924. unfreezeWorldMatrix(): this;
  13925. /**
  13926. * True if the World matrix has been frozen.
  13927. */
  13928. readonly isWorldMatrixFrozen: boolean;
  13929. /**
  13930. * Retuns the mesh absolute position in the World.
  13931. * @returns a Vector3.
  13932. */
  13933. getAbsolutePosition(): Vector3;
  13934. /**
  13935. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13936. * @param absolutePosition the absolute position to set
  13937. * @returns the TransformNode.
  13938. */
  13939. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13940. /**
  13941. * Sets the mesh position in its local space.
  13942. * @param vector3 the position to set in localspace
  13943. * @returns the TransformNode.
  13944. */
  13945. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13946. /**
  13947. * Returns the mesh position in the local space from the current World matrix values.
  13948. * @returns a new Vector3.
  13949. */
  13950. getPositionExpressedInLocalSpace(): Vector3;
  13951. /**
  13952. * Translates the mesh along the passed Vector3 in its local space.
  13953. * @param vector3 the distance to translate in localspace
  13954. * @returns the TransformNode.
  13955. */
  13956. locallyTranslate(vector3: Vector3): TransformNode;
  13957. private static _lookAtVectorCache;
  13958. /**
  13959. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13960. * @param targetPoint the position (must be in same space as current mesh) to look at
  13961. * @param yawCor optional yaw (y-axis) correction in radians
  13962. * @param pitchCor optional pitch (x-axis) correction in radians
  13963. * @param rollCor optional roll (z-axis) correction in radians
  13964. * @param space the choosen space of the target
  13965. * @returns the TransformNode.
  13966. */
  13967. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13968. /**
  13969. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13970. * This Vector3 is expressed in the World space.
  13971. * @param localAxis axis to rotate
  13972. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13973. */
  13974. getDirection(localAxis: Vector3): Vector3;
  13975. /**
  13976. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13977. * localAxis is expressed in the mesh local space.
  13978. * result is computed in the Wordl space from the mesh World matrix.
  13979. * @param localAxis axis to rotate
  13980. * @param result the resulting transformnode
  13981. * @returns this TransformNode.
  13982. */
  13983. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13984. /**
  13985. * Sets this transform node rotation to the given local axis.
  13986. * @param localAxis the axis in local space
  13987. * @param yawCor optional yaw (y-axis) correction in radians
  13988. * @param pitchCor optional pitch (x-axis) correction in radians
  13989. * @param rollCor optional roll (z-axis) correction in radians
  13990. * @returns this TransformNode
  13991. */
  13992. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13993. /**
  13994. * Sets a new pivot point to the current node
  13995. * @param point defines the new pivot point to use
  13996. * @param space defines if the point is in world or local space (local by default)
  13997. * @returns the current TransformNode
  13998. */
  13999. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14000. /**
  14001. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14002. * @returns the pivot point
  14003. */
  14004. getPivotPoint(): Vector3;
  14005. /**
  14006. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14007. * @param result the vector3 to store the result
  14008. * @returns this TransformNode.
  14009. */
  14010. getPivotPointToRef(result: Vector3): TransformNode;
  14011. /**
  14012. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14013. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14014. */
  14015. getAbsolutePivotPoint(): Vector3;
  14016. /**
  14017. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14018. * @param result vector3 to store the result
  14019. * @returns this TransformNode.
  14020. */
  14021. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14022. /**
  14023. * Defines the passed node as the parent of the current node.
  14024. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14025. * @see https://doc.babylonjs.com/how_to/parenting
  14026. * @param node the node ot set as the parent
  14027. * @returns this TransformNode.
  14028. */
  14029. setParent(node: Nullable<Node>): TransformNode;
  14030. private _nonUniformScaling;
  14031. /**
  14032. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14033. */
  14034. readonly nonUniformScaling: boolean;
  14035. /** @hidden */
  14036. _updateNonUniformScalingState(value: boolean): boolean;
  14037. /**
  14038. * Attach the current TransformNode to another TransformNode associated with a bone
  14039. * @param bone Bone affecting the TransformNode
  14040. * @param affectedTransformNode TransformNode associated with the bone
  14041. * @returns this object
  14042. */
  14043. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14044. /**
  14045. * Detach the transform node if its associated with a bone
  14046. * @returns this object
  14047. */
  14048. detachFromBone(): TransformNode;
  14049. private static _rotationAxisCache;
  14050. /**
  14051. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14052. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14053. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14054. * The passed axis is also normalized.
  14055. * @param axis the axis to rotate around
  14056. * @param amount the amount to rotate in radians
  14057. * @param space Space to rotate in (Default: local)
  14058. * @returns the TransformNode.
  14059. */
  14060. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14061. /**
  14062. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14063. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14064. * The passed axis is also normalized. .
  14065. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14066. * @param point the point to rotate around
  14067. * @param axis the axis to rotate around
  14068. * @param amount the amount to rotate in radians
  14069. * @returns the TransformNode
  14070. */
  14071. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14072. /**
  14073. * Translates the mesh along the axis vector for the passed distance in the given space.
  14074. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14075. * @param axis the axis to translate in
  14076. * @param distance the distance to translate
  14077. * @param space Space to rotate in (Default: local)
  14078. * @returns the TransformNode.
  14079. */
  14080. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14081. /**
  14082. * Adds a rotation step to the mesh current rotation.
  14083. * x, y, z are Euler angles expressed in radians.
  14084. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14085. * This means this rotation is made in the mesh local space only.
  14086. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14087. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14088. * ```javascript
  14089. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14090. * ```
  14091. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14092. * 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.
  14093. * @param x Rotation to add
  14094. * @param y Rotation to add
  14095. * @param z Rotation to add
  14096. * @returns the TransformNode.
  14097. */
  14098. addRotation(x: number, y: number, z: number): TransformNode;
  14099. /**
  14100. * @hidden
  14101. */
  14102. protected _getEffectiveParent(): Nullable<Node>;
  14103. /**
  14104. * Computes the world matrix of the node
  14105. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14106. * @returns the world matrix
  14107. */
  14108. computeWorldMatrix(force?: boolean): Matrix;
  14109. protected _afterComputeWorldMatrix(): void;
  14110. /**
  14111. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14112. * @param func callback function to add
  14113. *
  14114. * @returns the TransformNode.
  14115. */
  14116. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14117. /**
  14118. * Removes a registered callback function.
  14119. * @param func callback function to remove
  14120. * @returns the TransformNode.
  14121. */
  14122. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14123. /**
  14124. * Gets the position of the current mesh in camera space
  14125. * @param camera defines the camera to use
  14126. * @returns a position
  14127. */
  14128. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14129. /**
  14130. * Returns the distance from the mesh to the active camera
  14131. * @param camera defines the camera to use
  14132. * @returns the distance
  14133. */
  14134. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14135. /**
  14136. * Clone the current transform node
  14137. * @param name Name of the new clone
  14138. * @param newParent New parent for the clone
  14139. * @param doNotCloneChildren Do not clone children hierarchy
  14140. * @returns the new transform node
  14141. */
  14142. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14143. /**
  14144. * Serializes the objects information.
  14145. * @param currentSerializationObject defines the object to serialize in
  14146. * @returns the serialized object
  14147. */
  14148. serialize(currentSerializationObject?: any): any;
  14149. /**
  14150. * Returns a new TransformNode object parsed from the source provided.
  14151. * @param parsedTransformNode is the source.
  14152. * @param scene the scne the object belongs to
  14153. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14154. * @returns a new TransformNode object parsed from the source provided.
  14155. */
  14156. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14157. /**
  14158. * Get all child-transformNodes of this node
  14159. * @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
  14160. * @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
  14161. * @returns an array of TransformNode
  14162. */
  14163. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14164. /**
  14165. * Releases resources associated with this transform node.
  14166. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14167. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14168. */
  14169. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14170. /**
  14171. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14172. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14173. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14174. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14175. * @returns the current mesh
  14176. */
  14177. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14178. private _syncAbsoluteScalingAndRotation;
  14179. }
  14180. }
  14181. declare module BABYLON {
  14182. /**
  14183. * Defines the types of pose enabled controllers that are supported
  14184. */
  14185. export enum PoseEnabledControllerType {
  14186. /**
  14187. * HTC Vive
  14188. */
  14189. VIVE = 0,
  14190. /**
  14191. * Oculus Rift
  14192. */
  14193. OCULUS = 1,
  14194. /**
  14195. * Windows mixed reality
  14196. */
  14197. WINDOWS = 2,
  14198. /**
  14199. * Samsung gear VR
  14200. */
  14201. GEAR_VR = 3,
  14202. /**
  14203. * Google Daydream
  14204. */
  14205. DAYDREAM = 4,
  14206. /**
  14207. * Generic
  14208. */
  14209. GENERIC = 5
  14210. }
  14211. /**
  14212. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14213. */
  14214. export interface MutableGamepadButton {
  14215. /**
  14216. * Value of the button/trigger
  14217. */
  14218. value: number;
  14219. /**
  14220. * If the button/trigger is currently touched
  14221. */
  14222. touched: boolean;
  14223. /**
  14224. * If the button/trigger is currently pressed
  14225. */
  14226. pressed: boolean;
  14227. }
  14228. /**
  14229. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14230. * @hidden
  14231. */
  14232. export interface ExtendedGamepadButton extends GamepadButton {
  14233. /**
  14234. * If the button/trigger is currently pressed
  14235. */
  14236. readonly pressed: boolean;
  14237. /**
  14238. * If the button/trigger is currently touched
  14239. */
  14240. readonly touched: boolean;
  14241. /**
  14242. * Value of the button/trigger
  14243. */
  14244. readonly value: number;
  14245. }
  14246. /** @hidden */
  14247. export interface _GamePadFactory {
  14248. /**
  14249. * Returns wether or not the current gamepad can be created for this type of controller.
  14250. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14251. * @returns true if it can be created, otherwise false
  14252. */
  14253. canCreate(gamepadInfo: any): boolean;
  14254. /**
  14255. * Creates a new instance of the Gamepad.
  14256. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14257. * @returns the new gamepad instance
  14258. */
  14259. create(gamepadInfo: any): Gamepad;
  14260. }
  14261. /**
  14262. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14263. */
  14264. export class PoseEnabledControllerHelper {
  14265. /** @hidden */
  14266. static _ControllerFactories: _GamePadFactory[];
  14267. /** @hidden */
  14268. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14269. /**
  14270. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14271. * @param vrGamepad the gamepad to initialized
  14272. * @returns a vr controller of the type the gamepad identified as
  14273. */
  14274. static InitiateController(vrGamepad: any): Gamepad;
  14275. }
  14276. /**
  14277. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14278. */
  14279. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14280. /**
  14281. * If the controller is used in a webXR session
  14282. */
  14283. isXR: boolean;
  14284. private _deviceRoomPosition;
  14285. private _deviceRoomRotationQuaternion;
  14286. /**
  14287. * The device position in babylon space
  14288. */
  14289. devicePosition: Vector3;
  14290. /**
  14291. * The device rotation in babylon space
  14292. */
  14293. deviceRotationQuaternion: Quaternion;
  14294. /**
  14295. * The scale factor of the device in babylon space
  14296. */
  14297. deviceScaleFactor: number;
  14298. /**
  14299. * (Likely devicePosition should be used instead) The device position in its room space
  14300. */
  14301. position: Vector3;
  14302. /**
  14303. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14304. */
  14305. rotationQuaternion: Quaternion;
  14306. /**
  14307. * The type of controller (Eg. Windows mixed reality)
  14308. */
  14309. controllerType: PoseEnabledControllerType;
  14310. protected _calculatedPosition: Vector3;
  14311. private _calculatedRotation;
  14312. /**
  14313. * The raw pose from the device
  14314. */
  14315. rawPose: DevicePose;
  14316. private _trackPosition;
  14317. private _maxRotationDistFromHeadset;
  14318. private _draggedRoomRotation;
  14319. /**
  14320. * @hidden
  14321. */
  14322. _disableTrackPosition(fixedPosition: Vector3): void;
  14323. /**
  14324. * Internal, the mesh attached to the controller
  14325. * @hidden
  14326. */
  14327. _mesh: Nullable<AbstractMesh>;
  14328. private _poseControlledCamera;
  14329. private _leftHandSystemQuaternion;
  14330. /**
  14331. * Internal, matrix used to convert room space to babylon space
  14332. * @hidden
  14333. */
  14334. _deviceToWorld: Matrix;
  14335. /**
  14336. * Node to be used when casting a ray from the controller
  14337. * @hidden
  14338. */
  14339. _pointingPoseNode: Nullable<TransformNode>;
  14340. /**
  14341. * Name of the child mesh that can be used to cast a ray from the controller
  14342. */
  14343. static readonly POINTING_POSE: string;
  14344. /**
  14345. * Creates a new PoseEnabledController from a gamepad
  14346. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14347. */
  14348. constructor(browserGamepad: any);
  14349. private _workingMatrix;
  14350. /**
  14351. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14352. */
  14353. update(): void;
  14354. /**
  14355. * Updates only the pose device and mesh without doing any button event checking
  14356. */
  14357. protected _updatePoseAndMesh(): void;
  14358. /**
  14359. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14360. * @param poseData raw pose fromthe device
  14361. */
  14362. updateFromDevice(poseData: DevicePose): void;
  14363. /**
  14364. * @hidden
  14365. */
  14366. _meshAttachedObservable: Observable<AbstractMesh>;
  14367. /**
  14368. * Attaches a mesh to the controller
  14369. * @param mesh the mesh to be attached
  14370. */
  14371. attachToMesh(mesh: AbstractMesh): void;
  14372. /**
  14373. * Attaches the controllers mesh to a camera
  14374. * @param camera the camera the mesh should be attached to
  14375. */
  14376. attachToPoseControlledCamera(camera: TargetCamera): void;
  14377. /**
  14378. * Disposes of the controller
  14379. */
  14380. dispose(): void;
  14381. /**
  14382. * The mesh that is attached to the controller
  14383. */
  14384. readonly mesh: Nullable<AbstractMesh>;
  14385. /**
  14386. * Gets the ray of the controller in the direction the controller is pointing
  14387. * @param length the length the resulting ray should be
  14388. * @returns a ray in the direction the controller is pointing
  14389. */
  14390. getForwardRay(length?: number): Ray;
  14391. }
  14392. }
  14393. declare module BABYLON {
  14394. /**
  14395. * Defines the WebVRController object that represents controllers tracked in 3D space
  14396. */
  14397. export abstract class WebVRController extends PoseEnabledController {
  14398. /**
  14399. * Internal, the default controller model for the controller
  14400. */
  14401. protected _defaultModel: Nullable<AbstractMesh>;
  14402. /**
  14403. * Fired when the trigger state has changed
  14404. */
  14405. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14406. /**
  14407. * Fired when the main button state has changed
  14408. */
  14409. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14410. /**
  14411. * Fired when the secondary button state has changed
  14412. */
  14413. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14414. /**
  14415. * Fired when the pad state has changed
  14416. */
  14417. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14418. /**
  14419. * Fired when controllers stick values have changed
  14420. */
  14421. onPadValuesChangedObservable: Observable<StickValues>;
  14422. /**
  14423. * Array of button availible on the controller
  14424. */
  14425. protected _buttons: Array<MutableGamepadButton>;
  14426. private _onButtonStateChange;
  14427. /**
  14428. * Fired when a controller button's state has changed
  14429. * @param callback the callback containing the button that was modified
  14430. */
  14431. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14432. /**
  14433. * X and Y axis corresponding to the controllers joystick
  14434. */
  14435. pad: StickValues;
  14436. /**
  14437. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14438. */
  14439. hand: string;
  14440. /**
  14441. * The default controller model for the controller
  14442. */
  14443. readonly defaultModel: Nullable<AbstractMesh>;
  14444. /**
  14445. * Creates a new WebVRController from a gamepad
  14446. * @param vrGamepad the gamepad that the WebVRController should be created from
  14447. */
  14448. constructor(vrGamepad: any);
  14449. /**
  14450. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14451. */
  14452. update(): void;
  14453. /**
  14454. * Function to be called when a button is modified
  14455. */
  14456. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14457. /**
  14458. * Loads a mesh and attaches it to the controller
  14459. * @param scene the scene the mesh should be added to
  14460. * @param meshLoaded callback for when the mesh has been loaded
  14461. */
  14462. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14463. private _setButtonValue;
  14464. private _changes;
  14465. private _checkChanges;
  14466. /**
  14467. * Disposes of th webVRCOntroller
  14468. */
  14469. dispose(): void;
  14470. }
  14471. }
  14472. declare module BABYLON {
  14473. /**
  14474. * The HemisphericLight simulates the ambient environment light,
  14475. * so the passed direction is the light reflection direction, not the incoming direction.
  14476. */
  14477. export class HemisphericLight extends Light {
  14478. /**
  14479. * The groundColor is the light in the opposite direction to the one specified during creation.
  14480. * 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.
  14481. */
  14482. groundColor: Color3;
  14483. /**
  14484. * The light reflection direction, not the incoming direction.
  14485. */
  14486. direction: Vector3;
  14487. /**
  14488. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14489. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14490. * The HemisphericLight can't cast shadows.
  14491. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14492. * @param name The friendly name of the light
  14493. * @param direction The direction of the light reflection
  14494. * @param scene The scene the light belongs to
  14495. */
  14496. constructor(name: string, direction: Vector3, scene: Scene);
  14497. protected _buildUniformLayout(): void;
  14498. /**
  14499. * Returns the string "HemisphericLight".
  14500. * @return The class name
  14501. */
  14502. getClassName(): string;
  14503. /**
  14504. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14505. * Returns the updated direction.
  14506. * @param target The target the direction should point to
  14507. * @return The computed direction
  14508. */
  14509. setDirectionToTarget(target: Vector3): Vector3;
  14510. /**
  14511. * Returns the shadow generator associated to the light.
  14512. * @returns Always null for hemispheric lights because it does not support shadows.
  14513. */
  14514. getShadowGenerator(): Nullable<IShadowGenerator>;
  14515. /**
  14516. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14517. * @param effect The effect to update
  14518. * @param lightIndex The index of the light in the effect to update
  14519. * @returns The hemispheric light
  14520. */
  14521. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14522. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14523. /**
  14524. * Computes the world matrix of the node
  14525. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14526. * @param useWasUpdatedFlag defines a reserved property
  14527. * @returns the world matrix
  14528. */
  14529. computeWorldMatrix(): Matrix;
  14530. /**
  14531. * Returns the integer 3.
  14532. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14533. */
  14534. getTypeID(): number;
  14535. /**
  14536. * Prepares the list of defines specific to the light type.
  14537. * @param defines the list of defines
  14538. * @param lightIndex defines the index of the light for the effect
  14539. */
  14540. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14541. }
  14542. }
  14543. declare module BABYLON {
  14544. /** @hidden */
  14545. export var vrMultiviewToSingleviewPixelShader: {
  14546. name: string;
  14547. shader: string;
  14548. };
  14549. }
  14550. declare module BABYLON {
  14551. /**
  14552. * Renders to multiple views with a single draw call
  14553. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14554. */
  14555. export class MultiviewRenderTarget extends RenderTargetTexture {
  14556. /**
  14557. * Creates a multiview render target
  14558. * @param scene scene used with the render target
  14559. * @param size the size of the render target (used for each view)
  14560. */
  14561. constructor(scene: Scene, size?: number | {
  14562. width: number;
  14563. height: number;
  14564. } | {
  14565. ratio: number;
  14566. });
  14567. /**
  14568. * @hidden
  14569. * @param faceIndex the face index, if its a cube texture
  14570. */
  14571. _bindFrameBuffer(faceIndex?: number): void;
  14572. /**
  14573. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14574. * @returns the view count
  14575. */
  14576. getViewCount(): number;
  14577. }
  14578. }
  14579. declare module BABYLON {
  14580. /**
  14581. * Represents a camera frustum
  14582. */
  14583. export class Frustum {
  14584. /**
  14585. * Gets the planes representing the frustum
  14586. * @param transform matrix to be applied to the returned planes
  14587. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14588. */
  14589. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14590. /**
  14591. * Gets the near frustum plane transformed by the transform matrix
  14592. * @param transform transformation matrix to be applied to the resulting frustum plane
  14593. * @param frustumPlane the resuling frustum plane
  14594. */
  14595. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14596. /**
  14597. * Gets the far frustum plane transformed by the transform matrix
  14598. * @param transform transformation matrix to be applied to the resulting frustum plane
  14599. * @param frustumPlane the resuling frustum plane
  14600. */
  14601. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14602. /**
  14603. * Gets the left frustum plane transformed by the transform matrix
  14604. * @param transform transformation matrix to be applied to the resulting frustum plane
  14605. * @param frustumPlane the resuling frustum plane
  14606. */
  14607. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14608. /**
  14609. * Gets the right frustum plane transformed by the transform matrix
  14610. * @param transform transformation matrix to be applied to the resulting frustum plane
  14611. * @param frustumPlane the resuling frustum plane
  14612. */
  14613. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14614. /**
  14615. * Gets the top frustum plane transformed by the transform matrix
  14616. * @param transform transformation matrix to be applied to the resulting frustum plane
  14617. * @param frustumPlane the resuling frustum plane
  14618. */
  14619. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14620. /**
  14621. * Gets the bottom frustum plane transformed by the transform matrix
  14622. * @param transform transformation matrix to be applied to the resulting frustum plane
  14623. * @param frustumPlane the resuling frustum plane
  14624. */
  14625. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14626. /**
  14627. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14628. * @param transform transformation matrix to be applied to the resulting frustum planes
  14629. * @param frustumPlanes the resuling frustum planes
  14630. */
  14631. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14632. }
  14633. }
  14634. declare module BABYLON {
  14635. interface Engine {
  14636. /**
  14637. * Creates a new multiview render target
  14638. * @param width defines the width of the texture
  14639. * @param height defines the height of the texture
  14640. * @returns the created multiview texture
  14641. */
  14642. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14643. /**
  14644. * Binds a multiview framebuffer to be drawn to
  14645. * @param multiviewTexture texture to bind
  14646. */
  14647. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14648. }
  14649. interface Camera {
  14650. /**
  14651. * @hidden
  14652. * 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)
  14653. */
  14654. _useMultiviewToSingleView: boolean;
  14655. /**
  14656. * @hidden
  14657. * 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)
  14658. */
  14659. _multiviewTexture: Nullable<RenderTargetTexture>;
  14660. /**
  14661. * @hidden
  14662. * ensures the multiview texture of the camera exists and has the specified width/height
  14663. * @param width height to set on the multiview texture
  14664. * @param height width to set on the multiview texture
  14665. */
  14666. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14667. }
  14668. interface Scene {
  14669. /** @hidden */
  14670. _transformMatrixR: Matrix;
  14671. /** @hidden */
  14672. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14673. /** @hidden */
  14674. _createMultiviewUbo(): void;
  14675. /** @hidden */
  14676. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14677. /** @hidden */
  14678. _renderMultiviewToSingleView(camera: Camera): void;
  14679. }
  14680. }
  14681. declare module BABYLON {
  14682. /**
  14683. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14684. * This will not be used for webXR as it supports displaying texture arrays directly
  14685. */
  14686. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14687. /**
  14688. * Initializes a VRMultiviewToSingleview
  14689. * @param name name of the post process
  14690. * @param camera camera to be applied to
  14691. * @param scaleFactor scaling factor to the size of the output texture
  14692. */
  14693. constructor(name: string, camera: Camera, scaleFactor: number);
  14694. }
  14695. }
  14696. declare module BABYLON {
  14697. interface Engine {
  14698. /** @hidden */
  14699. _vrDisplay: any;
  14700. /** @hidden */
  14701. _vrSupported: boolean;
  14702. /** @hidden */
  14703. _oldSize: Size;
  14704. /** @hidden */
  14705. _oldHardwareScaleFactor: number;
  14706. /** @hidden */
  14707. _vrExclusivePointerMode: boolean;
  14708. /** @hidden */
  14709. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14710. /** @hidden */
  14711. _onVRDisplayPointerRestricted: () => void;
  14712. /** @hidden */
  14713. _onVRDisplayPointerUnrestricted: () => void;
  14714. /** @hidden */
  14715. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14716. /** @hidden */
  14717. _onVrDisplayDisconnect: Nullable<() => void>;
  14718. /** @hidden */
  14719. _onVrDisplayPresentChange: Nullable<() => void>;
  14720. /**
  14721. * Observable signaled when VR display mode changes
  14722. */
  14723. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14724. /**
  14725. * Observable signaled when VR request present is complete
  14726. */
  14727. onVRRequestPresentComplete: Observable<boolean>;
  14728. /**
  14729. * Observable signaled when VR request present starts
  14730. */
  14731. onVRRequestPresentStart: Observable<Engine>;
  14732. /**
  14733. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14734. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14735. */
  14736. isInVRExclusivePointerMode: boolean;
  14737. /**
  14738. * Gets a boolean indicating if a webVR device was detected
  14739. * @returns true if a webVR device was detected
  14740. */
  14741. isVRDevicePresent(): boolean;
  14742. /**
  14743. * Gets the current webVR device
  14744. * @returns the current webVR device (or null)
  14745. */
  14746. getVRDevice(): any;
  14747. /**
  14748. * Initializes a webVR display and starts listening to display change events
  14749. * The onVRDisplayChangedObservable will be notified upon these changes
  14750. * @returns A promise containing a VRDisplay and if vr is supported
  14751. */
  14752. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14753. /** @hidden */
  14754. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14755. /**
  14756. * Call this function to switch to webVR mode
  14757. * Will do nothing if webVR is not supported or if there is no webVR device
  14758. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14759. */
  14760. enableVR(): void;
  14761. /** @hidden */
  14762. _onVRFullScreenTriggered(): void;
  14763. }
  14764. }
  14765. declare module BABYLON {
  14766. /**
  14767. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14768. * IMPORTANT!! The data is right-hand data.
  14769. * @export
  14770. * @interface DevicePose
  14771. */
  14772. export interface DevicePose {
  14773. /**
  14774. * The position of the device, values in array are [x,y,z].
  14775. */
  14776. readonly position: Nullable<Float32Array>;
  14777. /**
  14778. * The linearVelocity of the device, values in array are [x,y,z].
  14779. */
  14780. readonly linearVelocity: Nullable<Float32Array>;
  14781. /**
  14782. * The linearAcceleration of the device, values in array are [x,y,z].
  14783. */
  14784. readonly linearAcceleration: Nullable<Float32Array>;
  14785. /**
  14786. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14787. */
  14788. readonly orientation: Nullable<Float32Array>;
  14789. /**
  14790. * The angularVelocity of the device, values in array are [x,y,z].
  14791. */
  14792. readonly angularVelocity: Nullable<Float32Array>;
  14793. /**
  14794. * The angularAcceleration of the device, values in array are [x,y,z].
  14795. */
  14796. readonly angularAcceleration: Nullable<Float32Array>;
  14797. }
  14798. /**
  14799. * Interface representing a pose controlled object in Babylon.
  14800. * A pose controlled object has both regular pose values as well as pose values
  14801. * from an external device such as a VR head mounted display
  14802. */
  14803. export interface PoseControlled {
  14804. /**
  14805. * The position of the object in babylon space.
  14806. */
  14807. position: Vector3;
  14808. /**
  14809. * The rotation quaternion of the object in babylon space.
  14810. */
  14811. rotationQuaternion: Quaternion;
  14812. /**
  14813. * The position of the device in babylon space.
  14814. */
  14815. devicePosition?: Vector3;
  14816. /**
  14817. * The rotation quaternion of the device in babylon space.
  14818. */
  14819. deviceRotationQuaternion: Quaternion;
  14820. /**
  14821. * The raw pose coming from the device.
  14822. */
  14823. rawPose: Nullable<DevicePose>;
  14824. /**
  14825. * The scale of the device to be used when translating from device space to babylon space.
  14826. */
  14827. deviceScaleFactor: number;
  14828. /**
  14829. * Updates the poseControlled values based on the input device pose.
  14830. * @param poseData the pose data to update the object with
  14831. */
  14832. updateFromDevice(poseData: DevicePose): void;
  14833. }
  14834. /**
  14835. * Set of options to customize the webVRCamera
  14836. */
  14837. export interface WebVROptions {
  14838. /**
  14839. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14840. */
  14841. trackPosition?: boolean;
  14842. /**
  14843. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14844. */
  14845. positionScale?: number;
  14846. /**
  14847. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14848. */
  14849. displayName?: string;
  14850. /**
  14851. * Should the native controller meshes be initialized. (default: true)
  14852. */
  14853. controllerMeshes?: boolean;
  14854. /**
  14855. * Creating a default HemiLight only on controllers. (default: true)
  14856. */
  14857. defaultLightingOnControllers?: boolean;
  14858. /**
  14859. * If you don't want to use the default VR button of the helper. (default: false)
  14860. */
  14861. useCustomVRButton?: boolean;
  14862. /**
  14863. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14864. */
  14865. customVRButton?: HTMLButtonElement;
  14866. /**
  14867. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14868. */
  14869. rayLength?: number;
  14870. /**
  14871. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14872. */
  14873. defaultHeight?: number;
  14874. /**
  14875. * If multiview should be used if availible (default: false)
  14876. */
  14877. useMultiview?: boolean;
  14878. }
  14879. /**
  14880. * This represents a WebVR camera.
  14881. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14882. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14883. */
  14884. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14885. private webVROptions;
  14886. /**
  14887. * @hidden
  14888. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14889. */
  14890. _vrDevice: any;
  14891. /**
  14892. * The rawPose of the vrDevice.
  14893. */
  14894. rawPose: Nullable<DevicePose>;
  14895. private _onVREnabled;
  14896. private _specsVersion;
  14897. private _attached;
  14898. private _frameData;
  14899. protected _descendants: Array<Node>;
  14900. private _deviceRoomPosition;
  14901. /** @hidden */
  14902. _deviceRoomRotationQuaternion: Quaternion;
  14903. private _standingMatrix;
  14904. /**
  14905. * Represents device position in babylon space.
  14906. */
  14907. devicePosition: Vector3;
  14908. /**
  14909. * Represents device rotation in babylon space.
  14910. */
  14911. deviceRotationQuaternion: Quaternion;
  14912. /**
  14913. * The scale of the device to be used when translating from device space to babylon space.
  14914. */
  14915. deviceScaleFactor: number;
  14916. private _deviceToWorld;
  14917. private _worldToDevice;
  14918. /**
  14919. * References to the webVR controllers for the vrDevice.
  14920. */
  14921. controllers: Array<WebVRController>;
  14922. /**
  14923. * Emits an event when a controller is attached.
  14924. */
  14925. onControllersAttachedObservable: Observable<WebVRController[]>;
  14926. /**
  14927. * Emits an event when a controller's mesh has been loaded;
  14928. */
  14929. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14930. /**
  14931. * Emits an event when the HMD's pose has been updated.
  14932. */
  14933. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14934. private _poseSet;
  14935. /**
  14936. * If the rig cameras be used as parent instead of this camera.
  14937. */
  14938. rigParenting: boolean;
  14939. private _lightOnControllers;
  14940. private _defaultHeight?;
  14941. /**
  14942. * Instantiates a WebVRFreeCamera.
  14943. * @param name The name of the WebVRFreeCamera
  14944. * @param position The starting anchor position for the camera
  14945. * @param scene The scene the camera belongs to
  14946. * @param webVROptions a set of customizable options for the webVRCamera
  14947. */
  14948. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14949. /**
  14950. * Gets the device distance from the ground in meters.
  14951. * @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.
  14952. */
  14953. deviceDistanceToRoomGround(): number;
  14954. /**
  14955. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14956. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14957. */
  14958. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14959. /**
  14960. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14961. * @returns A promise with a boolean set to if the standing matrix is supported.
  14962. */
  14963. useStandingMatrixAsync(): Promise<boolean>;
  14964. /**
  14965. * Disposes the camera
  14966. */
  14967. dispose(): void;
  14968. /**
  14969. * Gets a vrController by name.
  14970. * @param name The name of the controller to retreive
  14971. * @returns the controller matching the name specified or null if not found
  14972. */
  14973. getControllerByName(name: string): Nullable<WebVRController>;
  14974. private _leftController;
  14975. /**
  14976. * The controller corresponding to the users left hand.
  14977. */
  14978. readonly leftController: Nullable<WebVRController>;
  14979. private _rightController;
  14980. /**
  14981. * The controller corresponding to the users right hand.
  14982. */
  14983. readonly rightController: Nullable<WebVRController>;
  14984. /**
  14985. * Casts a ray forward from the vrCamera's gaze.
  14986. * @param length Length of the ray (default: 100)
  14987. * @returns the ray corresponding to the gaze
  14988. */
  14989. getForwardRay(length?: number): Ray;
  14990. /**
  14991. * @hidden
  14992. * Updates the camera based on device's frame data
  14993. */
  14994. _checkInputs(): void;
  14995. /**
  14996. * Updates the poseControlled values based on the input device pose.
  14997. * @param poseData Pose coming from the device
  14998. */
  14999. updateFromDevice(poseData: DevicePose): void;
  15000. private _htmlElementAttached;
  15001. private _detachIfAttached;
  15002. /**
  15003. * WebVR's attach control will start broadcasting frames to the device.
  15004. * Note that in certain browsers (chrome for example) this function must be called
  15005. * within a user-interaction callback. Example:
  15006. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15007. *
  15008. * @param element html element to attach the vrDevice to
  15009. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15010. */
  15011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15012. /**
  15013. * Detaches the camera from the html element and disables VR
  15014. *
  15015. * @param element html element to detach from
  15016. */
  15017. detachControl(element: HTMLElement): void;
  15018. /**
  15019. * @returns the name of this class
  15020. */
  15021. getClassName(): string;
  15022. /**
  15023. * Calls resetPose on the vrDisplay
  15024. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15025. */
  15026. resetToCurrentRotation(): void;
  15027. /**
  15028. * @hidden
  15029. * Updates the rig cameras (left and right eye)
  15030. */
  15031. _updateRigCameras(): void;
  15032. private _workingVector;
  15033. private _oneVector;
  15034. private _workingMatrix;
  15035. private updateCacheCalled;
  15036. private _correctPositionIfNotTrackPosition;
  15037. /**
  15038. * @hidden
  15039. * Updates the cached values of the camera
  15040. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15041. */
  15042. _updateCache(ignoreParentClass?: boolean): void;
  15043. /**
  15044. * @hidden
  15045. * Get current device position in babylon world
  15046. */
  15047. _computeDevicePosition(): void;
  15048. /**
  15049. * Updates the current device position and rotation in the babylon world
  15050. */
  15051. update(): void;
  15052. /**
  15053. * @hidden
  15054. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15055. * @returns an identity matrix
  15056. */
  15057. _getViewMatrix(): Matrix;
  15058. private _tmpMatrix;
  15059. /**
  15060. * This function is called by the two RIG cameras.
  15061. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15062. * @hidden
  15063. */
  15064. _getWebVRViewMatrix(): Matrix;
  15065. /** @hidden */
  15066. _getWebVRProjectionMatrix(): Matrix;
  15067. private _onGamepadConnectedObserver;
  15068. private _onGamepadDisconnectedObserver;
  15069. private _updateCacheWhenTrackingDisabledObserver;
  15070. /**
  15071. * Initializes the controllers and their meshes
  15072. */
  15073. initControllers(): void;
  15074. }
  15075. }
  15076. declare module BABYLON {
  15077. /**
  15078. * Size options for a post process
  15079. */
  15080. export type PostProcessOptions = {
  15081. width: number;
  15082. height: number;
  15083. };
  15084. /**
  15085. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15086. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15087. */
  15088. export class PostProcess {
  15089. /** Name of the PostProcess. */
  15090. name: string;
  15091. /**
  15092. * Gets or sets the unique id of the post process
  15093. */
  15094. uniqueId: number;
  15095. /**
  15096. * Width of the texture to apply the post process on
  15097. */
  15098. width: number;
  15099. /**
  15100. * Height of the texture to apply the post process on
  15101. */
  15102. height: number;
  15103. /**
  15104. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15105. * @hidden
  15106. */
  15107. _outputTexture: Nullable<InternalTexture>;
  15108. /**
  15109. * Sampling mode used by the shader
  15110. * See https://doc.babylonjs.com/classes/3.1/texture
  15111. */
  15112. renderTargetSamplingMode: number;
  15113. /**
  15114. * Clear color to use when screen clearing
  15115. */
  15116. clearColor: Color4;
  15117. /**
  15118. * If the buffer needs to be cleared before applying the post process. (default: true)
  15119. * Should be set to false if shader will overwrite all previous pixels.
  15120. */
  15121. autoClear: boolean;
  15122. /**
  15123. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15124. */
  15125. alphaMode: number;
  15126. /**
  15127. * Sets the setAlphaBlendConstants of the babylon engine
  15128. */
  15129. alphaConstants: Color4;
  15130. /**
  15131. * Animations to be used for the post processing
  15132. */
  15133. animations: Animation[];
  15134. /**
  15135. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15136. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15137. */
  15138. enablePixelPerfectMode: boolean;
  15139. /**
  15140. * Force the postprocess to be applied without taking in account viewport
  15141. */
  15142. forceFullscreenViewport: boolean;
  15143. /**
  15144. * List of inspectable custom properties (used by the Inspector)
  15145. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15146. */
  15147. inspectableCustomProperties: IInspectable[];
  15148. /**
  15149. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15150. *
  15151. * | Value | Type | Description |
  15152. * | ----- | ----------------------------------- | ----------- |
  15153. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15154. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15155. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15156. *
  15157. */
  15158. scaleMode: number;
  15159. /**
  15160. * Force textures to be a power of two (default: false)
  15161. */
  15162. alwaysForcePOT: boolean;
  15163. private _samples;
  15164. /**
  15165. * Number of sample textures (default: 1)
  15166. */
  15167. samples: number;
  15168. /**
  15169. * Modify the scale of the post process to be the same as the viewport (default: false)
  15170. */
  15171. adaptScaleToCurrentViewport: boolean;
  15172. private _camera;
  15173. private _scene;
  15174. private _engine;
  15175. private _options;
  15176. private _reusable;
  15177. private _textureType;
  15178. /**
  15179. * Smart array of input and output textures for the post process.
  15180. * @hidden
  15181. */
  15182. _textures: SmartArray<InternalTexture>;
  15183. /**
  15184. * The index in _textures that corresponds to the output texture.
  15185. * @hidden
  15186. */
  15187. _currentRenderTextureInd: number;
  15188. private _effect;
  15189. private _samplers;
  15190. private _fragmentUrl;
  15191. private _vertexUrl;
  15192. private _parameters;
  15193. private _scaleRatio;
  15194. protected _indexParameters: any;
  15195. private _shareOutputWithPostProcess;
  15196. private _texelSize;
  15197. private _forcedOutputTexture;
  15198. /**
  15199. * Returns the fragment url or shader name used in the post process.
  15200. * @returns the fragment url or name in the shader store.
  15201. */
  15202. getEffectName(): string;
  15203. /**
  15204. * An event triggered when the postprocess is activated.
  15205. */
  15206. onActivateObservable: Observable<Camera>;
  15207. private _onActivateObserver;
  15208. /**
  15209. * A function that is added to the onActivateObservable
  15210. */
  15211. onActivate: Nullable<(camera: Camera) => void>;
  15212. /**
  15213. * An event triggered when the postprocess changes its size.
  15214. */
  15215. onSizeChangedObservable: Observable<PostProcess>;
  15216. private _onSizeChangedObserver;
  15217. /**
  15218. * A function that is added to the onSizeChangedObservable
  15219. */
  15220. onSizeChanged: (postProcess: PostProcess) => void;
  15221. /**
  15222. * An event triggered when the postprocess applies its effect.
  15223. */
  15224. onApplyObservable: Observable<Effect>;
  15225. private _onApplyObserver;
  15226. /**
  15227. * A function that is added to the onApplyObservable
  15228. */
  15229. onApply: (effect: Effect) => void;
  15230. /**
  15231. * An event triggered before rendering the postprocess
  15232. */
  15233. onBeforeRenderObservable: Observable<Effect>;
  15234. private _onBeforeRenderObserver;
  15235. /**
  15236. * A function that is added to the onBeforeRenderObservable
  15237. */
  15238. onBeforeRender: (effect: Effect) => void;
  15239. /**
  15240. * An event triggered after rendering the postprocess
  15241. */
  15242. onAfterRenderObservable: Observable<Effect>;
  15243. private _onAfterRenderObserver;
  15244. /**
  15245. * A function that is added to the onAfterRenderObservable
  15246. */
  15247. onAfterRender: (efect: Effect) => void;
  15248. /**
  15249. * 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
  15250. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15251. */
  15252. inputTexture: InternalTexture;
  15253. /**
  15254. * Gets the camera which post process is applied to.
  15255. * @returns The camera the post process is applied to.
  15256. */
  15257. getCamera(): Camera;
  15258. /**
  15259. * Gets the texel size of the postprocess.
  15260. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15261. */
  15262. readonly texelSize: Vector2;
  15263. /**
  15264. * Creates a new instance PostProcess
  15265. * @param name The name of the PostProcess.
  15266. * @param fragmentUrl The url of the fragment shader to be used.
  15267. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15268. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15269. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15270. * @param camera The camera to apply the render pass to.
  15271. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15272. * @param engine The engine which the post process will be applied. (default: current engine)
  15273. * @param reusable If the post process can be reused on the same frame. (default: false)
  15274. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15275. * @param textureType Type of textures used when performing the post process. (default: 0)
  15276. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15277. * @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
  15278. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15279. */
  15280. constructor(
  15281. /** Name of the PostProcess. */
  15282. 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);
  15283. /**
  15284. * Gets a string idenfifying the name of the class
  15285. * @returns "PostProcess" string
  15286. */
  15287. getClassName(): string;
  15288. /**
  15289. * Gets the engine which this post process belongs to.
  15290. * @returns The engine the post process was enabled with.
  15291. */
  15292. getEngine(): Engine;
  15293. /**
  15294. * The effect that is created when initializing the post process.
  15295. * @returns The created effect corresponding the the postprocess.
  15296. */
  15297. getEffect(): Effect;
  15298. /**
  15299. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15300. * @param postProcess The post process to share the output with.
  15301. * @returns This post process.
  15302. */
  15303. shareOutputWith(postProcess: PostProcess): PostProcess;
  15304. /**
  15305. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15306. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15307. */
  15308. useOwnOutput(): void;
  15309. /**
  15310. * Updates the effect with the current post process compile time values and recompiles the shader.
  15311. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15312. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15313. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15314. * @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
  15315. * @param onCompiled Called when the shader has been compiled.
  15316. * @param onError Called if there is an error when compiling a shader.
  15317. */
  15318. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15319. /**
  15320. * The post process is reusable if it can be used multiple times within one frame.
  15321. * @returns If the post process is reusable
  15322. */
  15323. isReusable(): boolean;
  15324. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15325. markTextureDirty(): void;
  15326. /**
  15327. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15328. * 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.
  15329. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15330. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15331. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15332. * @returns The target texture that was bound to be written to.
  15333. */
  15334. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15335. /**
  15336. * If the post process is supported.
  15337. */
  15338. readonly isSupported: boolean;
  15339. /**
  15340. * The aspect ratio of the output texture.
  15341. */
  15342. readonly aspectRatio: number;
  15343. /**
  15344. * Get a value indicating if the post-process is ready to be used
  15345. * @returns true if the post-process is ready (shader is compiled)
  15346. */
  15347. isReady(): boolean;
  15348. /**
  15349. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15350. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15351. */
  15352. apply(): Nullable<Effect>;
  15353. private _disposeTextures;
  15354. /**
  15355. * Disposes the post process.
  15356. * @param camera The camera to dispose the post process on.
  15357. */
  15358. dispose(camera?: Camera): void;
  15359. }
  15360. }
  15361. declare module BABYLON {
  15362. /** @hidden */
  15363. export var kernelBlurVaryingDeclaration: {
  15364. name: string;
  15365. shader: string;
  15366. };
  15367. }
  15368. declare module BABYLON {
  15369. /** @hidden */
  15370. export var kernelBlurFragment: {
  15371. name: string;
  15372. shader: string;
  15373. };
  15374. }
  15375. declare module BABYLON {
  15376. /** @hidden */
  15377. export var kernelBlurFragment2: {
  15378. name: string;
  15379. shader: string;
  15380. };
  15381. }
  15382. declare module BABYLON {
  15383. /** @hidden */
  15384. export var kernelBlurPixelShader: {
  15385. name: string;
  15386. shader: string;
  15387. };
  15388. }
  15389. declare module BABYLON {
  15390. /** @hidden */
  15391. export var kernelBlurVertex: {
  15392. name: string;
  15393. shader: string;
  15394. };
  15395. }
  15396. declare module BABYLON {
  15397. /** @hidden */
  15398. export var kernelBlurVertexShader: {
  15399. name: string;
  15400. shader: string;
  15401. };
  15402. }
  15403. declare module BABYLON {
  15404. /**
  15405. * The Blur Post Process which blurs an image based on a kernel and direction.
  15406. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15407. */
  15408. export class BlurPostProcess extends PostProcess {
  15409. /** The direction in which to blur the image. */
  15410. direction: Vector2;
  15411. private blockCompilation;
  15412. protected _kernel: number;
  15413. protected _idealKernel: number;
  15414. protected _packedFloat: boolean;
  15415. private _staticDefines;
  15416. /**
  15417. * Sets the length in pixels of the blur sample region
  15418. */
  15419. /**
  15420. * Gets the length in pixels of the blur sample region
  15421. */
  15422. kernel: number;
  15423. /**
  15424. * Sets wether or not the blur needs to unpack/repack floats
  15425. */
  15426. /**
  15427. * Gets wether or not the blur is unpacking/repacking floats
  15428. */
  15429. packedFloat: boolean;
  15430. /**
  15431. * Creates a new instance BlurPostProcess
  15432. * @param name The name of the effect.
  15433. * @param direction The direction in which to blur the image.
  15434. * @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.
  15435. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15436. * @param camera The camera to apply the render pass to.
  15437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15438. * @param engine The engine which the post process will be applied. (default: current engine)
  15439. * @param reusable If the post process can be reused on the same frame. (default: false)
  15440. * @param textureType Type of textures used when performing the post process. (default: 0)
  15441. * @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)
  15442. */
  15443. constructor(name: string,
  15444. /** The direction in which to blur the image. */
  15445. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15446. /**
  15447. * Updates the effect with the current post process compile time values and recompiles the shader.
  15448. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15449. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15450. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15451. * @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
  15452. * @param onCompiled Called when the shader has been compiled.
  15453. * @param onError Called if there is an error when compiling a shader.
  15454. */
  15455. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15456. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15457. /**
  15458. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15459. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15460. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15461. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15462. * The gaps between physical kernels are compensated for in the weighting of the samples
  15463. * @param idealKernel Ideal blur kernel.
  15464. * @return Nearest best kernel.
  15465. */
  15466. protected _nearestBestKernel(idealKernel: number): number;
  15467. /**
  15468. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15469. * @param x The point on the Gaussian distribution to sample.
  15470. * @return the value of the Gaussian function at x.
  15471. */
  15472. protected _gaussianWeight(x: number): number;
  15473. /**
  15474. * Generates a string that can be used as a floating point number in GLSL.
  15475. * @param x Value to print.
  15476. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15477. * @return GLSL float string.
  15478. */
  15479. protected _glslFloat(x: number, decimalFigures?: number): string;
  15480. }
  15481. }
  15482. declare module BABYLON {
  15483. /**
  15484. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15485. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15486. * You can then easily use it as a reflectionTexture on a flat surface.
  15487. * In case the surface is not a plane, please consider relying on reflection probes.
  15488. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15489. */
  15490. export class MirrorTexture extends RenderTargetTexture {
  15491. private scene;
  15492. /**
  15493. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15494. * 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.
  15495. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15496. */
  15497. mirrorPlane: Plane;
  15498. /**
  15499. * Define the blur ratio used to blur the reflection if needed.
  15500. */
  15501. blurRatio: number;
  15502. /**
  15503. * Define the adaptive blur kernel used to blur the reflection if needed.
  15504. * This will autocompute the closest best match for the `blurKernel`
  15505. */
  15506. adaptiveBlurKernel: number;
  15507. /**
  15508. * Define the blur kernel used to blur the reflection if needed.
  15509. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15510. */
  15511. blurKernel: number;
  15512. /**
  15513. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15514. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15515. */
  15516. blurKernelX: number;
  15517. /**
  15518. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15519. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15520. */
  15521. blurKernelY: number;
  15522. private _autoComputeBlurKernel;
  15523. protected _onRatioRescale(): void;
  15524. private _updateGammaSpace;
  15525. private _imageProcessingConfigChangeObserver;
  15526. private _transformMatrix;
  15527. private _mirrorMatrix;
  15528. private _savedViewMatrix;
  15529. private _blurX;
  15530. private _blurY;
  15531. private _adaptiveBlurKernel;
  15532. private _blurKernelX;
  15533. private _blurKernelY;
  15534. private _blurRatio;
  15535. /**
  15536. * Instantiates a Mirror Texture.
  15537. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15538. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15539. * You can then easily use it as a reflectionTexture on a flat surface.
  15540. * In case the surface is not a plane, please consider relying on reflection probes.
  15541. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15542. * @param name
  15543. * @param size
  15544. * @param scene
  15545. * @param generateMipMaps
  15546. * @param type
  15547. * @param samplingMode
  15548. * @param generateDepthBuffer
  15549. */
  15550. constructor(name: string, size: number | {
  15551. width: number;
  15552. height: number;
  15553. } | {
  15554. ratio: number;
  15555. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15556. private _preparePostProcesses;
  15557. /**
  15558. * Clone the mirror texture.
  15559. * @returns the cloned texture
  15560. */
  15561. clone(): MirrorTexture;
  15562. /**
  15563. * Serialize the texture to a JSON representation you could use in Parse later on
  15564. * @returns the serialized JSON representation
  15565. */
  15566. serialize(): any;
  15567. /**
  15568. * Dispose the texture and release its associated resources.
  15569. */
  15570. dispose(): void;
  15571. }
  15572. }
  15573. declare module BABYLON {
  15574. /**
  15575. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15576. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15577. */
  15578. export class Texture extends BaseTexture {
  15579. /**
  15580. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15581. */
  15582. static SerializeBuffers: boolean;
  15583. /** @hidden */
  15584. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15585. /** @hidden */
  15586. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15587. /** @hidden */
  15588. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15589. /** nearest is mag = nearest and min = nearest and mip = linear */
  15590. static readonly NEAREST_SAMPLINGMODE: number;
  15591. /** nearest is mag = nearest and min = nearest and mip = linear */
  15592. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15593. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15594. static readonly BILINEAR_SAMPLINGMODE: number;
  15595. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15596. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15597. /** Trilinear is mag = linear and min = linear and mip = linear */
  15598. static readonly TRILINEAR_SAMPLINGMODE: number;
  15599. /** Trilinear is mag = linear and min = linear and mip = linear */
  15600. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15601. /** mag = nearest and min = nearest and mip = nearest */
  15602. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15603. /** mag = nearest and min = linear and mip = nearest */
  15604. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15605. /** mag = nearest and min = linear and mip = linear */
  15606. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15607. /** mag = nearest and min = linear and mip = none */
  15608. static readonly NEAREST_LINEAR: number;
  15609. /** mag = nearest and min = nearest and mip = none */
  15610. static readonly NEAREST_NEAREST: number;
  15611. /** mag = linear and min = nearest and mip = nearest */
  15612. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15613. /** mag = linear and min = nearest and mip = linear */
  15614. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15615. /** mag = linear and min = linear and mip = none */
  15616. static readonly LINEAR_LINEAR: number;
  15617. /** mag = linear and min = nearest and mip = none */
  15618. static readonly LINEAR_NEAREST: number;
  15619. /** Explicit coordinates mode */
  15620. static readonly EXPLICIT_MODE: number;
  15621. /** Spherical coordinates mode */
  15622. static readonly SPHERICAL_MODE: number;
  15623. /** Planar coordinates mode */
  15624. static readonly PLANAR_MODE: number;
  15625. /** Cubic coordinates mode */
  15626. static readonly CUBIC_MODE: number;
  15627. /** Projection coordinates mode */
  15628. static readonly PROJECTION_MODE: number;
  15629. /** Inverse Cubic coordinates mode */
  15630. static readonly SKYBOX_MODE: number;
  15631. /** Inverse Cubic coordinates mode */
  15632. static readonly INVCUBIC_MODE: number;
  15633. /** Equirectangular coordinates mode */
  15634. static readonly EQUIRECTANGULAR_MODE: number;
  15635. /** Equirectangular Fixed coordinates mode */
  15636. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15637. /** Equirectangular Fixed Mirrored coordinates mode */
  15638. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15639. /** Texture is not repeating outside of 0..1 UVs */
  15640. static readonly CLAMP_ADDRESSMODE: number;
  15641. /** Texture is repeating outside of 0..1 UVs */
  15642. static readonly WRAP_ADDRESSMODE: number;
  15643. /** Texture is repeating and mirrored */
  15644. static readonly MIRROR_ADDRESSMODE: number;
  15645. /**
  15646. * 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
  15647. */
  15648. static UseSerializedUrlIfAny: boolean;
  15649. /**
  15650. * Define the url of the texture.
  15651. */
  15652. url: Nullable<string>;
  15653. /**
  15654. * Define an offset on the texture to offset the u coordinates of the UVs
  15655. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15656. */
  15657. uOffset: number;
  15658. /**
  15659. * Define an offset on the texture to offset the v coordinates of the UVs
  15660. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15661. */
  15662. vOffset: number;
  15663. /**
  15664. * Define an offset on the texture to scale the u coordinates of the UVs
  15665. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15666. */
  15667. uScale: number;
  15668. /**
  15669. * Define an offset on the texture to scale the v coordinates of the UVs
  15670. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15671. */
  15672. vScale: number;
  15673. /**
  15674. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15675. * @see http://doc.babylonjs.com/how_to/more_materials
  15676. */
  15677. uAng: number;
  15678. /**
  15679. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15680. * @see http://doc.babylonjs.com/how_to/more_materials
  15681. */
  15682. vAng: number;
  15683. /**
  15684. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15685. * @see http://doc.babylonjs.com/how_to/more_materials
  15686. */
  15687. wAng: number;
  15688. /**
  15689. * Defines the center of rotation (U)
  15690. */
  15691. uRotationCenter: number;
  15692. /**
  15693. * Defines the center of rotation (V)
  15694. */
  15695. vRotationCenter: number;
  15696. /**
  15697. * Defines the center of rotation (W)
  15698. */
  15699. wRotationCenter: number;
  15700. /**
  15701. * Are mip maps generated for this texture or not.
  15702. */
  15703. readonly noMipmap: boolean;
  15704. /**
  15705. * List of inspectable custom properties (used by the Inspector)
  15706. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15707. */
  15708. inspectableCustomProperties: Nullable<IInspectable[]>;
  15709. private _noMipmap;
  15710. /** @hidden */
  15711. _invertY: boolean;
  15712. private _rowGenerationMatrix;
  15713. private _cachedTextureMatrix;
  15714. private _projectionModeMatrix;
  15715. private _t0;
  15716. private _t1;
  15717. private _t2;
  15718. private _cachedUOffset;
  15719. private _cachedVOffset;
  15720. private _cachedUScale;
  15721. private _cachedVScale;
  15722. private _cachedUAng;
  15723. private _cachedVAng;
  15724. private _cachedWAng;
  15725. private _cachedProjectionMatrixId;
  15726. private _cachedCoordinatesMode;
  15727. /** @hidden */
  15728. protected _initialSamplingMode: number;
  15729. /** @hidden */
  15730. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15731. private _deleteBuffer;
  15732. protected _format: Nullable<number>;
  15733. private _delayedOnLoad;
  15734. private _delayedOnError;
  15735. private _mimeType?;
  15736. /**
  15737. * Observable triggered once the texture has been loaded.
  15738. */
  15739. onLoadObservable: Observable<Texture>;
  15740. protected _isBlocking: boolean;
  15741. /**
  15742. * Is the texture preventing material to render while loading.
  15743. * If false, a default texture will be used instead of the loading one during the preparation step.
  15744. */
  15745. isBlocking: boolean;
  15746. /**
  15747. * Get the current sampling mode associated with the texture.
  15748. */
  15749. readonly samplingMode: number;
  15750. /**
  15751. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15752. */
  15753. readonly invertY: boolean;
  15754. /**
  15755. * Instantiates a new texture.
  15756. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15757. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15758. * @param url defines the url of the picture to load as a texture
  15759. * @param scene defines the scene or engine the texture will belong to
  15760. * @param noMipmap defines if the texture will require mip maps or not
  15761. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  15762. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15763. * @param onLoad defines a callback triggered when the texture has been loaded
  15764. * @param onError defines a callback triggered when an error occurred during the loading session
  15765. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  15766. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  15767. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15768. * @param mimeType defines an optional mime type information
  15769. */
  15770. 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);
  15771. /**
  15772. * Update the url (and optional buffer) of this texture if url was null during construction.
  15773. * @param url the url of the texture
  15774. * @param buffer the buffer of the texture (defaults to null)
  15775. * @param onLoad callback called when the texture is loaded (defaults to null)
  15776. */
  15777. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15778. /**
  15779. * Finish the loading sequence of a texture flagged as delayed load.
  15780. * @hidden
  15781. */
  15782. delayLoad(): void;
  15783. private _prepareRowForTextureGeneration;
  15784. /**
  15785. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15786. * @returns the transform matrix of the texture.
  15787. */
  15788. getTextureMatrix(): Matrix;
  15789. /**
  15790. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15791. * @returns The reflection texture transform
  15792. */
  15793. getReflectionTextureMatrix(): Matrix;
  15794. /**
  15795. * Clones the texture.
  15796. * @returns the cloned texture
  15797. */
  15798. clone(): Texture;
  15799. /**
  15800. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15801. * @returns The JSON representation of the texture
  15802. */
  15803. serialize(): any;
  15804. /**
  15805. * Get the current class name of the texture useful for serialization or dynamic coding.
  15806. * @returns "Texture"
  15807. */
  15808. getClassName(): string;
  15809. /**
  15810. * Dispose the texture and release its associated resources.
  15811. */
  15812. dispose(): void;
  15813. /**
  15814. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15815. * @param parsedTexture Define the JSON representation of the texture
  15816. * @param scene Define the scene the parsed texture should be instantiated in
  15817. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15818. * @returns The parsed texture if successful
  15819. */
  15820. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15821. /**
  15822. * Creates a texture from its base 64 representation.
  15823. * @param data Define the base64 payload without the data: prefix
  15824. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15825. * @param scene Define the scene the texture should belong to
  15826. * @param noMipmap Forces the texture to not create mip map information if true
  15827. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15828. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15829. * @param onLoad define a callback triggered when the texture has been loaded
  15830. * @param onError define a callback triggered when an error occurred during the loading session
  15831. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15832. * @returns the created texture
  15833. */
  15834. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15835. /**
  15836. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15837. * @param data Define the base64 payload without the data: prefix
  15838. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15839. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15840. * @param scene Define the scene the texture should belong to
  15841. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15842. * @param noMipmap Forces the texture to not create mip map information if true
  15843. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15844. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15845. * @param onLoad define a callback triggered when the texture has been loaded
  15846. * @param onError define a callback triggered when an error occurred during the loading session
  15847. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15848. * @returns the created texture
  15849. */
  15850. 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;
  15851. }
  15852. }
  15853. declare module BABYLON {
  15854. /**
  15855. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15856. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15857. */
  15858. export class PostProcessManager {
  15859. private _scene;
  15860. private _indexBuffer;
  15861. private _vertexBuffers;
  15862. /**
  15863. * Creates a new instance PostProcess
  15864. * @param scene The scene that the post process is associated with.
  15865. */
  15866. constructor(scene: Scene);
  15867. private _prepareBuffers;
  15868. private _buildIndexBuffer;
  15869. /**
  15870. * Rebuilds the vertex buffers of the manager.
  15871. * @hidden
  15872. */
  15873. _rebuild(): void;
  15874. /**
  15875. * Prepares a frame to be run through a post process.
  15876. * @param sourceTexture The input texture to the post procesess. (default: null)
  15877. * @param postProcesses An array of post processes to be run. (default: null)
  15878. * @returns True if the post processes were able to be run.
  15879. * @hidden
  15880. */
  15881. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15882. /**
  15883. * Manually render a set of post processes to a texture.
  15884. * @param postProcesses An array of post processes to be run.
  15885. * @param targetTexture The target texture to render to.
  15886. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15887. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15888. * @param lodLevel defines which lod of the texture to render to
  15889. */
  15890. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15891. /**
  15892. * Finalize the result of the output of the postprocesses.
  15893. * @param doNotPresent If true the result will not be displayed to the screen.
  15894. * @param targetTexture The target texture to render to.
  15895. * @param faceIndex The index of the face to bind the target texture to.
  15896. * @param postProcesses The array of post processes to render.
  15897. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15898. * @hidden
  15899. */
  15900. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15901. /**
  15902. * Disposes of the post process manager.
  15903. */
  15904. dispose(): void;
  15905. }
  15906. }
  15907. declare module BABYLON {
  15908. /** Interface used by value gradients (color, factor, ...) */
  15909. export interface IValueGradient {
  15910. /**
  15911. * Gets or sets the gradient value (between 0 and 1)
  15912. */
  15913. gradient: number;
  15914. }
  15915. /** Class used to store color4 gradient */
  15916. export class ColorGradient implements IValueGradient {
  15917. /**
  15918. * Gets or sets the gradient value (between 0 and 1)
  15919. */
  15920. gradient: number;
  15921. /**
  15922. * Gets or sets first associated color
  15923. */
  15924. color1: Color4;
  15925. /**
  15926. * Gets or sets second associated color
  15927. */
  15928. color2?: Color4;
  15929. /**
  15930. * Will get a color picked randomly between color1 and color2.
  15931. * If color2 is undefined then color1 will be used
  15932. * @param result defines the target Color4 to store the result in
  15933. */
  15934. getColorToRef(result: Color4): void;
  15935. }
  15936. /** Class used to store color 3 gradient */
  15937. export class Color3Gradient implements IValueGradient {
  15938. /**
  15939. * Gets or sets the gradient value (between 0 and 1)
  15940. */
  15941. gradient: number;
  15942. /**
  15943. * Gets or sets the associated color
  15944. */
  15945. color: Color3;
  15946. }
  15947. /** Class used to store factor gradient */
  15948. export class FactorGradient implements IValueGradient {
  15949. /**
  15950. * Gets or sets the gradient value (between 0 and 1)
  15951. */
  15952. gradient: number;
  15953. /**
  15954. * Gets or sets first associated factor
  15955. */
  15956. factor1: number;
  15957. /**
  15958. * Gets or sets second associated factor
  15959. */
  15960. factor2?: number;
  15961. /**
  15962. * Will get a number picked randomly between factor1 and factor2.
  15963. * If factor2 is undefined then factor1 will be used
  15964. * @returns the picked number
  15965. */
  15966. getFactor(): number;
  15967. }
  15968. /**
  15969. * Helper used to simplify some generic gradient tasks
  15970. */
  15971. export class GradientHelper {
  15972. /**
  15973. * Gets the current gradient from an array of IValueGradient
  15974. * @param ratio defines the current ratio to get
  15975. * @param gradients defines the array of IValueGradient
  15976. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15977. */
  15978. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15979. }
  15980. }
  15981. declare module BABYLON {
  15982. interface ThinEngine {
  15983. /**
  15984. * Creates a dynamic texture
  15985. * @param width defines the width of the texture
  15986. * @param height defines the height of the texture
  15987. * @param generateMipMaps defines if the engine should generate the mip levels
  15988. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  15989. * @returns the dynamic texture inside an InternalTexture
  15990. */
  15991. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  15992. /**
  15993. * Update the content of a dynamic texture
  15994. * @param texture defines the texture to update
  15995. * @param canvas defines the canvas containing the source
  15996. * @param invertY defines if data must be stored with Y axis inverted
  15997. * @param premulAlpha defines if alpha is stored as premultiplied
  15998. * @param format defines the format of the data
  15999. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16000. */
  16001. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16002. }
  16003. }
  16004. declare module BABYLON {
  16005. /**
  16006. * Helper class used to generate a canvas to manipulate images
  16007. */
  16008. export class CanvasGenerator {
  16009. /**
  16010. * Create a new canvas (or offscreen canvas depending on the context)
  16011. * @param width defines the expected width
  16012. * @param height defines the expected height
  16013. * @return a new canvas or offscreen canvas
  16014. */
  16015. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16016. }
  16017. }
  16018. declare module BABYLON {
  16019. /**
  16020. * A class extending Texture allowing drawing on a texture
  16021. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16022. */
  16023. export class DynamicTexture extends Texture {
  16024. private _generateMipMaps;
  16025. private _canvas;
  16026. private _context;
  16027. private _engine;
  16028. /**
  16029. * Creates a DynamicTexture
  16030. * @param name defines the name of the texture
  16031. * @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
  16032. * @param scene defines the scene where you want the texture
  16033. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16034. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16035. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16036. */
  16037. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16038. /**
  16039. * Get the current class name of the texture useful for serialization or dynamic coding.
  16040. * @returns "DynamicTexture"
  16041. */
  16042. getClassName(): string;
  16043. /**
  16044. * Gets the current state of canRescale
  16045. */
  16046. readonly canRescale: boolean;
  16047. private _recreate;
  16048. /**
  16049. * Scales the texture
  16050. * @param ratio the scale factor to apply to both width and height
  16051. */
  16052. scale(ratio: number): void;
  16053. /**
  16054. * Resizes the texture
  16055. * @param width the new width
  16056. * @param height the new height
  16057. */
  16058. scaleTo(width: number, height: number): void;
  16059. /**
  16060. * Gets the context of the canvas used by the texture
  16061. * @returns the canvas context of the dynamic texture
  16062. */
  16063. getContext(): CanvasRenderingContext2D;
  16064. /**
  16065. * Clears the texture
  16066. */
  16067. clear(): void;
  16068. /**
  16069. * Updates the texture
  16070. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16071. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16072. */
  16073. update(invertY?: boolean, premulAlpha?: boolean): void;
  16074. /**
  16075. * Draws text onto the texture
  16076. * @param text defines the text to be drawn
  16077. * @param x defines the placement of the text from the left
  16078. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16079. * @param font defines the font to be used with font-style, font-size, font-name
  16080. * @param color defines the color used for the text
  16081. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16082. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16083. * @param update defines whether texture is immediately update (default is true)
  16084. */
  16085. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16086. /**
  16087. * Clones the texture
  16088. * @returns the clone of the texture.
  16089. */
  16090. clone(): DynamicTexture;
  16091. /**
  16092. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16093. * @returns a serialized dynamic texture object
  16094. */
  16095. serialize(): any;
  16096. /** @hidden */
  16097. _rebuild(): void;
  16098. }
  16099. }
  16100. declare module BABYLON {
  16101. interface AbstractScene {
  16102. /**
  16103. * The list of procedural textures added to the scene
  16104. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16105. */
  16106. proceduralTextures: Array<ProceduralTexture>;
  16107. }
  16108. /**
  16109. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16110. * in a given scene.
  16111. */
  16112. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16113. /**
  16114. * The component name helpfull to identify the component in the list of scene components.
  16115. */
  16116. readonly name: string;
  16117. /**
  16118. * The scene the component belongs to.
  16119. */
  16120. scene: Scene;
  16121. /**
  16122. * Creates a new instance of the component for the given scene
  16123. * @param scene Defines the scene to register the component in
  16124. */
  16125. constructor(scene: Scene);
  16126. /**
  16127. * Registers the component in a given scene
  16128. */
  16129. register(): void;
  16130. /**
  16131. * Rebuilds the elements related to this component in case of
  16132. * context lost for instance.
  16133. */
  16134. rebuild(): void;
  16135. /**
  16136. * Disposes the component and the associated ressources.
  16137. */
  16138. dispose(): void;
  16139. private _beforeClear;
  16140. }
  16141. }
  16142. declare module BABYLON {
  16143. interface ThinEngine {
  16144. /**
  16145. * Creates a new render target cube texture
  16146. * @param size defines the size of the texture
  16147. * @param options defines the options used to create the texture
  16148. * @returns a new render target cube texture stored in an InternalTexture
  16149. */
  16150. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16151. }
  16152. }
  16153. declare module BABYLON {
  16154. /** @hidden */
  16155. export var proceduralVertexShader: {
  16156. name: string;
  16157. shader: string;
  16158. };
  16159. }
  16160. declare module BABYLON {
  16161. /**
  16162. * 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.
  16163. * This is the base class of any Procedural texture and contains most of the shareable code.
  16164. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16165. */
  16166. export class ProceduralTexture extends Texture {
  16167. isCube: boolean;
  16168. /**
  16169. * Define if the texture is enabled or not (disabled texture will not render)
  16170. */
  16171. isEnabled: boolean;
  16172. /**
  16173. * Define if the texture must be cleared before rendering (default is true)
  16174. */
  16175. autoClear: boolean;
  16176. /**
  16177. * Callback called when the texture is generated
  16178. */
  16179. onGenerated: () => void;
  16180. /**
  16181. * Event raised when the texture is generated
  16182. */
  16183. onGeneratedObservable: Observable<ProceduralTexture>;
  16184. /** @hidden */
  16185. _generateMipMaps: boolean;
  16186. /** @hidden **/
  16187. _effect: Effect;
  16188. /** @hidden */
  16189. _textures: {
  16190. [key: string]: Texture;
  16191. };
  16192. private _size;
  16193. private _currentRefreshId;
  16194. private _refreshRate;
  16195. private _vertexBuffers;
  16196. private _indexBuffer;
  16197. private _uniforms;
  16198. private _samplers;
  16199. private _fragment;
  16200. private _floats;
  16201. private _ints;
  16202. private _floatsArrays;
  16203. private _colors3;
  16204. private _colors4;
  16205. private _vectors2;
  16206. private _vectors3;
  16207. private _matrices;
  16208. private _fallbackTexture;
  16209. private _fallbackTextureUsed;
  16210. private _engine;
  16211. private _cachedDefines;
  16212. private _contentUpdateId;
  16213. private _contentData;
  16214. /**
  16215. * Instantiates a new procedural texture.
  16216. * 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.
  16217. * This is the base class of any Procedural texture and contains most of the shareable code.
  16218. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16219. * @param name Define the name of the texture
  16220. * @param size Define the size of the texture to create
  16221. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16222. * @param scene Define the scene the texture belongs to
  16223. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16224. * @param generateMipMaps Define if the texture should creates mip maps or not
  16225. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16226. */
  16227. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16228. /**
  16229. * The effect that is created when initializing the post process.
  16230. * @returns The created effect corresponding the the postprocess.
  16231. */
  16232. getEffect(): Effect;
  16233. /**
  16234. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16235. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16236. */
  16237. getContent(): Nullable<ArrayBufferView>;
  16238. private _createIndexBuffer;
  16239. /** @hidden */
  16240. _rebuild(): void;
  16241. /**
  16242. * Resets the texture in order to recreate its associated resources.
  16243. * This can be called in case of context loss
  16244. */
  16245. reset(): void;
  16246. protected _getDefines(): string;
  16247. /**
  16248. * Is the texture ready to be used ? (rendered at least once)
  16249. * @returns true if ready, otherwise, false.
  16250. */
  16251. isReady(): boolean;
  16252. /**
  16253. * Resets the refresh counter of the texture and start bak from scratch.
  16254. * Could be useful to regenerate the texture if it is setup to render only once.
  16255. */
  16256. resetRefreshCounter(): void;
  16257. /**
  16258. * Set the fragment shader to use in order to render the texture.
  16259. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16260. */
  16261. setFragment(fragment: any): void;
  16262. /**
  16263. * Define the refresh rate of the texture or the rendering frequency.
  16264. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16265. */
  16266. refreshRate: number;
  16267. /** @hidden */
  16268. _shouldRender(): boolean;
  16269. /**
  16270. * Get the size the texture is rendering at.
  16271. * @returns the size (texture is always squared)
  16272. */
  16273. getRenderSize(): number;
  16274. /**
  16275. * Resize the texture to new value.
  16276. * @param size Define the new size the texture should have
  16277. * @param generateMipMaps Define whether the new texture should create mip maps
  16278. */
  16279. resize(size: number, generateMipMaps: boolean): void;
  16280. private _checkUniform;
  16281. /**
  16282. * Set a texture in the shader program used to render.
  16283. * @param name Define the name of the uniform samplers as defined in the shader
  16284. * @param texture Define the texture to bind to this sampler
  16285. * @return the texture itself allowing "fluent" like uniform updates
  16286. */
  16287. setTexture(name: string, texture: Texture): ProceduralTexture;
  16288. /**
  16289. * Set a float in the shader.
  16290. * @param name Define the name of the uniform as defined in the shader
  16291. * @param value Define the value to give to the uniform
  16292. * @return the texture itself allowing "fluent" like uniform updates
  16293. */
  16294. setFloat(name: string, value: number): ProceduralTexture;
  16295. /**
  16296. * Set a int in the shader.
  16297. * @param name Define the name of the uniform as defined in the shader
  16298. * @param value Define the value to give to the uniform
  16299. * @return the texture itself allowing "fluent" like uniform updates
  16300. */
  16301. setInt(name: string, value: number): ProceduralTexture;
  16302. /**
  16303. * Set an array of floats in the shader.
  16304. * @param name Define the name of the uniform as defined in the shader
  16305. * @param value Define the value to give to the uniform
  16306. * @return the texture itself allowing "fluent" like uniform updates
  16307. */
  16308. setFloats(name: string, value: number[]): ProceduralTexture;
  16309. /**
  16310. * Set a vec3 in the shader from a Color3.
  16311. * @param name Define the name of the uniform as defined in the shader
  16312. * @param value Define the value to give to the uniform
  16313. * @return the texture itself allowing "fluent" like uniform updates
  16314. */
  16315. setColor3(name: string, value: Color3): ProceduralTexture;
  16316. /**
  16317. * Set a vec4 in the shader from a Color4.
  16318. * @param name Define the name of the uniform as defined in the shader
  16319. * @param value Define the value to give to the uniform
  16320. * @return the texture itself allowing "fluent" like uniform updates
  16321. */
  16322. setColor4(name: string, value: Color4): ProceduralTexture;
  16323. /**
  16324. * Set a vec2 in the shader from a Vector2.
  16325. * @param name Define the name of the uniform as defined in the shader
  16326. * @param value Define the value to give to the uniform
  16327. * @return the texture itself allowing "fluent" like uniform updates
  16328. */
  16329. setVector2(name: string, value: Vector2): ProceduralTexture;
  16330. /**
  16331. * Set a vec3 in the shader from a Vector3.
  16332. * @param name Define the name of the uniform as defined in the shader
  16333. * @param value Define the value to give to the uniform
  16334. * @return the texture itself allowing "fluent" like uniform updates
  16335. */
  16336. setVector3(name: string, value: Vector3): ProceduralTexture;
  16337. /**
  16338. * Set a mat4 in the shader from a MAtrix.
  16339. * @param name Define the name of the uniform as defined in the shader
  16340. * @param value Define the value to give to the uniform
  16341. * @return the texture itself allowing "fluent" like uniform updates
  16342. */
  16343. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16344. /**
  16345. * Render the texture to its associated render target.
  16346. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16347. */
  16348. render(useCameraPostProcess?: boolean): void;
  16349. /**
  16350. * Clone the texture.
  16351. * @returns the cloned texture
  16352. */
  16353. clone(): ProceduralTexture;
  16354. /**
  16355. * Dispose the texture and release its asoociated resources.
  16356. */
  16357. dispose(): void;
  16358. }
  16359. }
  16360. declare module BABYLON {
  16361. /**
  16362. * This represents the base class for particle system in Babylon.
  16363. * 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.
  16364. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16365. * @example https://doc.babylonjs.com/babylon101/particles
  16366. */
  16367. export class BaseParticleSystem {
  16368. /**
  16369. * Source color is added to the destination color without alpha affecting the result
  16370. */
  16371. static BLENDMODE_ONEONE: number;
  16372. /**
  16373. * Blend current color and particle color using particle’s alpha
  16374. */
  16375. static BLENDMODE_STANDARD: number;
  16376. /**
  16377. * Add current color and particle color multiplied by particle’s alpha
  16378. */
  16379. static BLENDMODE_ADD: number;
  16380. /**
  16381. * Multiply current color with particle color
  16382. */
  16383. static BLENDMODE_MULTIPLY: number;
  16384. /**
  16385. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16386. */
  16387. static BLENDMODE_MULTIPLYADD: number;
  16388. /**
  16389. * List of animations used by the particle system.
  16390. */
  16391. animations: Animation[];
  16392. /**
  16393. * The id of the Particle system.
  16394. */
  16395. id: string;
  16396. /**
  16397. * The friendly name of the Particle system.
  16398. */
  16399. name: string;
  16400. /**
  16401. * The rendering group used by the Particle system to chose when to render.
  16402. */
  16403. renderingGroupId: number;
  16404. /**
  16405. * The emitter represents the Mesh or position we are attaching the particle system to.
  16406. */
  16407. emitter: Nullable<AbstractMesh | Vector3>;
  16408. /**
  16409. * The maximum number of particles to emit per frame
  16410. */
  16411. emitRate: number;
  16412. /**
  16413. * If you want to launch only a few particles at once, that can be done, as well.
  16414. */
  16415. manualEmitCount: number;
  16416. /**
  16417. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16418. */
  16419. updateSpeed: number;
  16420. /**
  16421. * The amount of time the particle system is running (depends of the overall update speed).
  16422. */
  16423. targetStopDuration: number;
  16424. /**
  16425. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16426. */
  16427. disposeOnStop: boolean;
  16428. /**
  16429. * Minimum power of emitting particles.
  16430. */
  16431. minEmitPower: number;
  16432. /**
  16433. * Maximum power of emitting particles.
  16434. */
  16435. maxEmitPower: number;
  16436. /**
  16437. * Minimum life time of emitting particles.
  16438. */
  16439. minLifeTime: number;
  16440. /**
  16441. * Maximum life time of emitting particles.
  16442. */
  16443. maxLifeTime: number;
  16444. /**
  16445. * Minimum Size of emitting particles.
  16446. */
  16447. minSize: number;
  16448. /**
  16449. * Maximum Size of emitting particles.
  16450. */
  16451. maxSize: number;
  16452. /**
  16453. * Minimum scale of emitting particles on X axis.
  16454. */
  16455. minScaleX: number;
  16456. /**
  16457. * Maximum scale of emitting particles on X axis.
  16458. */
  16459. maxScaleX: number;
  16460. /**
  16461. * Minimum scale of emitting particles on Y axis.
  16462. */
  16463. minScaleY: number;
  16464. /**
  16465. * Maximum scale of emitting particles on Y axis.
  16466. */
  16467. maxScaleY: number;
  16468. /**
  16469. * Gets or sets the minimal initial rotation in radians.
  16470. */
  16471. minInitialRotation: number;
  16472. /**
  16473. * Gets or sets the maximal initial rotation in radians.
  16474. */
  16475. maxInitialRotation: number;
  16476. /**
  16477. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16478. */
  16479. minAngularSpeed: number;
  16480. /**
  16481. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16482. */
  16483. maxAngularSpeed: number;
  16484. /**
  16485. * The texture used to render each particle. (this can be a spritesheet)
  16486. */
  16487. particleTexture: Nullable<Texture>;
  16488. /**
  16489. * The layer mask we are rendering the particles through.
  16490. */
  16491. layerMask: number;
  16492. /**
  16493. * This can help using your own shader to render the particle system.
  16494. * The according effect will be created
  16495. */
  16496. customShader: any;
  16497. /**
  16498. * By default particle system starts as soon as they are created. This prevents the
  16499. * automatic start to happen and let you decide when to start emitting particles.
  16500. */
  16501. preventAutoStart: boolean;
  16502. private _noiseTexture;
  16503. /**
  16504. * Gets or sets a texture used to add random noise to particle positions
  16505. */
  16506. noiseTexture: Nullable<ProceduralTexture>;
  16507. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16508. noiseStrength: Vector3;
  16509. /**
  16510. * Callback triggered when the particle animation is ending.
  16511. */
  16512. onAnimationEnd: Nullable<() => void>;
  16513. /**
  16514. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16515. */
  16516. blendMode: number;
  16517. /**
  16518. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16519. * to override the particles.
  16520. */
  16521. forceDepthWrite: boolean;
  16522. /** 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 */
  16523. preWarmCycles: number;
  16524. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16525. preWarmStepOffset: number;
  16526. /**
  16527. * 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)
  16528. */
  16529. spriteCellChangeSpeed: number;
  16530. /**
  16531. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16532. */
  16533. startSpriteCellID: number;
  16534. /**
  16535. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16536. */
  16537. endSpriteCellID: number;
  16538. /**
  16539. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16540. */
  16541. spriteCellWidth: number;
  16542. /**
  16543. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16544. */
  16545. spriteCellHeight: number;
  16546. /**
  16547. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16548. */
  16549. spriteRandomStartCell: boolean;
  16550. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16551. translationPivot: Vector2;
  16552. /** @hidden */
  16553. protected _isAnimationSheetEnabled: boolean;
  16554. /**
  16555. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16556. */
  16557. beginAnimationOnStart: boolean;
  16558. /**
  16559. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16560. */
  16561. beginAnimationFrom: number;
  16562. /**
  16563. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16564. */
  16565. beginAnimationTo: number;
  16566. /**
  16567. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16568. */
  16569. beginAnimationLoop: boolean;
  16570. /**
  16571. * Gets or sets a world offset applied to all particles
  16572. */
  16573. worldOffset: Vector3;
  16574. /**
  16575. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16576. */
  16577. isAnimationSheetEnabled: boolean;
  16578. /**
  16579. * Get hosting scene
  16580. * @returns the scene
  16581. */
  16582. getScene(): Scene;
  16583. /**
  16584. * You can use gravity if you want to give an orientation to your particles.
  16585. */
  16586. gravity: Vector3;
  16587. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16588. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16589. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16590. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16591. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16592. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16593. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16594. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16595. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16596. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16597. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16598. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16599. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16600. /**
  16601. * Defines the delay in milliseconds before starting the system (0 by default)
  16602. */
  16603. startDelay: number;
  16604. /**
  16605. * Gets the current list of drag gradients.
  16606. * You must use addDragGradient and removeDragGradient to udpate this list
  16607. * @returns the list of drag gradients
  16608. */
  16609. getDragGradients(): Nullable<Array<FactorGradient>>;
  16610. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16611. limitVelocityDamping: number;
  16612. /**
  16613. * Gets the current list of limit velocity gradients.
  16614. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16615. * @returns the list of limit velocity gradients
  16616. */
  16617. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16618. /**
  16619. * Gets the current list of color gradients.
  16620. * You must use addColorGradient and removeColorGradient to udpate this list
  16621. * @returns the list of color gradients
  16622. */
  16623. getColorGradients(): Nullable<Array<ColorGradient>>;
  16624. /**
  16625. * Gets the current list of size gradients.
  16626. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16627. * @returns the list of size gradients
  16628. */
  16629. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16630. /**
  16631. * Gets the current list of color remap gradients.
  16632. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16633. * @returns the list of color remap gradients
  16634. */
  16635. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16636. /**
  16637. * Gets the current list of alpha remap gradients.
  16638. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16639. * @returns the list of alpha remap gradients
  16640. */
  16641. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16642. /**
  16643. * Gets the current list of life time gradients.
  16644. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16645. * @returns the list of life time gradients
  16646. */
  16647. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16648. /**
  16649. * Gets the current list of angular speed gradients.
  16650. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16651. * @returns the list of angular speed gradients
  16652. */
  16653. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16654. /**
  16655. * Gets the current list of velocity gradients.
  16656. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16657. * @returns the list of velocity gradients
  16658. */
  16659. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16660. /**
  16661. * Gets the current list of start size gradients.
  16662. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16663. * @returns the list of start size gradients
  16664. */
  16665. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16666. /**
  16667. * Gets the current list of emit rate gradients.
  16668. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16669. * @returns the list of emit rate gradients
  16670. */
  16671. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16672. /**
  16673. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16674. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16675. */
  16676. direction1: Vector3;
  16677. /**
  16678. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16679. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16680. */
  16681. direction2: Vector3;
  16682. /**
  16683. * 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.
  16684. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16685. */
  16686. minEmitBox: Vector3;
  16687. /**
  16688. * 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.
  16689. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16690. */
  16691. maxEmitBox: Vector3;
  16692. /**
  16693. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16694. */
  16695. color1: Color4;
  16696. /**
  16697. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16698. */
  16699. color2: Color4;
  16700. /**
  16701. * Color the particle will have at the end of its lifetime
  16702. */
  16703. colorDead: Color4;
  16704. /**
  16705. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16706. */
  16707. textureMask: Color4;
  16708. /**
  16709. * The particle emitter type defines the emitter used by the particle system.
  16710. * It can be for example box, sphere, or cone...
  16711. */
  16712. particleEmitterType: IParticleEmitterType;
  16713. /** @hidden */
  16714. _isSubEmitter: boolean;
  16715. /**
  16716. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16717. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16718. */
  16719. billboardMode: number;
  16720. protected _isBillboardBased: boolean;
  16721. /**
  16722. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16723. */
  16724. isBillboardBased: boolean;
  16725. /**
  16726. * The scene the particle system belongs to.
  16727. */
  16728. protected _scene: Scene;
  16729. /**
  16730. * Local cache of defines for image processing.
  16731. */
  16732. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16733. /**
  16734. * Default configuration related to image processing available in the standard Material.
  16735. */
  16736. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16737. /**
  16738. * Gets the image processing configuration used either in this material.
  16739. */
  16740. /**
  16741. * Sets the Default image processing configuration used either in the this material.
  16742. *
  16743. * If sets to null, the scene one is in use.
  16744. */
  16745. imageProcessingConfiguration: ImageProcessingConfiguration;
  16746. /**
  16747. * Attaches a new image processing configuration to the Standard Material.
  16748. * @param configuration
  16749. */
  16750. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16751. /** @hidden */
  16752. protected _reset(): void;
  16753. /** @hidden */
  16754. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16755. /**
  16756. * Instantiates a particle system.
  16757. * 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.
  16758. * @param name The name of the particle system
  16759. */
  16760. constructor(name: string);
  16761. /**
  16762. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16763. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16764. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16765. * @returns the emitter
  16766. */
  16767. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16768. /**
  16769. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16770. * @param radius The radius of the hemisphere to emit from
  16771. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16772. * @returns the emitter
  16773. */
  16774. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16775. /**
  16776. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16777. * @param radius The radius of the sphere to emit from
  16778. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16779. * @returns the emitter
  16780. */
  16781. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16782. /**
  16783. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16784. * @param radius The radius of the sphere to emit from
  16785. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16786. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16787. * @returns the emitter
  16788. */
  16789. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16790. /**
  16791. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16792. * @param radius The radius of the emission cylinder
  16793. * @param height The height of the emission cylinder
  16794. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16795. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16796. * @returns the emitter
  16797. */
  16798. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16799. /**
  16800. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16801. * @param radius The radius of the cylinder to emit from
  16802. * @param height The height of the emission cylinder
  16803. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16804. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16805. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16806. * @returns the emitter
  16807. */
  16808. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16809. /**
  16810. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16811. * @param radius The radius of the cone to emit from
  16812. * @param angle The base angle of the cone
  16813. * @returns the emitter
  16814. */
  16815. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16816. /**
  16817. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16818. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16819. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16820. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16821. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16822. * @returns the emitter
  16823. */
  16824. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16825. }
  16826. }
  16827. declare module BABYLON {
  16828. /**
  16829. * Type of sub emitter
  16830. */
  16831. export enum SubEmitterType {
  16832. /**
  16833. * Attached to the particle over it's lifetime
  16834. */
  16835. ATTACHED = 0,
  16836. /**
  16837. * Created when the particle dies
  16838. */
  16839. END = 1
  16840. }
  16841. /**
  16842. * Sub emitter class used to emit particles from an existing particle
  16843. */
  16844. export class SubEmitter {
  16845. /**
  16846. * the particle system to be used by the sub emitter
  16847. */
  16848. particleSystem: ParticleSystem;
  16849. /**
  16850. * Type of the submitter (Default: END)
  16851. */
  16852. type: SubEmitterType;
  16853. /**
  16854. * 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)
  16855. * Note: This only is supported when using an emitter of type Mesh
  16856. */
  16857. inheritDirection: boolean;
  16858. /**
  16859. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16860. */
  16861. inheritedVelocityAmount: number;
  16862. /**
  16863. * Creates a sub emitter
  16864. * @param particleSystem the particle system to be used by the sub emitter
  16865. */
  16866. constructor(
  16867. /**
  16868. * the particle system to be used by the sub emitter
  16869. */
  16870. particleSystem: ParticleSystem);
  16871. /**
  16872. * Clones the sub emitter
  16873. * @returns the cloned sub emitter
  16874. */
  16875. clone(): SubEmitter;
  16876. /**
  16877. * Serialize current object to a JSON object
  16878. * @returns the serialized object
  16879. */
  16880. serialize(): any;
  16881. /** @hidden */
  16882. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16883. /**
  16884. * Creates a new SubEmitter from a serialized JSON version
  16885. * @param serializationObject defines the JSON object to read from
  16886. * @param scene defines the hosting scene
  16887. * @param rootUrl defines the rootUrl for data loading
  16888. * @returns a new SubEmitter
  16889. */
  16890. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16891. /** Release associated resources */
  16892. dispose(): void;
  16893. }
  16894. }
  16895. declare module BABYLON {
  16896. /** @hidden */
  16897. export var clipPlaneFragmentDeclaration: {
  16898. name: string;
  16899. shader: string;
  16900. };
  16901. }
  16902. declare module BABYLON {
  16903. /** @hidden */
  16904. export var imageProcessingDeclaration: {
  16905. name: string;
  16906. shader: string;
  16907. };
  16908. }
  16909. declare module BABYLON {
  16910. /** @hidden */
  16911. export var imageProcessingFunctions: {
  16912. name: string;
  16913. shader: string;
  16914. };
  16915. }
  16916. declare module BABYLON {
  16917. /** @hidden */
  16918. export var clipPlaneFragment: {
  16919. name: string;
  16920. shader: string;
  16921. };
  16922. }
  16923. declare module BABYLON {
  16924. /** @hidden */
  16925. export var particlesPixelShader: {
  16926. name: string;
  16927. shader: string;
  16928. };
  16929. }
  16930. declare module BABYLON {
  16931. /** @hidden */
  16932. export var clipPlaneVertexDeclaration: {
  16933. name: string;
  16934. shader: string;
  16935. };
  16936. }
  16937. declare module BABYLON {
  16938. /** @hidden */
  16939. export var clipPlaneVertex: {
  16940. name: string;
  16941. shader: string;
  16942. };
  16943. }
  16944. declare module BABYLON {
  16945. /** @hidden */
  16946. export var particlesVertexShader: {
  16947. name: string;
  16948. shader: string;
  16949. };
  16950. }
  16951. declare module BABYLON {
  16952. /**
  16953. * This represents a particle system in Babylon.
  16954. * 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.
  16955. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16956. * @example https://doc.babylonjs.com/babylon101/particles
  16957. */
  16958. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16959. /**
  16960. * Billboard mode will only apply to Y axis
  16961. */
  16962. static readonly BILLBOARDMODE_Y: number;
  16963. /**
  16964. * Billboard mode will apply to all axes
  16965. */
  16966. static readonly BILLBOARDMODE_ALL: number;
  16967. /**
  16968. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16969. */
  16970. static readonly BILLBOARDMODE_STRETCHED: number;
  16971. /**
  16972. * This function can be defined to provide custom update for active particles.
  16973. * This function will be called instead of regular update (age, position, color, etc.).
  16974. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16975. */
  16976. updateFunction: (particles: Particle[]) => void;
  16977. private _emitterWorldMatrix;
  16978. /**
  16979. * This function can be defined to specify initial direction for every new particle.
  16980. * It by default use the emitterType defined function
  16981. */
  16982. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16983. /**
  16984. * This function can be defined to specify initial position for every new particle.
  16985. * It by default use the emitterType defined function
  16986. */
  16987. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16988. /**
  16989. * @hidden
  16990. */
  16991. _inheritedVelocityOffset: Vector3;
  16992. /**
  16993. * An event triggered when the system is disposed
  16994. */
  16995. onDisposeObservable: Observable<ParticleSystem>;
  16996. private _onDisposeObserver;
  16997. /**
  16998. * Sets a callback that will be triggered when the system is disposed
  16999. */
  17000. onDispose: () => void;
  17001. private _particles;
  17002. private _epsilon;
  17003. private _capacity;
  17004. private _stockParticles;
  17005. private _newPartsExcess;
  17006. private _vertexData;
  17007. private _vertexBuffer;
  17008. private _vertexBuffers;
  17009. private _spriteBuffer;
  17010. private _indexBuffer;
  17011. private _effect;
  17012. private _customEffect;
  17013. private _cachedDefines;
  17014. private _scaledColorStep;
  17015. private _colorDiff;
  17016. private _scaledDirection;
  17017. private _scaledGravity;
  17018. private _currentRenderId;
  17019. private _alive;
  17020. private _useInstancing;
  17021. private _started;
  17022. private _stopped;
  17023. private _actualFrame;
  17024. private _scaledUpdateSpeed;
  17025. private _vertexBufferSize;
  17026. /** @hidden */
  17027. _currentEmitRateGradient: Nullable<FactorGradient>;
  17028. /** @hidden */
  17029. _currentEmitRate1: number;
  17030. /** @hidden */
  17031. _currentEmitRate2: number;
  17032. /** @hidden */
  17033. _currentStartSizeGradient: Nullable<FactorGradient>;
  17034. /** @hidden */
  17035. _currentStartSize1: number;
  17036. /** @hidden */
  17037. _currentStartSize2: number;
  17038. private readonly _rawTextureWidth;
  17039. private _rampGradientsTexture;
  17040. private _useRampGradients;
  17041. /** Gets or sets a boolean indicating that ramp gradients must be used
  17042. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17043. */
  17044. useRampGradients: boolean;
  17045. /**
  17046. * 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.
  17047. * 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: [])
  17048. */
  17049. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17050. private _subEmitters;
  17051. /**
  17052. * @hidden
  17053. * If the particle systems emitter should be disposed when the particle system is disposed
  17054. */
  17055. _disposeEmitterOnDispose: boolean;
  17056. /**
  17057. * The current active Sub-systems, this property is used by the root particle system only.
  17058. */
  17059. activeSubSystems: Array<ParticleSystem>;
  17060. private _rootParticleSystem;
  17061. /**
  17062. * Gets the current list of active particles
  17063. */
  17064. readonly particles: Particle[];
  17065. /**
  17066. * Returns the string "ParticleSystem"
  17067. * @returns a string containing the class name
  17068. */
  17069. getClassName(): string;
  17070. /**
  17071. * Instantiates a particle system.
  17072. * 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.
  17073. * @param name The name of the particle system
  17074. * @param capacity The max number of particles alive at the same time
  17075. * @param scene The scene the particle system belongs to
  17076. * @param customEffect a custom effect used to change the way particles are rendered by default
  17077. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17078. * @param epsilon Offset used to render the particles
  17079. */
  17080. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17081. private _addFactorGradient;
  17082. private _removeFactorGradient;
  17083. /**
  17084. * Adds a new life time gradient
  17085. * @param gradient defines the gradient to use (between 0 and 1)
  17086. * @param factor defines the life time factor to affect to the specified gradient
  17087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17088. * @returns the current particle system
  17089. */
  17090. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17091. /**
  17092. * Remove a specific life time gradient
  17093. * @param gradient defines the gradient to remove
  17094. * @returns the current particle system
  17095. */
  17096. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17097. /**
  17098. * Adds a new size gradient
  17099. * @param gradient defines the gradient to use (between 0 and 1)
  17100. * @param factor defines the size factor to affect to the specified gradient
  17101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17102. * @returns the current particle system
  17103. */
  17104. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17105. /**
  17106. * Remove a specific size gradient
  17107. * @param gradient defines the gradient to remove
  17108. * @returns the current particle system
  17109. */
  17110. removeSizeGradient(gradient: number): IParticleSystem;
  17111. /**
  17112. * Adds a new color remap gradient
  17113. * @param gradient defines the gradient to use (between 0 and 1)
  17114. * @param min defines the color remap minimal range
  17115. * @param max defines the color remap maximal range
  17116. * @returns the current particle system
  17117. */
  17118. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17119. /**
  17120. * Remove a specific color remap gradient
  17121. * @param gradient defines the gradient to remove
  17122. * @returns the current particle system
  17123. */
  17124. removeColorRemapGradient(gradient: number): IParticleSystem;
  17125. /**
  17126. * Adds a new alpha remap gradient
  17127. * @param gradient defines the gradient to use (between 0 and 1)
  17128. * @param min defines the alpha remap minimal range
  17129. * @param max defines the alpha remap maximal range
  17130. * @returns the current particle system
  17131. */
  17132. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17133. /**
  17134. * Remove a specific alpha remap gradient
  17135. * @param gradient defines the gradient to remove
  17136. * @returns the current particle system
  17137. */
  17138. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17139. /**
  17140. * Adds a new angular speed gradient
  17141. * @param gradient defines the gradient to use (between 0 and 1)
  17142. * @param factor defines the angular speed to affect to the specified gradient
  17143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17144. * @returns the current particle system
  17145. */
  17146. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17147. /**
  17148. * Remove a specific angular speed gradient
  17149. * @param gradient defines the gradient to remove
  17150. * @returns the current particle system
  17151. */
  17152. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17153. /**
  17154. * Adds a new velocity gradient
  17155. * @param gradient defines the gradient to use (between 0 and 1)
  17156. * @param factor defines the velocity to affect to the specified gradient
  17157. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17158. * @returns the current particle system
  17159. */
  17160. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17161. /**
  17162. * Remove a specific velocity gradient
  17163. * @param gradient defines the gradient to remove
  17164. * @returns the current particle system
  17165. */
  17166. removeVelocityGradient(gradient: number): IParticleSystem;
  17167. /**
  17168. * Adds a new limit velocity gradient
  17169. * @param gradient defines the gradient to use (between 0 and 1)
  17170. * @param factor defines the limit velocity value to affect to the specified gradient
  17171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17172. * @returns the current particle system
  17173. */
  17174. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17175. /**
  17176. * Remove a specific limit velocity gradient
  17177. * @param gradient defines the gradient to remove
  17178. * @returns the current particle system
  17179. */
  17180. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17181. /**
  17182. * Adds a new drag gradient
  17183. * @param gradient defines the gradient to use (between 0 and 1)
  17184. * @param factor defines the drag value to affect to the specified gradient
  17185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17186. * @returns the current particle system
  17187. */
  17188. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17189. /**
  17190. * Remove a specific drag gradient
  17191. * @param gradient defines the gradient to remove
  17192. * @returns the current particle system
  17193. */
  17194. removeDragGradient(gradient: number): IParticleSystem;
  17195. /**
  17196. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17197. * @param gradient defines the gradient to use (between 0 and 1)
  17198. * @param factor defines the emit rate value to affect to the specified gradient
  17199. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17200. * @returns the current particle system
  17201. */
  17202. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17203. /**
  17204. * Remove a specific emit rate gradient
  17205. * @param gradient defines the gradient to remove
  17206. * @returns the current particle system
  17207. */
  17208. removeEmitRateGradient(gradient: number): IParticleSystem;
  17209. /**
  17210. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17211. * @param gradient defines the gradient to use (between 0 and 1)
  17212. * @param factor defines the start size value to affect to the specified gradient
  17213. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17214. * @returns the current particle system
  17215. */
  17216. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17217. /**
  17218. * Remove a specific start size gradient
  17219. * @param gradient defines the gradient to remove
  17220. * @returns the current particle system
  17221. */
  17222. removeStartSizeGradient(gradient: number): IParticleSystem;
  17223. private _createRampGradientTexture;
  17224. /**
  17225. * Gets the current list of ramp gradients.
  17226. * You must use addRampGradient and removeRampGradient to udpate this list
  17227. * @returns the list of ramp gradients
  17228. */
  17229. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17230. /**
  17231. * Adds a new ramp gradient used to remap particle colors
  17232. * @param gradient defines the gradient to use (between 0 and 1)
  17233. * @param color defines the color to affect to the specified gradient
  17234. * @returns the current particle system
  17235. */
  17236. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17237. /**
  17238. * Remove a specific ramp gradient
  17239. * @param gradient defines the gradient to remove
  17240. * @returns the current particle system
  17241. */
  17242. removeRampGradient(gradient: number): ParticleSystem;
  17243. /**
  17244. * Adds a new color gradient
  17245. * @param gradient defines the gradient to use (between 0 and 1)
  17246. * @param color1 defines the color to affect to the specified gradient
  17247. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17248. * @returns this particle system
  17249. */
  17250. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17251. /**
  17252. * Remove a specific color gradient
  17253. * @param gradient defines the gradient to remove
  17254. * @returns this particle system
  17255. */
  17256. removeColorGradient(gradient: number): IParticleSystem;
  17257. private _fetchR;
  17258. protected _reset(): void;
  17259. private _resetEffect;
  17260. private _createVertexBuffers;
  17261. private _createIndexBuffer;
  17262. /**
  17263. * Gets the maximum number of particles active at the same time.
  17264. * @returns The max number of active particles.
  17265. */
  17266. getCapacity(): number;
  17267. /**
  17268. * Gets whether there are still active particles in the system.
  17269. * @returns True if it is alive, otherwise false.
  17270. */
  17271. isAlive(): boolean;
  17272. /**
  17273. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17274. * @returns True if it has been started, otherwise false.
  17275. */
  17276. isStarted(): boolean;
  17277. private _prepareSubEmitterInternalArray;
  17278. /**
  17279. * Starts the particle system and begins to emit
  17280. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17281. */
  17282. start(delay?: number): void;
  17283. /**
  17284. * Stops the particle system.
  17285. * @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.
  17286. */
  17287. stop(stopSubEmitters?: boolean): void;
  17288. /**
  17289. * Remove all active particles
  17290. */
  17291. reset(): void;
  17292. /**
  17293. * @hidden (for internal use only)
  17294. */
  17295. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17296. /**
  17297. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17298. * Its lifetime will start back at 0.
  17299. */
  17300. recycleParticle: (particle: Particle) => void;
  17301. private _stopSubEmitters;
  17302. private _createParticle;
  17303. private _removeFromRoot;
  17304. private _emitFromParticle;
  17305. private _update;
  17306. /** @hidden */
  17307. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17308. /** @hidden */
  17309. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17310. /** @hidden */
  17311. private _getEffect;
  17312. /**
  17313. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17314. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17315. */
  17316. animate(preWarmOnly?: boolean): void;
  17317. private _appendParticleVertices;
  17318. /**
  17319. * Rebuilds the particle system.
  17320. */
  17321. rebuild(): void;
  17322. /**
  17323. * Is this system ready to be used/rendered
  17324. * @return true if the system is ready
  17325. */
  17326. isReady(): boolean;
  17327. private _render;
  17328. /**
  17329. * Renders the particle system in its current state.
  17330. * @returns the current number of particles
  17331. */
  17332. render(): number;
  17333. /**
  17334. * Disposes the particle system and free the associated resources
  17335. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17336. */
  17337. dispose(disposeTexture?: boolean): void;
  17338. /**
  17339. * Clones the particle system.
  17340. * @param name The name of the cloned object
  17341. * @param newEmitter The new emitter to use
  17342. * @returns the cloned particle system
  17343. */
  17344. clone(name: string, newEmitter: any): ParticleSystem;
  17345. /**
  17346. * Serializes the particle system to a JSON object.
  17347. * @returns the JSON object
  17348. */
  17349. serialize(): any;
  17350. /** @hidden */
  17351. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17352. /** @hidden */
  17353. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17354. /**
  17355. * Parses a JSON object to create a particle system.
  17356. * @param parsedParticleSystem The JSON object to parse
  17357. * @param scene The scene to create the particle system in
  17358. * @param rootUrl The root url to use to load external dependencies like texture
  17359. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17360. * @returns the Parsed particle system
  17361. */
  17362. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17363. }
  17364. }
  17365. declare module BABYLON {
  17366. /**
  17367. * A particle represents one of the element emitted by a particle system.
  17368. * This is mainly define by its coordinates, direction, velocity and age.
  17369. */
  17370. export class Particle {
  17371. /**
  17372. * The particle system the particle belongs to.
  17373. */
  17374. particleSystem: ParticleSystem;
  17375. private static _Count;
  17376. /**
  17377. * Unique ID of the particle
  17378. */
  17379. id: number;
  17380. /**
  17381. * The world position of the particle in the scene.
  17382. */
  17383. position: Vector3;
  17384. /**
  17385. * The world direction of the particle in the scene.
  17386. */
  17387. direction: Vector3;
  17388. /**
  17389. * The color of the particle.
  17390. */
  17391. color: Color4;
  17392. /**
  17393. * The color change of the particle per step.
  17394. */
  17395. colorStep: Color4;
  17396. /**
  17397. * Defines how long will the life of the particle be.
  17398. */
  17399. lifeTime: number;
  17400. /**
  17401. * The current age of the particle.
  17402. */
  17403. age: number;
  17404. /**
  17405. * The current size of the particle.
  17406. */
  17407. size: number;
  17408. /**
  17409. * The current scale of the particle.
  17410. */
  17411. scale: Vector2;
  17412. /**
  17413. * The current angle of the particle.
  17414. */
  17415. angle: number;
  17416. /**
  17417. * Defines how fast is the angle changing.
  17418. */
  17419. angularSpeed: number;
  17420. /**
  17421. * Defines the cell index used by the particle to be rendered from a sprite.
  17422. */
  17423. cellIndex: number;
  17424. /**
  17425. * The information required to support color remapping
  17426. */
  17427. remapData: Vector4;
  17428. /** @hidden */
  17429. _randomCellOffset?: number;
  17430. /** @hidden */
  17431. _initialDirection: Nullable<Vector3>;
  17432. /** @hidden */
  17433. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17434. /** @hidden */
  17435. _initialStartSpriteCellID: number;
  17436. /** @hidden */
  17437. _initialEndSpriteCellID: number;
  17438. /** @hidden */
  17439. _currentColorGradient: Nullable<ColorGradient>;
  17440. /** @hidden */
  17441. _currentColor1: Color4;
  17442. /** @hidden */
  17443. _currentColor2: Color4;
  17444. /** @hidden */
  17445. _currentSizeGradient: Nullable<FactorGradient>;
  17446. /** @hidden */
  17447. _currentSize1: number;
  17448. /** @hidden */
  17449. _currentSize2: number;
  17450. /** @hidden */
  17451. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17452. /** @hidden */
  17453. _currentAngularSpeed1: number;
  17454. /** @hidden */
  17455. _currentAngularSpeed2: number;
  17456. /** @hidden */
  17457. _currentVelocityGradient: Nullable<FactorGradient>;
  17458. /** @hidden */
  17459. _currentVelocity1: number;
  17460. /** @hidden */
  17461. _currentVelocity2: number;
  17462. /** @hidden */
  17463. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17464. /** @hidden */
  17465. _currentLimitVelocity1: number;
  17466. /** @hidden */
  17467. _currentLimitVelocity2: number;
  17468. /** @hidden */
  17469. _currentDragGradient: Nullable<FactorGradient>;
  17470. /** @hidden */
  17471. _currentDrag1: number;
  17472. /** @hidden */
  17473. _currentDrag2: number;
  17474. /** @hidden */
  17475. _randomNoiseCoordinates1: Vector3;
  17476. /** @hidden */
  17477. _randomNoiseCoordinates2: Vector3;
  17478. /**
  17479. * Creates a new instance Particle
  17480. * @param particleSystem the particle system the particle belongs to
  17481. */
  17482. constructor(
  17483. /**
  17484. * The particle system the particle belongs to.
  17485. */
  17486. particleSystem: ParticleSystem);
  17487. private updateCellInfoFromSystem;
  17488. /**
  17489. * Defines how the sprite cell index is updated for the particle
  17490. */
  17491. updateCellIndex(): void;
  17492. /** @hidden */
  17493. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17494. /** @hidden */
  17495. _inheritParticleInfoToSubEmitters(): void;
  17496. /** @hidden */
  17497. _reset(): void;
  17498. /**
  17499. * Copy the properties of particle to another one.
  17500. * @param other the particle to copy the information to.
  17501. */
  17502. copyTo(other: Particle): void;
  17503. }
  17504. }
  17505. declare module BABYLON {
  17506. /**
  17507. * Particle emitter represents a volume emitting particles.
  17508. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17509. */
  17510. export interface IParticleEmitterType {
  17511. /**
  17512. * Called by the particle System when the direction is computed for the created particle.
  17513. * @param worldMatrix is the world matrix of the particle system
  17514. * @param directionToUpdate is the direction vector to update with the result
  17515. * @param particle is the particle we are computed the direction for
  17516. */
  17517. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17518. /**
  17519. * Called by the particle System when the position is computed for the created particle.
  17520. * @param worldMatrix is the world matrix of the particle system
  17521. * @param positionToUpdate is the position vector to update with the result
  17522. * @param particle is the particle we are computed the position for
  17523. */
  17524. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17525. /**
  17526. * Clones the current emitter and returns a copy of it
  17527. * @returns the new emitter
  17528. */
  17529. clone(): IParticleEmitterType;
  17530. /**
  17531. * Called by the GPUParticleSystem to setup the update shader
  17532. * @param effect defines the update shader
  17533. */
  17534. applyToShader(effect: Effect): void;
  17535. /**
  17536. * Returns a string to use to update the GPU particles update shader
  17537. * @returns the effect defines string
  17538. */
  17539. getEffectDefines(): string;
  17540. /**
  17541. * Returns a string representing the class name
  17542. * @returns a string containing the class name
  17543. */
  17544. getClassName(): string;
  17545. /**
  17546. * Serializes the particle system to a JSON object.
  17547. * @returns the JSON object
  17548. */
  17549. serialize(): any;
  17550. /**
  17551. * Parse properties from a JSON object
  17552. * @param serializationObject defines the JSON object
  17553. */
  17554. parse(serializationObject: any): void;
  17555. }
  17556. }
  17557. declare module BABYLON {
  17558. /**
  17559. * Particle emitter emitting particles from the inside of a box.
  17560. * It emits the particles randomly between 2 given directions.
  17561. */
  17562. export class BoxParticleEmitter implements IParticleEmitterType {
  17563. /**
  17564. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17565. */
  17566. direction1: Vector3;
  17567. /**
  17568. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17569. */
  17570. direction2: Vector3;
  17571. /**
  17572. * 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.
  17573. */
  17574. minEmitBox: Vector3;
  17575. /**
  17576. * 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.
  17577. */
  17578. maxEmitBox: Vector3;
  17579. /**
  17580. * Creates a new instance BoxParticleEmitter
  17581. */
  17582. constructor();
  17583. /**
  17584. * Called by the particle System when the direction is computed for the created particle.
  17585. * @param worldMatrix is the world matrix of the particle system
  17586. * @param directionToUpdate is the direction vector to update with the result
  17587. * @param particle is the particle we are computed the direction for
  17588. */
  17589. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17590. /**
  17591. * Called by the particle System when the position is computed for the created particle.
  17592. * @param worldMatrix is the world matrix of the particle system
  17593. * @param positionToUpdate is the position vector to update with the result
  17594. * @param particle is the particle we are computed the position for
  17595. */
  17596. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17597. /**
  17598. * Clones the current emitter and returns a copy of it
  17599. * @returns the new emitter
  17600. */
  17601. clone(): BoxParticleEmitter;
  17602. /**
  17603. * Called by the GPUParticleSystem to setup the update shader
  17604. * @param effect defines the update shader
  17605. */
  17606. applyToShader(effect: Effect): void;
  17607. /**
  17608. * Returns a string to use to update the GPU particles update shader
  17609. * @returns a string containng the defines string
  17610. */
  17611. getEffectDefines(): string;
  17612. /**
  17613. * Returns the string "BoxParticleEmitter"
  17614. * @returns a string containing the class name
  17615. */
  17616. getClassName(): string;
  17617. /**
  17618. * Serializes the particle system to a JSON object.
  17619. * @returns the JSON object
  17620. */
  17621. serialize(): any;
  17622. /**
  17623. * Parse properties from a JSON object
  17624. * @param serializationObject defines the JSON object
  17625. */
  17626. parse(serializationObject: any): void;
  17627. }
  17628. }
  17629. declare module BABYLON {
  17630. /**
  17631. * Particle emitter emitting particles from the inside of a cone.
  17632. * It emits the particles alongside the cone volume from the base to the particle.
  17633. * The emission direction might be randomized.
  17634. */
  17635. export class ConeParticleEmitter implements IParticleEmitterType {
  17636. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17637. directionRandomizer: number;
  17638. private _radius;
  17639. private _angle;
  17640. private _height;
  17641. /**
  17642. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17643. */
  17644. radiusRange: number;
  17645. /**
  17646. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17647. */
  17648. heightRange: number;
  17649. /**
  17650. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17651. */
  17652. emitFromSpawnPointOnly: boolean;
  17653. /**
  17654. * Gets or sets the radius of the emission cone
  17655. */
  17656. radius: number;
  17657. /**
  17658. * Gets or sets the angle of the emission cone
  17659. */
  17660. angle: number;
  17661. private _buildHeight;
  17662. /**
  17663. * Creates a new instance ConeParticleEmitter
  17664. * @param radius the radius of the emission cone (1 by default)
  17665. * @param angle the cone base angle (PI by default)
  17666. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17667. */
  17668. constructor(radius?: number, angle?: number,
  17669. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17670. directionRandomizer?: number);
  17671. /**
  17672. * Called by the particle System when the direction is computed for the created particle.
  17673. * @param worldMatrix is the world matrix of the particle system
  17674. * @param directionToUpdate is the direction vector to update with the result
  17675. * @param particle is the particle we are computed the direction for
  17676. */
  17677. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17678. /**
  17679. * Called by the particle System when the position is computed for the created particle.
  17680. * @param worldMatrix is the world matrix of the particle system
  17681. * @param positionToUpdate is the position vector to update with the result
  17682. * @param particle is the particle we are computed the position for
  17683. */
  17684. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17685. /**
  17686. * Clones the current emitter and returns a copy of it
  17687. * @returns the new emitter
  17688. */
  17689. clone(): ConeParticleEmitter;
  17690. /**
  17691. * Called by the GPUParticleSystem to setup the update shader
  17692. * @param effect defines the update shader
  17693. */
  17694. applyToShader(effect: Effect): void;
  17695. /**
  17696. * Returns a string to use to update the GPU particles update shader
  17697. * @returns a string containng the defines string
  17698. */
  17699. getEffectDefines(): string;
  17700. /**
  17701. * Returns the string "ConeParticleEmitter"
  17702. * @returns a string containing the class name
  17703. */
  17704. getClassName(): string;
  17705. /**
  17706. * Serializes the particle system to a JSON object.
  17707. * @returns the JSON object
  17708. */
  17709. serialize(): any;
  17710. /**
  17711. * Parse properties from a JSON object
  17712. * @param serializationObject defines the JSON object
  17713. */
  17714. parse(serializationObject: any): void;
  17715. }
  17716. }
  17717. declare module BABYLON {
  17718. /**
  17719. * Particle emitter emitting particles from the inside of a cylinder.
  17720. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17721. */
  17722. export class CylinderParticleEmitter implements IParticleEmitterType {
  17723. /**
  17724. * The radius of the emission cylinder.
  17725. */
  17726. radius: number;
  17727. /**
  17728. * The height of the emission cylinder.
  17729. */
  17730. height: number;
  17731. /**
  17732. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17733. */
  17734. radiusRange: number;
  17735. /**
  17736. * How much to randomize the particle direction [0-1].
  17737. */
  17738. directionRandomizer: number;
  17739. /**
  17740. * Creates a new instance CylinderParticleEmitter
  17741. * @param radius the radius of the emission cylinder (1 by default)
  17742. * @param height the height of the emission cylinder (1 by default)
  17743. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17744. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17745. */
  17746. constructor(
  17747. /**
  17748. * The radius of the emission cylinder.
  17749. */
  17750. radius?: number,
  17751. /**
  17752. * The height of the emission cylinder.
  17753. */
  17754. height?: number,
  17755. /**
  17756. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17757. */
  17758. radiusRange?: number,
  17759. /**
  17760. * How much to randomize the particle direction [0-1].
  17761. */
  17762. directionRandomizer?: number);
  17763. /**
  17764. * Called by the particle System when the direction is computed for the created particle.
  17765. * @param worldMatrix is the world matrix of the particle system
  17766. * @param directionToUpdate is the direction vector to update with the result
  17767. * @param particle is the particle we are computed the direction for
  17768. */
  17769. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17770. /**
  17771. * Called by the particle System when the position is computed for the created particle.
  17772. * @param worldMatrix is the world matrix of the particle system
  17773. * @param positionToUpdate is the position vector to update with the result
  17774. * @param particle is the particle we are computed the position for
  17775. */
  17776. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17777. /**
  17778. * Clones the current emitter and returns a copy of it
  17779. * @returns the new emitter
  17780. */
  17781. clone(): CylinderParticleEmitter;
  17782. /**
  17783. * Called by the GPUParticleSystem to setup the update shader
  17784. * @param effect defines the update shader
  17785. */
  17786. applyToShader(effect: Effect): void;
  17787. /**
  17788. * Returns a string to use to update the GPU particles update shader
  17789. * @returns a string containng the defines string
  17790. */
  17791. getEffectDefines(): string;
  17792. /**
  17793. * Returns the string "CylinderParticleEmitter"
  17794. * @returns a string containing the class name
  17795. */
  17796. getClassName(): string;
  17797. /**
  17798. * Serializes the particle system to a JSON object.
  17799. * @returns the JSON object
  17800. */
  17801. serialize(): any;
  17802. /**
  17803. * Parse properties from a JSON object
  17804. * @param serializationObject defines the JSON object
  17805. */
  17806. parse(serializationObject: any): void;
  17807. }
  17808. /**
  17809. * Particle emitter emitting particles from the inside of a cylinder.
  17810. * It emits the particles randomly between two vectors.
  17811. */
  17812. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17813. /**
  17814. * The min limit of the emission direction.
  17815. */
  17816. direction1: Vector3;
  17817. /**
  17818. * The max limit of the emission direction.
  17819. */
  17820. direction2: Vector3;
  17821. /**
  17822. * Creates a new instance CylinderDirectedParticleEmitter
  17823. * @param radius the radius of the emission cylinder (1 by default)
  17824. * @param height the height of the emission cylinder (1 by default)
  17825. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17826. * @param direction1 the min limit of the emission direction (up vector by default)
  17827. * @param direction2 the max limit of the emission direction (up vector by default)
  17828. */
  17829. constructor(radius?: number, height?: number, radiusRange?: number,
  17830. /**
  17831. * The min limit of the emission direction.
  17832. */
  17833. direction1?: Vector3,
  17834. /**
  17835. * The max limit of the emission direction.
  17836. */
  17837. direction2?: Vector3);
  17838. /**
  17839. * Called by the particle System when the direction is computed for the created particle.
  17840. * @param worldMatrix is the world matrix of the particle system
  17841. * @param directionToUpdate is the direction vector to update with the result
  17842. * @param particle is the particle we are computed the direction for
  17843. */
  17844. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17845. /**
  17846. * Clones the current emitter and returns a copy of it
  17847. * @returns the new emitter
  17848. */
  17849. clone(): CylinderDirectedParticleEmitter;
  17850. /**
  17851. * Called by the GPUParticleSystem to setup the update shader
  17852. * @param effect defines the update shader
  17853. */
  17854. applyToShader(effect: Effect): void;
  17855. /**
  17856. * Returns a string to use to update the GPU particles update shader
  17857. * @returns a string containng the defines string
  17858. */
  17859. getEffectDefines(): string;
  17860. /**
  17861. * Returns the string "CylinderDirectedParticleEmitter"
  17862. * @returns a string containing the class name
  17863. */
  17864. getClassName(): string;
  17865. /**
  17866. * Serializes the particle system to a JSON object.
  17867. * @returns the JSON object
  17868. */
  17869. serialize(): any;
  17870. /**
  17871. * Parse properties from a JSON object
  17872. * @param serializationObject defines the JSON object
  17873. */
  17874. parse(serializationObject: any): void;
  17875. }
  17876. }
  17877. declare module BABYLON {
  17878. /**
  17879. * Particle emitter emitting particles from the inside of a hemisphere.
  17880. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17881. */
  17882. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17883. /**
  17884. * The radius of the emission hemisphere.
  17885. */
  17886. radius: number;
  17887. /**
  17888. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17889. */
  17890. radiusRange: number;
  17891. /**
  17892. * How much to randomize the particle direction [0-1].
  17893. */
  17894. directionRandomizer: number;
  17895. /**
  17896. * Creates a new instance HemisphericParticleEmitter
  17897. * @param radius the radius of the emission hemisphere (1 by default)
  17898. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17899. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17900. */
  17901. constructor(
  17902. /**
  17903. * The radius of the emission hemisphere.
  17904. */
  17905. radius?: number,
  17906. /**
  17907. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17908. */
  17909. radiusRange?: number,
  17910. /**
  17911. * How much to randomize the particle direction [0-1].
  17912. */
  17913. directionRandomizer?: number);
  17914. /**
  17915. * Called by the particle System when the direction is computed for the created particle.
  17916. * @param worldMatrix is the world matrix of the particle system
  17917. * @param directionToUpdate is the direction vector to update with the result
  17918. * @param particle is the particle we are computed the direction for
  17919. */
  17920. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17921. /**
  17922. * Called by the particle System when the position is computed for the created particle.
  17923. * @param worldMatrix is the world matrix of the particle system
  17924. * @param positionToUpdate is the position vector to update with the result
  17925. * @param particle is the particle we are computed the position for
  17926. */
  17927. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17928. /**
  17929. * Clones the current emitter and returns a copy of it
  17930. * @returns the new emitter
  17931. */
  17932. clone(): HemisphericParticleEmitter;
  17933. /**
  17934. * Called by the GPUParticleSystem to setup the update shader
  17935. * @param effect defines the update shader
  17936. */
  17937. applyToShader(effect: Effect): void;
  17938. /**
  17939. * Returns a string to use to update the GPU particles update shader
  17940. * @returns a string containng the defines string
  17941. */
  17942. getEffectDefines(): string;
  17943. /**
  17944. * Returns the string "HemisphericParticleEmitter"
  17945. * @returns a string containing the class name
  17946. */
  17947. getClassName(): string;
  17948. /**
  17949. * Serializes the particle system to a JSON object.
  17950. * @returns the JSON object
  17951. */
  17952. serialize(): any;
  17953. /**
  17954. * Parse properties from a JSON object
  17955. * @param serializationObject defines the JSON object
  17956. */
  17957. parse(serializationObject: any): void;
  17958. }
  17959. }
  17960. declare module BABYLON {
  17961. /**
  17962. * Particle emitter emitting particles from a point.
  17963. * It emits the particles randomly between 2 given directions.
  17964. */
  17965. export class PointParticleEmitter implements IParticleEmitterType {
  17966. /**
  17967. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17968. */
  17969. direction1: Vector3;
  17970. /**
  17971. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17972. */
  17973. direction2: Vector3;
  17974. /**
  17975. * Creates a new instance PointParticleEmitter
  17976. */
  17977. constructor();
  17978. /**
  17979. * Called by the particle System when the direction is computed for the created particle.
  17980. * @param worldMatrix is the world matrix of the particle system
  17981. * @param directionToUpdate is the direction vector to update with the result
  17982. * @param particle is the particle we are computed the direction for
  17983. */
  17984. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17985. /**
  17986. * Called by the particle System when the position is computed for the created particle.
  17987. * @param worldMatrix is the world matrix of the particle system
  17988. * @param positionToUpdate is the position vector to update with the result
  17989. * @param particle is the particle we are computed the position for
  17990. */
  17991. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17992. /**
  17993. * Clones the current emitter and returns a copy of it
  17994. * @returns the new emitter
  17995. */
  17996. clone(): PointParticleEmitter;
  17997. /**
  17998. * Called by the GPUParticleSystem to setup the update shader
  17999. * @param effect defines the update shader
  18000. */
  18001. applyToShader(effect: Effect): void;
  18002. /**
  18003. * Returns a string to use to update the GPU particles update shader
  18004. * @returns a string containng the defines string
  18005. */
  18006. getEffectDefines(): string;
  18007. /**
  18008. * Returns the string "PointParticleEmitter"
  18009. * @returns a string containing the class name
  18010. */
  18011. getClassName(): string;
  18012. /**
  18013. * Serializes the particle system to a JSON object.
  18014. * @returns the JSON object
  18015. */
  18016. serialize(): any;
  18017. /**
  18018. * Parse properties from a JSON object
  18019. * @param serializationObject defines the JSON object
  18020. */
  18021. parse(serializationObject: any): void;
  18022. }
  18023. }
  18024. declare module BABYLON {
  18025. /**
  18026. * Particle emitter emitting particles from the inside of a sphere.
  18027. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18028. */
  18029. export class SphereParticleEmitter implements IParticleEmitterType {
  18030. /**
  18031. * The radius of the emission sphere.
  18032. */
  18033. radius: number;
  18034. /**
  18035. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18036. */
  18037. radiusRange: number;
  18038. /**
  18039. * How much to randomize the particle direction [0-1].
  18040. */
  18041. directionRandomizer: number;
  18042. /**
  18043. * Creates a new instance SphereParticleEmitter
  18044. * @param radius the radius of the emission sphere (1 by default)
  18045. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18046. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18047. */
  18048. constructor(
  18049. /**
  18050. * The radius of the emission sphere.
  18051. */
  18052. radius?: number,
  18053. /**
  18054. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18055. */
  18056. radiusRange?: number,
  18057. /**
  18058. * How much to randomize the particle direction [0-1].
  18059. */
  18060. directionRandomizer?: number);
  18061. /**
  18062. * Called by the particle System when the direction is computed for the created particle.
  18063. * @param worldMatrix is the world matrix of the particle system
  18064. * @param directionToUpdate is the direction vector to update with the result
  18065. * @param particle is the particle we are computed the direction for
  18066. */
  18067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18068. /**
  18069. * Called by the particle System when the position is computed for the created particle.
  18070. * @param worldMatrix is the world matrix of the particle system
  18071. * @param positionToUpdate is the position vector to update with the result
  18072. * @param particle is the particle we are computed the position for
  18073. */
  18074. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18075. /**
  18076. * Clones the current emitter and returns a copy of it
  18077. * @returns the new emitter
  18078. */
  18079. clone(): SphereParticleEmitter;
  18080. /**
  18081. * Called by the GPUParticleSystem to setup the update shader
  18082. * @param effect defines the update shader
  18083. */
  18084. applyToShader(effect: Effect): void;
  18085. /**
  18086. * Returns a string to use to update the GPU particles update shader
  18087. * @returns a string containng the defines string
  18088. */
  18089. getEffectDefines(): string;
  18090. /**
  18091. * Returns the string "SphereParticleEmitter"
  18092. * @returns a string containing the class name
  18093. */
  18094. getClassName(): string;
  18095. /**
  18096. * Serializes the particle system to a JSON object.
  18097. * @returns the JSON object
  18098. */
  18099. serialize(): any;
  18100. /**
  18101. * Parse properties from a JSON object
  18102. * @param serializationObject defines the JSON object
  18103. */
  18104. parse(serializationObject: any): void;
  18105. }
  18106. /**
  18107. * Particle emitter emitting particles from the inside of a sphere.
  18108. * It emits the particles randomly between two vectors.
  18109. */
  18110. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18111. /**
  18112. * The min limit of the emission direction.
  18113. */
  18114. direction1: Vector3;
  18115. /**
  18116. * The max limit of the emission direction.
  18117. */
  18118. direction2: Vector3;
  18119. /**
  18120. * Creates a new instance SphereDirectedParticleEmitter
  18121. * @param radius the radius of the emission sphere (1 by default)
  18122. * @param direction1 the min limit of the emission direction (up vector by default)
  18123. * @param direction2 the max limit of the emission direction (up vector by default)
  18124. */
  18125. constructor(radius?: number,
  18126. /**
  18127. * The min limit of the emission direction.
  18128. */
  18129. direction1?: Vector3,
  18130. /**
  18131. * The max limit of the emission direction.
  18132. */
  18133. direction2?: Vector3);
  18134. /**
  18135. * Called by the particle System when the direction is computed for the created particle.
  18136. * @param worldMatrix is the world matrix of the particle system
  18137. * @param directionToUpdate is the direction vector to update with the result
  18138. * @param particle is the particle we are computed the direction for
  18139. */
  18140. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18141. /**
  18142. * Clones the current emitter and returns a copy of it
  18143. * @returns the new emitter
  18144. */
  18145. clone(): SphereDirectedParticleEmitter;
  18146. /**
  18147. * Called by the GPUParticleSystem to setup the update shader
  18148. * @param effect defines the update shader
  18149. */
  18150. applyToShader(effect: Effect): void;
  18151. /**
  18152. * Returns a string to use to update the GPU particles update shader
  18153. * @returns a string containng the defines string
  18154. */
  18155. getEffectDefines(): string;
  18156. /**
  18157. * Returns the string "SphereDirectedParticleEmitter"
  18158. * @returns a string containing the class name
  18159. */
  18160. getClassName(): string;
  18161. /**
  18162. * Serializes the particle system to a JSON object.
  18163. * @returns the JSON object
  18164. */
  18165. serialize(): any;
  18166. /**
  18167. * Parse properties from a JSON object
  18168. * @param serializationObject defines the JSON object
  18169. */
  18170. parse(serializationObject: any): void;
  18171. }
  18172. }
  18173. declare module BABYLON {
  18174. /**
  18175. * Interface representing a particle system in Babylon.js.
  18176. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18177. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18178. */
  18179. export interface IParticleSystem {
  18180. /**
  18181. * List of animations used by the particle system.
  18182. */
  18183. animations: Animation[];
  18184. /**
  18185. * The id of the Particle system.
  18186. */
  18187. id: string;
  18188. /**
  18189. * The name of the Particle system.
  18190. */
  18191. name: string;
  18192. /**
  18193. * The emitter represents the Mesh or position we are attaching the particle system to.
  18194. */
  18195. emitter: Nullable<AbstractMesh | Vector3>;
  18196. /**
  18197. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18198. */
  18199. isBillboardBased: boolean;
  18200. /**
  18201. * The rendering group used by the Particle system to chose when to render.
  18202. */
  18203. renderingGroupId: number;
  18204. /**
  18205. * The layer mask we are rendering the particles through.
  18206. */
  18207. layerMask: number;
  18208. /**
  18209. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18210. */
  18211. updateSpeed: number;
  18212. /**
  18213. * The amount of time the particle system is running (depends of the overall update speed).
  18214. */
  18215. targetStopDuration: number;
  18216. /**
  18217. * The texture used to render each particle. (this can be a spritesheet)
  18218. */
  18219. particleTexture: Nullable<Texture>;
  18220. /**
  18221. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18222. */
  18223. blendMode: number;
  18224. /**
  18225. * Minimum life time of emitting particles.
  18226. */
  18227. minLifeTime: number;
  18228. /**
  18229. * Maximum life time of emitting particles.
  18230. */
  18231. maxLifeTime: number;
  18232. /**
  18233. * Minimum Size of emitting particles.
  18234. */
  18235. minSize: number;
  18236. /**
  18237. * Maximum Size of emitting particles.
  18238. */
  18239. maxSize: number;
  18240. /**
  18241. * Minimum scale of emitting particles on X axis.
  18242. */
  18243. minScaleX: number;
  18244. /**
  18245. * Maximum scale of emitting particles on X axis.
  18246. */
  18247. maxScaleX: number;
  18248. /**
  18249. * Minimum scale of emitting particles on Y axis.
  18250. */
  18251. minScaleY: number;
  18252. /**
  18253. * Maximum scale of emitting particles on Y axis.
  18254. */
  18255. maxScaleY: number;
  18256. /**
  18257. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18258. */
  18259. color1: Color4;
  18260. /**
  18261. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18262. */
  18263. color2: Color4;
  18264. /**
  18265. * Color the particle will have at the end of its lifetime.
  18266. */
  18267. colorDead: Color4;
  18268. /**
  18269. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18270. */
  18271. emitRate: number;
  18272. /**
  18273. * You can use gravity if you want to give an orientation to your particles.
  18274. */
  18275. gravity: Vector3;
  18276. /**
  18277. * Minimum power of emitting particles.
  18278. */
  18279. minEmitPower: number;
  18280. /**
  18281. * Maximum power of emitting particles.
  18282. */
  18283. maxEmitPower: number;
  18284. /**
  18285. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18286. */
  18287. minAngularSpeed: number;
  18288. /**
  18289. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18290. */
  18291. maxAngularSpeed: number;
  18292. /**
  18293. * Gets or sets the minimal initial rotation in radians.
  18294. */
  18295. minInitialRotation: number;
  18296. /**
  18297. * Gets or sets the maximal initial rotation in radians.
  18298. */
  18299. maxInitialRotation: number;
  18300. /**
  18301. * The particle emitter type defines the emitter used by the particle system.
  18302. * It can be for example box, sphere, or cone...
  18303. */
  18304. particleEmitterType: Nullable<IParticleEmitterType>;
  18305. /**
  18306. * Defines the delay in milliseconds before starting the system (0 by default)
  18307. */
  18308. startDelay: number;
  18309. /**
  18310. * 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
  18311. */
  18312. preWarmCycles: number;
  18313. /**
  18314. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18315. */
  18316. preWarmStepOffset: number;
  18317. /**
  18318. * 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)
  18319. */
  18320. spriteCellChangeSpeed: number;
  18321. /**
  18322. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18323. */
  18324. startSpriteCellID: number;
  18325. /**
  18326. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18327. */
  18328. endSpriteCellID: number;
  18329. /**
  18330. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18331. */
  18332. spriteCellWidth: number;
  18333. /**
  18334. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18335. */
  18336. spriteCellHeight: number;
  18337. /**
  18338. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18339. */
  18340. spriteRandomStartCell: boolean;
  18341. /**
  18342. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18343. */
  18344. isAnimationSheetEnabled: boolean;
  18345. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18346. translationPivot: Vector2;
  18347. /**
  18348. * Gets or sets a texture used to add random noise to particle positions
  18349. */
  18350. noiseTexture: Nullable<BaseTexture>;
  18351. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18352. noiseStrength: Vector3;
  18353. /**
  18354. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18355. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18356. */
  18357. billboardMode: number;
  18358. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18359. limitVelocityDamping: number;
  18360. /**
  18361. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18362. */
  18363. beginAnimationOnStart: boolean;
  18364. /**
  18365. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18366. */
  18367. beginAnimationFrom: number;
  18368. /**
  18369. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18370. */
  18371. beginAnimationTo: number;
  18372. /**
  18373. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18374. */
  18375. beginAnimationLoop: boolean;
  18376. /**
  18377. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18378. */
  18379. disposeOnStop: boolean;
  18380. /**
  18381. * Gets the maximum number of particles active at the same time.
  18382. * @returns The max number of active particles.
  18383. */
  18384. getCapacity(): number;
  18385. /**
  18386. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18387. * @returns True if it has been started, otherwise false.
  18388. */
  18389. isStarted(): boolean;
  18390. /**
  18391. * Animates the particle system for this frame.
  18392. */
  18393. animate(): void;
  18394. /**
  18395. * Renders the particle system in its current state.
  18396. * @returns the current number of particles
  18397. */
  18398. render(): number;
  18399. /**
  18400. * Dispose the particle system and frees its associated resources.
  18401. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18402. */
  18403. dispose(disposeTexture?: boolean): void;
  18404. /**
  18405. * Clones the particle system.
  18406. * @param name The name of the cloned object
  18407. * @param newEmitter The new emitter to use
  18408. * @returns the cloned particle system
  18409. */
  18410. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18411. /**
  18412. * Serializes the particle system to a JSON object.
  18413. * @returns the JSON object
  18414. */
  18415. serialize(): any;
  18416. /**
  18417. * Rebuild the particle system
  18418. */
  18419. rebuild(): void;
  18420. /**
  18421. * Starts the particle system and begins to emit
  18422. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18423. */
  18424. start(delay?: number): void;
  18425. /**
  18426. * Stops the particle system.
  18427. */
  18428. stop(): void;
  18429. /**
  18430. * Remove all active particles
  18431. */
  18432. reset(): void;
  18433. /**
  18434. * Is this system ready to be used/rendered
  18435. * @return true if the system is ready
  18436. */
  18437. isReady(): boolean;
  18438. /**
  18439. * Adds a new color gradient
  18440. * @param gradient defines the gradient to use (between 0 and 1)
  18441. * @param color1 defines the color to affect to the specified gradient
  18442. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18443. * @returns the current particle system
  18444. */
  18445. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18446. /**
  18447. * Remove a specific color gradient
  18448. * @param gradient defines the gradient to remove
  18449. * @returns the current particle system
  18450. */
  18451. removeColorGradient(gradient: number): IParticleSystem;
  18452. /**
  18453. * Adds a new size gradient
  18454. * @param gradient defines the gradient to use (between 0 and 1)
  18455. * @param factor defines the size factor to affect to the specified gradient
  18456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18457. * @returns the current particle system
  18458. */
  18459. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18460. /**
  18461. * Remove a specific size gradient
  18462. * @param gradient defines the gradient to remove
  18463. * @returns the current particle system
  18464. */
  18465. removeSizeGradient(gradient: number): IParticleSystem;
  18466. /**
  18467. * Gets the current list of color gradients.
  18468. * You must use addColorGradient and removeColorGradient to udpate this list
  18469. * @returns the list of color gradients
  18470. */
  18471. getColorGradients(): Nullable<Array<ColorGradient>>;
  18472. /**
  18473. * Gets the current list of size gradients.
  18474. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18475. * @returns the list of size gradients
  18476. */
  18477. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18478. /**
  18479. * Gets the current list of angular speed gradients.
  18480. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18481. * @returns the list of angular speed gradients
  18482. */
  18483. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18484. /**
  18485. * Adds a new angular speed gradient
  18486. * @param gradient defines the gradient to use (between 0 and 1)
  18487. * @param factor defines the angular speed to affect to the specified gradient
  18488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18489. * @returns the current particle system
  18490. */
  18491. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18492. /**
  18493. * Remove a specific angular speed gradient
  18494. * @param gradient defines the gradient to remove
  18495. * @returns the current particle system
  18496. */
  18497. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18498. /**
  18499. * Gets the current list of velocity gradients.
  18500. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18501. * @returns the list of velocity gradients
  18502. */
  18503. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18504. /**
  18505. * Adds a new velocity gradient
  18506. * @param gradient defines the gradient to use (between 0 and 1)
  18507. * @param factor defines the velocity to affect to the specified gradient
  18508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18509. * @returns the current particle system
  18510. */
  18511. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18512. /**
  18513. * Remove a specific velocity gradient
  18514. * @param gradient defines the gradient to remove
  18515. * @returns the current particle system
  18516. */
  18517. removeVelocityGradient(gradient: number): IParticleSystem;
  18518. /**
  18519. * Gets the current list of limit velocity gradients.
  18520. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18521. * @returns the list of limit velocity gradients
  18522. */
  18523. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18524. /**
  18525. * Adds a new limit velocity gradient
  18526. * @param gradient defines the gradient to use (between 0 and 1)
  18527. * @param factor defines the limit velocity to affect to the specified gradient
  18528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18529. * @returns the current particle system
  18530. */
  18531. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18532. /**
  18533. * Remove a specific limit velocity gradient
  18534. * @param gradient defines the gradient to remove
  18535. * @returns the current particle system
  18536. */
  18537. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18538. /**
  18539. * Adds a new drag gradient
  18540. * @param gradient defines the gradient to use (between 0 and 1)
  18541. * @param factor defines the drag to affect to the specified gradient
  18542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18543. * @returns the current particle system
  18544. */
  18545. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18546. /**
  18547. * Remove a specific drag gradient
  18548. * @param gradient defines the gradient to remove
  18549. * @returns the current particle system
  18550. */
  18551. removeDragGradient(gradient: number): IParticleSystem;
  18552. /**
  18553. * Gets the current list of drag gradients.
  18554. * You must use addDragGradient and removeDragGradient to udpate this list
  18555. * @returns the list of drag gradients
  18556. */
  18557. getDragGradients(): Nullable<Array<FactorGradient>>;
  18558. /**
  18559. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18560. * @param gradient defines the gradient to use (between 0 and 1)
  18561. * @param factor defines the emit rate to affect to the specified gradient
  18562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18563. * @returns the current particle system
  18564. */
  18565. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18566. /**
  18567. * Remove a specific emit rate gradient
  18568. * @param gradient defines the gradient to remove
  18569. * @returns the current particle system
  18570. */
  18571. removeEmitRateGradient(gradient: number): IParticleSystem;
  18572. /**
  18573. * Gets the current list of emit rate gradients.
  18574. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18575. * @returns the list of emit rate gradients
  18576. */
  18577. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18578. /**
  18579. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18580. * @param gradient defines the gradient to use (between 0 and 1)
  18581. * @param factor defines the start size to affect to the specified gradient
  18582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18583. * @returns the current particle system
  18584. */
  18585. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18586. /**
  18587. * Remove a specific start size gradient
  18588. * @param gradient defines the gradient to remove
  18589. * @returns the current particle system
  18590. */
  18591. removeStartSizeGradient(gradient: number): IParticleSystem;
  18592. /**
  18593. * Gets the current list of start size gradients.
  18594. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18595. * @returns the list of start size gradients
  18596. */
  18597. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18598. /**
  18599. * Adds a new life time gradient
  18600. * @param gradient defines the gradient to use (between 0 and 1)
  18601. * @param factor defines the life time factor to affect to the specified gradient
  18602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18603. * @returns the current particle system
  18604. */
  18605. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18606. /**
  18607. * Remove a specific life time gradient
  18608. * @param gradient defines the gradient to remove
  18609. * @returns the current particle system
  18610. */
  18611. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18612. /**
  18613. * Gets the current list of life time gradients.
  18614. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18615. * @returns the list of life time gradients
  18616. */
  18617. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18618. /**
  18619. * Gets the current list of color gradients.
  18620. * You must use addColorGradient and removeColorGradient to udpate this list
  18621. * @returns the list of color gradients
  18622. */
  18623. getColorGradients(): Nullable<Array<ColorGradient>>;
  18624. /**
  18625. * Adds a new ramp gradient used to remap particle colors
  18626. * @param gradient defines the gradient to use (between 0 and 1)
  18627. * @param color defines the color to affect to the specified gradient
  18628. * @returns the current particle system
  18629. */
  18630. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18631. /**
  18632. * Gets the current list of ramp gradients.
  18633. * You must use addRampGradient and removeRampGradient to udpate this list
  18634. * @returns the list of ramp gradients
  18635. */
  18636. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18637. /** Gets or sets a boolean indicating that ramp gradients must be used
  18638. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18639. */
  18640. useRampGradients: boolean;
  18641. /**
  18642. * Adds a new color remap gradient
  18643. * @param gradient defines the gradient to use (between 0 and 1)
  18644. * @param min defines the color remap minimal range
  18645. * @param max defines the color remap maximal range
  18646. * @returns the current particle system
  18647. */
  18648. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18649. /**
  18650. * Gets the current list of color remap gradients.
  18651. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18652. * @returns the list of color remap gradients
  18653. */
  18654. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18655. /**
  18656. * Adds a new alpha remap gradient
  18657. * @param gradient defines the gradient to use (between 0 and 1)
  18658. * @param min defines the alpha remap minimal range
  18659. * @param max defines the alpha remap maximal range
  18660. * @returns the current particle system
  18661. */
  18662. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18663. /**
  18664. * Gets the current list of alpha remap gradients.
  18665. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18666. * @returns the list of alpha remap gradients
  18667. */
  18668. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18669. /**
  18670. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18671. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18672. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18673. * @returns the emitter
  18674. */
  18675. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18676. /**
  18677. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18678. * @param radius The radius of the hemisphere to emit from
  18679. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18680. * @returns the emitter
  18681. */
  18682. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18683. /**
  18684. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18685. * @param radius The radius of the sphere to emit from
  18686. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18687. * @returns the emitter
  18688. */
  18689. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18690. /**
  18691. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18692. * @param radius The radius of the sphere to emit from
  18693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18695. * @returns the emitter
  18696. */
  18697. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18698. /**
  18699. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18700. * @param radius The radius of the emission cylinder
  18701. * @param height The height of the emission cylinder
  18702. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18703. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18704. * @returns the emitter
  18705. */
  18706. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18707. /**
  18708. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18709. * @param radius The radius of the cylinder to emit from
  18710. * @param height The height of the emission cylinder
  18711. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18712. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18713. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18714. * @returns the emitter
  18715. */
  18716. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18717. /**
  18718. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18719. * @param radius The radius of the cone to emit from
  18720. * @param angle The base angle of the cone
  18721. * @returns the emitter
  18722. */
  18723. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18724. /**
  18725. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18726. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18727. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18728. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18729. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18730. * @returns the emitter
  18731. */
  18732. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18733. /**
  18734. * Get hosting scene
  18735. * @returns the scene
  18736. */
  18737. getScene(): Scene;
  18738. }
  18739. }
  18740. declare module BABYLON {
  18741. /**
  18742. * Creates an instance based on a source mesh.
  18743. */
  18744. export class InstancedMesh extends AbstractMesh {
  18745. private _sourceMesh;
  18746. private _currentLOD;
  18747. /** @hidden */
  18748. _indexInSourceMeshInstanceArray: number;
  18749. constructor(name: string, source: Mesh);
  18750. /**
  18751. * Returns the string "InstancedMesh".
  18752. */
  18753. getClassName(): string;
  18754. /** Gets the list of lights affecting that mesh */
  18755. readonly lightSources: Light[];
  18756. _resyncLightSources(): void;
  18757. _resyncLighSource(light: Light): void;
  18758. _removeLightSource(light: Light, dispose: boolean): void;
  18759. /**
  18760. * If the source mesh receives shadows
  18761. */
  18762. readonly receiveShadows: boolean;
  18763. /**
  18764. * The material of the source mesh
  18765. */
  18766. readonly material: Nullable<Material>;
  18767. /**
  18768. * Visibility of the source mesh
  18769. */
  18770. readonly visibility: number;
  18771. /**
  18772. * Skeleton of the source mesh
  18773. */
  18774. readonly skeleton: Nullable<Skeleton>;
  18775. /**
  18776. * Rendering ground id of the source mesh
  18777. */
  18778. renderingGroupId: number;
  18779. /**
  18780. * Returns the total number of vertices (integer).
  18781. */
  18782. getTotalVertices(): number;
  18783. /**
  18784. * Returns a positive integer : the total number of indices in this mesh geometry.
  18785. * @returns the numner of indices or zero if the mesh has no geometry.
  18786. */
  18787. getTotalIndices(): number;
  18788. /**
  18789. * The source mesh of the instance
  18790. */
  18791. readonly sourceMesh: Mesh;
  18792. /**
  18793. * Is this node ready to be used/rendered
  18794. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18795. * @return {boolean} is it ready
  18796. */
  18797. isReady(completeCheck?: boolean): boolean;
  18798. /**
  18799. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18800. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18801. * @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.
  18802. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18803. */
  18804. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18805. /**
  18806. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18807. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18808. * The `data` are either a numeric array either a Float32Array.
  18809. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18810. * 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).
  18811. * Note that a new underlying VertexBuffer object is created each call.
  18812. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18813. *
  18814. * Possible `kind` values :
  18815. * - VertexBuffer.PositionKind
  18816. * - VertexBuffer.UVKind
  18817. * - VertexBuffer.UV2Kind
  18818. * - VertexBuffer.UV3Kind
  18819. * - VertexBuffer.UV4Kind
  18820. * - VertexBuffer.UV5Kind
  18821. * - VertexBuffer.UV6Kind
  18822. * - VertexBuffer.ColorKind
  18823. * - VertexBuffer.MatricesIndicesKind
  18824. * - VertexBuffer.MatricesIndicesExtraKind
  18825. * - VertexBuffer.MatricesWeightsKind
  18826. * - VertexBuffer.MatricesWeightsExtraKind
  18827. *
  18828. * Returns the Mesh.
  18829. */
  18830. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18831. /**
  18832. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18833. * If the mesh has no geometry, it is simply returned as it is.
  18834. * The `data` are either a numeric array either a Float32Array.
  18835. * No new underlying VertexBuffer object is created.
  18836. * 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.
  18837. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18838. *
  18839. * Possible `kind` values :
  18840. * - VertexBuffer.PositionKind
  18841. * - VertexBuffer.UVKind
  18842. * - VertexBuffer.UV2Kind
  18843. * - VertexBuffer.UV3Kind
  18844. * - VertexBuffer.UV4Kind
  18845. * - VertexBuffer.UV5Kind
  18846. * - VertexBuffer.UV6Kind
  18847. * - VertexBuffer.ColorKind
  18848. * - VertexBuffer.MatricesIndicesKind
  18849. * - VertexBuffer.MatricesIndicesExtraKind
  18850. * - VertexBuffer.MatricesWeightsKind
  18851. * - VertexBuffer.MatricesWeightsExtraKind
  18852. *
  18853. * Returns the Mesh.
  18854. */
  18855. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18856. /**
  18857. * Sets the mesh indices.
  18858. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18859. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18860. * This method creates a new index buffer each call.
  18861. * Returns the Mesh.
  18862. */
  18863. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18864. /**
  18865. * Boolean : True if the mesh owns the requested kind of data.
  18866. */
  18867. isVerticesDataPresent(kind: string): boolean;
  18868. /**
  18869. * Returns an array of indices (IndicesArray).
  18870. */
  18871. getIndices(): Nullable<IndicesArray>;
  18872. readonly _positions: Nullable<Vector3[]>;
  18873. /**
  18874. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18875. * This means the mesh underlying bounding box and sphere are recomputed.
  18876. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18877. * @returns the current mesh
  18878. */
  18879. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18880. /** @hidden */
  18881. _preActivate(): InstancedMesh;
  18882. /** @hidden */
  18883. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18884. /** @hidden */
  18885. _postActivate(): void;
  18886. getWorldMatrix(): Matrix;
  18887. readonly isAnInstance: boolean;
  18888. /**
  18889. * Returns the current associated LOD AbstractMesh.
  18890. */
  18891. getLOD(camera: Camera): AbstractMesh;
  18892. /** @hidden */
  18893. _syncSubMeshes(): InstancedMesh;
  18894. /** @hidden */
  18895. _generatePointsArray(): boolean;
  18896. /**
  18897. * Creates a new InstancedMesh from the current mesh.
  18898. * - name (string) : the cloned mesh name
  18899. * - newParent (optional Node) : the optional Node to parent the clone to.
  18900. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18901. *
  18902. * Returns the clone.
  18903. */
  18904. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18905. /**
  18906. * Disposes the InstancedMesh.
  18907. * Returns nothing.
  18908. */
  18909. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18910. }
  18911. }
  18912. declare module BABYLON {
  18913. /**
  18914. * Defines the options associated with the creation of a shader material.
  18915. */
  18916. export interface IShaderMaterialOptions {
  18917. /**
  18918. * Does the material work in alpha blend mode
  18919. */
  18920. needAlphaBlending: boolean;
  18921. /**
  18922. * Does the material work in alpha test mode
  18923. */
  18924. needAlphaTesting: boolean;
  18925. /**
  18926. * The list of attribute names used in the shader
  18927. */
  18928. attributes: string[];
  18929. /**
  18930. * The list of unifrom names used in the shader
  18931. */
  18932. uniforms: string[];
  18933. /**
  18934. * The list of UBO names used in the shader
  18935. */
  18936. uniformBuffers: string[];
  18937. /**
  18938. * The list of sampler names used in the shader
  18939. */
  18940. samplers: string[];
  18941. /**
  18942. * The list of defines used in the shader
  18943. */
  18944. defines: string[];
  18945. }
  18946. /**
  18947. * 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.
  18948. *
  18949. * This returned material effects how the mesh will look based on the code in the shaders.
  18950. *
  18951. * @see http://doc.babylonjs.com/how_to/shader_material
  18952. */
  18953. export class ShaderMaterial extends Material {
  18954. private _shaderPath;
  18955. private _options;
  18956. private _textures;
  18957. private _textureArrays;
  18958. private _floats;
  18959. private _ints;
  18960. private _floatsArrays;
  18961. private _colors3;
  18962. private _colors3Arrays;
  18963. private _colors4;
  18964. private _colors4Arrays;
  18965. private _vectors2;
  18966. private _vectors3;
  18967. private _vectors4;
  18968. private _matrices;
  18969. private _matrices3x3;
  18970. private _matrices2x2;
  18971. private _vectors2Arrays;
  18972. private _vectors3Arrays;
  18973. private _vectors4Arrays;
  18974. private _cachedWorldViewMatrix;
  18975. private _cachedWorldViewProjectionMatrix;
  18976. private _renderId;
  18977. /**
  18978. * Instantiate a new shader material.
  18979. * 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.
  18980. * This returned material effects how the mesh will look based on the code in the shaders.
  18981. * @see http://doc.babylonjs.com/how_to/shader_material
  18982. * @param name Define the name of the material in the scene
  18983. * @param scene Define the scene the material belongs to
  18984. * @param shaderPath Defines the route to the shader code in one of three ways:
  18985. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18986. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18987. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18988. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18989. * @param options Define the options used to create the shader
  18990. */
  18991. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18992. /**
  18993. * Gets the options used to compile the shader.
  18994. * They can be modified to trigger a new compilation
  18995. */
  18996. readonly options: IShaderMaterialOptions;
  18997. /**
  18998. * Gets the current class name of the material e.g. "ShaderMaterial"
  18999. * Mainly use in serialization.
  19000. * @returns the class name
  19001. */
  19002. getClassName(): string;
  19003. /**
  19004. * Specifies if the material will require alpha blending
  19005. * @returns a boolean specifying if alpha blending is needed
  19006. */
  19007. needAlphaBlending(): boolean;
  19008. /**
  19009. * Specifies if this material should be rendered in alpha test mode
  19010. * @returns a boolean specifying if an alpha test is needed.
  19011. */
  19012. needAlphaTesting(): boolean;
  19013. private _checkUniform;
  19014. /**
  19015. * Set a texture in the shader.
  19016. * @param name Define the name of the uniform samplers as defined in the shader
  19017. * @param texture Define the texture to bind to this sampler
  19018. * @return the material itself allowing "fluent" like uniform updates
  19019. */
  19020. setTexture(name: string, texture: Texture): ShaderMaterial;
  19021. /**
  19022. * Set a texture array in the shader.
  19023. * @param name Define the name of the uniform sampler array as defined in the shader
  19024. * @param textures Define the list of textures to bind to this sampler
  19025. * @return the material itself allowing "fluent" like uniform updates
  19026. */
  19027. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19028. /**
  19029. * Set a float in the shader.
  19030. * @param name Define the name of the uniform as defined in the shader
  19031. * @param value Define the value to give to the uniform
  19032. * @return the material itself allowing "fluent" like uniform updates
  19033. */
  19034. setFloat(name: string, value: number): ShaderMaterial;
  19035. /**
  19036. * Set a int in the shader.
  19037. * @param name Define the name of the uniform as defined in the shader
  19038. * @param value Define the value to give to the uniform
  19039. * @return the material itself allowing "fluent" like uniform updates
  19040. */
  19041. setInt(name: string, value: number): ShaderMaterial;
  19042. /**
  19043. * Set an array of floats in the shader.
  19044. * @param name Define the name of the uniform as defined in the shader
  19045. * @param value Define the value to give to the uniform
  19046. * @return the material itself allowing "fluent" like uniform updates
  19047. */
  19048. setFloats(name: string, value: number[]): ShaderMaterial;
  19049. /**
  19050. * Set a vec3 in the shader from a Color3.
  19051. * @param name Define the name of the uniform as defined in the shader
  19052. * @param value Define the value to give to the uniform
  19053. * @return the material itself allowing "fluent" like uniform updates
  19054. */
  19055. setColor3(name: string, value: Color3): ShaderMaterial;
  19056. /**
  19057. * Set a vec3 array in the shader from a Color3 array.
  19058. * @param name Define the name of the uniform as defined in the shader
  19059. * @param value Define the value to give to the uniform
  19060. * @return the material itself allowing "fluent" like uniform updates
  19061. */
  19062. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19063. /**
  19064. * Set a vec4 in the shader from a Color4.
  19065. * @param name Define the name of the uniform as defined in the shader
  19066. * @param value Define the value to give to the uniform
  19067. * @return the material itself allowing "fluent" like uniform updates
  19068. */
  19069. setColor4(name: string, value: Color4): ShaderMaterial;
  19070. /**
  19071. * Set a vec4 array in the shader from a Color4 array.
  19072. * @param name Define the name of the uniform as defined in the shader
  19073. * @param value Define the value to give to the uniform
  19074. * @return the material itself allowing "fluent" like uniform updates
  19075. */
  19076. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19077. /**
  19078. * Set a vec2 in the shader from a Vector2.
  19079. * @param name Define the name of the uniform as defined in the shader
  19080. * @param value Define the value to give to the uniform
  19081. * @return the material itself allowing "fluent" like uniform updates
  19082. */
  19083. setVector2(name: string, value: Vector2): ShaderMaterial;
  19084. /**
  19085. * Set a vec3 in the shader from a Vector3.
  19086. * @param name Define the name of the uniform as defined in the shader
  19087. * @param value Define the value to give to the uniform
  19088. * @return the material itself allowing "fluent" like uniform updates
  19089. */
  19090. setVector3(name: string, value: Vector3): ShaderMaterial;
  19091. /**
  19092. * Set a vec4 in the shader from a Vector4.
  19093. * @param name Define the name of the uniform as defined in the shader
  19094. * @param value Define the value to give to the uniform
  19095. * @return the material itself allowing "fluent" like uniform updates
  19096. */
  19097. setVector4(name: string, value: Vector4): ShaderMaterial;
  19098. /**
  19099. * Set a mat4 in the shader from a Matrix.
  19100. * @param name Define the name of the uniform as defined in the shader
  19101. * @param value Define the value to give to the uniform
  19102. * @return the material itself allowing "fluent" like uniform updates
  19103. */
  19104. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19105. /**
  19106. * Set a mat3 in the shader from a Float32Array.
  19107. * @param name Define the name of the uniform as defined in the shader
  19108. * @param value Define the value to give to the uniform
  19109. * @return the material itself allowing "fluent" like uniform updates
  19110. */
  19111. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19112. /**
  19113. * Set a mat2 in the shader from a Float32Array.
  19114. * @param name Define the name of the uniform as defined in the shader
  19115. * @param value Define the value to give to the uniform
  19116. * @return the material itself allowing "fluent" like uniform updates
  19117. */
  19118. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19119. /**
  19120. * Set a vec2 array in the shader from a number array.
  19121. * @param name Define the name of the uniform as defined in the shader
  19122. * @param value Define the value to give to the uniform
  19123. * @return the material itself allowing "fluent" like uniform updates
  19124. */
  19125. setArray2(name: string, value: number[]): ShaderMaterial;
  19126. /**
  19127. * Set a vec3 array in the shader from a number array.
  19128. * @param name Define the name of the uniform as defined in the shader
  19129. * @param value Define the value to give to the uniform
  19130. * @return the material itself allowing "fluent" like uniform updates
  19131. */
  19132. setArray3(name: string, value: number[]): ShaderMaterial;
  19133. /**
  19134. * Set a vec4 array in the shader from a number array.
  19135. * @param name Define the name of the uniform as defined in the shader
  19136. * @param value Define the value to give to the uniform
  19137. * @return the material itself allowing "fluent" like uniform updates
  19138. */
  19139. setArray4(name: string, value: number[]): ShaderMaterial;
  19140. private _checkCache;
  19141. /**
  19142. * Specifies that the submesh is ready to be used
  19143. * @param mesh defines the mesh to check
  19144. * @param subMesh defines which submesh to check
  19145. * @param useInstances specifies that instances should be used
  19146. * @returns a boolean indicating that the submesh is ready or not
  19147. */
  19148. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19149. /**
  19150. * Checks if the material is ready to render the requested mesh
  19151. * @param mesh Define the mesh to render
  19152. * @param useInstances Define whether or not the material is used with instances
  19153. * @returns true if ready, otherwise false
  19154. */
  19155. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19156. /**
  19157. * Binds the world matrix to the material
  19158. * @param world defines the world transformation matrix
  19159. */
  19160. bindOnlyWorldMatrix(world: Matrix): void;
  19161. /**
  19162. * Binds the material to the mesh
  19163. * @param world defines the world transformation matrix
  19164. * @param mesh defines the mesh to bind the material to
  19165. */
  19166. bind(world: Matrix, mesh?: Mesh): void;
  19167. /**
  19168. * Gets the active textures from the material
  19169. * @returns an array of textures
  19170. */
  19171. getActiveTextures(): BaseTexture[];
  19172. /**
  19173. * Specifies if the material uses a texture
  19174. * @param texture defines the texture to check against the material
  19175. * @returns a boolean specifying if the material uses the texture
  19176. */
  19177. hasTexture(texture: BaseTexture): boolean;
  19178. /**
  19179. * Makes a duplicate of the material, and gives it a new name
  19180. * @param name defines the new name for the duplicated material
  19181. * @returns the cloned material
  19182. */
  19183. clone(name: string): ShaderMaterial;
  19184. /**
  19185. * Disposes the material
  19186. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19187. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19188. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19189. */
  19190. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19191. /**
  19192. * Serializes this material in a JSON representation
  19193. * @returns the serialized material object
  19194. */
  19195. serialize(): any;
  19196. /**
  19197. * Creates a shader material from parsed shader material data
  19198. * @param source defines the JSON represnetation of the material
  19199. * @param scene defines the hosting scene
  19200. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19201. * @returns a new material
  19202. */
  19203. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19204. }
  19205. }
  19206. declare module BABYLON {
  19207. /** @hidden */
  19208. export var colorPixelShader: {
  19209. name: string;
  19210. shader: string;
  19211. };
  19212. }
  19213. declare module BABYLON {
  19214. /** @hidden */
  19215. export var colorVertexShader: {
  19216. name: string;
  19217. shader: string;
  19218. };
  19219. }
  19220. declare module BABYLON {
  19221. /**
  19222. * Line mesh
  19223. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19224. */
  19225. export class LinesMesh extends Mesh {
  19226. /**
  19227. * If vertex color should be applied to the mesh
  19228. */
  19229. readonly useVertexColor?: boolean | undefined;
  19230. /**
  19231. * If vertex alpha should be applied to the mesh
  19232. */
  19233. readonly useVertexAlpha?: boolean | undefined;
  19234. /**
  19235. * Color of the line (Default: White)
  19236. */
  19237. color: Color3;
  19238. /**
  19239. * Alpha of the line (Default: 1)
  19240. */
  19241. alpha: number;
  19242. /**
  19243. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19244. * This margin is expressed in world space coordinates, so its value may vary.
  19245. * Default value is 0.1
  19246. */
  19247. intersectionThreshold: number;
  19248. private _colorShader;
  19249. private color4;
  19250. /**
  19251. * Creates a new LinesMesh
  19252. * @param name defines the name
  19253. * @param scene defines the hosting scene
  19254. * @param parent defines the parent mesh if any
  19255. * @param source defines the optional source LinesMesh used to clone data from
  19256. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19257. * When false, achieved by calling a clone(), also passing False.
  19258. * This will make creation of children, recursive.
  19259. * @param useVertexColor defines if this LinesMesh supports vertex color
  19260. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19261. */
  19262. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19263. /**
  19264. * If vertex color should be applied to the mesh
  19265. */
  19266. useVertexColor?: boolean | undefined,
  19267. /**
  19268. * If vertex alpha should be applied to the mesh
  19269. */
  19270. useVertexAlpha?: boolean | undefined);
  19271. private _addClipPlaneDefine;
  19272. private _removeClipPlaneDefine;
  19273. isReady(): boolean;
  19274. /**
  19275. * Returns the string "LineMesh"
  19276. */
  19277. getClassName(): string;
  19278. /**
  19279. * @hidden
  19280. */
  19281. /**
  19282. * @hidden
  19283. */
  19284. material: Material;
  19285. /**
  19286. * @hidden
  19287. */
  19288. readonly checkCollisions: boolean;
  19289. /** @hidden */
  19290. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19291. /** @hidden */
  19292. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19293. /**
  19294. * Disposes of the line mesh
  19295. * @param doNotRecurse If children should be disposed
  19296. */
  19297. dispose(doNotRecurse?: boolean): void;
  19298. /**
  19299. * Returns a new LineMesh object cloned from the current one.
  19300. */
  19301. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19302. /**
  19303. * Creates a new InstancedLinesMesh object from the mesh model.
  19304. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19305. * @param name defines the name of the new instance
  19306. * @returns a new InstancedLinesMesh
  19307. */
  19308. createInstance(name: string): InstancedLinesMesh;
  19309. }
  19310. /**
  19311. * Creates an instance based on a source LinesMesh
  19312. */
  19313. export class InstancedLinesMesh extends InstancedMesh {
  19314. /**
  19315. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19316. * This margin is expressed in world space coordinates, so its value may vary.
  19317. * Initilized with the intersectionThreshold value of the source LinesMesh
  19318. */
  19319. intersectionThreshold: number;
  19320. constructor(name: string, source: LinesMesh);
  19321. /**
  19322. * Returns the string "InstancedLinesMesh".
  19323. */
  19324. getClassName(): string;
  19325. }
  19326. }
  19327. declare module BABYLON {
  19328. /** @hidden */
  19329. export var linePixelShader: {
  19330. name: string;
  19331. shader: string;
  19332. };
  19333. }
  19334. declare module BABYLON {
  19335. /** @hidden */
  19336. export var lineVertexShader: {
  19337. name: string;
  19338. shader: string;
  19339. };
  19340. }
  19341. declare module BABYLON {
  19342. interface AbstractMesh {
  19343. /**
  19344. * Gets the edgesRenderer associated with the mesh
  19345. */
  19346. edgesRenderer: Nullable<EdgesRenderer>;
  19347. }
  19348. interface LinesMesh {
  19349. /**
  19350. * Enables the edge rendering mode on the mesh.
  19351. * This mode makes the mesh edges visible
  19352. * @param epsilon defines the maximal distance between two angles to detect a face
  19353. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19354. * @returns the currentAbstractMesh
  19355. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19356. */
  19357. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19358. }
  19359. interface InstancedLinesMesh {
  19360. /**
  19361. * Enables the edge rendering mode on the mesh.
  19362. * This mode makes the mesh edges visible
  19363. * @param epsilon defines the maximal distance between two angles to detect a face
  19364. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19365. * @returns the current InstancedLinesMesh
  19366. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19367. */
  19368. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19369. }
  19370. /**
  19371. * Defines the minimum contract an Edges renderer should follow.
  19372. */
  19373. export interface IEdgesRenderer extends IDisposable {
  19374. /**
  19375. * Gets or sets a boolean indicating if the edgesRenderer is active
  19376. */
  19377. isEnabled: boolean;
  19378. /**
  19379. * Renders the edges of the attached mesh,
  19380. */
  19381. render(): void;
  19382. /**
  19383. * Checks wether or not the edges renderer is ready to render.
  19384. * @return true if ready, otherwise false.
  19385. */
  19386. isReady(): boolean;
  19387. }
  19388. /**
  19389. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19390. */
  19391. export class EdgesRenderer implements IEdgesRenderer {
  19392. /**
  19393. * Define the size of the edges with an orthographic camera
  19394. */
  19395. edgesWidthScalerForOrthographic: number;
  19396. /**
  19397. * Define the size of the edges with a perspective camera
  19398. */
  19399. edgesWidthScalerForPerspective: number;
  19400. protected _source: AbstractMesh;
  19401. protected _linesPositions: number[];
  19402. protected _linesNormals: number[];
  19403. protected _linesIndices: number[];
  19404. protected _epsilon: number;
  19405. protected _indicesCount: number;
  19406. protected _lineShader: ShaderMaterial;
  19407. protected _ib: DataBuffer;
  19408. protected _buffers: {
  19409. [key: string]: Nullable<VertexBuffer>;
  19410. };
  19411. protected _checkVerticesInsteadOfIndices: boolean;
  19412. private _meshRebuildObserver;
  19413. private _meshDisposeObserver;
  19414. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19415. isEnabled: boolean;
  19416. /**
  19417. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19418. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19419. * @param source Mesh used to create edges
  19420. * @param epsilon sum of angles in adjacency to check for edge
  19421. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19422. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19423. */
  19424. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19425. protected _prepareRessources(): void;
  19426. /** @hidden */
  19427. _rebuild(): void;
  19428. /**
  19429. * Releases the required resources for the edges renderer
  19430. */
  19431. dispose(): void;
  19432. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19433. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19434. /**
  19435. * Checks if the pair of p0 and p1 is en edge
  19436. * @param faceIndex
  19437. * @param edge
  19438. * @param faceNormals
  19439. * @param p0
  19440. * @param p1
  19441. * @private
  19442. */
  19443. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19444. /**
  19445. * push line into the position, normal and index buffer
  19446. * @protected
  19447. */
  19448. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19449. /**
  19450. * Generates lines edges from adjacencjes
  19451. * @private
  19452. */
  19453. _generateEdgesLines(): void;
  19454. /**
  19455. * Checks wether or not the edges renderer is ready to render.
  19456. * @return true if ready, otherwise false.
  19457. */
  19458. isReady(): boolean;
  19459. /**
  19460. * Renders the edges of the attached mesh,
  19461. */
  19462. render(): void;
  19463. }
  19464. /**
  19465. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19466. */
  19467. export class LineEdgesRenderer extends EdgesRenderer {
  19468. /**
  19469. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19470. * @param source LineMesh used to generate edges
  19471. * @param epsilon not important (specified angle for edge detection)
  19472. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19473. */
  19474. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19475. /**
  19476. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19477. */
  19478. _generateEdgesLines(): void;
  19479. }
  19480. }
  19481. declare module BABYLON {
  19482. /**
  19483. * This represents the object necessary to create a rendering group.
  19484. * This is exclusively used and created by the rendering manager.
  19485. * To modify the behavior, you use the available helpers in your scene or meshes.
  19486. * @hidden
  19487. */
  19488. export class RenderingGroup {
  19489. index: number;
  19490. private static _zeroVector;
  19491. private _scene;
  19492. private _opaqueSubMeshes;
  19493. private _transparentSubMeshes;
  19494. private _alphaTestSubMeshes;
  19495. private _depthOnlySubMeshes;
  19496. private _particleSystems;
  19497. private _spriteManagers;
  19498. private _opaqueSortCompareFn;
  19499. private _alphaTestSortCompareFn;
  19500. private _transparentSortCompareFn;
  19501. private _renderOpaque;
  19502. private _renderAlphaTest;
  19503. private _renderTransparent;
  19504. /** @hidden */
  19505. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19506. onBeforeTransparentRendering: () => void;
  19507. /**
  19508. * Set the opaque sort comparison function.
  19509. * If null the sub meshes will be render in the order they were created
  19510. */
  19511. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19512. /**
  19513. * Set the alpha test sort comparison function.
  19514. * If null the sub meshes will be render in the order they were created
  19515. */
  19516. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19517. /**
  19518. * Set the transparent sort comparison function.
  19519. * If null the sub meshes will be render in the order they were created
  19520. */
  19521. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19522. /**
  19523. * Creates a new rendering group.
  19524. * @param index The rendering group index
  19525. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19526. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19527. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19528. */
  19529. 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>);
  19530. /**
  19531. * Render all the sub meshes contained in the group.
  19532. * @param customRenderFunction Used to override the default render behaviour of the group.
  19533. * @returns true if rendered some submeshes.
  19534. */
  19535. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19536. /**
  19537. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19538. * @param subMeshes The submeshes to render
  19539. */
  19540. private renderOpaqueSorted;
  19541. /**
  19542. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19543. * @param subMeshes The submeshes to render
  19544. */
  19545. private renderAlphaTestSorted;
  19546. /**
  19547. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19548. * @param subMeshes The submeshes to render
  19549. */
  19550. private renderTransparentSorted;
  19551. /**
  19552. * Renders the submeshes in a specified order.
  19553. * @param subMeshes The submeshes to sort before render
  19554. * @param sortCompareFn The comparison function use to sort
  19555. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19556. * @param transparent Specifies to activate blending if true
  19557. */
  19558. private static renderSorted;
  19559. /**
  19560. * Renders the submeshes in the order they were dispatched (no sort applied).
  19561. * @param subMeshes The submeshes to render
  19562. */
  19563. private static renderUnsorted;
  19564. /**
  19565. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19566. * are rendered back to front if in the same alpha index.
  19567. *
  19568. * @param a The first submesh
  19569. * @param b The second submesh
  19570. * @returns The result of the comparison
  19571. */
  19572. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19573. /**
  19574. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19575. * are rendered back to front.
  19576. *
  19577. * @param a The first submesh
  19578. * @param b The second submesh
  19579. * @returns The result of the comparison
  19580. */
  19581. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19582. /**
  19583. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19584. * are rendered front to back (prevent overdraw).
  19585. *
  19586. * @param a The first submesh
  19587. * @param b The second submesh
  19588. * @returns The result of the comparison
  19589. */
  19590. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19591. /**
  19592. * Resets the different lists of submeshes to prepare a new frame.
  19593. */
  19594. prepare(): void;
  19595. dispose(): void;
  19596. /**
  19597. * Inserts the submesh in its correct queue depending on its material.
  19598. * @param subMesh The submesh to dispatch
  19599. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19600. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19601. */
  19602. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19603. dispatchSprites(spriteManager: ISpriteManager): void;
  19604. dispatchParticles(particleSystem: IParticleSystem): void;
  19605. private _renderParticles;
  19606. private _renderSprites;
  19607. }
  19608. }
  19609. declare module BABYLON {
  19610. /**
  19611. * Interface describing the different options available in the rendering manager
  19612. * regarding Auto Clear between groups.
  19613. */
  19614. export interface IRenderingManagerAutoClearSetup {
  19615. /**
  19616. * Defines whether or not autoclear is enable.
  19617. */
  19618. autoClear: boolean;
  19619. /**
  19620. * Defines whether or not to autoclear the depth buffer.
  19621. */
  19622. depth: boolean;
  19623. /**
  19624. * Defines whether or not to autoclear the stencil buffer.
  19625. */
  19626. stencil: boolean;
  19627. }
  19628. /**
  19629. * This class is used by the onRenderingGroupObservable
  19630. */
  19631. export class RenderingGroupInfo {
  19632. /**
  19633. * The Scene that being rendered
  19634. */
  19635. scene: Scene;
  19636. /**
  19637. * The camera currently used for the rendering pass
  19638. */
  19639. camera: Nullable<Camera>;
  19640. /**
  19641. * The ID of the renderingGroup being processed
  19642. */
  19643. renderingGroupId: number;
  19644. }
  19645. /**
  19646. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19647. * It is enable to manage the different groups as well as the different necessary sort functions.
  19648. * This should not be used directly aside of the few static configurations
  19649. */
  19650. export class RenderingManager {
  19651. /**
  19652. * The max id used for rendering groups (not included)
  19653. */
  19654. static MAX_RENDERINGGROUPS: number;
  19655. /**
  19656. * The min id used for rendering groups (included)
  19657. */
  19658. static MIN_RENDERINGGROUPS: number;
  19659. /**
  19660. * Used to globally prevent autoclearing scenes.
  19661. */
  19662. static AUTOCLEAR: boolean;
  19663. /**
  19664. * @hidden
  19665. */
  19666. _useSceneAutoClearSetup: boolean;
  19667. private _scene;
  19668. private _renderingGroups;
  19669. private _depthStencilBufferAlreadyCleaned;
  19670. private _autoClearDepthStencil;
  19671. private _customOpaqueSortCompareFn;
  19672. private _customAlphaTestSortCompareFn;
  19673. private _customTransparentSortCompareFn;
  19674. private _renderingGroupInfo;
  19675. /**
  19676. * Instantiates a new rendering group for a particular scene
  19677. * @param scene Defines the scene the groups belongs to
  19678. */
  19679. constructor(scene: Scene);
  19680. private _clearDepthStencilBuffer;
  19681. /**
  19682. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19683. * @hidden
  19684. */
  19685. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19686. /**
  19687. * Resets the different information of the group to prepare a new frame
  19688. * @hidden
  19689. */
  19690. reset(): void;
  19691. /**
  19692. * Dispose and release the group and its associated resources.
  19693. * @hidden
  19694. */
  19695. dispose(): void;
  19696. /**
  19697. * Clear the info related to rendering groups preventing retention points during dispose.
  19698. */
  19699. freeRenderingGroups(): void;
  19700. private _prepareRenderingGroup;
  19701. /**
  19702. * Add a sprite manager to the rendering manager in order to render it this frame.
  19703. * @param spriteManager Define the sprite manager to render
  19704. */
  19705. dispatchSprites(spriteManager: ISpriteManager): void;
  19706. /**
  19707. * Add a particle system to the rendering manager in order to render it this frame.
  19708. * @param particleSystem Define the particle system to render
  19709. */
  19710. dispatchParticles(particleSystem: IParticleSystem): void;
  19711. /**
  19712. * Add a submesh to the manager in order to render it this frame
  19713. * @param subMesh The submesh to dispatch
  19714. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19715. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19716. */
  19717. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19718. /**
  19719. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19720. * This allowed control for front to back rendering or reversly depending of the special needs.
  19721. *
  19722. * @param renderingGroupId The rendering group id corresponding to its index
  19723. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19724. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19725. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19726. */
  19727. 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;
  19728. /**
  19729. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19730. *
  19731. * @param renderingGroupId The rendering group id corresponding to its index
  19732. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19733. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19734. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19735. */
  19736. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19737. /**
  19738. * Gets the current auto clear configuration for one rendering group of the rendering
  19739. * manager.
  19740. * @param index the rendering group index to get the information for
  19741. * @returns The auto clear setup for the requested rendering group
  19742. */
  19743. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19744. }
  19745. }
  19746. declare module BABYLON {
  19747. /**
  19748. * This Helps creating a texture that will be created from a camera in your scene.
  19749. * It is basically a dynamic texture that could be used to create special effects for instance.
  19750. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19751. */
  19752. export class RenderTargetTexture extends Texture {
  19753. isCube: boolean;
  19754. /**
  19755. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19756. */
  19757. static readonly REFRESHRATE_RENDER_ONCE: number;
  19758. /**
  19759. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19760. */
  19761. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19762. /**
  19763. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19764. * the central point of your effect and can save a lot of performances.
  19765. */
  19766. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19767. /**
  19768. * Use this predicate to dynamically define the list of mesh you want to render.
  19769. * If set, the renderList property will be overwritten.
  19770. */
  19771. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19772. private _renderList;
  19773. /**
  19774. * Use this list to define the list of mesh you want to render.
  19775. */
  19776. renderList: Nullable<Array<AbstractMesh>>;
  19777. private _hookArray;
  19778. /**
  19779. * Define if particles should be rendered in your texture.
  19780. */
  19781. renderParticles: boolean;
  19782. /**
  19783. * Define if sprites should be rendered in your texture.
  19784. */
  19785. renderSprites: boolean;
  19786. /**
  19787. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19788. */
  19789. coordinatesMode: number;
  19790. /**
  19791. * Define the camera used to render the texture.
  19792. */
  19793. activeCamera: Nullable<Camera>;
  19794. /**
  19795. * Override the render function of the texture with your own one.
  19796. */
  19797. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19798. /**
  19799. * Define if camera post processes should be use while rendering the texture.
  19800. */
  19801. useCameraPostProcesses: boolean;
  19802. /**
  19803. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19804. */
  19805. ignoreCameraViewport: boolean;
  19806. private _postProcessManager;
  19807. private _postProcesses;
  19808. private _resizeObserver;
  19809. /**
  19810. * An event triggered when the texture is unbind.
  19811. */
  19812. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19813. /**
  19814. * An event triggered when the texture is unbind.
  19815. */
  19816. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19817. private _onAfterUnbindObserver;
  19818. /**
  19819. * Set a after unbind callback in the texture.
  19820. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19821. */
  19822. onAfterUnbind: () => void;
  19823. /**
  19824. * An event triggered before rendering the texture
  19825. */
  19826. onBeforeRenderObservable: Observable<number>;
  19827. private _onBeforeRenderObserver;
  19828. /**
  19829. * Set a before render callback in the texture.
  19830. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19831. */
  19832. onBeforeRender: (faceIndex: number) => void;
  19833. /**
  19834. * An event triggered after rendering the texture
  19835. */
  19836. onAfterRenderObservable: Observable<number>;
  19837. private _onAfterRenderObserver;
  19838. /**
  19839. * Set a after render callback in the texture.
  19840. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19841. */
  19842. onAfterRender: (faceIndex: number) => void;
  19843. /**
  19844. * An event triggered after the texture clear
  19845. */
  19846. onClearObservable: Observable<Engine>;
  19847. private _onClearObserver;
  19848. /**
  19849. * Set a clear callback in the texture.
  19850. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19851. */
  19852. onClear: (Engine: Engine) => void;
  19853. /**
  19854. * An event triggered when the texture is resized.
  19855. */
  19856. onResizeObservable: Observable<RenderTargetTexture>;
  19857. /**
  19858. * Define the clear color of the Render Target if it should be different from the scene.
  19859. */
  19860. clearColor: Color4;
  19861. protected _size: number | {
  19862. width: number;
  19863. height: number;
  19864. };
  19865. protected _initialSizeParameter: number | {
  19866. width: number;
  19867. height: number;
  19868. } | {
  19869. ratio: number;
  19870. };
  19871. protected _sizeRatio: Nullable<number>;
  19872. /** @hidden */
  19873. _generateMipMaps: boolean;
  19874. protected _renderingManager: RenderingManager;
  19875. /** @hidden */
  19876. _waitingRenderList: string[];
  19877. protected _doNotChangeAspectRatio: boolean;
  19878. protected _currentRefreshId: number;
  19879. protected _refreshRate: number;
  19880. protected _textureMatrix: Matrix;
  19881. protected _samples: number;
  19882. protected _renderTargetOptions: RenderTargetCreationOptions;
  19883. /**
  19884. * Gets render target creation options that were used.
  19885. */
  19886. readonly renderTargetOptions: RenderTargetCreationOptions;
  19887. protected _engine: Engine;
  19888. protected _onRatioRescale(): void;
  19889. /**
  19890. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19891. * It must define where the camera used to render the texture is set
  19892. */
  19893. boundingBoxPosition: Vector3;
  19894. private _boundingBoxSize;
  19895. /**
  19896. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19897. * When defined, the cubemap will switch to local mode
  19898. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19899. * @example https://www.babylonjs-playground.com/#RNASML
  19900. */
  19901. boundingBoxSize: Vector3;
  19902. /**
  19903. * In case the RTT has been created with a depth texture, get the associated
  19904. * depth texture.
  19905. * Otherwise, return null.
  19906. */
  19907. depthStencilTexture: Nullable<InternalTexture>;
  19908. /**
  19909. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19910. * or used a shadow, depth texture...
  19911. * @param name The friendly name of the texture
  19912. * @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)
  19913. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19914. * @param generateMipMaps True if mip maps need to be generated after render.
  19915. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19916. * @param type The type of the buffer in the RTT (int, half float, float...)
  19917. * @param isCube True if a cube texture needs to be created
  19918. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19919. * @param generateDepthBuffer True to generate a depth buffer
  19920. * @param generateStencilBuffer True to generate a stencil buffer
  19921. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19922. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19923. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19924. */
  19925. constructor(name: string, size: number | {
  19926. width: number;
  19927. height: number;
  19928. } | {
  19929. ratio: number;
  19930. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19931. /**
  19932. * Creates a depth stencil texture.
  19933. * This is only available in WebGL 2 or with the depth texture extension available.
  19934. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19935. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19936. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19937. */
  19938. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19939. private _processSizeParameter;
  19940. /**
  19941. * Define the number of samples to use in case of MSAA.
  19942. * It defaults to one meaning no MSAA has been enabled.
  19943. */
  19944. samples: number;
  19945. /**
  19946. * Resets the refresh counter of the texture and start bak from scratch.
  19947. * Could be useful to regenerate the texture if it is setup to render only once.
  19948. */
  19949. resetRefreshCounter(): void;
  19950. /**
  19951. * Define the refresh rate of the texture or the rendering frequency.
  19952. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19953. */
  19954. refreshRate: number;
  19955. /**
  19956. * Adds a post process to the render target rendering passes.
  19957. * @param postProcess define the post process to add
  19958. */
  19959. addPostProcess(postProcess: PostProcess): void;
  19960. /**
  19961. * Clear all the post processes attached to the render target
  19962. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19963. */
  19964. clearPostProcesses(dispose?: boolean): void;
  19965. /**
  19966. * Remove one of the post process from the list of attached post processes to the texture
  19967. * @param postProcess define the post process to remove from the list
  19968. */
  19969. removePostProcess(postProcess: PostProcess): void;
  19970. /** @hidden */
  19971. _shouldRender(): boolean;
  19972. /**
  19973. * Gets the actual render size of the texture.
  19974. * @returns the width of the render size
  19975. */
  19976. getRenderSize(): number;
  19977. /**
  19978. * Gets the actual render width of the texture.
  19979. * @returns the width of the render size
  19980. */
  19981. getRenderWidth(): number;
  19982. /**
  19983. * Gets the actual render height of the texture.
  19984. * @returns the height of the render size
  19985. */
  19986. getRenderHeight(): number;
  19987. /**
  19988. * Get if the texture can be rescaled or not.
  19989. */
  19990. readonly canRescale: boolean;
  19991. /**
  19992. * Resize the texture using a ratio.
  19993. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19994. */
  19995. scale(ratio: number): void;
  19996. /**
  19997. * Get the texture reflection matrix used to rotate/transform the reflection.
  19998. * @returns the reflection matrix
  19999. */
  20000. getReflectionTextureMatrix(): Matrix;
  20001. /**
  20002. * Resize the texture to a new desired size.
  20003. * Be carrefull as it will recreate all the data in the new texture.
  20004. * @param size Define the new size. It can be:
  20005. * - a number for squared texture,
  20006. * - an object containing { width: number, height: number }
  20007. * - or an object containing a ratio { ratio: number }
  20008. */
  20009. resize(size: number | {
  20010. width: number;
  20011. height: number;
  20012. } | {
  20013. ratio: number;
  20014. }): void;
  20015. /**
  20016. * Renders all the objects from the render list into the texture.
  20017. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20018. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20019. */
  20020. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20021. private _bestReflectionRenderTargetDimension;
  20022. /**
  20023. * @hidden
  20024. * @param faceIndex face index to bind to if this is a cubetexture
  20025. */
  20026. _bindFrameBuffer(faceIndex?: number): void;
  20027. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20028. private renderToTarget;
  20029. /**
  20030. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20031. * This allowed control for front to back rendering or reversly depending of the special needs.
  20032. *
  20033. * @param renderingGroupId The rendering group id corresponding to its index
  20034. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20035. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20036. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20037. */
  20038. 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;
  20039. /**
  20040. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20041. *
  20042. * @param renderingGroupId The rendering group id corresponding to its index
  20043. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20044. */
  20045. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20046. /**
  20047. * Clones the texture.
  20048. * @returns the cloned texture
  20049. */
  20050. clone(): RenderTargetTexture;
  20051. /**
  20052. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20053. * @returns The JSON representation of the texture
  20054. */
  20055. serialize(): any;
  20056. /**
  20057. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20058. */
  20059. disposeFramebufferObjects(): void;
  20060. /**
  20061. * Dispose the texture and release its associated resources.
  20062. */
  20063. dispose(): void;
  20064. /** @hidden */
  20065. _rebuild(): void;
  20066. /**
  20067. * Clear the info related to rendering groups preventing retention point in material dispose.
  20068. */
  20069. freeRenderingGroups(): void;
  20070. /**
  20071. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20072. * @returns the view count
  20073. */
  20074. getViewCount(): number;
  20075. }
  20076. }
  20077. declare module BABYLON {
  20078. /**
  20079. * Base class for the main features of a material in Babylon.js
  20080. */
  20081. export class Material implements IAnimatable {
  20082. /**
  20083. * Returns the triangle fill mode
  20084. */
  20085. static readonly TriangleFillMode: number;
  20086. /**
  20087. * Returns the wireframe mode
  20088. */
  20089. static readonly WireFrameFillMode: number;
  20090. /**
  20091. * Returns the point fill mode
  20092. */
  20093. static readonly PointFillMode: number;
  20094. /**
  20095. * Returns the point list draw mode
  20096. */
  20097. static readonly PointListDrawMode: number;
  20098. /**
  20099. * Returns the line list draw mode
  20100. */
  20101. static readonly LineListDrawMode: number;
  20102. /**
  20103. * Returns the line loop draw mode
  20104. */
  20105. static readonly LineLoopDrawMode: number;
  20106. /**
  20107. * Returns the line strip draw mode
  20108. */
  20109. static readonly LineStripDrawMode: number;
  20110. /**
  20111. * Returns the triangle strip draw mode
  20112. */
  20113. static readonly TriangleStripDrawMode: number;
  20114. /**
  20115. * Returns the triangle fan draw mode
  20116. */
  20117. static readonly TriangleFanDrawMode: number;
  20118. /**
  20119. * Stores the clock-wise side orientation
  20120. */
  20121. static readonly ClockWiseSideOrientation: number;
  20122. /**
  20123. * Stores the counter clock-wise side orientation
  20124. */
  20125. static readonly CounterClockWiseSideOrientation: number;
  20126. /**
  20127. * The dirty texture flag value
  20128. */
  20129. static readonly TextureDirtyFlag: number;
  20130. /**
  20131. * The dirty light flag value
  20132. */
  20133. static readonly LightDirtyFlag: number;
  20134. /**
  20135. * The dirty fresnel flag value
  20136. */
  20137. static readonly FresnelDirtyFlag: number;
  20138. /**
  20139. * The dirty attribute flag value
  20140. */
  20141. static readonly AttributesDirtyFlag: number;
  20142. /**
  20143. * The dirty misc flag value
  20144. */
  20145. static readonly MiscDirtyFlag: number;
  20146. /**
  20147. * The all dirty flag value
  20148. */
  20149. static readonly AllDirtyFlag: number;
  20150. /**
  20151. * The ID of the material
  20152. */
  20153. id: string;
  20154. /**
  20155. * Gets or sets the unique id of the material
  20156. */
  20157. uniqueId: number;
  20158. /**
  20159. * The name of the material
  20160. */
  20161. name: string;
  20162. /**
  20163. * Gets or sets user defined metadata
  20164. */
  20165. metadata: any;
  20166. /**
  20167. * For internal use only. Please do not use.
  20168. */
  20169. reservedDataStore: any;
  20170. /**
  20171. * Specifies if the ready state should be checked on each call
  20172. */
  20173. checkReadyOnEveryCall: boolean;
  20174. /**
  20175. * Specifies if the ready state should be checked once
  20176. */
  20177. checkReadyOnlyOnce: boolean;
  20178. /**
  20179. * The state of the material
  20180. */
  20181. state: string;
  20182. /**
  20183. * The alpha value of the material
  20184. */
  20185. protected _alpha: number;
  20186. /**
  20187. * List of inspectable custom properties (used by the Inspector)
  20188. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20189. */
  20190. inspectableCustomProperties: IInspectable[];
  20191. /**
  20192. * Sets the alpha value of the material
  20193. */
  20194. /**
  20195. * Gets the alpha value of the material
  20196. */
  20197. alpha: number;
  20198. /**
  20199. * Specifies if back face culling is enabled
  20200. */
  20201. protected _backFaceCulling: boolean;
  20202. /**
  20203. * Sets the back-face culling state
  20204. */
  20205. /**
  20206. * Gets the back-face culling state
  20207. */
  20208. backFaceCulling: boolean;
  20209. /**
  20210. * Stores the value for side orientation
  20211. */
  20212. sideOrientation: number;
  20213. /**
  20214. * Callback triggered when the material is compiled
  20215. */
  20216. onCompiled: Nullable<(effect: Effect) => void>;
  20217. /**
  20218. * Callback triggered when an error occurs
  20219. */
  20220. onError: Nullable<(effect: Effect, errors: string) => void>;
  20221. /**
  20222. * Callback triggered to get the render target textures
  20223. */
  20224. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20225. /**
  20226. * Gets a boolean indicating that current material needs to register RTT
  20227. */
  20228. readonly hasRenderTargetTextures: boolean;
  20229. /**
  20230. * Specifies if the material should be serialized
  20231. */
  20232. doNotSerialize: boolean;
  20233. /**
  20234. * @hidden
  20235. */
  20236. _storeEffectOnSubMeshes: boolean;
  20237. /**
  20238. * Stores the animations for the material
  20239. */
  20240. animations: Nullable<Array<Animation>>;
  20241. /**
  20242. * An event triggered when the material is disposed
  20243. */
  20244. onDisposeObservable: Observable<Material>;
  20245. /**
  20246. * An observer which watches for dispose events
  20247. */
  20248. private _onDisposeObserver;
  20249. private _onUnBindObservable;
  20250. /**
  20251. * Called during a dispose event
  20252. */
  20253. onDispose: () => void;
  20254. private _onBindObservable;
  20255. /**
  20256. * An event triggered when the material is bound
  20257. */
  20258. readonly onBindObservable: Observable<AbstractMesh>;
  20259. /**
  20260. * An observer which watches for bind events
  20261. */
  20262. private _onBindObserver;
  20263. /**
  20264. * Called during a bind event
  20265. */
  20266. onBind: (Mesh: AbstractMesh) => void;
  20267. /**
  20268. * An event triggered when the material is unbound
  20269. */
  20270. readonly onUnBindObservable: Observable<Material>;
  20271. /**
  20272. * Stores the value of the alpha mode
  20273. */
  20274. private _alphaMode;
  20275. /**
  20276. * Sets the value of the alpha mode.
  20277. *
  20278. * | Value | Type | Description |
  20279. * | --- | --- | --- |
  20280. * | 0 | ALPHA_DISABLE | |
  20281. * | 1 | ALPHA_ADD | |
  20282. * | 2 | ALPHA_COMBINE | |
  20283. * | 3 | ALPHA_SUBTRACT | |
  20284. * | 4 | ALPHA_MULTIPLY | |
  20285. * | 5 | ALPHA_MAXIMIZED | |
  20286. * | 6 | ALPHA_ONEONE | |
  20287. * | 7 | ALPHA_PREMULTIPLIED | |
  20288. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20289. * | 9 | ALPHA_INTERPOLATE | |
  20290. * | 10 | ALPHA_SCREENMODE | |
  20291. *
  20292. */
  20293. /**
  20294. * Gets the value of the alpha mode
  20295. */
  20296. alphaMode: number;
  20297. /**
  20298. * Stores the state of the need depth pre-pass value
  20299. */
  20300. private _needDepthPrePass;
  20301. /**
  20302. * Sets the need depth pre-pass value
  20303. */
  20304. /**
  20305. * Gets the depth pre-pass value
  20306. */
  20307. needDepthPrePass: boolean;
  20308. /**
  20309. * Specifies if depth writing should be disabled
  20310. */
  20311. disableDepthWrite: boolean;
  20312. /**
  20313. * Specifies if depth writing should be forced
  20314. */
  20315. forceDepthWrite: boolean;
  20316. /**
  20317. * Specifies if there should be a separate pass for culling
  20318. */
  20319. separateCullingPass: boolean;
  20320. /**
  20321. * Stores the state specifing if fog should be enabled
  20322. */
  20323. private _fogEnabled;
  20324. /**
  20325. * Sets the state for enabling fog
  20326. */
  20327. /**
  20328. * Gets the value of the fog enabled state
  20329. */
  20330. fogEnabled: boolean;
  20331. /**
  20332. * Stores the size of points
  20333. */
  20334. pointSize: number;
  20335. /**
  20336. * Stores the z offset value
  20337. */
  20338. zOffset: number;
  20339. /**
  20340. * Gets a value specifying if wireframe mode is enabled
  20341. */
  20342. /**
  20343. * Sets the state of wireframe mode
  20344. */
  20345. wireframe: boolean;
  20346. /**
  20347. * Gets the value specifying if point clouds are enabled
  20348. */
  20349. /**
  20350. * Sets the state of point cloud mode
  20351. */
  20352. pointsCloud: boolean;
  20353. /**
  20354. * Gets the material fill mode
  20355. */
  20356. /**
  20357. * Sets the material fill mode
  20358. */
  20359. fillMode: number;
  20360. /**
  20361. * @hidden
  20362. * Stores the effects for the material
  20363. */
  20364. _effect: Nullable<Effect>;
  20365. /**
  20366. * @hidden
  20367. * Specifies if the material was previously ready
  20368. */
  20369. _wasPreviouslyReady: boolean;
  20370. /**
  20371. * Specifies if uniform buffers should be used
  20372. */
  20373. private _useUBO;
  20374. /**
  20375. * Stores a reference to the scene
  20376. */
  20377. private _scene;
  20378. /**
  20379. * Stores the fill mode state
  20380. */
  20381. private _fillMode;
  20382. /**
  20383. * Specifies if the depth write state should be cached
  20384. */
  20385. private _cachedDepthWriteState;
  20386. /**
  20387. * Stores the uniform buffer
  20388. */
  20389. protected _uniformBuffer: UniformBuffer;
  20390. /** @hidden */
  20391. _indexInSceneMaterialArray: number;
  20392. /** @hidden */
  20393. meshMap: Nullable<{
  20394. [id: string]: AbstractMesh | undefined;
  20395. }>;
  20396. /**
  20397. * Creates a material instance
  20398. * @param name defines the name of the material
  20399. * @param scene defines the scene to reference
  20400. * @param doNotAdd specifies if the material should be added to the scene
  20401. */
  20402. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20403. /**
  20404. * Returns a string representation of the current material
  20405. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20406. * @returns a string with material information
  20407. */
  20408. toString(fullDetails?: boolean): string;
  20409. /**
  20410. * Gets the class name of the material
  20411. * @returns a string with the class name of the material
  20412. */
  20413. getClassName(): string;
  20414. /**
  20415. * Specifies if updates for the material been locked
  20416. */
  20417. readonly isFrozen: boolean;
  20418. /**
  20419. * Locks updates for the material
  20420. */
  20421. freeze(): void;
  20422. /**
  20423. * Unlocks updates for the material
  20424. */
  20425. unfreeze(): void;
  20426. /**
  20427. * Specifies if the material is ready to be used
  20428. * @param mesh defines the mesh to check
  20429. * @param useInstances specifies if instances should be used
  20430. * @returns a boolean indicating if the material is ready to be used
  20431. */
  20432. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20433. /**
  20434. * Specifies that the submesh is ready to be used
  20435. * @param mesh defines the mesh to check
  20436. * @param subMesh defines which submesh to check
  20437. * @param useInstances specifies that instances should be used
  20438. * @returns a boolean indicating that the submesh is ready or not
  20439. */
  20440. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20441. /**
  20442. * Returns the material effect
  20443. * @returns the effect associated with the material
  20444. */
  20445. getEffect(): Nullable<Effect>;
  20446. /**
  20447. * Returns the current scene
  20448. * @returns a Scene
  20449. */
  20450. getScene(): Scene;
  20451. /**
  20452. * Specifies if the material will require alpha blending
  20453. * @returns a boolean specifying if alpha blending is needed
  20454. */
  20455. needAlphaBlending(): boolean;
  20456. /**
  20457. * Specifies if the mesh will require alpha blending
  20458. * @param mesh defines the mesh to check
  20459. * @returns a boolean specifying if alpha blending is needed for the mesh
  20460. */
  20461. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20462. /**
  20463. * Specifies if this material should be rendered in alpha test mode
  20464. * @returns a boolean specifying if an alpha test is needed.
  20465. */
  20466. needAlphaTesting(): boolean;
  20467. /**
  20468. * Gets the texture used for the alpha test
  20469. * @returns the texture to use for alpha testing
  20470. */
  20471. getAlphaTestTexture(): Nullable<BaseTexture>;
  20472. /**
  20473. * Marks the material to indicate that it needs to be re-calculated
  20474. */
  20475. markDirty(): void;
  20476. /** @hidden */
  20477. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20478. /**
  20479. * Binds the material to the mesh
  20480. * @param world defines the world transformation matrix
  20481. * @param mesh defines the mesh to bind the material to
  20482. */
  20483. bind(world: Matrix, mesh?: Mesh): void;
  20484. /**
  20485. * Binds the submesh to the material
  20486. * @param world defines the world transformation matrix
  20487. * @param mesh defines the mesh containing the submesh
  20488. * @param subMesh defines the submesh to bind the material to
  20489. */
  20490. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20491. /**
  20492. * Binds the world matrix to the material
  20493. * @param world defines the world transformation matrix
  20494. */
  20495. bindOnlyWorldMatrix(world: Matrix): void;
  20496. /**
  20497. * Binds the scene's uniform buffer to the effect.
  20498. * @param effect defines the effect to bind to the scene uniform buffer
  20499. * @param sceneUbo defines the uniform buffer storing scene data
  20500. */
  20501. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20502. /**
  20503. * Binds the view matrix to the effect
  20504. * @param effect defines the effect to bind the view matrix to
  20505. */
  20506. bindView(effect: Effect): void;
  20507. /**
  20508. * Binds the view projection matrix to the effect
  20509. * @param effect defines the effect to bind the view projection matrix to
  20510. */
  20511. bindViewProjection(effect: Effect): void;
  20512. /**
  20513. * Specifies if material alpha testing should be turned on for the mesh
  20514. * @param mesh defines the mesh to check
  20515. */
  20516. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20517. /**
  20518. * Processes to execute after binding the material to a mesh
  20519. * @param mesh defines the rendered mesh
  20520. */
  20521. protected _afterBind(mesh?: Mesh): void;
  20522. /**
  20523. * Unbinds the material from the mesh
  20524. */
  20525. unbind(): void;
  20526. /**
  20527. * Gets the active textures from the material
  20528. * @returns an array of textures
  20529. */
  20530. getActiveTextures(): BaseTexture[];
  20531. /**
  20532. * Specifies if the material uses a texture
  20533. * @param texture defines the texture to check against the material
  20534. * @returns a boolean specifying if the material uses the texture
  20535. */
  20536. hasTexture(texture: BaseTexture): boolean;
  20537. /**
  20538. * Makes a duplicate of the material, and gives it a new name
  20539. * @param name defines the new name for the duplicated material
  20540. * @returns the cloned material
  20541. */
  20542. clone(name: string): Nullable<Material>;
  20543. /**
  20544. * Gets the meshes bound to the material
  20545. * @returns an array of meshes bound to the material
  20546. */
  20547. getBindedMeshes(): AbstractMesh[];
  20548. /**
  20549. * Force shader compilation
  20550. * @param mesh defines the mesh associated with this material
  20551. * @param onCompiled defines a function to execute once the material is compiled
  20552. * @param options defines the options to configure the compilation
  20553. * @param onError defines a function to execute if the material fails compiling
  20554. */
  20555. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20556. clipPlane: boolean;
  20557. }>, onError?: (reason: string) => void): void;
  20558. /**
  20559. * Force shader compilation
  20560. * @param mesh defines the mesh that will use this material
  20561. * @param options defines additional options for compiling the shaders
  20562. * @returns a promise that resolves when the compilation completes
  20563. */
  20564. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20565. clipPlane: boolean;
  20566. }>): Promise<void>;
  20567. private static readonly _AllDirtyCallBack;
  20568. private static readonly _ImageProcessingDirtyCallBack;
  20569. private static readonly _TextureDirtyCallBack;
  20570. private static readonly _FresnelDirtyCallBack;
  20571. private static readonly _MiscDirtyCallBack;
  20572. private static readonly _LightsDirtyCallBack;
  20573. private static readonly _AttributeDirtyCallBack;
  20574. private static _FresnelAndMiscDirtyCallBack;
  20575. private static _TextureAndMiscDirtyCallBack;
  20576. private static readonly _DirtyCallbackArray;
  20577. private static readonly _RunDirtyCallBacks;
  20578. /**
  20579. * Marks a define in the material to indicate that it needs to be re-computed
  20580. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20581. */
  20582. markAsDirty(flag: number): void;
  20583. /**
  20584. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20585. * @param func defines a function which checks material defines against the submeshes
  20586. */
  20587. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20588. /**
  20589. * Indicates that we need to re-calculated for all submeshes
  20590. */
  20591. protected _markAllSubMeshesAsAllDirty(): void;
  20592. /**
  20593. * Indicates that image processing needs to be re-calculated for all submeshes
  20594. */
  20595. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20596. /**
  20597. * Indicates that textures need to be re-calculated for all submeshes
  20598. */
  20599. protected _markAllSubMeshesAsTexturesDirty(): void;
  20600. /**
  20601. * Indicates that fresnel needs to be re-calculated for all submeshes
  20602. */
  20603. protected _markAllSubMeshesAsFresnelDirty(): void;
  20604. /**
  20605. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20606. */
  20607. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20608. /**
  20609. * Indicates that lights need to be re-calculated for all submeshes
  20610. */
  20611. protected _markAllSubMeshesAsLightsDirty(): void;
  20612. /**
  20613. * Indicates that attributes need to be re-calculated for all submeshes
  20614. */
  20615. protected _markAllSubMeshesAsAttributesDirty(): void;
  20616. /**
  20617. * Indicates that misc needs to be re-calculated for all submeshes
  20618. */
  20619. protected _markAllSubMeshesAsMiscDirty(): void;
  20620. /**
  20621. * Indicates that textures and misc need to be re-calculated for all submeshes
  20622. */
  20623. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20624. /**
  20625. * Disposes the material
  20626. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20627. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20628. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20629. */
  20630. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20631. /** @hidden */
  20632. private releaseVertexArrayObject;
  20633. /**
  20634. * Serializes this material
  20635. * @returns the serialized material object
  20636. */
  20637. serialize(): any;
  20638. /**
  20639. * Creates a material from parsed material data
  20640. * @param parsedMaterial defines parsed material data
  20641. * @param scene defines the hosting scene
  20642. * @param rootUrl defines the root URL to use to load textures
  20643. * @returns a new material
  20644. */
  20645. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20646. }
  20647. }
  20648. declare module BABYLON {
  20649. /**
  20650. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20651. * separate meshes. This can be use to improve performances.
  20652. * @see http://doc.babylonjs.com/how_to/multi_materials
  20653. */
  20654. export class MultiMaterial extends Material {
  20655. private _subMaterials;
  20656. /**
  20657. * Gets or Sets the list of Materials used within the multi material.
  20658. * They need to be ordered according to the submeshes order in the associated mesh
  20659. */
  20660. subMaterials: Nullable<Material>[];
  20661. /**
  20662. * Function used to align with Node.getChildren()
  20663. * @returns the list of Materials used within the multi material
  20664. */
  20665. getChildren(): Nullable<Material>[];
  20666. /**
  20667. * Instantiates a new Multi Material
  20668. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20669. * separate meshes. This can be use to improve performances.
  20670. * @see http://doc.babylonjs.com/how_to/multi_materials
  20671. * @param name Define the name in the scene
  20672. * @param scene Define the scene the material belongs to
  20673. */
  20674. constructor(name: string, scene: Scene);
  20675. private _hookArray;
  20676. /**
  20677. * Get one of the submaterial by its index in the submaterials array
  20678. * @param index The index to look the sub material at
  20679. * @returns The Material if the index has been defined
  20680. */
  20681. getSubMaterial(index: number): Nullable<Material>;
  20682. /**
  20683. * Get the list of active textures for the whole sub materials list.
  20684. * @returns All the textures that will be used during the rendering
  20685. */
  20686. getActiveTextures(): BaseTexture[];
  20687. /**
  20688. * Gets the current class name of the material e.g. "MultiMaterial"
  20689. * Mainly use in serialization.
  20690. * @returns the class name
  20691. */
  20692. getClassName(): string;
  20693. /**
  20694. * Checks if the material is ready to render the requested sub mesh
  20695. * @param mesh Define the mesh the submesh belongs to
  20696. * @param subMesh Define the sub mesh to look readyness for
  20697. * @param useInstances Define whether or not the material is used with instances
  20698. * @returns true if ready, otherwise false
  20699. */
  20700. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20701. /**
  20702. * Clones the current material and its related sub materials
  20703. * @param name Define the name of the newly cloned material
  20704. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20705. * @returns the cloned material
  20706. */
  20707. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20708. /**
  20709. * Serializes the materials into a JSON representation.
  20710. * @returns the JSON representation
  20711. */
  20712. serialize(): any;
  20713. /**
  20714. * Dispose the material and release its associated resources
  20715. * @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)
  20716. * @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)
  20717. * @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)
  20718. */
  20719. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20720. /**
  20721. * Creates a MultiMaterial from parsed MultiMaterial data.
  20722. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20723. * @param scene defines the hosting scene
  20724. * @returns a new MultiMaterial
  20725. */
  20726. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20727. }
  20728. }
  20729. declare module BABYLON {
  20730. /**
  20731. * Base class for submeshes
  20732. */
  20733. export class BaseSubMesh {
  20734. /** @hidden */
  20735. _materialDefines: Nullable<MaterialDefines>;
  20736. /** @hidden */
  20737. _materialEffect: Nullable<Effect>;
  20738. /**
  20739. * Gets associated effect
  20740. */
  20741. readonly effect: Nullable<Effect>;
  20742. /**
  20743. * Sets associated effect (effect used to render this submesh)
  20744. * @param effect defines the effect to associate with
  20745. * @param defines defines the set of defines used to compile this effect
  20746. */
  20747. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20748. }
  20749. /**
  20750. * Defines a subdivision inside a mesh
  20751. */
  20752. export class SubMesh extends BaseSubMesh implements ICullable {
  20753. /** the material index to use */
  20754. materialIndex: number;
  20755. /** vertex index start */
  20756. verticesStart: number;
  20757. /** vertices count */
  20758. verticesCount: number;
  20759. /** index start */
  20760. indexStart: number;
  20761. /** indices count */
  20762. indexCount: number;
  20763. /** @hidden */
  20764. _linesIndexCount: number;
  20765. private _mesh;
  20766. private _renderingMesh;
  20767. private _boundingInfo;
  20768. private _linesIndexBuffer;
  20769. /** @hidden */
  20770. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20771. /** @hidden */
  20772. _trianglePlanes: Plane[];
  20773. /** @hidden */
  20774. _lastColliderTransformMatrix: Nullable<Matrix>;
  20775. /** @hidden */
  20776. _renderId: number;
  20777. /** @hidden */
  20778. _alphaIndex: number;
  20779. /** @hidden */
  20780. _distanceToCamera: number;
  20781. /** @hidden */
  20782. _id: number;
  20783. private _currentMaterial;
  20784. /**
  20785. * Add a new submesh to a mesh
  20786. * @param materialIndex defines the material index to use
  20787. * @param verticesStart defines vertex index start
  20788. * @param verticesCount defines vertices count
  20789. * @param indexStart defines index start
  20790. * @param indexCount defines indices count
  20791. * @param mesh defines the parent mesh
  20792. * @param renderingMesh defines an optional rendering mesh
  20793. * @param createBoundingBox defines if bounding box should be created for this submesh
  20794. * @returns the new submesh
  20795. */
  20796. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20797. /**
  20798. * Creates a new submesh
  20799. * @param materialIndex defines the material index to use
  20800. * @param verticesStart defines vertex index start
  20801. * @param verticesCount defines vertices count
  20802. * @param indexStart defines index start
  20803. * @param indexCount defines indices count
  20804. * @param mesh defines the parent mesh
  20805. * @param renderingMesh defines an optional rendering mesh
  20806. * @param createBoundingBox defines if bounding box should be created for this submesh
  20807. */
  20808. constructor(
  20809. /** the material index to use */
  20810. materialIndex: number,
  20811. /** vertex index start */
  20812. verticesStart: number,
  20813. /** vertices count */
  20814. verticesCount: number,
  20815. /** index start */
  20816. indexStart: number,
  20817. /** indices count */
  20818. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20819. /**
  20820. * Returns true if this submesh covers the entire parent mesh
  20821. * @ignorenaming
  20822. */
  20823. readonly IsGlobal: boolean;
  20824. /**
  20825. * Returns the submesh BoudingInfo object
  20826. * @returns current bounding info (or mesh's one if the submesh is global)
  20827. */
  20828. getBoundingInfo(): BoundingInfo;
  20829. /**
  20830. * Sets the submesh BoundingInfo
  20831. * @param boundingInfo defines the new bounding info to use
  20832. * @returns the SubMesh
  20833. */
  20834. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20835. /**
  20836. * Returns the mesh of the current submesh
  20837. * @return the parent mesh
  20838. */
  20839. getMesh(): AbstractMesh;
  20840. /**
  20841. * Returns the rendering mesh of the submesh
  20842. * @returns the rendering mesh (could be different from parent mesh)
  20843. */
  20844. getRenderingMesh(): Mesh;
  20845. /**
  20846. * Returns the submesh material
  20847. * @returns null or the current material
  20848. */
  20849. getMaterial(): Nullable<Material>;
  20850. /**
  20851. * Sets a new updated BoundingInfo object to the submesh
  20852. * @param data defines an optional position array to use to determine the bounding info
  20853. * @returns the SubMesh
  20854. */
  20855. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20856. /** @hidden */
  20857. _checkCollision(collider: Collider): boolean;
  20858. /**
  20859. * Updates the submesh BoundingInfo
  20860. * @param world defines the world matrix to use to update the bounding info
  20861. * @returns the submesh
  20862. */
  20863. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20864. /**
  20865. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20866. * @param frustumPlanes defines the frustum planes
  20867. * @returns true if the submesh is intersecting with the frustum
  20868. */
  20869. isInFrustum(frustumPlanes: Plane[]): boolean;
  20870. /**
  20871. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20872. * @param frustumPlanes defines the frustum planes
  20873. * @returns true if the submesh is inside the frustum
  20874. */
  20875. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20876. /**
  20877. * Renders the submesh
  20878. * @param enableAlphaMode defines if alpha needs to be used
  20879. * @returns the submesh
  20880. */
  20881. render(enableAlphaMode: boolean): SubMesh;
  20882. /**
  20883. * @hidden
  20884. */
  20885. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20886. /**
  20887. * Checks if the submesh intersects with a ray
  20888. * @param ray defines the ray to test
  20889. * @returns true is the passed ray intersects the submesh bounding box
  20890. */
  20891. canIntersects(ray: Ray): boolean;
  20892. /**
  20893. * Intersects current submesh with a ray
  20894. * @param ray defines the ray to test
  20895. * @param positions defines mesh's positions array
  20896. * @param indices defines mesh's indices array
  20897. * @param fastCheck defines if only bounding info should be used
  20898. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20899. * @returns intersection info or null if no intersection
  20900. */
  20901. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20902. /** @hidden */
  20903. private _intersectLines;
  20904. /** @hidden */
  20905. private _intersectUnIndexedLines;
  20906. /** @hidden */
  20907. private _intersectTriangles;
  20908. /** @hidden */
  20909. private _intersectUnIndexedTriangles;
  20910. /** @hidden */
  20911. _rebuild(): void;
  20912. /**
  20913. * Creates a new submesh from the passed mesh
  20914. * @param newMesh defines the new hosting mesh
  20915. * @param newRenderingMesh defines an optional rendering mesh
  20916. * @returns the new submesh
  20917. */
  20918. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20919. /**
  20920. * Release associated resources
  20921. */
  20922. dispose(): void;
  20923. /**
  20924. * Gets the class name
  20925. * @returns the string "SubMesh".
  20926. */
  20927. getClassName(): string;
  20928. /**
  20929. * Creates a new submesh from indices data
  20930. * @param materialIndex the index of the main mesh material
  20931. * @param startIndex the index where to start the copy in the mesh indices array
  20932. * @param indexCount the number of indices to copy then from the startIndex
  20933. * @param mesh the main mesh to create the submesh from
  20934. * @param renderingMesh the optional rendering mesh
  20935. * @returns a new submesh
  20936. */
  20937. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20938. }
  20939. }
  20940. declare module BABYLON {
  20941. /**
  20942. * Class used to represent data loading progression
  20943. */
  20944. export class SceneLoaderFlags {
  20945. private static _ForceFullSceneLoadingForIncremental;
  20946. private static _ShowLoadingScreen;
  20947. private static _CleanBoneMatrixWeights;
  20948. private static _loggingLevel;
  20949. /**
  20950. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20951. */
  20952. static ForceFullSceneLoadingForIncremental: boolean;
  20953. /**
  20954. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20955. */
  20956. static ShowLoadingScreen: boolean;
  20957. /**
  20958. * Defines the current logging level (while loading the scene)
  20959. * @ignorenaming
  20960. */
  20961. static loggingLevel: number;
  20962. /**
  20963. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20964. */
  20965. static CleanBoneMatrixWeights: boolean;
  20966. }
  20967. }
  20968. declare module BABYLON {
  20969. /**
  20970. * Class used to store geometry data (vertex buffers + index buffer)
  20971. */
  20972. export class Geometry implements IGetSetVerticesData {
  20973. /**
  20974. * Gets or sets the ID of the geometry
  20975. */
  20976. id: string;
  20977. /**
  20978. * Gets or sets the unique ID of the geometry
  20979. */
  20980. uniqueId: number;
  20981. /**
  20982. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20983. */
  20984. delayLoadState: number;
  20985. /**
  20986. * Gets the file containing the data to load when running in delay load state
  20987. */
  20988. delayLoadingFile: Nullable<string>;
  20989. /**
  20990. * Callback called when the geometry is updated
  20991. */
  20992. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20993. private _scene;
  20994. private _engine;
  20995. private _meshes;
  20996. private _totalVertices;
  20997. /** @hidden */
  20998. _indices: IndicesArray;
  20999. /** @hidden */
  21000. _vertexBuffers: {
  21001. [key: string]: VertexBuffer;
  21002. };
  21003. private _isDisposed;
  21004. private _extend;
  21005. private _boundingBias;
  21006. /** @hidden */
  21007. _delayInfo: Array<string>;
  21008. private _indexBuffer;
  21009. private _indexBufferIsUpdatable;
  21010. /** @hidden */
  21011. _boundingInfo: Nullable<BoundingInfo>;
  21012. /** @hidden */
  21013. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21014. /** @hidden */
  21015. _softwareSkinningFrameId: number;
  21016. private _vertexArrayObjects;
  21017. private _updatable;
  21018. /** @hidden */
  21019. _positions: Nullable<Vector3[]>;
  21020. /**
  21021. * 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
  21022. */
  21023. /**
  21024. * 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
  21025. */
  21026. boundingBias: Vector2;
  21027. /**
  21028. * Static function used to attach a new empty geometry to a mesh
  21029. * @param mesh defines the mesh to attach the geometry to
  21030. * @returns the new Geometry
  21031. */
  21032. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21033. /**
  21034. * Creates a new geometry
  21035. * @param id defines the unique ID
  21036. * @param scene defines the hosting scene
  21037. * @param vertexData defines the VertexData used to get geometry data
  21038. * @param updatable defines if geometry must be updatable (false by default)
  21039. * @param mesh defines the mesh that will be associated with the geometry
  21040. */
  21041. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21042. /**
  21043. * Gets the current extend of the geometry
  21044. */
  21045. readonly extend: {
  21046. minimum: Vector3;
  21047. maximum: Vector3;
  21048. };
  21049. /**
  21050. * Gets the hosting scene
  21051. * @returns the hosting Scene
  21052. */
  21053. getScene(): Scene;
  21054. /**
  21055. * Gets the hosting engine
  21056. * @returns the hosting Engine
  21057. */
  21058. getEngine(): Engine;
  21059. /**
  21060. * Defines if the geometry is ready to use
  21061. * @returns true if the geometry is ready to be used
  21062. */
  21063. isReady(): boolean;
  21064. /**
  21065. * Gets a value indicating that the geometry should not be serialized
  21066. */
  21067. readonly doNotSerialize: boolean;
  21068. /** @hidden */
  21069. _rebuild(): void;
  21070. /**
  21071. * Affects all geometry data in one call
  21072. * @param vertexData defines the geometry data
  21073. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21074. */
  21075. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21076. /**
  21077. * Set specific vertex data
  21078. * @param kind defines the data kind (Position, normal, etc...)
  21079. * @param data defines the vertex data to use
  21080. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21081. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21082. */
  21083. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21084. /**
  21085. * Removes a specific vertex data
  21086. * @param kind defines the data kind (Position, normal, etc...)
  21087. */
  21088. removeVerticesData(kind: string): void;
  21089. /**
  21090. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21091. * @param buffer defines the vertex buffer to use
  21092. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21093. */
  21094. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21095. /**
  21096. * Update a specific vertex buffer
  21097. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21098. * It will do nothing if the buffer is not updatable
  21099. * @param kind defines the data kind (Position, normal, etc...)
  21100. * @param data defines the data to use
  21101. * @param offset defines the offset in the target buffer where to store the data
  21102. * @param useBytes set to true if the offset is in bytes
  21103. */
  21104. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21105. /**
  21106. * Update a specific vertex buffer
  21107. * This function will create a new buffer if the current one is not updatable
  21108. * @param kind defines the data kind (Position, normal, etc...)
  21109. * @param data defines the data to use
  21110. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21111. */
  21112. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21113. private _updateBoundingInfo;
  21114. /** @hidden */
  21115. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21116. /**
  21117. * Gets total number of vertices
  21118. * @returns the total number of vertices
  21119. */
  21120. getTotalVertices(): number;
  21121. /**
  21122. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21123. * @param kind defines the data kind (Position, normal, etc...)
  21124. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21125. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21126. * @returns a float array containing vertex data
  21127. */
  21128. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21129. /**
  21130. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21131. * @param kind defines the data kind (Position, normal, etc...)
  21132. * @returns true if the vertex buffer with the specified kind is updatable
  21133. */
  21134. isVertexBufferUpdatable(kind: string): boolean;
  21135. /**
  21136. * Gets a specific vertex buffer
  21137. * @param kind defines the data kind (Position, normal, etc...)
  21138. * @returns a VertexBuffer
  21139. */
  21140. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21141. /**
  21142. * Returns all vertex buffers
  21143. * @return an object holding all vertex buffers indexed by kind
  21144. */
  21145. getVertexBuffers(): Nullable<{
  21146. [key: string]: VertexBuffer;
  21147. }>;
  21148. /**
  21149. * Gets a boolean indicating if specific vertex buffer is present
  21150. * @param kind defines the data kind (Position, normal, etc...)
  21151. * @returns true if data is present
  21152. */
  21153. isVerticesDataPresent(kind: string): boolean;
  21154. /**
  21155. * Gets a list of all attached data kinds (Position, normal, etc...)
  21156. * @returns a list of string containing all kinds
  21157. */
  21158. getVerticesDataKinds(): string[];
  21159. /**
  21160. * Update index buffer
  21161. * @param indices defines the indices to store in the index buffer
  21162. * @param offset defines the offset in the target buffer where to store the data
  21163. * @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)
  21164. */
  21165. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21166. /**
  21167. * Creates a new index buffer
  21168. * @param indices defines the indices to store in the index buffer
  21169. * @param totalVertices defines the total number of vertices (could be null)
  21170. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21171. */
  21172. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21173. /**
  21174. * Return the total number of indices
  21175. * @returns the total number of indices
  21176. */
  21177. getTotalIndices(): number;
  21178. /**
  21179. * Gets the index buffer array
  21180. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21181. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21182. * @returns the index buffer array
  21183. */
  21184. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21185. /**
  21186. * Gets the index buffer
  21187. * @return the index buffer
  21188. */
  21189. getIndexBuffer(): Nullable<DataBuffer>;
  21190. /** @hidden */
  21191. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21192. /**
  21193. * Release the associated resources for a specific mesh
  21194. * @param mesh defines the source mesh
  21195. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21196. */
  21197. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21198. /**
  21199. * Apply current geometry to a given mesh
  21200. * @param mesh defines the mesh to apply geometry to
  21201. */
  21202. applyToMesh(mesh: Mesh): void;
  21203. private _updateExtend;
  21204. private _applyToMesh;
  21205. private notifyUpdate;
  21206. /**
  21207. * Load the geometry if it was flagged as delay loaded
  21208. * @param scene defines the hosting scene
  21209. * @param onLoaded defines a callback called when the geometry is loaded
  21210. */
  21211. load(scene: Scene, onLoaded?: () => void): void;
  21212. private _queueLoad;
  21213. /**
  21214. * Invert the geometry to move from a right handed system to a left handed one.
  21215. */
  21216. toLeftHanded(): void;
  21217. /** @hidden */
  21218. _resetPointsArrayCache(): void;
  21219. /** @hidden */
  21220. _generatePointsArray(): boolean;
  21221. /**
  21222. * Gets a value indicating if the geometry is disposed
  21223. * @returns true if the geometry was disposed
  21224. */
  21225. isDisposed(): boolean;
  21226. private _disposeVertexArrayObjects;
  21227. /**
  21228. * Free all associated resources
  21229. */
  21230. dispose(): void;
  21231. /**
  21232. * Clone the current geometry into a new geometry
  21233. * @param id defines the unique ID of the new geometry
  21234. * @returns a new geometry object
  21235. */
  21236. copy(id: string): Geometry;
  21237. /**
  21238. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21239. * @return a JSON representation of the current geometry data (without the vertices data)
  21240. */
  21241. serialize(): any;
  21242. private toNumberArray;
  21243. /**
  21244. * Serialize all vertices data into a JSON oject
  21245. * @returns a JSON representation of the current geometry data
  21246. */
  21247. serializeVerticeData(): any;
  21248. /**
  21249. * Extracts a clone of a mesh geometry
  21250. * @param mesh defines the source mesh
  21251. * @param id defines the unique ID of the new geometry object
  21252. * @returns the new geometry object
  21253. */
  21254. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21255. /**
  21256. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21257. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21258. * Be aware Math.random() could cause collisions, but:
  21259. * "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"
  21260. * @returns a string containing a new GUID
  21261. */
  21262. static RandomId(): string;
  21263. /** @hidden */
  21264. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21265. private static _CleanMatricesWeights;
  21266. /**
  21267. * Create a new geometry from persisted data (Using .babylon file format)
  21268. * @param parsedVertexData defines the persisted data
  21269. * @param scene defines the hosting scene
  21270. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21271. * @returns the new geometry object
  21272. */
  21273. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21274. }
  21275. }
  21276. declare module BABYLON {
  21277. /**
  21278. * Define an interface for all classes that will get and set the data on vertices
  21279. */
  21280. export interface IGetSetVerticesData {
  21281. /**
  21282. * Gets a boolean indicating if specific vertex data is present
  21283. * @param kind defines the vertex data kind to use
  21284. * @returns true is data kind is present
  21285. */
  21286. isVerticesDataPresent(kind: string): boolean;
  21287. /**
  21288. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21289. * @param kind defines the data kind (Position, normal, etc...)
  21290. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21291. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21292. * @returns a float array containing vertex data
  21293. */
  21294. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21295. /**
  21296. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21297. * @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.
  21298. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21299. * @returns the indices array or an empty array if the mesh has no geometry
  21300. */
  21301. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21302. /**
  21303. * Set specific vertex data
  21304. * @param kind defines the data kind (Position, normal, etc...)
  21305. * @param data defines the vertex data to use
  21306. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21307. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21308. */
  21309. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21310. /**
  21311. * Update a specific associated vertex buffer
  21312. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21313. * - VertexBuffer.PositionKind
  21314. * - VertexBuffer.UVKind
  21315. * - VertexBuffer.UV2Kind
  21316. * - VertexBuffer.UV3Kind
  21317. * - VertexBuffer.UV4Kind
  21318. * - VertexBuffer.UV5Kind
  21319. * - VertexBuffer.UV6Kind
  21320. * - VertexBuffer.ColorKind
  21321. * - VertexBuffer.MatricesIndicesKind
  21322. * - VertexBuffer.MatricesIndicesExtraKind
  21323. * - VertexBuffer.MatricesWeightsKind
  21324. * - VertexBuffer.MatricesWeightsExtraKind
  21325. * @param data defines the data source
  21326. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21327. * @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)
  21328. */
  21329. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21330. /**
  21331. * Creates a new index buffer
  21332. * @param indices defines the indices to store in the index buffer
  21333. * @param totalVertices defines the total number of vertices (could be null)
  21334. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21335. */
  21336. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21337. }
  21338. /**
  21339. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21340. */
  21341. export class VertexData {
  21342. /**
  21343. * Mesh side orientation : usually the external or front surface
  21344. */
  21345. static readonly FRONTSIDE: number;
  21346. /**
  21347. * Mesh side orientation : usually the internal or back surface
  21348. */
  21349. static readonly BACKSIDE: number;
  21350. /**
  21351. * Mesh side orientation : both internal and external or front and back surfaces
  21352. */
  21353. static readonly DOUBLESIDE: number;
  21354. /**
  21355. * Mesh side orientation : by default, `FRONTSIDE`
  21356. */
  21357. static readonly DEFAULTSIDE: number;
  21358. /**
  21359. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21360. */
  21361. positions: Nullable<FloatArray>;
  21362. /**
  21363. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21364. */
  21365. normals: Nullable<FloatArray>;
  21366. /**
  21367. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21368. */
  21369. tangents: Nullable<FloatArray>;
  21370. /**
  21371. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21372. */
  21373. uvs: Nullable<FloatArray>;
  21374. /**
  21375. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21376. */
  21377. uvs2: Nullable<FloatArray>;
  21378. /**
  21379. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21380. */
  21381. uvs3: Nullable<FloatArray>;
  21382. /**
  21383. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21384. */
  21385. uvs4: Nullable<FloatArray>;
  21386. /**
  21387. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21388. */
  21389. uvs5: Nullable<FloatArray>;
  21390. /**
  21391. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21392. */
  21393. uvs6: Nullable<FloatArray>;
  21394. /**
  21395. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21396. */
  21397. colors: Nullable<FloatArray>;
  21398. /**
  21399. * 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).
  21400. */
  21401. matricesIndices: Nullable<FloatArray>;
  21402. /**
  21403. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21404. */
  21405. matricesWeights: Nullable<FloatArray>;
  21406. /**
  21407. * An array extending the number of possible indices
  21408. */
  21409. matricesIndicesExtra: Nullable<FloatArray>;
  21410. /**
  21411. * An array extending the number of possible weights when the number of indices is extended
  21412. */
  21413. matricesWeightsExtra: Nullable<FloatArray>;
  21414. /**
  21415. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21416. */
  21417. indices: Nullable<IndicesArray>;
  21418. /**
  21419. * Uses the passed data array to set the set the values for the specified kind of data
  21420. * @param data a linear array of floating numbers
  21421. * @param kind the type of data that is being set, eg positions, colors etc
  21422. */
  21423. set(data: FloatArray, kind: string): void;
  21424. /**
  21425. * Associates the vertexData to the passed Mesh.
  21426. * Sets it as updatable or not (default `false`)
  21427. * @param mesh the mesh the vertexData is applied to
  21428. * @param updatable when used and having the value true allows new data to update the vertexData
  21429. * @returns the VertexData
  21430. */
  21431. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21432. /**
  21433. * Associates the vertexData to the passed Geometry.
  21434. * Sets it as updatable or not (default `false`)
  21435. * @param geometry the geometry the vertexData is applied to
  21436. * @param updatable when used and having the value true allows new data to update the vertexData
  21437. * @returns VertexData
  21438. */
  21439. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21440. /**
  21441. * Updates the associated mesh
  21442. * @param mesh the mesh to be updated
  21443. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21444. * @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
  21445. * @returns VertexData
  21446. */
  21447. updateMesh(mesh: Mesh): VertexData;
  21448. /**
  21449. * Updates the associated geometry
  21450. * @param geometry the geometry to be updated
  21451. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21452. * @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
  21453. * @returns VertexData.
  21454. */
  21455. updateGeometry(geometry: Geometry): VertexData;
  21456. private _applyTo;
  21457. private _update;
  21458. /**
  21459. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21460. * @param matrix the transforming matrix
  21461. * @returns the VertexData
  21462. */
  21463. transform(matrix: Matrix): VertexData;
  21464. /**
  21465. * Merges the passed VertexData into the current one
  21466. * @param other the VertexData to be merged into the current one
  21467. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21468. * @returns the modified VertexData
  21469. */
  21470. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21471. private _mergeElement;
  21472. private _validate;
  21473. /**
  21474. * Serializes the VertexData
  21475. * @returns a serialized object
  21476. */
  21477. serialize(): any;
  21478. /**
  21479. * Extracts the vertexData from a mesh
  21480. * @param mesh the mesh from which to extract the VertexData
  21481. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21482. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21483. * @returns the object VertexData associated to the passed mesh
  21484. */
  21485. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21486. /**
  21487. * Extracts the vertexData from the geometry
  21488. * @param geometry the geometry from which to extract the VertexData
  21489. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21490. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21491. * @returns the object VertexData associated to the passed mesh
  21492. */
  21493. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21494. private static _ExtractFrom;
  21495. /**
  21496. * Creates the VertexData for a Ribbon
  21497. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21498. * * pathArray array of paths, each of which an array of successive Vector3
  21499. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21500. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21501. * * 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
  21502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21503. * * 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)
  21504. * * 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)
  21505. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21506. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21507. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21508. * @returns the VertexData of the ribbon
  21509. */
  21510. static CreateRibbon(options: {
  21511. pathArray: Vector3[][];
  21512. closeArray?: boolean;
  21513. closePath?: boolean;
  21514. offset?: number;
  21515. sideOrientation?: number;
  21516. frontUVs?: Vector4;
  21517. backUVs?: Vector4;
  21518. invertUV?: boolean;
  21519. uvs?: Vector2[];
  21520. colors?: Color4[];
  21521. }): VertexData;
  21522. /**
  21523. * Creates the VertexData for a box
  21524. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21525. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21526. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21527. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21528. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21529. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21530. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21531. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21532. * * 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)
  21533. * * 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)
  21534. * @returns the VertexData of the box
  21535. */
  21536. static CreateBox(options: {
  21537. size?: number;
  21538. width?: number;
  21539. height?: number;
  21540. depth?: number;
  21541. faceUV?: Vector4[];
  21542. faceColors?: Color4[];
  21543. sideOrientation?: number;
  21544. frontUVs?: Vector4;
  21545. backUVs?: Vector4;
  21546. }): VertexData;
  21547. /**
  21548. * Creates the VertexData for a tiled box
  21549. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21550. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21551. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21552. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21553. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21554. * @returns the VertexData of the box
  21555. */
  21556. static CreateTiledBox(options: {
  21557. pattern?: number;
  21558. width?: number;
  21559. height?: number;
  21560. depth?: number;
  21561. tileSize?: number;
  21562. tileWidth?: number;
  21563. tileHeight?: number;
  21564. alignHorizontal?: number;
  21565. alignVertical?: number;
  21566. faceUV?: Vector4[];
  21567. faceColors?: Color4[];
  21568. sideOrientation?: number;
  21569. }): VertexData;
  21570. /**
  21571. * Creates the VertexData for a tiled plane
  21572. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21573. * * pattern a limited pattern arrangement depending on the number
  21574. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21575. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21576. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21577. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21578. * * 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)
  21579. * * 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)
  21580. * @returns the VertexData of the tiled plane
  21581. */
  21582. static CreateTiledPlane(options: {
  21583. pattern?: number;
  21584. tileSize?: number;
  21585. tileWidth?: number;
  21586. tileHeight?: number;
  21587. size?: number;
  21588. width?: number;
  21589. height?: number;
  21590. alignHorizontal?: number;
  21591. alignVertical?: number;
  21592. sideOrientation?: number;
  21593. frontUVs?: Vector4;
  21594. backUVs?: Vector4;
  21595. }): VertexData;
  21596. /**
  21597. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21598. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21599. * * segments sets the number of horizontal strips optional, default 32
  21600. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21601. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21602. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21603. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21604. * * 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
  21605. * * 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
  21606. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21607. * * 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)
  21608. * * 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)
  21609. * @returns the VertexData of the ellipsoid
  21610. */
  21611. static CreateSphere(options: {
  21612. segments?: number;
  21613. diameter?: number;
  21614. diameterX?: number;
  21615. diameterY?: number;
  21616. diameterZ?: number;
  21617. arc?: number;
  21618. slice?: number;
  21619. sideOrientation?: number;
  21620. frontUVs?: Vector4;
  21621. backUVs?: Vector4;
  21622. }): VertexData;
  21623. /**
  21624. * Creates the VertexData for a cylinder, cone or prism
  21625. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21626. * * height sets the height (y direction) of the cylinder, optional, default 2
  21627. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21628. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21629. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21630. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21631. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21632. * * 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
  21633. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21634. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21635. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21636. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21637. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21638. * * 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)
  21639. * * 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)
  21640. * @returns the VertexData of the cylinder, cone or prism
  21641. */
  21642. static CreateCylinder(options: {
  21643. height?: number;
  21644. diameterTop?: number;
  21645. diameterBottom?: number;
  21646. diameter?: number;
  21647. tessellation?: number;
  21648. subdivisions?: number;
  21649. arc?: number;
  21650. faceColors?: Color4[];
  21651. faceUV?: Vector4[];
  21652. hasRings?: boolean;
  21653. enclose?: boolean;
  21654. sideOrientation?: number;
  21655. frontUVs?: Vector4;
  21656. backUVs?: Vector4;
  21657. }): VertexData;
  21658. /**
  21659. * Creates the VertexData for a torus
  21660. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21661. * * diameter the diameter of the torus, optional default 1
  21662. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21663. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21665. * * 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)
  21666. * * 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)
  21667. * @returns the VertexData of the torus
  21668. */
  21669. static CreateTorus(options: {
  21670. diameter?: number;
  21671. thickness?: number;
  21672. tessellation?: number;
  21673. sideOrientation?: number;
  21674. frontUVs?: Vector4;
  21675. backUVs?: Vector4;
  21676. }): VertexData;
  21677. /**
  21678. * Creates the VertexData of the LineSystem
  21679. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21680. * - lines an array of lines, each line being an array of successive Vector3
  21681. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21682. * @returns the VertexData of the LineSystem
  21683. */
  21684. static CreateLineSystem(options: {
  21685. lines: Vector3[][];
  21686. colors?: Nullable<Color4[][]>;
  21687. }): VertexData;
  21688. /**
  21689. * Create the VertexData for a DashedLines
  21690. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21691. * - points an array successive Vector3
  21692. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21693. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21694. * - dashNb the intended total number of dashes, optional, default 200
  21695. * @returns the VertexData for the DashedLines
  21696. */
  21697. static CreateDashedLines(options: {
  21698. points: Vector3[];
  21699. dashSize?: number;
  21700. gapSize?: number;
  21701. dashNb?: number;
  21702. }): VertexData;
  21703. /**
  21704. * Creates the VertexData for a Ground
  21705. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21706. * - width the width (x direction) of the ground, optional, default 1
  21707. * - height the height (z direction) of the ground, optional, default 1
  21708. * - subdivisions the number of subdivisions per side, optional, default 1
  21709. * @returns the VertexData of the Ground
  21710. */
  21711. static CreateGround(options: {
  21712. width?: number;
  21713. height?: number;
  21714. subdivisions?: number;
  21715. subdivisionsX?: number;
  21716. subdivisionsY?: number;
  21717. }): VertexData;
  21718. /**
  21719. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21720. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21721. * * xmin the ground minimum X coordinate, optional, default -1
  21722. * * zmin the ground minimum Z coordinate, optional, default -1
  21723. * * xmax the ground maximum X coordinate, optional, default 1
  21724. * * zmax the ground maximum Z coordinate, optional, default 1
  21725. * * 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}
  21726. * * 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}
  21727. * @returns the VertexData of the TiledGround
  21728. */
  21729. static CreateTiledGround(options: {
  21730. xmin: number;
  21731. zmin: number;
  21732. xmax: number;
  21733. zmax: number;
  21734. subdivisions?: {
  21735. w: number;
  21736. h: number;
  21737. };
  21738. precision?: {
  21739. w: number;
  21740. h: number;
  21741. };
  21742. }): VertexData;
  21743. /**
  21744. * Creates the VertexData of the Ground designed from a heightmap
  21745. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21746. * * width the width (x direction) of the ground
  21747. * * height the height (z direction) of the ground
  21748. * * subdivisions the number of subdivisions per side
  21749. * * minHeight the minimum altitude on the ground, optional, default 0
  21750. * * maxHeight the maximum altitude on the ground, optional default 1
  21751. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21752. * * buffer the array holding the image color data
  21753. * * bufferWidth the width of image
  21754. * * bufferHeight the height of image
  21755. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21756. * @returns the VertexData of the Ground designed from a heightmap
  21757. */
  21758. static CreateGroundFromHeightMap(options: {
  21759. width: number;
  21760. height: number;
  21761. subdivisions: number;
  21762. minHeight: number;
  21763. maxHeight: number;
  21764. colorFilter: Color3;
  21765. buffer: Uint8Array;
  21766. bufferWidth: number;
  21767. bufferHeight: number;
  21768. alphaFilter: number;
  21769. }): VertexData;
  21770. /**
  21771. * Creates the VertexData for a Plane
  21772. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21773. * * size sets the width and height of the plane to the value of size, optional default 1
  21774. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21775. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21776. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21777. * * 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)
  21778. * * 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)
  21779. * @returns the VertexData of the box
  21780. */
  21781. static CreatePlane(options: {
  21782. size?: number;
  21783. width?: number;
  21784. height?: number;
  21785. sideOrientation?: number;
  21786. frontUVs?: Vector4;
  21787. backUVs?: Vector4;
  21788. }): VertexData;
  21789. /**
  21790. * Creates the VertexData of the Disc or regular Polygon
  21791. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21792. * * radius the radius of the disc, optional default 0.5
  21793. * * tessellation the number of polygon sides, optional, default 64
  21794. * * 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
  21795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21796. * * 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)
  21797. * * 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)
  21798. * @returns the VertexData of the box
  21799. */
  21800. static CreateDisc(options: {
  21801. radius?: number;
  21802. tessellation?: number;
  21803. arc?: number;
  21804. sideOrientation?: number;
  21805. frontUVs?: Vector4;
  21806. backUVs?: Vector4;
  21807. }): VertexData;
  21808. /**
  21809. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21810. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21811. * @param polygon a mesh built from polygonTriangulation.build()
  21812. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21813. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21814. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21815. * @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)
  21816. * @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)
  21817. * @returns the VertexData of the Polygon
  21818. */
  21819. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21820. /**
  21821. * Creates the VertexData of the IcoSphere
  21822. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21823. * * radius the radius of the IcoSphere, optional default 1
  21824. * * radiusX allows stretching in the x direction, optional, default radius
  21825. * * radiusY allows stretching in the y direction, optional, default radius
  21826. * * radiusZ allows stretching in the z direction, optional, default radius
  21827. * * flat when true creates a flat shaded mesh, optional, default true
  21828. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21830. * * 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)
  21831. * * 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)
  21832. * @returns the VertexData of the IcoSphere
  21833. */
  21834. static CreateIcoSphere(options: {
  21835. radius?: number;
  21836. radiusX?: number;
  21837. radiusY?: number;
  21838. radiusZ?: number;
  21839. flat?: boolean;
  21840. subdivisions?: number;
  21841. sideOrientation?: number;
  21842. frontUVs?: Vector4;
  21843. backUVs?: Vector4;
  21844. }): VertexData;
  21845. /**
  21846. * Creates the VertexData for a Polyhedron
  21847. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21848. * * type provided types are:
  21849. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21850. * * 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)
  21851. * * size the size of the IcoSphere, optional default 1
  21852. * * sizeX allows stretching in the x direction, optional, default size
  21853. * * sizeY allows stretching in the y direction, optional, default size
  21854. * * sizeZ allows stretching in the z direction, optional, default size
  21855. * * 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
  21856. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21857. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21858. * * flat when true creates a flat shaded mesh, optional, default true
  21859. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21860. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21861. * * 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)
  21862. * * 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)
  21863. * @returns the VertexData of the Polyhedron
  21864. */
  21865. static CreatePolyhedron(options: {
  21866. type?: number;
  21867. size?: number;
  21868. sizeX?: number;
  21869. sizeY?: number;
  21870. sizeZ?: number;
  21871. custom?: any;
  21872. faceUV?: Vector4[];
  21873. faceColors?: Color4[];
  21874. flat?: boolean;
  21875. sideOrientation?: number;
  21876. frontUVs?: Vector4;
  21877. backUVs?: Vector4;
  21878. }): VertexData;
  21879. /**
  21880. * Creates the VertexData for a TorusKnot
  21881. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21882. * * radius the radius of the torus knot, optional, default 2
  21883. * * tube the thickness of the tube, optional, default 0.5
  21884. * * radialSegments the number of sides on each tube segments, optional, default 32
  21885. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21886. * * p the number of windings around the z axis, optional, default 2
  21887. * * q the number of windings around the x axis, optional, default 3
  21888. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21889. * * 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)
  21890. * * 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)
  21891. * @returns the VertexData of the Torus Knot
  21892. */
  21893. static CreateTorusKnot(options: {
  21894. radius?: number;
  21895. tube?: number;
  21896. radialSegments?: number;
  21897. tubularSegments?: number;
  21898. p?: number;
  21899. q?: number;
  21900. sideOrientation?: number;
  21901. frontUVs?: Vector4;
  21902. backUVs?: Vector4;
  21903. }): VertexData;
  21904. /**
  21905. * Compute normals for given positions and indices
  21906. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21907. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21908. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21909. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21910. * * facetNormals : optional array of facet normals (vector3)
  21911. * * facetPositions : optional array of facet positions (vector3)
  21912. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21913. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21914. * * bInfo : optional bounding info, required for facetPartitioning computation
  21915. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21916. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21917. * * useRightHandedSystem: optional boolean to for right handed system computation
  21918. * * depthSort : optional boolean to enable the facet depth sort computation
  21919. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21920. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21921. */
  21922. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21923. facetNormals?: any;
  21924. facetPositions?: any;
  21925. facetPartitioning?: any;
  21926. ratio?: number;
  21927. bInfo?: any;
  21928. bbSize?: Vector3;
  21929. subDiv?: any;
  21930. useRightHandedSystem?: boolean;
  21931. depthSort?: boolean;
  21932. distanceTo?: Vector3;
  21933. depthSortedFacets?: any;
  21934. }): void;
  21935. /** @hidden */
  21936. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21937. /**
  21938. * Applies VertexData created from the imported parameters to the geometry
  21939. * @param parsedVertexData the parsed data from an imported file
  21940. * @param geometry the geometry to apply the VertexData to
  21941. */
  21942. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21943. }
  21944. }
  21945. declare module BABYLON {
  21946. /**
  21947. * Defines a target to use with MorphTargetManager
  21948. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21949. */
  21950. export class MorphTarget implements IAnimatable {
  21951. /** defines the name of the target */
  21952. name: string;
  21953. /**
  21954. * Gets or sets the list of animations
  21955. */
  21956. animations: Animation[];
  21957. private _scene;
  21958. private _positions;
  21959. private _normals;
  21960. private _tangents;
  21961. private _uvs;
  21962. private _influence;
  21963. /**
  21964. * Observable raised when the influence changes
  21965. */
  21966. onInfluenceChanged: Observable<boolean>;
  21967. /** @hidden */
  21968. _onDataLayoutChanged: Observable<void>;
  21969. /**
  21970. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21971. */
  21972. influence: number;
  21973. /**
  21974. * Gets or sets the id of the morph Target
  21975. */
  21976. id: string;
  21977. private _animationPropertiesOverride;
  21978. /**
  21979. * Gets or sets the animation properties override
  21980. */
  21981. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21982. /**
  21983. * Creates a new MorphTarget
  21984. * @param name defines the name of the target
  21985. * @param influence defines the influence to use
  21986. * @param scene defines the scene the morphtarget belongs to
  21987. */
  21988. constructor(
  21989. /** defines the name of the target */
  21990. name: string, influence?: number, scene?: Nullable<Scene>);
  21991. /**
  21992. * Gets a boolean defining if the target contains position data
  21993. */
  21994. readonly hasPositions: boolean;
  21995. /**
  21996. * Gets a boolean defining if the target contains normal data
  21997. */
  21998. readonly hasNormals: boolean;
  21999. /**
  22000. * Gets a boolean defining if the target contains tangent data
  22001. */
  22002. readonly hasTangents: boolean;
  22003. /**
  22004. * Gets a boolean defining if the target contains texture coordinates data
  22005. */
  22006. readonly hasUVs: boolean;
  22007. /**
  22008. * Affects position data to this target
  22009. * @param data defines the position data to use
  22010. */
  22011. setPositions(data: Nullable<FloatArray>): void;
  22012. /**
  22013. * Gets the position data stored in this target
  22014. * @returns a FloatArray containing the position data (or null if not present)
  22015. */
  22016. getPositions(): Nullable<FloatArray>;
  22017. /**
  22018. * Affects normal data to this target
  22019. * @param data defines the normal data to use
  22020. */
  22021. setNormals(data: Nullable<FloatArray>): void;
  22022. /**
  22023. * Gets the normal data stored in this target
  22024. * @returns a FloatArray containing the normal data (or null if not present)
  22025. */
  22026. getNormals(): Nullable<FloatArray>;
  22027. /**
  22028. * Affects tangent data to this target
  22029. * @param data defines the tangent data to use
  22030. */
  22031. setTangents(data: Nullable<FloatArray>): void;
  22032. /**
  22033. * Gets the tangent data stored in this target
  22034. * @returns a FloatArray containing the tangent data (or null if not present)
  22035. */
  22036. getTangents(): Nullable<FloatArray>;
  22037. /**
  22038. * Affects texture coordinates data to this target
  22039. * @param data defines the texture coordinates data to use
  22040. */
  22041. setUVs(data: Nullable<FloatArray>): void;
  22042. /**
  22043. * Gets the texture coordinates data stored in this target
  22044. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22045. */
  22046. getUVs(): Nullable<FloatArray>;
  22047. /**
  22048. * Serializes the current target into a Serialization object
  22049. * @returns the serialized object
  22050. */
  22051. serialize(): any;
  22052. /**
  22053. * Returns the string "MorphTarget"
  22054. * @returns "MorphTarget"
  22055. */
  22056. getClassName(): string;
  22057. /**
  22058. * Creates a new target from serialized data
  22059. * @param serializationObject defines the serialized data to use
  22060. * @returns a new MorphTarget
  22061. */
  22062. static Parse(serializationObject: any): MorphTarget;
  22063. /**
  22064. * Creates a MorphTarget from mesh data
  22065. * @param mesh defines the source mesh
  22066. * @param name defines the name to use for the new target
  22067. * @param influence defines the influence to attach to the target
  22068. * @returns a new MorphTarget
  22069. */
  22070. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22071. }
  22072. }
  22073. declare module BABYLON {
  22074. /**
  22075. * This class is used to deform meshes using morphing between different targets
  22076. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22077. */
  22078. export class MorphTargetManager {
  22079. private _targets;
  22080. private _targetInfluenceChangedObservers;
  22081. private _targetDataLayoutChangedObservers;
  22082. private _activeTargets;
  22083. private _scene;
  22084. private _influences;
  22085. private _supportsNormals;
  22086. private _supportsTangents;
  22087. private _supportsUVs;
  22088. private _vertexCount;
  22089. private _uniqueId;
  22090. private _tempInfluences;
  22091. /**
  22092. * Gets or sets a boolean indicating if normals must be morphed
  22093. */
  22094. enableNormalMorphing: boolean;
  22095. /**
  22096. * Gets or sets a boolean indicating if tangents must be morphed
  22097. */
  22098. enableTangentMorphing: boolean;
  22099. /**
  22100. * Gets or sets a boolean indicating if UV must be morphed
  22101. */
  22102. enableUVMorphing: boolean;
  22103. /**
  22104. * Creates a new MorphTargetManager
  22105. * @param scene defines the current scene
  22106. */
  22107. constructor(scene?: Nullable<Scene>);
  22108. /**
  22109. * Gets the unique ID of this manager
  22110. */
  22111. readonly uniqueId: number;
  22112. /**
  22113. * Gets the number of vertices handled by this manager
  22114. */
  22115. readonly vertexCount: number;
  22116. /**
  22117. * Gets a boolean indicating if this manager supports morphing of normals
  22118. */
  22119. readonly supportsNormals: boolean;
  22120. /**
  22121. * Gets a boolean indicating if this manager supports morphing of tangents
  22122. */
  22123. readonly supportsTangents: boolean;
  22124. /**
  22125. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22126. */
  22127. readonly supportsUVs: boolean;
  22128. /**
  22129. * Gets the number of targets stored in this manager
  22130. */
  22131. readonly numTargets: number;
  22132. /**
  22133. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22134. */
  22135. readonly numInfluencers: number;
  22136. /**
  22137. * Gets the list of influences (one per target)
  22138. */
  22139. readonly influences: Float32Array;
  22140. /**
  22141. * Gets the active target at specified index. An active target is a target with an influence > 0
  22142. * @param index defines the index to check
  22143. * @returns the requested target
  22144. */
  22145. getActiveTarget(index: number): MorphTarget;
  22146. /**
  22147. * Gets the target at specified index
  22148. * @param index defines the index to check
  22149. * @returns the requested target
  22150. */
  22151. getTarget(index: number): MorphTarget;
  22152. /**
  22153. * Add a new target to this manager
  22154. * @param target defines the target to add
  22155. */
  22156. addTarget(target: MorphTarget): void;
  22157. /**
  22158. * Removes a target from the manager
  22159. * @param target defines the target to remove
  22160. */
  22161. removeTarget(target: MorphTarget): void;
  22162. /**
  22163. * Serializes the current manager into a Serialization object
  22164. * @returns the serialized object
  22165. */
  22166. serialize(): any;
  22167. private _syncActiveTargets;
  22168. /**
  22169. * Syncrhonize the targets with all the meshes using this morph target manager
  22170. */
  22171. synchronize(): void;
  22172. /**
  22173. * Creates a new MorphTargetManager from serialized data
  22174. * @param serializationObject defines the serialized data
  22175. * @param scene defines the hosting scene
  22176. * @returns the new MorphTargetManager
  22177. */
  22178. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22179. }
  22180. }
  22181. declare module BABYLON {
  22182. /**
  22183. * Class used to represent a specific level of detail of a mesh
  22184. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22185. */
  22186. export class MeshLODLevel {
  22187. /** Defines the distance where this level should start being displayed */
  22188. distance: number;
  22189. /** Defines the mesh to use to render this level */
  22190. mesh: Nullable<Mesh>;
  22191. /**
  22192. * Creates a new LOD level
  22193. * @param distance defines the distance where this level should star being displayed
  22194. * @param mesh defines the mesh to use to render this level
  22195. */
  22196. constructor(
  22197. /** Defines the distance where this level should start being displayed */
  22198. distance: number,
  22199. /** Defines the mesh to use to render this level */
  22200. mesh: Nullable<Mesh>);
  22201. }
  22202. }
  22203. declare module BABYLON {
  22204. /**
  22205. * Mesh representing the gorund
  22206. */
  22207. export class GroundMesh extends Mesh {
  22208. /** If octree should be generated */
  22209. generateOctree: boolean;
  22210. private _heightQuads;
  22211. /** @hidden */
  22212. _subdivisionsX: number;
  22213. /** @hidden */
  22214. _subdivisionsY: number;
  22215. /** @hidden */
  22216. _width: number;
  22217. /** @hidden */
  22218. _height: number;
  22219. /** @hidden */
  22220. _minX: number;
  22221. /** @hidden */
  22222. _maxX: number;
  22223. /** @hidden */
  22224. _minZ: number;
  22225. /** @hidden */
  22226. _maxZ: number;
  22227. constructor(name: string, scene: Scene);
  22228. /**
  22229. * "GroundMesh"
  22230. * @returns "GroundMesh"
  22231. */
  22232. getClassName(): string;
  22233. /**
  22234. * The minimum of x and y subdivisions
  22235. */
  22236. readonly subdivisions: number;
  22237. /**
  22238. * X subdivisions
  22239. */
  22240. readonly subdivisionsX: number;
  22241. /**
  22242. * Y subdivisions
  22243. */
  22244. readonly subdivisionsY: number;
  22245. /**
  22246. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22247. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22248. * @param chunksCount the number of subdivisions for x and y
  22249. * @param octreeBlocksSize (Default: 32)
  22250. */
  22251. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22252. /**
  22253. * Returns a height (y) value in the Worl system :
  22254. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22255. * @param x x coordinate
  22256. * @param z z coordinate
  22257. * @returns the ground y position if (x, z) are outside the ground surface.
  22258. */
  22259. getHeightAtCoordinates(x: number, z: number): number;
  22260. /**
  22261. * Returns a normalized vector (Vector3) orthogonal to the ground
  22262. * at the ground coordinates (x, z) expressed in the World system.
  22263. * @param x x coordinate
  22264. * @param z z coordinate
  22265. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22266. */
  22267. getNormalAtCoordinates(x: number, z: number): Vector3;
  22268. /**
  22269. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22270. * at the ground coordinates (x, z) expressed in the World system.
  22271. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22272. * @param x x coordinate
  22273. * @param z z coordinate
  22274. * @param ref vector to store the result
  22275. * @returns the GroundMesh.
  22276. */
  22277. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22278. /**
  22279. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22280. * if the ground has been updated.
  22281. * This can be used in the render loop.
  22282. * @returns the GroundMesh.
  22283. */
  22284. updateCoordinateHeights(): GroundMesh;
  22285. private _getFacetAt;
  22286. private _initHeightQuads;
  22287. private _computeHeightQuads;
  22288. /**
  22289. * Serializes this ground mesh
  22290. * @param serializationObject object to write serialization to
  22291. */
  22292. serialize(serializationObject: any): void;
  22293. /**
  22294. * Parses a serialized ground mesh
  22295. * @param parsedMesh the serialized mesh
  22296. * @param scene the scene to create the ground mesh in
  22297. * @returns the created ground mesh
  22298. */
  22299. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22300. }
  22301. }
  22302. declare module BABYLON {
  22303. /**
  22304. * Interface for Physics-Joint data
  22305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22306. */
  22307. export interface PhysicsJointData {
  22308. /**
  22309. * The main pivot of the joint
  22310. */
  22311. mainPivot?: Vector3;
  22312. /**
  22313. * The connected pivot of the joint
  22314. */
  22315. connectedPivot?: Vector3;
  22316. /**
  22317. * The main axis of the joint
  22318. */
  22319. mainAxis?: Vector3;
  22320. /**
  22321. * The connected axis of the joint
  22322. */
  22323. connectedAxis?: Vector3;
  22324. /**
  22325. * The collision of the joint
  22326. */
  22327. collision?: boolean;
  22328. /**
  22329. * Native Oimo/Cannon/Energy data
  22330. */
  22331. nativeParams?: any;
  22332. }
  22333. /**
  22334. * This is a holder class for the physics joint created by the physics plugin
  22335. * It holds a set of functions to control the underlying joint
  22336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22337. */
  22338. export class PhysicsJoint {
  22339. /**
  22340. * The type of the physics joint
  22341. */
  22342. type: number;
  22343. /**
  22344. * The data for the physics joint
  22345. */
  22346. jointData: PhysicsJointData;
  22347. private _physicsJoint;
  22348. protected _physicsPlugin: IPhysicsEnginePlugin;
  22349. /**
  22350. * Initializes the physics joint
  22351. * @param type The type of the physics joint
  22352. * @param jointData The data for the physics joint
  22353. */
  22354. constructor(
  22355. /**
  22356. * The type of the physics joint
  22357. */
  22358. type: number,
  22359. /**
  22360. * The data for the physics joint
  22361. */
  22362. jointData: PhysicsJointData);
  22363. /**
  22364. * Gets the physics joint
  22365. */
  22366. /**
  22367. * Sets the physics joint
  22368. */
  22369. physicsJoint: any;
  22370. /**
  22371. * Sets the physics plugin
  22372. */
  22373. physicsPlugin: IPhysicsEnginePlugin;
  22374. /**
  22375. * Execute a function that is physics-plugin specific.
  22376. * @param {Function} func the function that will be executed.
  22377. * It accepts two parameters: the physics world and the physics joint
  22378. */
  22379. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22380. /**
  22381. * Distance-Joint type
  22382. */
  22383. static DistanceJoint: number;
  22384. /**
  22385. * Hinge-Joint type
  22386. */
  22387. static HingeJoint: number;
  22388. /**
  22389. * Ball-and-Socket joint type
  22390. */
  22391. static BallAndSocketJoint: number;
  22392. /**
  22393. * Wheel-Joint type
  22394. */
  22395. static WheelJoint: number;
  22396. /**
  22397. * Slider-Joint type
  22398. */
  22399. static SliderJoint: number;
  22400. /**
  22401. * Prismatic-Joint type
  22402. */
  22403. static PrismaticJoint: number;
  22404. /**
  22405. * Universal-Joint type
  22406. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22407. */
  22408. static UniversalJoint: number;
  22409. /**
  22410. * Hinge-Joint 2 type
  22411. */
  22412. static Hinge2Joint: number;
  22413. /**
  22414. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22415. */
  22416. static PointToPointJoint: number;
  22417. /**
  22418. * Spring-Joint type
  22419. */
  22420. static SpringJoint: number;
  22421. /**
  22422. * Lock-Joint type
  22423. */
  22424. static LockJoint: number;
  22425. }
  22426. /**
  22427. * A class representing a physics distance joint
  22428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22429. */
  22430. export class DistanceJoint extends PhysicsJoint {
  22431. /**
  22432. *
  22433. * @param jointData The data for the Distance-Joint
  22434. */
  22435. constructor(jointData: DistanceJointData);
  22436. /**
  22437. * Update the predefined distance.
  22438. * @param maxDistance The maximum preferred distance
  22439. * @param minDistance The minimum preferred distance
  22440. */
  22441. updateDistance(maxDistance: number, minDistance?: number): void;
  22442. }
  22443. /**
  22444. * Represents a Motor-Enabled Joint
  22445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22446. */
  22447. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22448. /**
  22449. * Initializes the Motor-Enabled Joint
  22450. * @param type The type of the joint
  22451. * @param jointData The physica joint data for the joint
  22452. */
  22453. constructor(type: number, jointData: PhysicsJointData);
  22454. /**
  22455. * Set the motor values.
  22456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22457. * @param force the force to apply
  22458. * @param maxForce max force for this motor.
  22459. */
  22460. setMotor(force?: number, maxForce?: number): void;
  22461. /**
  22462. * Set the motor's limits.
  22463. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22464. * @param upperLimit The upper limit of the motor
  22465. * @param lowerLimit The lower limit of the motor
  22466. */
  22467. setLimit(upperLimit: number, lowerLimit?: number): void;
  22468. }
  22469. /**
  22470. * This class represents a single physics Hinge-Joint
  22471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22472. */
  22473. export class HingeJoint extends MotorEnabledJoint {
  22474. /**
  22475. * Initializes the Hinge-Joint
  22476. * @param jointData The joint data for the Hinge-Joint
  22477. */
  22478. constructor(jointData: PhysicsJointData);
  22479. /**
  22480. * Set the motor values.
  22481. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22482. * @param {number} force the force to apply
  22483. * @param {number} maxForce max force for this motor.
  22484. */
  22485. setMotor(force?: number, maxForce?: number): void;
  22486. /**
  22487. * Set the motor's limits.
  22488. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22489. * @param upperLimit The upper limit of the motor
  22490. * @param lowerLimit The lower limit of the motor
  22491. */
  22492. setLimit(upperLimit: number, lowerLimit?: number): void;
  22493. }
  22494. /**
  22495. * This class represents a dual hinge physics joint (same as wheel joint)
  22496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22497. */
  22498. export class Hinge2Joint extends MotorEnabledJoint {
  22499. /**
  22500. * Initializes the Hinge2-Joint
  22501. * @param jointData The joint data for the Hinge2-Joint
  22502. */
  22503. constructor(jointData: PhysicsJointData);
  22504. /**
  22505. * Set the motor values.
  22506. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22507. * @param {number} targetSpeed the speed the motor is to reach
  22508. * @param {number} maxForce max force for this motor.
  22509. * @param {motorIndex} the motor's index, 0 or 1.
  22510. */
  22511. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22512. /**
  22513. * Set the motor limits.
  22514. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22515. * @param {number} upperLimit the upper limit
  22516. * @param {number} lowerLimit lower limit
  22517. * @param {motorIndex} the motor's index, 0 or 1.
  22518. */
  22519. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22520. }
  22521. /**
  22522. * Interface for a motor enabled joint
  22523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22524. */
  22525. export interface IMotorEnabledJoint {
  22526. /**
  22527. * Physics joint
  22528. */
  22529. physicsJoint: any;
  22530. /**
  22531. * Sets the motor of the motor-enabled joint
  22532. * @param force The force of the motor
  22533. * @param maxForce The maximum force of the motor
  22534. * @param motorIndex The index of the motor
  22535. */
  22536. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22537. /**
  22538. * Sets the limit of the motor
  22539. * @param upperLimit The upper limit of the motor
  22540. * @param lowerLimit The lower limit of the motor
  22541. * @param motorIndex The index of the motor
  22542. */
  22543. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22544. }
  22545. /**
  22546. * Joint data for a Distance-Joint
  22547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22548. */
  22549. export interface DistanceJointData extends PhysicsJointData {
  22550. /**
  22551. * Max distance the 2 joint objects can be apart
  22552. */
  22553. maxDistance: number;
  22554. }
  22555. /**
  22556. * Joint data from a spring joint
  22557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22558. */
  22559. export interface SpringJointData extends PhysicsJointData {
  22560. /**
  22561. * Length of the spring
  22562. */
  22563. length: number;
  22564. /**
  22565. * Stiffness of the spring
  22566. */
  22567. stiffness: number;
  22568. /**
  22569. * Damping of the spring
  22570. */
  22571. damping: number;
  22572. /** this callback will be called when applying the force to the impostors. */
  22573. forceApplicationCallback: () => void;
  22574. }
  22575. }
  22576. declare module BABYLON {
  22577. /**
  22578. * Holds the data for the raycast result
  22579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22580. */
  22581. export class PhysicsRaycastResult {
  22582. private _hasHit;
  22583. private _hitDistance;
  22584. private _hitNormalWorld;
  22585. private _hitPointWorld;
  22586. private _rayFromWorld;
  22587. private _rayToWorld;
  22588. /**
  22589. * Gets if there was a hit
  22590. */
  22591. readonly hasHit: boolean;
  22592. /**
  22593. * Gets the distance from the hit
  22594. */
  22595. readonly hitDistance: number;
  22596. /**
  22597. * Gets the hit normal/direction in the world
  22598. */
  22599. readonly hitNormalWorld: Vector3;
  22600. /**
  22601. * Gets the hit point in the world
  22602. */
  22603. readonly hitPointWorld: Vector3;
  22604. /**
  22605. * Gets the ray "start point" of the ray in the world
  22606. */
  22607. readonly rayFromWorld: Vector3;
  22608. /**
  22609. * Gets the ray "end point" of the ray in the world
  22610. */
  22611. readonly rayToWorld: Vector3;
  22612. /**
  22613. * Sets the hit data (normal & point in world space)
  22614. * @param hitNormalWorld defines the normal in world space
  22615. * @param hitPointWorld defines the point in world space
  22616. */
  22617. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22618. /**
  22619. * Sets the distance from the start point to the hit point
  22620. * @param distance
  22621. */
  22622. setHitDistance(distance: number): void;
  22623. /**
  22624. * Calculates the distance manually
  22625. */
  22626. calculateHitDistance(): void;
  22627. /**
  22628. * Resets all the values to default
  22629. * @param from The from point on world space
  22630. * @param to The to point on world space
  22631. */
  22632. reset(from?: Vector3, to?: Vector3): void;
  22633. }
  22634. /**
  22635. * Interface for the size containing width and height
  22636. */
  22637. interface IXYZ {
  22638. /**
  22639. * X
  22640. */
  22641. x: number;
  22642. /**
  22643. * Y
  22644. */
  22645. y: number;
  22646. /**
  22647. * Z
  22648. */
  22649. z: number;
  22650. }
  22651. }
  22652. declare module BABYLON {
  22653. /**
  22654. * Interface used to describe a physics joint
  22655. */
  22656. export interface PhysicsImpostorJoint {
  22657. /** Defines the main impostor to which the joint is linked */
  22658. mainImpostor: PhysicsImpostor;
  22659. /** Defines the impostor that is connected to the main impostor using this joint */
  22660. connectedImpostor: PhysicsImpostor;
  22661. /** Defines the joint itself */
  22662. joint: PhysicsJoint;
  22663. }
  22664. /** @hidden */
  22665. export interface IPhysicsEnginePlugin {
  22666. world: any;
  22667. name: string;
  22668. setGravity(gravity: Vector3): void;
  22669. setTimeStep(timeStep: number): void;
  22670. getTimeStep(): number;
  22671. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22672. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22673. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22674. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22675. removePhysicsBody(impostor: PhysicsImpostor): void;
  22676. generateJoint(joint: PhysicsImpostorJoint): void;
  22677. removeJoint(joint: PhysicsImpostorJoint): void;
  22678. isSupported(): boolean;
  22679. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22680. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22681. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22682. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22683. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22684. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22685. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22686. getBodyMass(impostor: PhysicsImpostor): number;
  22687. getBodyFriction(impostor: PhysicsImpostor): number;
  22688. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22689. getBodyRestitution(impostor: PhysicsImpostor): number;
  22690. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22691. getBodyPressure?(impostor: PhysicsImpostor): number;
  22692. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22693. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22694. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22695. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22696. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22697. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22698. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22699. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22700. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22701. sleepBody(impostor: PhysicsImpostor): void;
  22702. wakeUpBody(impostor: PhysicsImpostor): void;
  22703. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22704. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22705. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22706. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22707. getRadius(impostor: PhysicsImpostor): number;
  22708. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22709. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22710. dispose(): void;
  22711. }
  22712. /**
  22713. * Interface used to define a physics engine
  22714. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22715. */
  22716. export interface IPhysicsEngine {
  22717. /**
  22718. * Gets the gravity vector used by the simulation
  22719. */
  22720. gravity: Vector3;
  22721. /**
  22722. * Sets the gravity vector used by the simulation
  22723. * @param gravity defines the gravity vector to use
  22724. */
  22725. setGravity(gravity: Vector3): void;
  22726. /**
  22727. * Set the time step of the physics engine.
  22728. * Default is 1/60.
  22729. * To slow it down, enter 1/600 for example.
  22730. * To speed it up, 1/30
  22731. * @param newTimeStep the new timestep to apply to this world.
  22732. */
  22733. setTimeStep(newTimeStep: number): void;
  22734. /**
  22735. * Get the time step of the physics engine.
  22736. * @returns the current time step
  22737. */
  22738. getTimeStep(): number;
  22739. /**
  22740. * Release all resources
  22741. */
  22742. dispose(): void;
  22743. /**
  22744. * Gets the name of the current physics plugin
  22745. * @returns the name of the plugin
  22746. */
  22747. getPhysicsPluginName(): string;
  22748. /**
  22749. * Adding a new impostor for the impostor tracking.
  22750. * This will be done by the impostor itself.
  22751. * @param impostor the impostor to add
  22752. */
  22753. addImpostor(impostor: PhysicsImpostor): void;
  22754. /**
  22755. * Remove an impostor from the engine.
  22756. * This impostor and its mesh will not longer be updated by the physics engine.
  22757. * @param impostor the impostor to remove
  22758. */
  22759. removeImpostor(impostor: PhysicsImpostor): void;
  22760. /**
  22761. * Add a joint to the physics engine
  22762. * @param mainImpostor defines the main impostor to which the joint is added.
  22763. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22764. * @param joint defines the joint that will connect both impostors.
  22765. */
  22766. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22767. /**
  22768. * Removes a joint from the simulation
  22769. * @param mainImpostor defines the impostor used with the joint
  22770. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22771. * @param joint defines the joint to remove
  22772. */
  22773. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22774. /**
  22775. * Gets the current plugin used to run the simulation
  22776. * @returns current plugin
  22777. */
  22778. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22779. /**
  22780. * Gets the list of physic impostors
  22781. * @returns an array of PhysicsImpostor
  22782. */
  22783. getImpostors(): Array<PhysicsImpostor>;
  22784. /**
  22785. * Gets the impostor for a physics enabled object
  22786. * @param object defines the object impersonated by the impostor
  22787. * @returns the PhysicsImpostor or null if not found
  22788. */
  22789. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22790. /**
  22791. * Gets the impostor for a physics body object
  22792. * @param body defines physics body used by the impostor
  22793. * @returns the PhysicsImpostor or null if not found
  22794. */
  22795. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22796. /**
  22797. * Does a raycast in the physics world
  22798. * @param from when should the ray start?
  22799. * @param to when should the ray end?
  22800. * @returns PhysicsRaycastResult
  22801. */
  22802. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22803. /**
  22804. * Called by the scene. No need to call it.
  22805. * @param delta defines the timespam between frames
  22806. */
  22807. _step(delta: number): void;
  22808. }
  22809. }
  22810. declare module BABYLON {
  22811. /**
  22812. * The interface for the physics imposter parameters
  22813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22814. */
  22815. export interface PhysicsImpostorParameters {
  22816. /**
  22817. * The mass of the physics imposter
  22818. */
  22819. mass: number;
  22820. /**
  22821. * The friction of the physics imposter
  22822. */
  22823. friction?: number;
  22824. /**
  22825. * The coefficient of restitution of the physics imposter
  22826. */
  22827. restitution?: number;
  22828. /**
  22829. * The native options of the physics imposter
  22830. */
  22831. nativeOptions?: any;
  22832. /**
  22833. * Specifies if the parent should be ignored
  22834. */
  22835. ignoreParent?: boolean;
  22836. /**
  22837. * Specifies if bi-directional transformations should be disabled
  22838. */
  22839. disableBidirectionalTransformation?: boolean;
  22840. /**
  22841. * The pressure inside the physics imposter, soft object only
  22842. */
  22843. pressure?: number;
  22844. /**
  22845. * The stiffness the physics imposter, soft object only
  22846. */
  22847. stiffness?: number;
  22848. /**
  22849. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22850. */
  22851. velocityIterations?: number;
  22852. /**
  22853. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22854. */
  22855. positionIterations?: number;
  22856. /**
  22857. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22858. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22859. * Add to fix multiple points
  22860. */
  22861. fixedPoints?: number;
  22862. /**
  22863. * The collision margin around a soft object
  22864. */
  22865. margin?: number;
  22866. /**
  22867. * The collision margin around a soft object
  22868. */
  22869. damping?: number;
  22870. /**
  22871. * The path for a rope based on an extrusion
  22872. */
  22873. path?: any;
  22874. /**
  22875. * The shape of an extrusion used for a rope based on an extrusion
  22876. */
  22877. shape?: any;
  22878. }
  22879. /**
  22880. * Interface for a physics-enabled object
  22881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22882. */
  22883. export interface IPhysicsEnabledObject {
  22884. /**
  22885. * The position of the physics-enabled object
  22886. */
  22887. position: Vector3;
  22888. /**
  22889. * The rotation of the physics-enabled object
  22890. */
  22891. rotationQuaternion: Nullable<Quaternion>;
  22892. /**
  22893. * The scale of the physics-enabled object
  22894. */
  22895. scaling: Vector3;
  22896. /**
  22897. * The rotation of the physics-enabled object
  22898. */
  22899. rotation?: Vector3;
  22900. /**
  22901. * The parent of the physics-enabled object
  22902. */
  22903. parent?: any;
  22904. /**
  22905. * The bounding info of the physics-enabled object
  22906. * @returns The bounding info of the physics-enabled object
  22907. */
  22908. getBoundingInfo(): BoundingInfo;
  22909. /**
  22910. * Computes the world matrix
  22911. * @param force Specifies if the world matrix should be computed by force
  22912. * @returns A world matrix
  22913. */
  22914. computeWorldMatrix(force: boolean): Matrix;
  22915. /**
  22916. * Gets the world matrix
  22917. * @returns A world matrix
  22918. */
  22919. getWorldMatrix?(): Matrix;
  22920. /**
  22921. * Gets the child meshes
  22922. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22923. * @returns An array of abstract meshes
  22924. */
  22925. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22926. /**
  22927. * Gets the vertex data
  22928. * @param kind The type of vertex data
  22929. * @returns A nullable array of numbers, or a float32 array
  22930. */
  22931. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22932. /**
  22933. * Gets the indices from the mesh
  22934. * @returns A nullable array of index arrays
  22935. */
  22936. getIndices?(): Nullable<IndicesArray>;
  22937. /**
  22938. * Gets the scene from the mesh
  22939. * @returns the indices array or null
  22940. */
  22941. getScene?(): Scene;
  22942. /**
  22943. * Gets the absolute position from the mesh
  22944. * @returns the absolute position
  22945. */
  22946. getAbsolutePosition(): Vector3;
  22947. /**
  22948. * Gets the absolute pivot point from the mesh
  22949. * @returns the absolute pivot point
  22950. */
  22951. getAbsolutePivotPoint(): Vector3;
  22952. /**
  22953. * Rotates the mesh
  22954. * @param axis The axis of rotation
  22955. * @param amount The amount of rotation
  22956. * @param space The space of the rotation
  22957. * @returns The rotation transform node
  22958. */
  22959. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22960. /**
  22961. * Translates the mesh
  22962. * @param axis The axis of translation
  22963. * @param distance The distance of translation
  22964. * @param space The space of the translation
  22965. * @returns The transform node
  22966. */
  22967. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22968. /**
  22969. * Sets the absolute position of the mesh
  22970. * @param absolutePosition The absolute position of the mesh
  22971. * @returns The transform node
  22972. */
  22973. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22974. /**
  22975. * Gets the class name of the mesh
  22976. * @returns The class name
  22977. */
  22978. getClassName(): string;
  22979. }
  22980. /**
  22981. * Represents a physics imposter
  22982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22983. */
  22984. export class PhysicsImpostor {
  22985. /**
  22986. * The physics-enabled object used as the physics imposter
  22987. */
  22988. object: IPhysicsEnabledObject;
  22989. /**
  22990. * The type of the physics imposter
  22991. */
  22992. type: number;
  22993. private _options;
  22994. private _scene?;
  22995. /**
  22996. * The default object size of the imposter
  22997. */
  22998. static DEFAULT_OBJECT_SIZE: Vector3;
  22999. /**
  23000. * The identity quaternion of the imposter
  23001. */
  23002. static IDENTITY_QUATERNION: Quaternion;
  23003. /** @hidden */
  23004. _pluginData: any;
  23005. private _physicsEngine;
  23006. private _physicsBody;
  23007. private _bodyUpdateRequired;
  23008. private _onBeforePhysicsStepCallbacks;
  23009. private _onAfterPhysicsStepCallbacks;
  23010. /** @hidden */
  23011. _onPhysicsCollideCallbacks: Array<{
  23012. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23013. otherImpostors: Array<PhysicsImpostor>;
  23014. }>;
  23015. private _deltaPosition;
  23016. private _deltaRotation;
  23017. private _deltaRotationConjugated;
  23018. /** @hidden */
  23019. _isFromLine: boolean;
  23020. private _parent;
  23021. private _isDisposed;
  23022. private static _tmpVecs;
  23023. private static _tmpQuat;
  23024. /**
  23025. * Specifies if the physics imposter is disposed
  23026. */
  23027. readonly isDisposed: boolean;
  23028. /**
  23029. * Gets the mass of the physics imposter
  23030. */
  23031. mass: number;
  23032. /**
  23033. * Gets the coefficient of friction
  23034. */
  23035. /**
  23036. * Sets the coefficient of friction
  23037. */
  23038. friction: number;
  23039. /**
  23040. * Gets the coefficient of restitution
  23041. */
  23042. /**
  23043. * Sets the coefficient of restitution
  23044. */
  23045. restitution: number;
  23046. /**
  23047. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23048. */
  23049. /**
  23050. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23051. */
  23052. pressure: number;
  23053. /**
  23054. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23055. */
  23056. /**
  23057. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23058. */
  23059. stiffness: number;
  23060. /**
  23061. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23062. */
  23063. /**
  23064. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23065. */
  23066. velocityIterations: number;
  23067. /**
  23068. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23069. */
  23070. /**
  23071. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23072. */
  23073. positionIterations: number;
  23074. /**
  23075. * The unique id of the physics imposter
  23076. * set by the physics engine when adding this impostor to the array
  23077. */
  23078. uniqueId: number;
  23079. /**
  23080. * @hidden
  23081. */
  23082. soft: boolean;
  23083. /**
  23084. * @hidden
  23085. */
  23086. segments: number;
  23087. private _joints;
  23088. /**
  23089. * Initializes the physics imposter
  23090. * @param object The physics-enabled object used as the physics imposter
  23091. * @param type The type of the physics imposter
  23092. * @param _options The options for the physics imposter
  23093. * @param _scene The Babylon scene
  23094. */
  23095. constructor(
  23096. /**
  23097. * The physics-enabled object used as the physics imposter
  23098. */
  23099. object: IPhysicsEnabledObject,
  23100. /**
  23101. * The type of the physics imposter
  23102. */
  23103. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23104. /**
  23105. * This function will completly initialize this impostor.
  23106. * It will create a new body - but only if this mesh has no parent.
  23107. * If it has, this impostor will not be used other than to define the impostor
  23108. * of the child mesh.
  23109. * @hidden
  23110. */
  23111. _init(): void;
  23112. private _getPhysicsParent;
  23113. /**
  23114. * Should a new body be generated.
  23115. * @returns boolean specifying if body initialization is required
  23116. */
  23117. isBodyInitRequired(): boolean;
  23118. /**
  23119. * Sets the updated scaling
  23120. * @param updated Specifies if the scaling is updated
  23121. */
  23122. setScalingUpdated(): void;
  23123. /**
  23124. * Force a regeneration of this or the parent's impostor's body.
  23125. * Use under cautious - This will remove all joints already implemented.
  23126. */
  23127. forceUpdate(): void;
  23128. /**
  23129. * Gets the body that holds this impostor. Either its own, or its parent.
  23130. */
  23131. /**
  23132. * Set the physics body. Used mainly by the physics engine/plugin
  23133. */
  23134. physicsBody: any;
  23135. /**
  23136. * Get the parent of the physics imposter
  23137. * @returns Physics imposter or null
  23138. */
  23139. /**
  23140. * Sets the parent of the physics imposter
  23141. */
  23142. parent: Nullable<PhysicsImpostor>;
  23143. /**
  23144. * Resets the update flags
  23145. */
  23146. resetUpdateFlags(): void;
  23147. /**
  23148. * Gets the object extend size
  23149. * @returns the object extend size
  23150. */
  23151. getObjectExtendSize(): Vector3;
  23152. /**
  23153. * Gets the object center
  23154. * @returns The object center
  23155. */
  23156. getObjectCenter(): Vector3;
  23157. /**
  23158. * Get a specific parametes from the options parameter
  23159. * @param paramName The object parameter name
  23160. * @returns The object parameter
  23161. */
  23162. getParam(paramName: string): any;
  23163. /**
  23164. * Sets a specific parameter in the options given to the physics plugin
  23165. * @param paramName The parameter name
  23166. * @param value The value of the parameter
  23167. */
  23168. setParam(paramName: string, value: number): void;
  23169. /**
  23170. * Specifically change the body's mass option. Won't recreate the physics body object
  23171. * @param mass The mass of the physics imposter
  23172. */
  23173. setMass(mass: number): void;
  23174. /**
  23175. * Gets the linear velocity
  23176. * @returns linear velocity or null
  23177. */
  23178. getLinearVelocity(): Nullable<Vector3>;
  23179. /**
  23180. * Sets the linear velocity
  23181. * @param velocity linear velocity or null
  23182. */
  23183. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23184. /**
  23185. * Gets the angular velocity
  23186. * @returns angular velocity or null
  23187. */
  23188. getAngularVelocity(): Nullable<Vector3>;
  23189. /**
  23190. * Sets the angular velocity
  23191. * @param velocity The velocity or null
  23192. */
  23193. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23194. /**
  23195. * Execute a function with the physics plugin native code
  23196. * Provide a function the will have two variables - the world object and the physics body object
  23197. * @param func The function to execute with the physics plugin native code
  23198. */
  23199. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23200. /**
  23201. * Register a function that will be executed before the physics world is stepping forward
  23202. * @param func The function to execute before the physics world is stepped forward
  23203. */
  23204. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23205. /**
  23206. * Unregister a function that will be executed before the physics world is stepping forward
  23207. * @param func The function to execute before the physics world is stepped forward
  23208. */
  23209. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23210. /**
  23211. * Register a function that will be executed after the physics step
  23212. * @param func The function to execute after physics step
  23213. */
  23214. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23215. /**
  23216. * Unregisters a function that will be executed after the physics step
  23217. * @param func The function to execute after physics step
  23218. */
  23219. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23220. /**
  23221. * register a function that will be executed when this impostor collides against a different body
  23222. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23223. * @param func Callback that is executed on collision
  23224. */
  23225. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23226. /**
  23227. * Unregisters the physics imposter on contact
  23228. * @param collideAgainst The physics object to collide against
  23229. * @param func Callback to execute on collision
  23230. */
  23231. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23232. private _tmpQuat;
  23233. private _tmpQuat2;
  23234. /**
  23235. * Get the parent rotation
  23236. * @returns The parent rotation
  23237. */
  23238. getParentsRotation(): Quaternion;
  23239. /**
  23240. * this function is executed by the physics engine.
  23241. */
  23242. beforeStep: () => void;
  23243. /**
  23244. * this function is executed by the physics engine
  23245. */
  23246. afterStep: () => void;
  23247. /**
  23248. * Legacy collision detection event support
  23249. */
  23250. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23251. /**
  23252. * event and body object due to cannon's event-based architecture.
  23253. */
  23254. onCollide: (e: {
  23255. body: any;
  23256. }) => void;
  23257. /**
  23258. * Apply a force
  23259. * @param force The force to apply
  23260. * @param contactPoint The contact point for the force
  23261. * @returns The physics imposter
  23262. */
  23263. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23264. /**
  23265. * Apply an impulse
  23266. * @param force The impulse force
  23267. * @param contactPoint The contact point for the impulse force
  23268. * @returns The physics imposter
  23269. */
  23270. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23271. /**
  23272. * A help function to create a joint
  23273. * @param otherImpostor A physics imposter used to create a joint
  23274. * @param jointType The type of joint
  23275. * @param jointData The data for the joint
  23276. * @returns The physics imposter
  23277. */
  23278. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23279. /**
  23280. * Add a joint to this impostor with a different impostor
  23281. * @param otherImpostor A physics imposter used to add a joint
  23282. * @param joint The joint to add
  23283. * @returns The physics imposter
  23284. */
  23285. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23286. /**
  23287. * Add an anchor to a cloth impostor
  23288. * @param otherImpostor rigid impostor to anchor to
  23289. * @param width ratio across width from 0 to 1
  23290. * @param height ratio up height from 0 to 1
  23291. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23292. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23293. * @returns impostor the soft imposter
  23294. */
  23295. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23296. /**
  23297. * Add a hook to a rope impostor
  23298. * @param otherImpostor rigid impostor to anchor to
  23299. * @param length ratio across rope from 0 to 1
  23300. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23301. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23302. * @returns impostor the rope imposter
  23303. */
  23304. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23305. /**
  23306. * Will keep this body still, in a sleep mode.
  23307. * @returns the physics imposter
  23308. */
  23309. sleep(): PhysicsImpostor;
  23310. /**
  23311. * Wake the body up.
  23312. * @returns The physics imposter
  23313. */
  23314. wakeUp(): PhysicsImpostor;
  23315. /**
  23316. * Clones the physics imposter
  23317. * @param newObject The physics imposter clones to this physics-enabled object
  23318. * @returns A nullable physics imposter
  23319. */
  23320. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23321. /**
  23322. * Disposes the physics imposter
  23323. */
  23324. dispose(): void;
  23325. /**
  23326. * Sets the delta position
  23327. * @param position The delta position amount
  23328. */
  23329. setDeltaPosition(position: Vector3): void;
  23330. /**
  23331. * Sets the delta rotation
  23332. * @param rotation The delta rotation amount
  23333. */
  23334. setDeltaRotation(rotation: Quaternion): void;
  23335. /**
  23336. * Gets the box size of the physics imposter and stores the result in the input parameter
  23337. * @param result Stores the box size
  23338. * @returns The physics imposter
  23339. */
  23340. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23341. /**
  23342. * Gets the radius of the physics imposter
  23343. * @returns Radius of the physics imposter
  23344. */
  23345. getRadius(): number;
  23346. /**
  23347. * Sync a bone with this impostor
  23348. * @param bone The bone to sync to the impostor.
  23349. * @param boneMesh The mesh that the bone is influencing.
  23350. * @param jointPivot The pivot of the joint / bone in local space.
  23351. * @param distToJoint Optional distance from the impostor to the joint.
  23352. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23353. */
  23354. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23355. /**
  23356. * Sync impostor to a bone
  23357. * @param bone The bone that the impostor will be synced to.
  23358. * @param boneMesh The mesh that the bone is influencing.
  23359. * @param jointPivot The pivot of the joint / bone in local space.
  23360. * @param distToJoint Optional distance from the impostor to the joint.
  23361. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23362. * @param boneAxis Optional vector3 axis the bone is aligned with
  23363. */
  23364. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23365. /**
  23366. * No-Imposter type
  23367. */
  23368. static NoImpostor: number;
  23369. /**
  23370. * Sphere-Imposter type
  23371. */
  23372. static SphereImpostor: number;
  23373. /**
  23374. * Box-Imposter type
  23375. */
  23376. static BoxImpostor: number;
  23377. /**
  23378. * Plane-Imposter type
  23379. */
  23380. static PlaneImpostor: number;
  23381. /**
  23382. * Mesh-imposter type
  23383. */
  23384. static MeshImpostor: number;
  23385. /**
  23386. * Capsule-Impostor type (Ammo.js plugin only)
  23387. */
  23388. static CapsuleImpostor: number;
  23389. /**
  23390. * Cylinder-Imposter type
  23391. */
  23392. static CylinderImpostor: number;
  23393. /**
  23394. * Particle-Imposter type
  23395. */
  23396. static ParticleImpostor: number;
  23397. /**
  23398. * Heightmap-Imposter type
  23399. */
  23400. static HeightmapImpostor: number;
  23401. /**
  23402. * ConvexHull-Impostor type (Ammo.js plugin only)
  23403. */
  23404. static ConvexHullImpostor: number;
  23405. /**
  23406. * Rope-Imposter type
  23407. */
  23408. static RopeImpostor: number;
  23409. /**
  23410. * Cloth-Imposter type
  23411. */
  23412. static ClothImpostor: number;
  23413. /**
  23414. * Softbody-Imposter type
  23415. */
  23416. static SoftbodyImpostor: number;
  23417. }
  23418. }
  23419. declare module BABYLON {
  23420. /**
  23421. * @hidden
  23422. **/
  23423. export class _CreationDataStorage {
  23424. closePath?: boolean;
  23425. closeArray?: boolean;
  23426. idx: number[];
  23427. dashSize: number;
  23428. gapSize: number;
  23429. path3D: Path3D;
  23430. pathArray: Vector3[][];
  23431. arc: number;
  23432. radius: number;
  23433. cap: number;
  23434. tessellation: number;
  23435. }
  23436. /**
  23437. * @hidden
  23438. **/
  23439. class _InstanceDataStorage {
  23440. visibleInstances: any;
  23441. batchCache: _InstancesBatch;
  23442. instancesBufferSize: number;
  23443. instancesBuffer: Nullable<Buffer>;
  23444. instancesData: Float32Array;
  23445. overridenInstanceCount: number;
  23446. isFrozen: boolean;
  23447. previousBatch: Nullable<_InstancesBatch>;
  23448. hardwareInstancedRendering: boolean;
  23449. sideOrientation: number;
  23450. }
  23451. /**
  23452. * @hidden
  23453. **/
  23454. export class _InstancesBatch {
  23455. mustReturn: boolean;
  23456. visibleInstances: Nullable<InstancedMesh[]>[];
  23457. renderSelf: boolean[];
  23458. hardwareInstancedRendering: boolean[];
  23459. }
  23460. /**
  23461. * Class used to represent renderable models
  23462. */
  23463. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23464. /**
  23465. * Mesh side orientation : usually the external or front surface
  23466. */
  23467. static readonly FRONTSIDE: number;
  23468. /**
  23469. * Mesh side orientation : usually the internal or back surface
  23470. */
  23471. static readonly BACKSIDE: number;
  23472. /**
  23473. * Mesh side orientation : both internal and external or front and back surfaces
  23474. */
  23475. static readonly DOUBLESIDE: number;
  23476. /**
  23477. * Mesh side orientation : by default, `FRONTSIDE`
  23478. */
  23479. static readonly DEFAULTSIDE: number;
  23480. /**
  23481. * Mesh cap setting : no cap
  23482. */
  23483. static readonly NO_CAP: number;
  23484. /**
  23485. * Mesh cap setting : one cap at the beginning of the mesh
  23486. */
  23487. static readonly CAP_START: number;
  23488. /**
  23489. * Mesh cap setting : one cap at the end of the mesh
  23490. */
  23491. static readonly CAP_END: number;
  23492. /**
  23493. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23494. */
  23495. static readonly CAP_ALL: number;
  23496. /**
  23497. * Mesh pattern setting : no flip or rotate
  23498. */
  23499. static readonly NO_FLIP: number;
  23500. /**
  23501. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23502. */
  23503. static readonly FLIP_TILE: number;
  23504. /**
  23505. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23506. */
  23507. static readonly ROTATE_TILE: number;
  23508. /**
  23509. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23510. */
  23511. static readonly FLIP_ROW: number;
  23512. /**
  23513. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23514. */
  23515. static readonly ROTATE_ROW: number;
  23516. /**
  23517. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23518. */
  23519. static readonly FLIP_N_ROTATE_TILE: number;
  23520. /**
  23521. * Mesh pattern setting : rotate pattern and rotate
  23522. */
  23523. static readonly FLIP_N_ROTATE_ROW: number;
  23524. /**
  23525. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23526. */
  23527. static readonly CENTER: number;
  23528. /**
  23529. * Mesh tile positioning : part tiles on left
  23530. */
  23531. static readonly LEFT: number;
  23532. /**
  23533. * Mesh tile positioning : part tiles on right
  23534. */
  23535. static readonly RIGHT: number;
  23536. /**
  23537. * Mesh tile positioning : part tiles on top
  23538. */
  23539. static readonly TOP: number;
  23540. /**
  23541. * Mesh tile positioning : part tiles on bottom
  23542. */
  23543. static readonly BOTTOM: number;
  23544. /**
  23545. * Gets the default side orientation.
  23546. * @param orientation the orientation to value to attempt to get
  23547. * @returns the default orientation
  23548. * @hidden
  23549. */
  23550. static _GetDefaultSideOrientation(orientation?: number): number;
  23551. private _internalMeshDataInfo;
  23552. /**
  23553. * An event triggered before rendering the mesh
  23554. */
  23555. readonly onBeforeRenderObservable: Observable<Mesh>;
  23556. /**
  23557. * An event triggered before binding the mesh
  23558. */
  23559. readonly onBeforeBindObservable: Observable<Mesh>;
  23560. /**
  23561. * An event triggered after rendering the mesh
  23562. */
  23563. readonly onAfterRenderObservable: Observable<Mesh>;
  23564. /**
  23565. * An event triggered before drawing the mesh
  23566. */
  23567. readonly onBeforeDrawObservable: Observable<Mesh>;
  23568. private _onBeforeDrawObserver;
  23569. /**
  23570. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23571. */
  23572. onBeforeDraw: () => void;
  23573. readonly hasInstances: boolean;
  23574. /**
  23575. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23576. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23577. */
  23578. delayLoadState: number;
  23579. /**
  23580. * Gets the list of instances created from this mesh
  23581. * it is not supposed to be modified manually.
  23582. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23583. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23584. */
  23585. instances: InstancedMesh[];
  23586. /**
  23587. * Gets the file containing delay loading data for this mesh
  23588. */
  23589. delayLoadingFile: string;
  23590. /** @hidden */
  23591. _binaryInfo: any;
  23592. /**
  23593. * User defined function used to change how LOD level selection is done
  23594. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23595. */
  23596. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23597. /**
  23598. * Gets or sets the morph target manager
  23599. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23600. */
  23601. morphTargetManager: Nullable<MorphTargetManager>;
  23602. /** @hidden */
  23603. _creationDataStorage: Nullable<_CreationDataStorage>;
  23604. /** @hidden */
  23605. _geometry: Nullable<Geometry>;
  23606. /** @hidden */
  23607. _delayInfo: Array<string>;
  23608. /** @hidden */
  23609. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23610. /** @hidden */
  23611. _instanceDataStorage: _InstanceDataStorage;
  23612. private _effectiveMaterial;
  23613. /** @hidden */
  23614. _shouldGenerateFlatShading: boolean;
  23615. /** @hidden */
  23616. _originalBuilderSideOrientation: number;
  23617. /**
  23618. * Use this property to change the original side orientation defined at construction time
  23619. */
  23620. overrideMaterialSideOrientation: Nullable<number>;
  23621. /**
  23622. * Gets the source mesh (the one used to clone this one from)
  23623. */
  23624. readonly source: Nullable<Mesh>;
  23625. /**
  23626. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23627. */
  23628. isUnIndexed: boolean;
  23629. /**
  23630. * @constructor
  23631. * @param name The value used by scene.getMeshByName() to do a lookup.
  23632. * @param scene The scene to add this mesh to.
  23633. * @param parent The parent of this mesh, if it has one
  23634. * @param source An optional Mesh from which geometry is shared, cloned.
  23635. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23636. * When false, achieved by calling a clone(), also passing False.
  23637. * This will make creation of children, recursive.
  23638. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23639. */
  23640. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23641. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23642. /**
  23643. * Gets the class name
  23644. * @returns the string "Mesh".
  23645. */
  23646. getClassName(): string;
  23647. /** @hidden */
  23648. readonly _isMesh: boolean;
  23649. /**
  23650. * Returns a description of this mesh
  23651. * @param fullDetails define if full details about this mesh must be used
  23652. * @returns a descriptive string representing this mesh
  23653. */
  23654. toString(fullDetails?: boolean): string;
  23655. /** @hidden */
  23656. _unBindEffect(): void;
  23657. /**
  23658. * Gets a boolean indicating if this mesh has LOD
  23659. */
  23660. readonly hasLODLevels: boolean;
  23661. /**
  23662. * Gets the list of MeshLODLevel associated with the current mesh
  23663. * @returns an array of MeshLODLevel
  23664. */
  23665. getLODLevels(): MeshLODLevel[];
  23666. private _sortLODLevels;
  23667. /**
  23668. * Add a mesh as LOD level triggered at the given distance.
  23669. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23670. * @param distance The distance from the center of the object to show this level
  23671. * @param mesh The mesh to be added as LOD level (can be null)
  23672. * @return This mesh (for chaining)
  23673. */
  23674. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23675. /**
  23676. * Returns the LOD level mesh at the passed distance or null if not found.
  23677. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23678. * @param distance The distance from the center of the object to show this level
  23679. * @returns a Mesh or `null`
  23680. */
  23681. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23682. /**
  23683. * Remove a mesh from the LOD array
  23684. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23685. * @param mesh defines the mesh to be removed
  23686. * @return This mesh (for chaining)
  23687. */
  23688. removeLODLevel(mesh: Mesh): Mesh;
  23689. /**
  23690. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23691. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23692. * @param camera defines the camera to use to compute distance
  23693. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23694. * @return This mesh (for chaining)
  23695. */
  23696. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23697. /**
  23698. * Gets the mesh internal Geometry object
  23699. */
  23700. readonly geometry: Nullable<Geometry>;
  23701. /**
  23702. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23703. * @returns the total number of vertices
  23704. */
  23705. getTotalVertices(): number;
  23706. /**
  23707. * Returns the content of an associated vertex buffer
  23708. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23709. * - VertexBuffer.PositionKind
  23710. * - VertexBuffer.UVKind
  23711. * - VertexBuffer.UV2Kind
  23712. * - VertexBuffer.UV3Kind
  23713. * - VertexBuffer.UV4Kind
  23714. * - VertexBuffer.UV5Kind
  23715. * - VertexBuffer.UV6Kind
  23716. * - VertexBuffer.ColorKind
  23717. * - VertexBuffer.MatricesIndicesKind
  23718. * - VertexBuffer.MatricesIndicesExtraKind
  23719. * - VertexBuffer.MatricesWeightsKind
  23720. * - VertexBuffer.MatricesWeightsExtraKind
  23721. * @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
  23722. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23723. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23724. */
  23725. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23726. /**
  23727. * Returns the mesh VertexBuffer object from the requested `kind`
  23728. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23729. * - VertexBuffer.PositionKind
  23730. * - VertexBuffer.NormalKind
  23731. * - VertexBuffer.UVKind
  23732. * - VertexBuffer.UV2Kind
  23733. * - VertexBuffer.UV3Kind
  23734. * - VertexBuffer.UV4Kind
  23735. * - VertexBuffer.UV5Kind
  23736. * - VertexBuffer.UV6Kind
  23737. * - VertexBuffer.ColorKind
  23738. * - VertexBuffer.MatricesIndicesKind
  23739. * - VertexBuffer.MatricesIndicesExtraKind
  23740. * - VertexBuffer.MatricesWeightsKind
  23741. * - VertexBuffer.MatricesWeightsExtraKind
  23742. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23743. */
  23744. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23745. /**
  23746. * Tests if a specific vertex buffer is associated with this mesh
  23747. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23748. * - VertexBuffer.PositionKind
  23749. * - VertexBuffer.NormalKind
  23750. * - VertexBuffer.UVKind
  23751. * - VertexBuffer.UV2Kind
  23752. * - VertexBuffer.UV3Kind
  23753. * - VertexBuffer.UV4Kind
  23754. * - VertexBuffer.UV5Kind
  23755. * - VertexBuffer.UV6Kind
  23756. * - VertexBuffer.ColorKind
  23757. * - VertexBuffer.MatricesIndicesKind
  23758. * - VertexBuffer.MatricesIndicesExtraKind
  23759. * - VertexBuffer.MatricesWeightsKind
  23760. * - VertexBuffer.MatricesWeightsExtraKind
  23761. * @returns a boolean
  23762. */
  23763. isVerticesDataPresent(kind: string): boolean;
  23764. /**
  23765. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23766. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23767. * - VertexBuffer.PositionKind
  23768. * - VertexBuffer.UVKind
  23769. * - VertexBuffer.UV2Kind
  23770. * - VertexBuffer.UV3Kind
  23771. * - VertexBuffer.UV4Kind
  23772. * - VertexBuffer.UV5Kind
  23773. * - VertexBuffer.UV6Kind
  23774. * - VertexBuffer.ColorKind
  23775. * - VertexBuffer.MatricesIndicesKind
  23776. * - VertexBuffer.MatricesIndicesExtraKind
  23777. * - VertexBuffer.MatricesWeightsKind
  23778. * - VertexBuffer.MatricesWeightsExtraKind
  23779. * @returns a boolean
  23780. */
  23781. isVertexBufferUpdatable(kind: string): boolean;
  23782. /**
  23783. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23784. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23785. * - VertexBuffer.PositionKind
  23786. * - VertexBuffer.NormalKind
  23787. * - VertexBuffer.UVKind
  23788. * - VertexBuffer.UV2Kind
  23789. * - VertexBuffer.UV3Kind
  23790. * - VertexBuffer.UV4Kind
  23791. * - VertexBuffer.UV5Kind
  23792. * - VertexBuffer.UV6Kind
  23793. * - VertexBuffer.ColorKind
  23794. * - VertexBuffer.MatricesIndicesKind
  23795. * - VertexBuffer.MatricesIndicesExtraKind
  23796. * - VertexBuffer.MatricesWeightsKind
  23797. * - VertexBuffer.MatricesWeightsExtraKind
  23798. * @returns an array of strings
  23799. */
  23800. getVerticesDataKinds(): string[];
  23801. /**
  23802. * Returns a positive integer : the total number of indices in this mesh geometry.
  23803. * @returns the numner of indices or zero if the mesh has no geometry.
  23804. */
  23805. getTotalIndices(): number;
  23806. /**
  23807. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23808. * @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.
  23809. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23810. * @returns the indices array or an empty array if the mesh has no geometry
  23811. */
  23812. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23813. readonly isBlocked: boolean;
  23814. /**
  23815. * Determine if the current mesh is ready to be rendered
  23816. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23817. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23818. * @returns true if all associated assets are ready (material, textures, shaders)
  23819. */
  23820. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23821. /**
  23822. * 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.
  23823. */
  23824. readonly areNormalsFrozen: boolean;
  23825. /**
  23826. * 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.
  23827. * @returns the current mesh
  23828. */
  23829. freezeNormals(): Mesh;
  23830. /**
  23831. * 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
  23832. * @returns the current mesh
  23833. */
  23834. unfreezeNormals(): Mesh;
  23835. /**
  23836. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23837. */
  23838. overridenInstanceCount: number;
  23839. /** @hidden */
  23840. _preActivate(): Mesh;
  23841. /** @hidden */
  23842. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23843. /** @hidden */
  23844. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23845. /**
  23846. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23847. * This means the mesh underlying bounding box and sphere are recomputed.
  23848. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23849. * @returns the current mesh
  23850. */
  23851. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23852. /** @hidden */
  23853. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23854. /**
  23855. * This function will subdivide the mesh into multiple submeshes
  23856. * @param count defines the expected number of submeshes
  23857. */
  23858. subdivide(count: number): void;
  23859. /**
  23860. * Copy a FloatArray into a specific associated vertex buffer
  23861. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23862. * - VertexBuffer.PositionKind
  23863. * - VertexBuffer.UVKind
  23864. * - VertexBuffer.UV2Kind
  23865. * - VertexBuffer.UV3Kind
  23866. * - VertexBuffer.UV4Kind
  23867. * - VertexBuffer.UV5Kind
  23868. * - VertexBuffer.UV6Kind
  23869. * - VertexBuffer.ColorKind
  23870. * - VertexBuffer.MatricesIndicesKind
  23871. * - VertexBuffer.MatricesIndicesExtraKind
  23872. * - VertexBuffer.MatricesWeightsKind
  23873. * - VertexBuffer.MatricesWeightsExtraKind
  23874. * @param data defines the data source
  23875. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23876. * @param stride defines the data stride size (can be null)
  23877. * @returns the current mesh
  23878. */
  23879. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23880. /**
  23881. * Flags an associated vertex buffer as updatable
  23882. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23883. * - VertexBuffer.PositionKind
  23884. * - VertexBuffer.UVKind
  23885. * - VertexBuffer.UV2Kind
  23886. * - VertexBuffer.UV3Kind
  23887. * - VertexBuffer.UV4Kind
  23888. * - VertexBuffer.UV5Kind
  23889. * - VertexBuffer.UV6Kind
  23890. * - VertexBuffer.ColorKind
  23891. * - VertexBuffer.MatricesIndicesKind
  23892. * - VertexBuffer.MatricesIndicesExtraKind
  23893. * - VertexBuffer.MatricesWeightsKind
  23894. * - VertexBuffer.MatricesWeightsExtraKind
  23895. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23896. */
  23897. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23898. /**
  23899. * Sets the mesh global Vertex Buffer
  23900. * @param buffer defines the buffer to use
  23901. * @returns the current mesh
  23902. */
  23903. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23904. /**
  23905. * Update a specific associated vertex buffer
  23906. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23907. * - VertexBuffer.PositionKind
  23908. * - VertexBuffer.UVKind
  23909. * - VertexBuffer.UV2Kind
  23910. * - VertexBuffer.UV3Kind
  23911. * - VertexBuffer.UV4Kind
  23912. * - VertexBuffer.UV5Kind
  23913. * - VertexBuffer.UV6Kind
  23914. * - VertexBuffer.ColorKind
  23915. * - VertexBuffer.MatricesIndicesKind
  23916. * - VertexBuffer.MatricesIndicesExtraKind
  23917. * - VertexBuffer.MatricesWeightsKind
  23918. * - VertexBuffer.MatricesWeightsExtraKind
  23919. * @param data defines the data source
  23920. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23921. * @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)
  23922. * @returns the current mesh
  23923. */
  23924. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23925. /**
  23926. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23927. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23928. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23929. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23930. * @returns the current mesh
  23931. */
  23932. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23933. /**
  23934. * Creates a un-shared specific occurence of the geometry for the mesh.
  23935. * @returns the current mesh
  23936. */
  23937. makeGeometryUnique(): Mesh;
  23938. /**
  23939. * Set the index buffer of this mesh
  23940. * @param indices defines the source data
  23941. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23942. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23943. * @returns the current mesh
  23944. */
  23945. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23946. /**
  23947. * Update the current index buffer
  23948. * @param indices defines the source data
  23949. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23950. * @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)
  23951. * @returns the current mesh
  23952. */
  23953. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23954. /**
  23955. * Invert the geometry to move from a right handed system to a left handed one.
  23956. * @returns the current mesh
  23957. */
  23958. toLeftHanded(): Mesh;
  23959. /** @hidden */
  23960. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23961. /** @hidden */
  23962. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23963. /**
  23964. * Registers for this mesh a javascript function called just before the rendering process
  23965. * @param func defines the function to call before rendering this mesh
  23966. * @returns the current mesh
  23967. */
  23968. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23969. /**
  23970. * Disposes a previously registered javascript function called before the rendering
  23971. * @param func defines the function to remove
  23972. * @returns the current mesh
  23973. */
  23974. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23975. /**
  23976. * Registers for this mesh a javascript function called just after the rendering is complete
  23977. * @param func defines the function to call after rendering this mesh
  23978. * @returns the current mesh
  23979. */
  23980. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23981. /**
  23982. * Disposes a previously registered javascript function called after the rendering.
  23983. * @param func defines the function to remove
  23984. * @returns the current mesh
  23985. */
  23986. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23987. /** @hidden */
  23988. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23989. /** @hidden */
  23990. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23991. /** @hidden */
  23992. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23993. /** @hidden */
  23994. _rebuild(): void;
  23995. /** @hidden */
  23996. _freeze(): void;
  23997. /** @hidden */
  23998. _unFreeze(): void;
  23999. /**
  24000. * 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
  24001. * @param subMesh defines the subMesh to render
  24002. * @param enableAlphaMode defines if alpha mode can be changed
  24003. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24004. * @returns the current mesh
  24005. */
  24006. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24007. private _onBeforeDraw;
  24008. /**
  24009. * Renormalize the mesh and patch it up if there are no weights
  24010. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24011. * However in the case of zero weights then we set just a single influence to 1.
  24012. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24013. */
  24014. cleanMatrixWeights(): void;
  24015. private normalizeSkinFourWeights;
  24016. private normalizeSkinWeightsAndExtra;
  24017. /**
  24018. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24019. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24020. * the user know there was an issue with importing the mesh
  24021. * @returns a validation object with skinned, valid and report string
  24022. */
  24023. validateSkinning(): {
  24024. skinned: boolean;
  24025. valid: boolean;
  24026. report: string;
  24027. };
  24028. /** @hidden */
  24029. _checkDelayState(): Mesh;
  24030. private _queueLoad;
  24031. /**
  24032. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24033. * A mesh is in the frustum if its bounding box intersects the frustum
  24034. * @param frustumPlanes defines the frustum to test
  24035. * @returns true if the mesh is in the frustum planes
  24036. */
  24037. isInFrustum(frustumPlanes: Plane[]): boolean;
  24038. /**
  24039. * Sets the mesh material by the material or multiMaterial `id` property
  24040. * @param id is a string identifying the material or the multiMaterial
  24041. * @returns the current mesh
  24042. */
  24043. setMaterialByID(id: string): Mesh;
  24044. /**
  24045. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24046. * @returns an array of IAnimatable
  24047. */
  24048. getAnimatables(): IAnimatable[];
  24049. /**
  24050. * Modifies the mesh geometry according to the passed transformation matrix.
  24051. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24052. * The mesh normals are modified using the same transformation.
  24053. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24054. * @param transform defines the transform matrix to use
  24055. * @see http://doc.babylonjs.com/resources/baking_transformations
  24056. * @returns the current mesh
  24057. */
  24058. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24059. /**
  24060. * Modifies the mesh geometry according to its own current World Matrix.
  24061. * The mesh World Matrix is then reset.
  24062. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24063. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24064. * @see http://doc.babylonjs.com/resources/baking_transformations
  24065. * @returns the current mesh
  24066. */
  24067. bakeCurrentTransformIntoVertices(): Mesh;
  24068. /** @hidden */
  24069. readonly _positions: Nullable<Vector3[]>;
  24070. /** @hidden */
  24071. _resetPointsArrayCache(): Mesh;
  24072. /** @hidden */
  24073. _generatePointsArray(): boolean;
  24074. /**
  24075. * Returns a new Mesh object generated from the current mesh properties.
  24076. * This method must not get confused with createInstance()
  24077. * @param name is a string, the name given to the new mesh
  24078. * @param newParent can be any Node object (default `null`)
  24079. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24080. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24081. * @returns a new mesh
  24082. */
  24083. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24084. /**
  24085. * Releases resources associated with this mesh.
  24086. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24087. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24088. */
  24089. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24090. /**
  24091. * Modifies the mesh geometry according to a displacement map.
  24092. * 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.
  24093. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24094. * @param url is a string, the URL from the image file is to be downloaded.
  24095. * @param minHeight is the lower limit of the displacement.
  24096. * @param maxHeight is the upper limit of the displacement.
  24097. * @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.
  24098. * @param uvOffset is an optional vector2 used to offset UV.
  24099. * @param uvScale is an optional vector2 used to scale UV.
  24100. * @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.
  24101. * @returns the Mesh.
  24102. */
  24103. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24104. /**
  24105. * Modifies the mesh geometry according to a displacementMap buffer.
  24106. * 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.
  24107. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24108. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24109. * @param heightMapWidth is the width of the buffer image.
  24110. * @param heightMapHeight is the height of the buffer image.
  24111. * @param minHeight is the lower limit of the displacement.
  24112. * @param maxHeight is the upper limit of the displacement.
  24113. * @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.
  24114. * @param uvOffset is an optional vector2 used to offset UV.
  24115. * @param uvScale is an optional vector2 used to scale UV.
  24116. * @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.
  24117. * @returns the Mesh.
  24118. */
  24119. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24120. /**
  24121. * Modify the mesh to get a flat shading rendering.
  24122. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24123. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24124. * @returns current mesh
  24125. */
  24126. convertToFlatShadedMesh(): Mesh;
  24127. /**
  24128. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24129. * In other words, more vertices, no more indices and a single bigger VBO.
  24130. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24131. * @returns current mesh
  24132. */
  24133. convertToUnIndexedMesh(): Mesh;
  24134. /**
  24135. * Inverses facet orientations.
  24136. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24137. * @param flipNormals will also inverts the normals
  24138. * @returns current mesh
  24139. */
  24140. flipFaces(flipNormals?: boolean): Mesh;
  24141. /**
  24142. * Increase the number of facets and hence vertices in a mesh
  24143. * Vertex normals are interpolated from existing vertex normals
  24144. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24145. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24146. */
  24147. increaseVertices(numberPerEdge: number): void;
  24148. /**
  24149. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24150. * This will undo any application of covertToFlatShadedMesh
  24151. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24152. */
  24153. forceSharedVertices(): void;
  24154. /** @hidden */
  24155. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24156. /** @hidden */
  24157. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24158. /**
  24159. * Creates a new InstancedMesh object from the mesh model.
  24160. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24161. * @param name defines the name of the new instance
  24162. * @returns a new InstancedMesh
  24163. */
  24164. createInstance(name: string): InstancedMesh;
  24165. /**
  24166. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24167. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24168. * @returns the current mesh
  24169. */
  24170. synchronizeInstances(): Mesh;
  24171. /**
  24172. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24173. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24174. * This should be used together with the simplification to avoid disappearing triangles.
  24175. * @param successCallback an optional success callback to be called after the optimization finished.
  24176. * @returns the current mesh
  24177. */
  24178. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24179. /**
  24180. * Serialize current mesh
  24181. * @param serializationObject defines the object which will receive the serialization data
  24182. */
  24183. serialize(serializationObject: any): void;
  24184. /** @hidden */
  24185. _syncGeometryWithMorphTargetManager(): void;
  24186. /** @hidden */
  24187. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24188. /**
  24189. * Returns a new Mesh object parsed from the source provided.
  24190. * @param parsedMesh is the source
  24191. * @param scene defines the hosting scene
  24192. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24193. * @returns a new Mesh
  24194. */
  24195. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24196. /**
  24197. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24198. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24199. * @param name defines the name of the mesh to create
  24200. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24201. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24202. * @param closePath creates a seam between the first and the last points of each path of the path array
  24203. * @param offset is taken in account only if the `pathArray` is containing a single path
  24204. * @param scene defines the hosting scene
  24205. * @param updatable defines if the mesh must be flagged as updatable
  24206. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24207. * @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)
  24208. * @returns a new Mesh
  24209. */
  24210. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24211. /**
  24212. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24213. * @param name defines the name of the mesh to create
  24214. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24215. * @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
  24216. * @param scene defines the hosting scene
  24217. * @param updatable defines if the mesh must be flagged as updatable
  24218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24219. * @returns a new Mesh
  24220. */
  24221. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24222. /**
  24223. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24224. * @param name defines the name of the mesh to create
  24225. * @param size sets the size (float) of each box side (default 1)
  24226. * @param scene defines the hosting scene
  24227. * @param updatable defines if the mesh must be flagged as updatable
  24228. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24229. * @returns a new Mesh
  24230. */
  24231. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24232. /**
  24233. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24234. * @param name defines the name of the mesh to create
  24235. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24236. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24237. * @param scene defines the hosting scene
  24238. * @param updatable defines if the mesh must be flagged as updatable
  24239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24240. * @returns a new Mesh
  24241. */
  24242. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24243. /**
  24244. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24245. * @param name defines the name of the mesh to create
  24246. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24247. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24248. * @param scene defines the hosting scene
  24249. * @returns a new Mesh
  24250. */
  24251. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24252. /**
  24253. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24254. * @param name defines the name of the mesh to create
  24255. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24256. * @param diameterTop set the top cap diameter (floats, default 1)
  24257. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24258. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24259. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24260. * @param scene defines the hosting scene
  24261. * @param updatable defines if the mesh must be flagged as updatable
  24262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24263. * @returns a new Mesh
  24264. */
  24265. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24266. /**
  24267. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24268. * @param name defines the name of the mesh to create
  24269. * @param diameter sets the diameter size (float) of the torus (default 1)
  24270. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24271. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24272. * @param scene defines the hosting scene
  24273. * @param updatable defines if the mesh must be flagged as updatable
  24274. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24275. * @returns a new Mesh
  24276. */
  24277. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24278. /**
  24279. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24280. * @param name defines the name of the mesh to create
  24281. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24282. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24283. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24284. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24285. * @param p the number of windings on X axis (positive integers, default 2)
  24286. * @param q the number of windings on Y axis (positive integers, default 3)
  24287. * @param scene defines the hosting scene
  24288. * @param updatable defines if the mesh must be flagged as updatable
  24289. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24290. * @returns a new Mesh
  24291. */
  24292. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24293. /**
  24294. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24295. * @param name defines the name of the mesh to create
  24296. * @param points is an array successive Vector3
  24297. * @param scene defines the hosting scene
  24298. * @param updatable defines if the mesh must be flagged as updatable
  24299. * @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).
  24300. * @returns a new Mesh
  24301. */
  24302. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24303. /**
  24304. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24305. * @param name defines the name of the mesh to create
  24306. * @param points is an array successive Vector3
  24307. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24308. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24309. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24310. * @param scene defines the hosting scene
  24311. * @param updatable defines if the mesh must be flagged as updatable
  24312. * @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)
  24313. * @returns a new Mesh
  24314. */
  24315. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24316. /**
  24317. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24318. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24319. * 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.
  24320. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24321. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24322. * Remember you can only change the shape positions, not their number when updating a polygon.
  24323. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24324. * @param name defines the name of the mesh to create
  24325. * @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
  24326. * @param scene defines the hosting scene
  24327. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24328. * @param updatable defines if the mesh must be flagged as updatable
  24329. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24330. * @param earcutInjection can be used to inject your own earcut reference
  24331. * @returns a new Mesh
  24332. */
  24333. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24334. /**
  24335. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24336. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24337. * @param name defines the name of the mesh to create
  24338. * @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
  24339. * @param depth defines the height of extrusion
  24340. * @param scene defines the hosting scene
  24341. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24342. * @param updatable defines if the mesh must be flagged as updatable
  24343. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24344. * @param earcutInjection can be used to inject your own earcut reference
  24345. * @returns a new Mesh
  24346. */
  24347. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24348. /**
  24349. * Creates an extruded shape mesh.
  24350. * 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
  24351. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24352. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24353. * @param name defines the name of the mesh to create
  24354. * @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
  24355. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24356. * @param scale is the value to scale the shape
  24357. * @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
  24358. * @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
  24359. * @param scene defines the hosting scene
  24360. * @param updatable defines if the mesh must be flagged as updatable
  24361. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24362. * @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)
  24363. * @returns a new Mesh
  24364. */
  24365. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24366. /**
  24367. * Creates an custom extruded shape mesh.
  24368. * The custom extrusion is a parametric shape.
  24369. * It has no predefined shape. Its final shape will depend on the input parameters.
  24370. * Please consider using the same method from the MeshBuilder class instead
  24371. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24372. * @param name defines the name of the mesh to create
  24373. * @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
  24374. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24375. * @param scaleFunction is a custom Javascript function called on each path point
  24376. * @param rotationFunction is a custom Javascript function called on each path point
  24377. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24378. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24379. * @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
  24380. * @param scene defines the hosting scene
  24381. * @param updatable defines if the mesh must be flagged as updatable
  24382. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24383. * @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)
  24384. * @returns a new Mesh
  24385. */
  24386. 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;
  24387. /**
  24388. * Creates lathe mesh.
  24389. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24390. * Please consider using the same method from the MeshBuilder class instead
  24391. * @param name defines the name of the mesh to create
  24392. * @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
  24393. * @param radius is the radius value of the lathe
  24394. * @param tessellation is the side number of the lathe.
  24395. * @param scene defines the hosting scene
  24396. * @param updatable defines if the mesh must be flagged as updatable
  24397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24398. * @returns a new Mesh
  24399. */
  24400. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24401. /**
  24402. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24403. * @param name defines the name of the mesh to create
  24404. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24405. * @param scene defines the hosting scene
  24406. * @param updatable defines if the mesh must be flagged as updatable
  24407. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24408. * @returns a new Mesh
  24409. */
  24410. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24411. /**
  24412. * Creates a ground mesh.
  24413. * Please consider using the same method from the MeshBuilder class instead
  24414. * @param name defines the name of the mesh to create
  24415. * @param width set the width of the ground
  24416. * @param height set the height of the ground
  24417. * @param subdivisions sets the number of subdivisions per side
  24418. * @param scene defines the hosting scene
  24419. * @param updatable defines if the mesh must be flagged as updatable
  24420. * @returns a new Mesh
  24421. */
  24422. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24423. /**
  24424. * Creates a tiled ground mesh.
  24425. * Please consider using the same method from the MeshBuilder class instead
  24426. * @param name defines the name of the mesh to create
  24427. * @param xmin set the ground minimum X coordinate
  24428. * @param zmin set the ground minimum Y coordinate
  24429. * @param xmax set the ground maximum X coordinate
  24430. * @param zmax set the ground maximum Z coordinate
  24431. * @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
  24432. * @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
  24433. * @param scene defines the hosting scene
  24434. * @param updatable defines if the mesh must be flagged as updatable
  24435. * @returns a new Mesh
  24436. */
  24437. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24438. w: number;
  24439. h: number;
  24440. }, precision: {
  24441. w: number;
  24442. h: number;
  24443. }, scene: Scene, updatable?: boolean): Mesh;
  24444. /**
  24445. * Creates a ground mesh from a height map.
  24446. * Please consider using the same method from the MeshBuilder class instead
  24447. * @see http://doc.babylonjs.com/babylon101/height_map
  24448. * @param name defines the name of the mesh to create
  24449. * @param url sets the URL of the height map image resource
  24450. * @param width set the ground width size
  24451. * @param height set the ground height size
  24452. * @param subdivisions sets the number of subdivision per side
  24453. * @param minHeight is the minimum altitude on the ground
  24454. * @param maxHeight is the maximum altitude on the ground
  24455. * @param scene defines the hosting scene
  24456. * @param updatable defines if the mesh must be flagged as updatable
  24457. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24458. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24459. * @returns a new Mesh
  24460. */
  24461. 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;
  24462. /**
  24463. * Creates a tube mesh.
  24464. * The tube is a parametric shape.
  24465. * It has no predefined shape. Its final shape will depend on the input parameters.
  24466. * Please consider using the same method from the MeshBuilder class instead
  24467. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24468. * @param name defines the name of the mesh to create
  24469. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24470. * @param radius sets the tube radius size
  24471. * @param tessellation is the number of sides on the tubular surface
  24472. * @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
  24473. * @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
  24474. * @param scene defines the hosting scene
  24475. * @param updatable defines if the mesh must be flagged as updatable
  24476. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24477. * @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)
  24478. * @returns a new Mesh
  24479. */
  24480. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24481. (i: number, distance: number): number;
  24482. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24483. /**
  24484. * Creates a polyhedron mesh.
  24485. * Please consider using the same method from the MeshBuilder class instead.
  24486. * * 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
  24487. * * The parameter `size` (positive float, default 1) sets the polygon size
  24488. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24489. * * 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`
  24490. * * 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
  24491. * * 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)`)
  24492. * * 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
  24493. * * 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
  24494. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24495. * * 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
  24496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24497. * @param name defines the name of the mesh to create
  24498. * @param options defines the options used to create the mesh
  24499. * @param scene defines the hosting scene
  24500. * @returns a new Mesh
  24501. */
  24502. static CreatePolyhedron(name: string, options: {
  24503. type?: number;
  24504. size?: number;
  24505. sizeX?: number;
  24506. sizeY?: number;
  24507. sizeZ?: number;
  24508. custom?: any;
  24509. faceUV?: Vector4[];
  24510. faceColors?: Color4[];
  24511. updatable?: boolean;
  24512. sideOrientation?: number;
  24513. }, scene: Scene): Mesh;
  24514. /**
  24515. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24516. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24517. * * 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`)
  24518. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24519. * * 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
  24520. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24521. * * 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
  24522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24523. * @param name defines the name of the mesh
  24524. * @param options defines the options used to create the mesh
  24525. * @param scene defines the hosting scene
  24526. * @returns a new Mesh
  24527. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24528. */
  24529. static CreateIcoSphere(name: string, options: {
  24530. radius?: number;
  24531. flat?: boolean;
  24532. subdivisions?: number;
  24533. sideOrientation?: number;
  24534. updatable?: boolean;
  24535. }, scene: Scene): Mesh;
  24536. /**
  24537. * Creates a decal mesh.
  24538. * Please consider using the same method from the MeshBuilder class instead.
  24539. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24540. * @param name defines the name of the mesh
  24541. * @param sourceMesh defines the mesh receiving the decal
  24542. * @param position sets the position of the decal in world coordinates
  24543. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24544. * @param size sets the decal scaling
  24545. * @param angle sets the angle to rotate the decal
  24546. * @returns a new Mesh
  24547. */
  24548. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24549. /**
  24550. * Prepare internal position array for software CPU skinning
  24551. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24552. */
  24553. setPositionsForCPUSkinning(): Float32Array;
  24554. /**
  24555. * Prepare internal normal array for software CPU skinning
  24556. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24557. */
  24558. setNormalsForCPUSkinning(): Float32Array;
  24559. /**
  24560. * Updates the vertex buffer by applying transformation from the bones
  24561. * @param skeleton defines the skeleton to apply to current mesh
  24562. * @returns the current mesh
  24563. */
  24564. applySkeleton(skeleton: Skeleton): Mesh;
  24565. /**
  24566. * 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
  24567. * @param meshes defines the list of meshes to scan
  24568. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24569. */
  24570. static MinMax(meshes: AbstractMesh[]): {
  24571. min: Vector3;
  24572. max: Vector3;
  24573. };
  24574. /**
  24575. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24576. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24577. * @returns a vector3
  24578. */
  24579. static Center(meshesOrMinMaxVector: {
  24580. min: Vector3;
  24581. max: Vector3;
  24582. } | AbstractMesh[]): Vector3;
  24583. /**
  24584. * Merge the array of meshes into a single mesh for performance reasons.
  24585. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24586. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24587. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24588. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24589. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24590. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24591. * @returns a new mesh
  24592. */
  24593. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24594. /** @hidden */
  24595. addInstance(instance: InstancedMesh): void;
  24596. /** @hidden */
  24597. removeInstance(instance: InstancedMesh): void;
  24598. }
  24599. }
  24600. declare module BABYLON {
  24601. /**
  24602. * This is the base class of all the camera used in the application.
  24603. * @see http://doc.babylonjs.com/features/cameras
  24604. */
  24605. export class Camera extends Node {
  24606. /** @hidden */
  24607. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24608. /**
  24609. * This is the default projection mode used by the cameras.
  24610. * It helps recreating a feeling of perspective and better appreciate depth.
  24611. * This is the best way to simulate real life cameras.
  24612. */
  24613. static readonly PERSPECTIVE_CAMERA: number;
  24614. /**
  24615. * This helps creating camera with an orthographic mode.
  24616. * 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.
  24617. */
  24618. static readonly ORTHOGRAPHIC_CAMERA: number;
  24619. /**
  24620. * This is the default FOV mode for perspective cameras.
  24621. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24622. */
  24623. static readonly FOVMODE_VERTICAL_FIXED: number;
  24624. /**
  24625. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24626. */
  24627. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24628. /**
  24629. * This specifies ther is no need for a camera rig.
  24630. * Basically only one eye is rendered corresponding to the camera.
  24631. */
  24632. static readonly RIG_MODE_NONE: number;
  24633. /**
  24634. * Simulates a camera Rig with one blue eye and one red eye.
  24635. * This can be use with 3d blue and red glasses.
  24636. */
  24637. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24638. /**
  24639. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24640. */
  24641. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24642. /**
  24643. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24644. */
  24645. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24646. /**
  24647. * Defines that both eyes of the camera will be rendered over under each other.
  24648. */
  24649. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24650. /**
  24651. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24652. */
  24653. static readonly RIG_MODE_VR: number;
  24654. /**
  24655. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24656. */
  24657. static readonly RIG_MODE_WEBVR: number;
  24658. /**
  24659. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24660. */
  24661. static readonly RIG_MODE_CUSTOM: number;
  24662. /**
  24663. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24664. */
  24665. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24666. /**
  24667. * Define the input manager associated with the camera.
  24668. */
  24669. inputs: CameraInputsManager<Camera>;
  24670. /** @hidden */
  24671. _position: Vector3;
  24672. /**
  24673. * Define the current local position of the camera in the scene
  24674. */
  24675. position: Vector3;
  24676. /**
  24677. * The vector the camera should consider as up.
  24678. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24679. */
  24680. upVector: Vector3;
  24681. /**
  24682. * Define the current limit on the left side for an orthographic camera
  24683. * In scene unit
  24684. */
  24685. orthoLeft: Nullable<number>;
  24686. /**
  24687. * Define the current limit on the right side for an orthographic camera
  24688. * In scene unit
  24689. */
  24690. orthoRight: Nullable<number>;
  24691. /**
  24692. * Define the current limit on the bottom side for an orthographic camera
  24693. * In scene unit
  24694. */
  24695. orthoBottom: Nullable<number>;
  24696. /**
  24697. * Define the current limit on the top side for an orthographic camera
  24698. * In scene unit
  24699. */
  24700. orthoTop: Nullable<number>;
  24701. /**
  24702. * Field Of View is set in Radians. (default is 0.8)
  24703. */
  24704. fov: number;
  24705. /**
  24706. * Define the minimum distance the camera can see from.
  24707. * This is important to note that the depth buffer are not infinite and the closer it starts
  24708. * the more your scene might encounter depth fighting issue.
  24709. */
  24710. minZ: number;
  24711. /**
  24712. * Define the maximum distance the camera can see to.
  24713. * This is important to note that the depth buffer are not infinite and the further it end
  24714. * the more your scene might encounter depth fighting issue.
  24715. */
  24716. maxZ: number;
  24717. /**
  24718. * Define the default inertia of the camera.
  24719. * This helps giving a smooth feeling to the camera movement.
  24720. */
  24721. inertia: number;
  24722. /**
  24723. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24724. */
  24725. mode: number;
  24726. /**
  24727. * Define wether the camera is intermediate.
  24728. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24729. */
  24730. isIntermediate: boolean;
  24731. /**
  24732. * Define the viewport of the camera.
  24733. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24734. */
  24735. viewport: Viewport;
  24736. /**
  24737. * Restricts the camera to viewing objects with the same layerMask.
  24738. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24739. */
  24740. layerMask: number;
  24741. /**
  24742. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24743. */
  24744. fovMode: number;
  24745. /**
  24746. * Rig mode of the camera.
  24747. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24748. * This is normally controlled byt the camera themselves as internal use.
  24749. */
  24750. cameraRigMode: number;
  24751. /**
  24752. * Defines the distance between both "eyes" in case of a RIG
  24753. */
  24754. interaxialDistance: number;
  24755. /**
  24756. * Defines if stereoscopic rendering is done side by side or over under.
  24757. */
  24758. isStereoscopicSideBySide: boolean;
  24759. /**
  24760. * 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
  24761. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24762. * else in the scene. (Eg. security camera)
  24763. *
  24764. * 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)
  24765. */
  24766. customRenderTargets: RenderTargetTexture[];
  24767. /**
  24768. * When set, the camera will render to this render target instead of the default canvas
  24769. *
  24770. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24771. */
  24772. outputRenderTarget: Nullable<RenderTargetTexture>;
  24773. /**
  24774. * Observable triggered when the camera view matrix has changed.
  24775. */
  24776. onViewMatrixChangedObservable: Observable<Camera>;
  24777. /**
  24778. * Observable triggered when the camera Projection matrix has changed.
  24779. */
  24780. onProjectionMatrixChangedObservable: Observable<Camera>;
  24781. /**
  24782. * Observable triggered when the inputs have been processed.
  24783. */
  24784. onAfterCheckInputsObservable: Observable<Camera>;
  24785. /**
  24786. * Observable triggered when reset has been called and applied to the camera.
  24787. */
  24788. onRestoreStateObservable: Observable<Camera>;
  24789. /** @hidden */
  24790. _cameraRigParams: any;
  24791. /** @hidden */
  24792. _rigCameras: Camera[];
  24793. /** @hidden */
  24794. _rigPostProcess: Nullable<PostProcess>;
  24795. protected _webvrViewMatrix: Matrix;
  24796. /** @hidden */
  24797. _skipRendering: boolean;
  24798. /** @hidden */
  24799. _projectionMatrix: Matrix;
  24800. /** @hidden */
  24801. _postProcesses: Nullable<PostProcess>[];
  24802. /** @hidden */
  24803. _activeMeshes: SmartArray<AbstractMesh>;
  24804. protected _globalPosition: Vector3;
  24805. /** @hidden */
  24806. _computedViewMatrix: Matrix;
  24807. private _doNotComputeProjectionMatrix;
  24808. private _transformMatrix;
  24809. private _frustumPlanes;
  24810. private _refreshFrustumPlanes;
  24811. private _storedFov;
  24812. private _stateStored;
  24813. /**
  24814. * Instantiates a new camera object.
  24815. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24816. * @see http://doc.babylonjs.com/features/cameras
  24817. * @param name Defines the name of the camera in the scene
  24818. * @param position Defines the position of the camera
  24819. * @param scene Defines the scene the camera belongs too
  24820. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24821. */
  24822. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24823. /**
  24824. * Store current camera state (fov, position, etc..)
  24825. * @returns the camera
  24826. */
  24827. storeState(): Camera;
  24828. /**
  24829. * Restores the camera state values if it has been stored. You must call storeState() first
  24830. */
  24831. protected _restoreStateValues(): boolean;
  24832. /**
  24833. * Restored camera state. You must call storeState() first.
  24834. * @returns true if restored and false otherwise
  24835. */
  24836. restoreState(): boolean;
  24837. /**
  24838. * Gets the class name of the camera.
  24839. * @returns the class name
  24840. */
  24841. getClassName(): string;
  24842. /** @hidden */
  24843. readonly _isCamera: boolean;
  24844. /**
  24845. * Gets a string representation of the camera useful for debug purpose.
  24846. * @param fullDetails Defines that a more verboe level of logging is required
  24847. * @returns the string representation
  24848. */
  24849. toString(fullDetails?: boolean): string;
  24850. /**
  24851. * Gets the current world space position of the camera.
  24852. */
  24853. readonly globalPosition: Vector3;
  24854. /**
  24855. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24856. * @returns the active meshe list
  24857. */
  24858. getActiveMeshes(): SmartArray<AbstractMesh>;
  24859. /**
  24860. * Check wether a mesh is part of the current active mesh list of the camera
  24861. * @param mesh Defines the mesh to check
  24862. * @returns true if active, false otherwise
  24863. */
  24864. isActiveMesh(mesh: Mesh): boolean;
  24865. /**
  24866. * Is this camera ready to be used/rendered
  24867. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24868. * @return true if the camera is ready
  24869. */
  24870. isReady(completeCheck?: boolean): boolean;
  24871. /** @hidden */
  24872. _initCache(): void;
  24873. /** @hidden */
  24874. _updateCache(ignoreParentClass?: boolean): void;
  24875. /** @hidden */
  24876. _isSynchronized(): boolean;
  24877. /** @hidden */
  24878. _isSynchronizedViewMatrix(): boolean;
  24879. /** @hidden */
  24880. _isSynchronizedProjectionMatrix(): boolean;
  24881. /**
  24882. * Attach the input controls to a specific dom element to get the input from.
  24883. * @param element Defines the element the controls should be listened from
  24884. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24885. */
  24886. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24887. /**
  24888. * Detach the current controls from the specified dom element.
  24889. * @param element Defines the element to stop listening the inputs from
  24890. */
  24891. detachControl(element: HTMLElement): void;
  24892. /**
  24893. * Update the camera state according to the different inputs gathered during the frame.
  24894. */
  24895. update(): void;
  24896. /** @hidden */
  24897. _checkInputs(): void;
  24898. /** @hidden */
  24899. readonly rigCameras: Camera[];
  24900. /**
  24901. * Gets the post process used by the rig cameras
  24902. */
  24903. readonly rigPostProcess: Nullable<PostProcess>;
  24904. /**
  24905. * Internal, gets the first post proces.
  24906. * @returns the first post process to be run on this camera.
  24907. */
  24908. _getFirstPostProcess(): Nullable<PostProcess>;
  24909. private _cascadePostProcessesToRigCams;
  24910. /**
  24911. * Attach a post process to the camera.
  24912. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24913. * @param postProcess The post process to attach to the camera
  24914. * @param insertAt The position of the post process in case several of them are in use in the scene
  24915. * @returns the position the post process has been inserted at
  24916. */
  24917. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24918. /**
  24919. * Detach a post process to the camera.
  24920. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24921. * @param postProcess The post process to detach from the camera
  24922. */
  24923. detachPostProcess(postProcess: PostProcess): void;
  24924. /**
  24925. * Gets the current world matrix of the camera
  24926. */
  24927. getWorldMatrix(): Matrix;
  24928. /** @hidden */
  24929. _getViewMatrix(): Matrix;
  24930. /**
  24931. * Gets the current view matrix of the camera.
  24932. * @param force forces the camera to recompute the matrix without looking at the cached state
  24933. * @returns the view matrix
  24934. */
  24935. getViewMatrix(force?: boolean): Matrix;
  24936. /**
  24937. * Freeze the projection matrix.
  24938. * It will prevent the cache check of the camera projection compute and can speed up perf
  24939. * if no parameter of the camera are meant to change
  24940. * @param projection Defines manually a projection if necessary
  24941. */
  24942. freezeProjectionMatrix(projection?: Matrix): void;
  24943. /**
  24944. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24945. */
  24946. unfreezeProjectionMatrix(): void;
  24947. /**
  24948. * Gets the current projection matrix of the camera.
  24949. * @param force forces the camera to recompute the matrix without looking at the cached state
  24950. * @returns the projection matrix
  24951. */
  24952. getProjectionMatrix(force?: boolean): Matrix;
  24953. /**
  24954. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24955. * @returns a Matrix
  24956. */
  24957. getTransformationMatrix(): Matrix;
  24958. private _updateFrustumPlanes;
  24959. /**
  24960. * Checks if a cullable object (mesh...) is in the camera frustum
  24961. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24962. * @param target The object to check
  24963. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24964. * @returns true if the object is in frustum otherwise false
  24965. */
  24966. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24967. /**
  24968. * Checks if a cullable object (mesh...) is in the camera frustum
  24969. * Unlike isInFrustum this cheks the full bounding box
  24970. * @param target The object to check
  24971. * @returns true if the object is in frustum otherwise false
  24972. */
  24973. isCompletelyInFrustum(target: ICullable): boolean;
  24974. /**
  24975. * Gets a ray in the forward direction from the camera.
  24976. * @param length Defines the length of the ray to create
  24977. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24978. * @param origin Defines the start point of the ray which defaults to the camera position
  24979. * @returns the forward ray
  24980. */
  24981. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24982. /**
  24983. * Releases resources associated with this node.
  24984. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24985. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24986. */
  24987. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24988. /** @hidden */
  24989. _isLeftCamera: boolean;
  24990. /**
  24991. * Gets the left camera of a rig setup in case of Rigged Camera
  24992. */
  24993. readonly isLeftCamera: boolean;
  24994. /** @hidden */
  24995. _isRightCamera: boolean;
  24996. /**
  24997. * Gets the right camera of a rig setup in case of Rigged Camera
  24998. */
  24999. readonly isRightCamera: boolean;
  25000. /**
  25001. * Gets the left camera of a rig setup in case of Rigged Camera
  25002. */
  25003. readonly leftCamera: Nullable<FreeCamera>;
  25004. /**
  25005. * Gets the right camera of a rig setup in case of Rigged Camera
  25006. */
  25007. readonly rightCamera: Nullable<FreeCamera>;
  25008. /**
  25009. * Gets the left camera target of a rig setup in case of Rigged Camera
  25010. * @returns the target position
  25011. */
  25012. getLeftTarget(): Nullable<Vector3>;
  25013. /**
  25014. * Gets the right camera target of a rig setup in case of Rigged Camera
  25015. * @returns the target position
  25016. */
  25017. getRightTarget(): Nullable<Vector3>;
  25018. /**
  25019. * @hidden
  25020. */
  25021. setCameraRigMode(mode: number, rigParams: any): void;
  25022. /** @hidden */
  25023. static _setStereoscopicRigMode(camera: Camera): void;
  25024. /** @hidden */
  25025. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25026. /** @hidden */
  25027. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25028. /** @hidden */
  25029. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25030. /** @hidden */
  25031. _getVRProjectionMatrix(): Matrix;
  25032. protected _updateCameraRotationMatrix(): void;
  25033. protected _updateWebVRCameraRotationMatrix(): void;
  25034. /**
  25035. * This function MUST be overwritten by the different WebVR cameras available.
  25036. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25037. * @hidden
  25038. */
  25039. _getWebVRProjectionMatrix(): Matrix;
  25040. /**
  25041. * This function MUST be overwritten by the different WebVR cameras available.
  25042. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25043. * @hidden
  25044. */
  25045. _getWebVRViewMatrix(): Matrix;
  25046. /** @hidden */
  25047. setCameraRigParameter(name: string, value: any): void;
  25048. /**
  25049. * needs to be overridden by children so sub has required properties to be copied
  25050. * @hidden
  25051. */
  25052. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25053. /**
  25054. * May need to be overridden by children
  25055. * @hidden
  25056. */
  25057. _updateRigCameras(): void;
  25058. /** @hidden */
  25059. _setupInputs(): void;
  25060. /**
  25061. * Serialiaze the camera setup to a json represention
  25062. * @returns the JSON representation
  25063. */
  25064. serialize(): any;
  25065. /**
  25066. * Clones the current camera.
  25067. * @param name The cloned camera name
  25068. * @returns the cloned camera
  25069. */
  25070. clone(name: string): Camera;
  25071. /**
  25072. * Gets the direction of the camera relative to a given local axis.
  25073. * @param localAxis Defines the reference axis to provide a relative direction.
  25074. * @return the direction
  25075. */
  25076. getDirection(localAxis: Vector3): Vector3;
  25077. /**
  25078. * Returns the current camera absolute rotation
  25079. */
  25080. readonly absoluteRotation: Quaternion;
  25081. /**
  25082. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25083. * @param localAxis Defines the reference axis to provide a relative direction.
  25084. * @param result Defines the vector to store the result in
  25085. */
  25086. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25087. /**
  25088. * Gets a camera constructor for a given camera type
  25089. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25090. * @param name The name of the camera the result will be able to instantiate
  25091. * @param scene The scene the result will construct the camera in
  25092. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25093. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25094. * @returns a factory method to construc the camera
  25095. */
  25096. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25097. /**
  25098. * Compute the world matrix of the camera.
  25099. * @returns the camera workd matrix
  25100. */
  25101. computeWorldMatrix(): Matrix;
  25102. /**
  25103. * Parse a JSON and creates the camera from the parsed information
  25104. * @param parsedCamera The JSON to parse
  25105. * @param scene The scene to instantiate the camera in
  25106. * @returns the newly constructed camera
  25107. */
  25108. static Parse(parsedCamera: any, scene: Scene): Camera;
  25109. }
  25110. }
  25111. declare module BABYLON {
  25112. /**
  25113. * Class containing static functions to help procedurally build meshes
  25114. */
  25115. export class DiscBuilder {
  25116. /**
  25117. * Creates a plane polygonal mesh. By default, this is a disc
  25118. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25119. * * 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
  25120. * * 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
  25121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25122. * * 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
  25123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25124. * @param name defines the name of the mesh
  25125. * @param options defines the options used to create the mesh
  25126. * @param scene defines the hosting scene
  25127. * @returns the plane polygonal mesh
  25128. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25129. */
  25130. static CreateDisc(name: string, options: {
  25131. radius?: number;
  25132. tessellation?: number;
  25133. arc?: number;
  25134. updatable?: boolean;
  25135. sideOrientation?: number;
  25136. frontUVs?: Vector4;
  25137. backUVs?: Vector4;
  25138. }, scene?: Nullable<Scene>): Mesh;
  25139. }
  25140. }
  25141. declare module BABYLON {
  25142. /**
  25143. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25144. *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.
  25145. * The SPS is also a particle system. It provides some methods to manage the particles.
  25146. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25147. *
  25148. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25149. */
  25150. export class SolidParticleSystem implements IDisposable {
  25151. /**
  25152. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25153. * Example : var p = SPS.particles[i];
  25154. */
  25155. particles: SolidParticle[];
  25156. /**
  25157. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25158. */
  25159. nbParticles: number;
  25160. /**
  25161. * If the particles must ever face the camera (default false). Useful for planar particles.
  25162. */
  25163. billboard: boolean;
  25164. /**
  25165. * Recompute normals when adding a shape
  25166. */
  25167. recomputeNormals: boolean;
  25168. /**
  25169. * This a counter ofr your own usage. It's not set by any SPS functions.
  25170. */
  25171. counter: number;
  25172. /**
  25173. * The SPS name. This name is also given to the underlying mesh.
  25174. */
  25175. name: string;
  25176. /**
  25177. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25178. */
  25179. mesh: Mesh;
  25180. /**
  25181. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25182. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25183. */
  25184. vars: any;
  25185. /**
  25186. * This array is populated when the SPS is set as 'pickable'.
  25187. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25188. * Each element of this array is an object `{idx: int, faceId: int}`.
  25189. * `idx` is the picked particle index in the `SPS.particles` array
  25190. * `faceId` is the picked face index counted within this particle.
  25191. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25192. */
  25193. pickedParticles: {
  25194. idx: number;
  25195. faceId: number;
  25196. }[];
  25197. /**
  25198. * This array is populated when `enableDepthSort` is set to true.
  25199. * Each element of this array is an instance of the class DepthSortedParticle.
  25200. */
  25201. depthSortedParticles: DepthSortedParticle[];
  25202. /**
  25203. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25204. * @hidden
  25205. */
  25206. _bSphereOnly: boolean;
  25207. /**
  25208. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25209. * @hidden
  25210. */
  25211. _bSphereRadiusFactor: number;
  25212. private _scene;
  25213. private _positions;
  25214. private _indices;
  25215. private _normals;
  25216. private _colors;
  25217. private _uvs;
  25218. private _indices32;
  25219. private _positions32;
  25220. private _normals32;
  25221. private _fixedNormal32;
  25222. private _colors32;
  25223. private _uvs32;
  25224. private _index;
  25225. private _updatable;
  25226. private _pickable;
  25227. private _isVisibilityBoxLocked;
  25228. private _alwaysVisible;
  25229. private _depthSort;
  25230. private _expandable;
  25231. private _shapeCounter;
  25232. private _copy;
  25233. private _color;
  25234. private _computeParticleColor;
  25235. private _computeParticleTexture;
  25236. private _computeParticleRotation;
  25237. private _computeParticleVertex;
  25238. private _computeBoundingBox;
  25239. private _depthSortParticles;
  25240. private _camera;
  25241. private _mustUnrotateFixedNormals;
  25242. private _particlesIntersect;
  25243. private _needs32Bits;
  25244. /**
  25245. * Creates a SPS (Solid Particle System) object.
  25246. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25247. * @param scene (Scene) is the scene in which the SPS is added.
  25248. * @param options defines the options of the sps e.g.
  25249. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25250. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25251. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25252. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25253. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25254. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25255. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25256. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25257. */
  25258. constructor(name: string, scene: Scene, options?: {
  25259. updatable?: boolean;
  25260. isPickable?: boolean;
  25261. enableDepthSort?: boolean;
  25262. particleIntersection?: boolean;
  25263. boundingSphereOnly?: boolean;
  25264. bSphereRadiusFactor?: number;
  25265. expandable?: boolean;
  25266. });
  25267. /**
  25268. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25269. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25270. * @returns the created mesh
  25271. */
  25272. buildMesh(): Mesh;
  25273. /**
  25274. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25275. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25276. * Thus the particles generated from `digest()` have their property `position` set yet.
  25277. * @param mesh ( Mesh ) is the mesh to be digested
  25278. * @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
  25279. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25280. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25281. * @returns the current SPS
  25282. */
  25283. digest(mesh: Mesh, options?: {
  25284. facetNb?: number;
  25285. number?: number;
  25286. delta?: number;
  25287. }): SolidParticleSystem;
  25288. private _unrotateFixedNormals;
  25289. private _resetCopy;
  25290. private _meshBuilder;
  25291. private _posToShape;
  25292. private _uvsToShapeUV;
  25293. private _addParticle;
  25294. /**
  25295. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25296. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25297. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25298. * @param nb (positive integer) the number of particles to be created from this model
  25299. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25300. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25301. * @returns the number of shapes in the system
  25302. */
  25303. addShape(mesh: Mesh, nb: number, options?: {
  25304. positionFunction?: any;
  25305. vertexFunction?: any;
  25306. }): number;
  25307. private _rebuildParticle;
  25308. /**
  25309. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25310. * @returns the SPS.
  25311. */
  25312. rebuildMesh(): SolidParticleSystem;
  25313. /**
  25314. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25315. * This method calls `updateParticle()` for each particle of the SPS.
  25316. * For an animated SPS, it is usually called within the render loop.
  25317. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25318. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25319. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25320. * @returns the SPS.
  25321. */
  25322. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25323. /**
  25324. * Disposes the SPS.
  25325. */
  25326. dispose(): void;
  25327. /**
  25328. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25329. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25330. * @returns the SPS.
  25331. */
  25332. refreshVisibleSize(): SolidParticleSystem;
  25333. /**
  25334. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25335. * @param size the size (float) of the visibility box
  25336. * note : this doesn't lock the SPS mesh bounding box.
  25337. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25338. */
  25339. setVisibilityBox(size: number): void;
  25340. /**
  25341. * Gets whether the SPS as always visible or not
  25342. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25343. */
  25344. /**
  25345. * Sets the SPS as always visible or not
  25346. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25347. */
  25348. isAlwaysVisible: boolean;
  25349. /**
  25350. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25351. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25352. */
  25353. /**
  25354. * Gets if 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. isVisibilityBoxLocked: boolean;
  25358. /**
  25359. * Tells to `setParticles()` to compute the particle rotations or not.
  25360. * Default value : true. The SPS is faster when it's set to false.
  25361. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25362. */
  25363. /**
  25364. * Gets if `setParticles()` computes the particle rotations or not.
  25365. * Default value : true. The SPS is faster when it's set to false.
  25366. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25367. */
  25368. computeParticleRotation: boolean;
  25369. /**
  25370. * Tells to `setParticles()` to compute the particle colors or not.
  25371. * Default value : true. The SPS is faster when it's set to false.
  25372. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25373. */
  25374. /**
  25375. * Gets if `setParticles()` computes the particle colors or not.
  25376. * Default value : true. The SPS is faster when it's set to false.
  25377. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25378. */
  25379. computeParticleColor: boolean;
  25380. /**
  25381. * Gets if `setParticles()` computes the particle textures or not.
  25382. * Default value : true. The SPS is faster when it's set to false.
  25383. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25384. */
  25385. computeParticleTexture: boolean;
  25386. /**
  25387. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25388. * Default value : false. The SPS is faster when it's set to false.
  25389. * Note : the particle custom vertex positions aren't stored values.
  25390. */
  25391. /**
  25392. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25393. * Default value : false. The SPS is faster when it's set to false.
  25394. * Note : the particle custom vertex positions aren't stored values.
  25395. */
  25396. computeParticleVertex: boolean;
  25397. /**
  25398. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25399. */
  25400. /**
  25401. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25402. */
  25403. computeBoundingBox: boolean;
  25404. /**
  25405. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25406. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25407. * Default : `true`
  25408. */
  25409. /**
  25410. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25411. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25412. * Default : `true`
  25413. */
  25414. depthSortParticles: boolean;
  25415. /**
  25416. * Gets if the SPS is created as expandable at construction time.
  25417. * Default : `false`
  25418. */
  25419. readonly expandable: boolean;
  25420. /**
  25421. * This function does nothing. It may be overwritten to set all the particle first values.
  25422. * The SPS doesn't call this function, you may have to call it by your own.
  25423. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25424. */
  25425. initParticles(): void;
  25426. /**
  25427. * This function does nothing. It may be overwritten to recycle a particle.
  25428. * The SPS doesn't call this function, you may have to call it by your own.
  25429. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25430. * @param particle The particle to recycle
  25431. * @returns the recycled particle
  25432. */
  25433. recycleParticle(particle: SolidParticle): SolidParticle;
  25434. /**
  25435. * Updates a particle : this function should be overwritten by the user.
  25436. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25437. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25438. * @example : just set a particle position or velocity and recycle conditions
  25439. * @param particle The particle to update
  25440. * @returns the updated particle
  25441. */
  25442. updateParticle(particle: SolidParticle): SolidParticle;
  25443. /**
  25444. * Updates a vertex of a particle : it can be overwritten by the user.
  25445. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25446. * @param particle the current particle
  25447. * @param vertex the current index of the current particle
  25448. * @param pt the index of the current vertex in the particle shape
  25449. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25450. * @example : just set a vertex particle position
  25451. * @returns the updated vertex
  25452. */
  25453. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25454. /**
  25455. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25456. * This does nothing and may be overwritten by the user.
  25457. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25458. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25459. * @param update the boolean update value actually passed to setParticles()
  25460. */
  25461. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25462. /**
  25463. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25464. * This will be passed three parameters.
  25465. * This does nothing and may be overwritten by the user.
  25466. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25467. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25468. * @param update the boolean update value actually passed to setParticles()
  25469. */
  25470. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25471. }
  25472. }
  25473. declare module BABYLON {
  25474. /**
  25475. * Represents one particle of a solid particle system.
  25476. */
  25477. export class SolidParticle {
  25478. /**
  25479. * particle global index
  25480. */
  25481. idx: number;
  25482. /**
  25483. * The color of the particle
  25484. */
  25485. color: Nullable<Color4>;
  25486. /**
  25487. * The world space position of the particle.
  25488. */
  25489. position: Vector3;
  25490. /**
  25491. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25492. */
  25493. rotation: Vector3;
  25494. /**
  25495. * The world space rotation quaternion of the particle.
  25496. */
  25497. rotationQuaternion: Nullable<Quaternion>;
  25498. /**
  25499. * The scaling of the particle.
  25500. */
  25501. scaling: Vector3;
  25502. /**
  25503. * The uvs of the particle.
  25504. */
  25505. uvs: Vector4;
  25506. /**
  25507. * The current speed of the particle.
  25508. */
  25509. velocity: Vector3;
  25510. /**
  25511. * The pivot point in the particle local space.
  25512. */
  25513. pivot: Vector3;
  25514. /**
  25515. * Must the particle be translated from its pivot point in its local space ?
  25516. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25517. * Default : false
  25518. */
  25519. translateFromPivot: boolean;
  25520. /**
  25521. * Is the particle active or not ?
  25522. */
  25523. alive: boolean;
  25524. /**
  25525. * Is the particle visible or not ?
  25526. */
  25527. isVisible: boolean;
  25528. /**
  25529. * Index of this particle in the global "positions" array (Internal use)
  25530. * @hidden
  25531. */
  25532. _pos: number;
  25533. /**
  25534. * @hidden Index of this particle in the global "indices" array (Internal use)
  25535. */
  25536. _ind: number;
  25537. /**
  25538. * @hidden ModelShape of this particle (Internal use)
  25539. */
  25540. _model: ModelShape;
  25541. /**
  25542. * ModelShape id of this particle
  25543. */
  25544. shapeId: number;
  25545. /**
  25546. * Index of the particle in its shape id
  25547. */
  25548. idxInShape: number;
  25549. /**
  25550. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25551. */
  25552. _modelBoundingInfo: BoundingInfo;
  25553. /**
  25554. * @hidden Particle BoundingInfo object (Internal use)
  25555. */
  25556. _boundingInfo: BoundingInfo;
  25557. /**
  25558. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25559. */
  25560. _sps: SolidParticleSystem;
  25561. /**
  25562. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25563. */
  25564. _stillInvisible: boolean;
  25565. /**
  25566. * @hidden Last computed particle rotation matrix
  25567. */
  25568. _rotationMatrix: number[];
  25569. /**
  25570. * Parent particle Id, if any.
  25571. * Default null.
  25572. */
  25573. parentId: Nullable<number>;
  25574. /**
  25575. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25576. * The possible values are :
  25577. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25578. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25579. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25580. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25581. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25582. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25583. * */
  25584. cullingStrategy: number;
  25585. /**
  25586. * @hidden Internal global position in the SPS.
  25587. */
  25588. _globalPosition: Vector3;
  25589. /**
  25590. * Creates a Solid Particle object.
  25591. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25592. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25593. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25594. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25595. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25596. * @param shapeId (integer) is the model shape identifier in the SPS.
  25597. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25598. * @param sps defines the sps it is associated to
  25599. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25600. */
  25601. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25602. /**
  25603. * Legacy support, changed scale to scaling
  25604. */
  25605. /**
  25606. * Legacy support, changed scale to scaling
  25607. */
  25608. scale: Vector3;
  25609. /**
  25610. * Legacy support, changed quaternion to rotationQuaternion
  25611. */
  25612. /**
  25613. * Legacy support, changed quaternion to rotationQuaternion
  25614. */
  25615. quaternion: Nullable<Quaternion>;
  25616. /**
  25617. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25618. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25619. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25620. * @returns true if it intersects
  25621. */
  25622. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25623. /**
  25624. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25625. * A particle is in the frustum if its bounding box intersects the frustum
  25626. * @param frustumPlanes defines the frustum to test
  25627. * @returns true if the particle is in the frustum planes
  25628. */
  25629. isInFrustum(frustumPlanes: Plane[]): boolean;
  25630. /**
  25631. * get the rotation matrix of the particle
  25632. * @hidden
  25633. */
  25634. getRotationMatrix(m: Matrix): void;
  25635. }
  25636. /**
  25637. * Represents the shape of the model used by one particle of a solid particle system.
  25638. * SPS internal tool, don't use it manually.
  25639. */
  25640. export class ModelShape {
  25641. /**
  25642. * The shape id
  25643. * @hidden
  25644. */
  25645. shapeID: number;
  25646. /**
  25647. * flat array of model positions (internal use)
  25648. * @hidden
  25649. */
  25650. _shape: Vector3[];
  25651. /**
  25652. * flat array of model UVs (internal use)
  25653. * @hidden
  25654. */
  25655. _shapeUV: number[];
  25656. /**
  25657. * length of the shape in the model indices array (internal use)
  25658. * @hidden
  25659. */
  25660. _indicesLength: number;
  25661. /**
  25662. * Custom position function (internal use)
  25663. * @hidden
  25664. */
  25665. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25666. /**
  25667. * Custom vertex function (internal use)
  25668. * @hidden
  25669. */
  25670. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25671. /**
  25672. * 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.
  25673. * SPS internal tool, don't use it manually.
  25674. * @hidden
  25675. */
  25676. 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>);
  25677. }
  25678. /**
  25679. * Represents a Depth Sorted Particle in the solid particle system.
  25680. */
  25681. export class DepthSortedParticle {
  25682. /**
  25683. * Index of the particle in the "indices" array
  25684. */
  25685. ind: number;
  25686. /**
  25687. * Length of the particle shape in the "indices" array
  25688. */
  25689. indicesLength: number;
  25690. /**
  25691. * Squared distance from the particle to the camera
  25692. */
  25693. sqDistance: number;
  25694. }
  25695. }
  25696. declare module BABYLON {
  25697. /**
  25698. * @hidden
  25699. */
  25700. export class _MeshCollisionData {
  25701. _checkCollisions: boolean;
  25702. _collisionMask: number;
  25703. _collisionGroup: number;
  25704. _collider: Nullable<Collider>;
  25705. _oldPositionForCollisions: Vector3;
  25706. _diffPositionForCollisions: Vector3;
  25707. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25708. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25709. }
  25710. }
  25711. declare module BABYLON {
  25712. /** @hidden */
  25713. class _FacetDataStorage {
  25714. facetPositions: Vector3[];
  25715. facetNormals: Vector3[];
  25716. facetPartitioning: number[][];
  25717. facetNb: number;
  25718. partitioningSubdivisions: number;
  25719. partitioningBBoxRatio: number;
  25720. facetDataEnabled: boolean;
  25721. facetParameters: any;
  25722. bbSize: Vector3;
  25723. subDiv: {
  25724. max: number;
  25725. X: number;
  25726. Y: number;
  25727. Z: number;
  25728. };
  25729. facetDepthSort: boolean;
  25730. facetDepthSortEnabled: boolean;
  25731. depthSortedIndices: IndicesArray;
  25732. depthSortedFacets: {
  25733. ind: number;
  25734. sqDistance: number;
  25735. }[];
  25736. facetDepthSortFunction: (f1: {
  25737. ind: number;
  25738. sqDistance: number;
  25739. }, f2: {
  25740. ind: number;
  25741. sqDistance: number;
  25742. }) => number;
  25743. facetDepthSortFrom: Vector3;
  25744. facetDepthSortOrigin: Vector3;
  25745. invertedMatrix: Matrix;
  25746. }
  25747. /**
  25748. * @hidden
  25749. **/
  25750. class _InternalAbstractMeshDataInfo {
  25751. _hasVertexAlpha: boolean;
  25752. _useVertexColors: boolean;
  25753. _numBoneInfluencers: number;
  25754. _applyFog: boolean;
  25755. _receiveShadows: boolean;
  25756. _facetData: _FacetDataStorage;
  25757. _visibility: number;
  25758. _skeleton: Nullable<Skeleton>;
  25759. _layerMask: number;
  25760. _computeBonesUsingShaders: boolean;
  25761. _isActive: boolean;
  25762. _onlyForInstances: boolean;
  25763. _isActiveIntermediate: boolean;
  25764. _onlyForInstancesIntermediate: boolean;
  25765. _actAsRegularMesh: boolean;
  25766. }
  25767. /**
  25768. * Class used to store all common mesh properties
  25769. */
  25770. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25771. /** No occlusion */
  25772. static OCCLUSION_TYPE_NONE: number;
  25773. /** Occlusion set to optimisitic */
  25774. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25775. /** Occlusion set to strict */
  25776. static OCCLUSION_TYPE_STRICT: number;
  25777. /** Use an accurante occlusion algorithm */
  25778. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25779. /** Use a conservative occlusion algorithm */
  25780. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25781. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25782. * Test order :
  25783. * Is the bounding sphere outside the frustum ?
  25784. * If not, are the bounding box vertices outside the frustum ?
  25785. * It not, then the cullable object is in the frustum.
  25786. */
  25787. static readonly CULLINGSTRATEGY_STANDARD: number;
  25788. /** Culling strategy : Bounding Sphere Only.
  25789. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25790. * It's also less accurate than the standard because some not visible objects can still be selected.
  25791. * Test : is the bounding sphere outside the frustum ?
  25792. * If not, then the cullable object is in the frustum.
  25793. */
  25794. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25795. /** Culling strategy : Optimistic Inclusion.
  25796. * This in an inclusion test first, then the standard exclusion test.
  25797. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25798. * 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.
  25799. * Anyway, it's as accurate as the standard strategy.
  25800. * Test :
  25801. * Is the cullable object bounding sphere center in the frustum ?
  25802. * If not, apply the default culling strategy.
  25803. */
  25804. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25805. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25806. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25807. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25808. * 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.
  25809. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25810. * Test :
  25811. * Is the cullable object bounding sphere center in the frustum ?
  25812. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25813. */
  25814. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25815. /**
  25816. * No billboard
  25817. */
  25818. static readonly BILLBOARDMODE_NONE: number;
  25819. /** Billboard on X axis */
  25820. static readonly BILLBOARDMODE_X: number;
  25821. /** Billboard on Y axis */
  25822. static readonly BILLBOARDMODE_Y: number;
  25823. /** Billboard on Z axis */
  25824. static readonly BILLBOARDMODE_Z: number;
  25825. /** Billboard on all axes */
  25826. static readonly BILLBOARDMODE_ALL: number;
  25827. /** Billboard on using position instead of orientation */
  25828. static readonly BILLBOARDMODE_USE_POSITION: number;
  25829. /** @hidden */
  25830. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25831. /**
  25832. * The culling strategy to use to check whether the mesh must be rendered or not.
  25833. * This value can be changed at any time and will be used on the next render mesh selection.
  25834. * The possible values are :
  25835. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25836. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25837. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25838. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25839. * Please read each static variable documentation to get details about the culling process.
  25840. * */
  25841. cullingStrategy: number;
  25842. /**
  25843. * Gets the number of facets in the mesh
  25844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25845. */
  25846. readonly facetNb: number;
  25847. /**
  25848. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25849. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25850. */
  25851. partitioningSubdivisions: number;
  25852. /**
  25853. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25854. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25856. */
  25857. partitioningBBoxRatio: number;
  25858. /**
  25859. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25860. * Works only for updatable meshes.
  25861. * Doesn't work with multi-materials
  25862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25863. */
  25864. mustDepthSortFacets: boolean;
  25865. /**
  25866. * The location (Vector3) where the facet depth sort must be computed from.
  25867. * By default, the active camera position.
  25868. * Used only when facet depth sort is enabled
  25869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25870. */
  25871. facetDepthSortFrom: Vector3;
  25872. /**
  25873. * gets a boolean indicating if facetData is enabled
  25874. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25875. */
  25876. readonly isFacetDataEnabled: boolean;
  25877. /** @hidden */
  25878. _updateNonUniformScalingState(value: boolean): boolean;
  25879. /**
  25880. * An event triggered when this mesh collides with another one
  25881. */
  25882. onCollideObservable: Observable<AbstractMesh>;
  25883. /** Set a function to call when this mesh collides with another one */
  25884. onCollide: () => void;
  25885. /**
  25886. * An event triggered when the collision's position changes
  25887. */
  25888. onCollisionPositionChangeObservable: Observable<Vector3>;
  25889. /** Set a function to call when the collision's position changes */
  25890. onCollisionPositionChange: () => void;
  25891. /**
  25892. * An event triggered when material is changed
  25893. */
  25894. onMaterialChangedObservable: Observable<AbstractMesh>;
  25895. /**
  25896. * Gets or sets the orientation for POV movement & rotation
  25897. */
  25898. definedFacingForward: boolean;
  25899. /** @hidden */
  25900. _occlusionQuery: Nullable<WebGLQuery>;
  25901. /** @hidden */
  25902. _renderingGroup: Nullable<RenderingGroup>;
  25903. /**
  25904. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25905. */
  25906. /**
  25907. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25908. */
  25909. visibility: number;
  25910. /** Gets or sets the alpha index used to sort transparent meshes
  25911. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25912. */
  25913. alphaIndex: number;
  25914. /**
  25915. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25916. */
  25917. isVisible: boolean;
  25918. /**
  25919. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25920. */
  25921. isPickable: boolean;
  25922. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25923. showSubMeshesBoundingBox: boolean;
  25924. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25925. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25926. */
  25927. isBlocker: boolean;
  25928. /**
  25929. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25930. */
  25931. enablePointerMoveEvents: boolean;
  25932. /**
  25933. * Specifies the rendering group id for this mesh (0 by default)
  25934. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25935. */
  25936. renderingGroupId: number;
  25937. private _material;
  25938. /** Gets or sets current material */
  25939. material: Nullable<Material>;
  25940. /**
  25941. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25942. * @see http://doc.babylonjs.com/babylon101/shadows
  25943. */
  25944. receiveShadows: boolean;
  25945. /** Defines color to use when rendering outline */
  25946. outlineColor: Color3;
  25947. /** Define width to use when rendering outline */
  25948. outlineWidth: number;
  25949. /** Defines color to use when rendering overlay */
  25950. overlayColor: Color3;
  25951. /** Defines alpha to use when rendering overlay */
  25952. overlayAlpha: number;
  25953. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25954. hasVertexAlpha: boolean;
  25955. /** 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) */
  25956. useVertexColors: boolean;
  25957. /**
  25958. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25959. */
  25960. computeBonesUsingShaders: boolean;
  25961. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25962. numBoneInfluencers: number;
  25963. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25964. applyFog: boolean;
  25965. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25966. useOctreeForRenderingSelection: boolean;
  25967. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25968. useOctreeForPicking: boolean;
  25969. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25970. useOctreeForCollisions: boolean;
  25971. /**
  25972. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25973. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25974. */
  25975. layerMask: number;
  25976. /**
  25977. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25978. */
  25979. alwaysSelectAsActiveMesh: boolean;
  25980. /**
  25981. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25982. */
  25983. doNotSyncBoundingInfo: boolean;
  25984. /**
  25985. * Gets or sets the current action manager
  25986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25987. */
  25988. actionManager: Nullable<AbstractActionManager>;
  25989. private _meshCollisionData;
  25990. /**
  25991. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25992. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25993. */
  25994. ellipsoid: Vector3;
  25995. /**
  25996. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25997. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25998. */
  25999. ellipsoidOffset: Vector3;
  26000. /**
  26001. * Gets or sets a collision mask used to mask collisions (default is -1).
  26002. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26003. */
  26004. collisionMask: number;
  26005. /**
  26006. * Gets or sets the current collision group mask (-1 by default).
  26007. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26008. */
  26009. collisionGroup: number;
  26010. /**
  26011. * Defines edge width used when edgesRenderer is enabled
  26012. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26013. */
  26014. edgesWidth: number;
  26015. /**
  26016. * Defines edge color used when edgesRenderer is enabled
  26017. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26018. */
  26019. edgesColor: Color4;
  26020. /** @hidden */
  26021. _edgesRenderer: Nullable<IEdgesRenderer>;
  26022. /** @hidden */
  26023. _masterMesh: Nullable<AbstractMesh>;
  26024. /** @hidden */
  26025. _boundingInfo: Nullable<BoundingInfo>;
  26026. /** @hidden */
  26027. _renderId: number;
  26028. /**
  26029. * Gets or sets the list of subMeshes
  26030. * @see http://doc.babylonjs.com/how_to/multi_materials
  26031. */
  26032. subMeshes: SubMesh[];
  26033. /** @hidden */
  26034. _intersectionsInProgress: AbstractMesh[];
  26035. /** @hidden */
  26036. _unIndexed: boolean;
  26037. /** @hidden */
  26038. _lightSources: Light[];
  26039. /** Gets the list of lights affecting that mesh */
  26040. readonly lightSources: Light[];
  26041. /** @hidden */
  26042. readonly _positions: Nullable<Vector3[]>;
  26043. /** @hidden */
  26044. _waitingData: {
  26045. lods: Nullable<any>;
  26046. actions: Nullable<any>;
  26047. freezeWorldMatrix: Nullable<boolean>;
  26048. };
  26049. /** @hidden */
  26050. _bonesTransformMatrices: Nullable<Float32Array>;
  26051. /** @hidden */
  26052. _transformMatrixTexture: Nullable<RawTexture>;
  26053. /**
  26054. * Gets or sets a skeleton to apply skining transformations
  26055. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26056. */
  26057. skeleton: Nullable<Skeleton>;
  26058. /**
  26059. * An event triggered when the mesh is rebuilt.
  26060. */
  26061. onRebuildObservable: Observable<AbstractMesh>;
  26062. /**
  26063. * Creates a new AbstractMesh
  26064. * @param name defines the name of the mesh
  26065. * @param scene defines the hosting scene
  26066. */
  26067. constructor(name: string, scene?: Nullable<Scene>);
  26068. /**
  26069. * Returns the string "AbstractMesh"
  26070. * @returns "AbstractMesh"
  26071. */
  26072. getClassName(): string;
  26073. /**
  26074. * Gets a string representation of the current mesh
  26075. * @param fullDetails defines a boolean indicating if full details must be included
  26076. * @returns a string representation of the current mesh
  26077. */
  26078. toString(fullDetails?: boolean): string;
  26079. /**
  26080. * @hidden
  26081. */
  26082. protected _getEffectiveParent(): Nullable<Node>;
  26083. /** @hidden */
  26084. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26085. /** @hidden */
  26086. _rebuild(): void;
  26087. /** @hidden */
  26088. _resyncLightSources(): void;
  26089. /** @hidden */
  26090. _resyncLighSource(light: Light): void;
  26091. /** @hidden */
  26092. _unBindEffect(): void;
  26093. /** @hidden */
  26094. _removeLightSource(light: Light, dispose: boolean): void;
  26095. private _markSubMeshesAsDirty;
  26096. /** @hidden */
  26097. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26098. /** @hidden */
  26099. _markSubMeshesAsAttributesDirty(): void;
  26100. /** @hidden */
  26101. _markSubMeshesAsMiscDirty(): void;
  26102. /**
  26103. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26104. */
  26105. scaling: Vector3;
  26106. /**
  26107. * Returns true if the mesh is blocked. Implemented by child classes
  26108. */
  26109. readonly isBlocked: boolean;
  26110. /**
  26111. * Returns the mesh itself by default. Implemented by child classes
  26112. * @param camera defines the camera to use to pick the right LOD level
  26113. * @returns the currentAbstractMesh
  26114. */
  26115. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26116. /**
  26117. * Returns 0 by default. Implemented by child classes
  26118. * @returns an integer
  26119. */
  26120. getTotalVertices(): number;
  26121. /**
  26122. * Returns a positive integer : the total number of indices in this mesh geometry.
  26123. * @returns the numner of indices or zero if the mesh has no geometry.
  26124. */
  26125. getTotalIndices(): number;
  26126. /**
  26127. * Returns null by default. Implemented by child classes
  26128. * @returns null
  26129. */
  26130. getIndices(): Nullable<IndicesArray>;
  26131. /**
  26132. * Returns the array of the requested vertex data kind. Implemented by child classes
  26133. * @param kind defines the vertex data kind to use
  26134. * @returns null
  26135. */
  26136. getVerticesData(kind: string): Nullable<FloatArray>;
  26137. /**
  26138. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26139. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26140. * Note that a new underlying VertexBuffer object is created each call.
  26141. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26142. * @param kind defines vertex data kind:
  26143. * * VertexBuffer.PositionKind
  26144. * * VertexBuffer.UVKind
  26145. * * VertexBuffer.UV2Kind
  26146. * * VertexBuffer.UV3Kind
  26147. * * VertexBuffer.UV4Kind
  26148. * * VertexBuffer.UV5Kind
  26149. * * VertexBuffer.UV6Kind
  26150. * * VertexBuffer.ColorKind
  26151. * * VertexBuffer.MatricesIndicesKind
  26152. * * VertexBuffer.MatricesIndicesExtraKind
  26153. * * VertexBuffer.MatricesWeightsKind
  26154. * * VertexBuffer.MatricesWeightsExtraKind
  26155. * @param data defines the data source
  26156. * @param updatable defines if the data must be flagged as updatable (or static)
  26157. * @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
  26158. * @returns the current mesh
  26159. */
  26160. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26161. /**
  26162. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26163. * If the mesh has no geometry, it is simply returned as it is.
  26164. * @param kind defines vertex data kind:
  26165. * * VertexBuffer.PositionKind
  26166. * * VertexBuffer.UVKind
  26167. * * VertexBuffer.UV2Kind
  26168. * * VertexBuffer.UV3Kind
  26169. * * VertexBuffer.UV4Kind
  26170. * * VertexBuffer.UV5Kind
  26171. * * VertexBuffer.UV6Kind
  26172. * * VertexBuffer.ColorKind
  26173. * * VertexBuffer.MatricesIndicesKind
  26174. * * VertexBuffer.MatricesIndicesExtraKind
  26175. * * VertexBuffer.MatricesWeightsKind
  26176. * * VertexBuffer.MatricesWeightsExtraKind
  26177. * @param data defines the data source
  26178. * @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
  26179. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26180. * @returns the current mesh
  26181. */
  26182. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26183. /**
  26184. * Sets the mesh indices,
  26185. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26186. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26187. * @param totalVertices Defines the total number of vertices
  26188. * @returns the current mesh
  26189. */
  26190. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26191. /**
  26192. * Gets a boolean indicating if specific vertex data is present
  26193. * @param kind defines the vertex data kind to use
  26194. * @returns true is data kind is present
  26195. */
  26196. isVerticesDataPresent(kind: string): boolean;
  26197. /**
  26198. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26199. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26200. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26201. * @returns a BoundingInfo
  26202. */
  26203. getBoundingInfo(): BoundingInfo;
  26204. /**
  26205. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26206. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26207. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26208. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26209. * @returns the current mesh
  26210. */
  26211. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26212. /**
  26213. * Overwrite the current bounding info
  26214. * @param boundingInfo defines the new bounding info
  26215. * @returns the current mesh
  26216. */
  26217. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26218. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26219. readonly useBones: boolean;
  26220. /** @hidden */
  26221. _preActivate(): void;
  26222. /** @hidden */
  26223. _preActivateForIntermediateRendering(renderId: number): void;
  26224. /** @hidden */
  26225. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26226. /** @hidden */
  26227. _postActivate(): void;
  26228. /** @hidden */
  26229. _freeze(): void;
  26230. /** @hidden */
  26231. _unFreeze(): void;
  26232. /**
  26233. * Gets the current world matrix
  26234. * @returns a Matrix
  26235. */
  26236. getWorldMatrix(): Matrix;
  26237. /** @hidden */
  26238. _getWorldMatrixDeterminant(): number;
  26239. /**
  26240. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26241. */
  26242. readonly isAnInstance: boolean;
  26243. /**
  26244. * Gets a boolean indicating if this mesh has instances
  26245. */
  26246. readonly hasInstances: boolean;
  26247. /**
  26248. * Perform relative position change from the point of view of behind the front of the mesh.
  26249. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26250. * Supports definition of mesh facing forward or backward
  26251. * @param amountRight defines the distance on the right axis
  26252. * @param amountUp defines the distance on the up axis
  26253. * @param amountForward defines the distance on the forward axis
  26254. * @returns the current mesh
  26255. */
  26256. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26257. /**
  26258. * Calculate relative position change from the point of view of behind the front of the mesh.
  26259. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26260. * Supports definition of mesh facing forward or backward
  26261. * @param amountRight defines the distance on the right axis
  26262. * @param amountUp defines the distance on the up axis
  26263. * @param amountForward defines the distance on the forward axis
  26264. * @returns the new displacement vector
  26265. */
  26266. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26267. /**
  26268. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26269. * Supports definition of mesh facing forward or backward
  26270. * @param flipBack defines the flip
  26271. * @param twirlClockwise defines the twirl
  26272. * @param tiltRight defines the tilt
  26273. * @returns the current mesh
  26274. */
  26275. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26276. /**
  26277. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26278. * Supports definition of mesh facing forward or backward.
  26279. * @param flipBack defines the flip
  26280. * @param twirlClockwise defines the twirl
  26281. * @param tiltRight defines the tilt
  26282. * @returns the new rotation vector
  26283. */
  26284. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26285. /**
  26286. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26287. * This means the mesh underlying bounding box and sphere are recomputed.
  26288. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26289. * @returns the current mesh
  26290. */
  26291. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26292. /** @hidden */
  26293. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26294. /** @hidden */
  26295. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26296. /** @hidden */
  26297. _updateBoundingInfo(): AbstractMesh;
  26298. /** @hidden */
  26299. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26300. /** @hidden */
  26301. protected _afterComputeWorldMatrix(): void;
  26302. /** @hidden */
  26303. readonly _effectiveMesh: AbstractMesh;
  26304. /**
  26305. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26306. * A mesh is in the frustum if its bounding box intersects the frustum
  26307. * @param frustumPlanes defines the frustum to test
  26308. * @returns true if the mesh is in the frustum planes
  26309. */
  26310. isInFrustum(frustumPlanes: Plane[]): boolean;
  26311. /**
  26312. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26313. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26314. * @param frustumPlanes defines the frustum to test
  26315. * @returns true if the mesh is completely in the frustum planes
  26316. */
  26317. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26318. /**
  26319. * True if the mesh intersects another mesh or a SolidParticle object
  26320. * @param mesh defines a target mesh or SolidParticle to test
  26321. * @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)
  26322. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26323. * @returns true if there is an intersection
  26324. */
  26325. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26326. /**
  26327. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26328. * @param point defines the point to test
  26329. * @returns true if there is an intersection
  26330. */
  26331. intersectsPoint(point: Vector3): boolean;
  26332. /**
  26333. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26334. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26335. */
  26336. checkCollisions: boolean;
  26337. /**
  26338. * Gets Collider object used to compute collisions (not physics)
  26339. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26340. */
  26341. readonly collider: Nullable<Collider>;
  26342. /**
  26343. * Move the mesh using collision engine
  26344. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26345. * @param displacement defines the requested displacement vector
  26346. * @returns the current mesh
  26347. */
  26348. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26349. private _onCollisionPositionChange;
  26350. /** @hidden */
  26351. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26352. /** @hidden */
  26353. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26354. /** @hidden */
  26355. _checkCollision(collider: Collider): AbstractMesh;
  26356. /** @hidden */
  26357. _generatePointsArray(): boolean;
  26358. /**
  26359. * Checks if the passed Ray intersects with the mesh
  26360. * @param ray defines the ray to use
  26361. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26362. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26363. * @returns the picking info
  26364. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26365. */
  26366. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26367. /**
  26368. * Clones the current mesh
  26369. * @param name defines the mesh name
  26370. * @param newParent defines the new mesh parent
  26371. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26372. * @returns the new mesh
  26373. */
  26374. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26375. /**
  26376. * Disposes all the submeshes of the current meshnp
  26377. * @returns the current mesh
  26378. */
  26379. releaseSubMeshes(): AbstractMesh;
  26380. /**
  26381. * Releases resources associated with this abstract mesh.
  26382. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26383. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26384. */
  26385. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26386. /**
  26387. * Adds the passed mesh as a child to the current mesh
  26388. * @param mesh defines the child mesh
  26389. * @returns the current mesh
  26390. */
  26391. addChild(mesh: AbstractMesh): AbstractMesh;
  26392. /**
  26393. * Removes the passed mesh from the current mesh children list
  26394. * @param mesh defines the child mesh
  26395. * @returns the current mesh
  26396. */
  26397. removeChild(mesh: AbstractMesh): AbstractMesh;
  26398. /** @hidden */
  26399. private _initFacetData;
  26400. /**
  26401. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26402. * This method can be called within the render loop.
  26403. * 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
  26404. * @returns the current mesh
  26405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26406. */
  26407. updateFacetData(): AbstractMesh;
  26408. /**
  26409. * Returns the facetLocalNormals array.
  26410. * The normals are expressed in the mesh local spac
  26411. * @returns an array of Vector3
  26412. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26413. */
  26414. getFacetLocalNormals(): Vector3[];
  26415. /**
  26416. * Returns the facetLocalPositions array.
  26417. * The facet positions are expressed in the mesh local space
  26418. * @returns an array of Vector3
  26419. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26420. */
  26421. getFacetLocalPositions(): Vector3[];
  26422. /**
  26423. * Returns the facetLocalPartioning array
  26424. * @returns an array of array of numbers
  26425. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26426. */
  26427. getFacetLocalPartitioning(): number[][];
  26428. /**
  26429. * Returns the i-th facet position in the world system.
  26430. * This method allocates a new Vector3 per call
  26431. * @param i defines the facet index
  26432. * @returns a new Vector3
  26433. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26434. */
  26435. getFacetPosition(i: number): Vector3;
  26436. /**
  26437. * Sets the reference Vector3 with the i-th facet position in the world system
  26438. * @param i defines the facet index
  26439. * @param ref defines the target vector
  26440. * @returns the current mesh
  26441. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26442. */
  26443. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26444. /**
  26445. * Returns the i-th facet normal in the world system.
  26446. * This method allocates a new Vector3 per call
  26447. * @param i defines the facet index
  26448. * @returns a new Vector3
  26449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26450. */
  26451. getFacetNormal(i: number): Vector3;
  26452. /**
  26453. * Sets the reference Vector3 with the i-th facet normal in the world system
  26454. * @param i defines the facet index
  26455. * @param ref defines the target vector
  26456. * @returns the current mesh
  26457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26458. */
  26459. getFacetNormalToRef(i: number, ref: Vector3): this;
  26460. /**
  26461. * 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)
  26462. * @param x defines x coordinate
  26463. * @param y defines y coordinate
  26464. * @param z defines z coordinate
  26465. * @returns the array of facet indexes
  26466. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26467. */
  26468. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26469. /**
  26470. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26471. * @param projected sets as the (x,y,z) world projection on the facet
  26472. * @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
  26473. * @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
  26474. * @param x defines x coordinate
  26475. * @param y defines y coordinate
  26476. * @param z defines z coordinate
  26477. * @returns the face index if found (or null instead)
  26478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26479. */
  26480. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26481. /**
  26482. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26483. * @param projected sets as the (x,y,z) local projection on the facet
  26484. * @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
  26485. * @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
  26486. * @param x defines x coordinate
  26487. * @param y defines y coordinate
  26488. * @param z defines z coordinate
  26489. * @returns the face index if found (or null instead)
  26490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26491. */
  26492. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26493. /**
  26494. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26495. * @returns the parameters
  26496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26497. */
  26498. getFacetDataParameters(): any;
  26499. /**
  26500. * Disables the feature FacetData and frees the related memory
  26501. * @returns the current mesh
  26502. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26503. */
  26504. disableFacetData(): AbstractMesh;
  26505. /**
  26506. * Updates the AbstractMesh indices array
  26507. * @param indices defines the data source
  26508. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26509. * @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)
  26510. * @returns the current mesh
  26511. */
  26512. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26513. /**
  26514. * Creates new normals data for the mesh
  26515. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26516. * @returns the current mesh
  26517. */
  26518. createNormals(updatable: boolean): AbstractMesh;
  26519. /**
  26520. * Align the mesh with a normal
  26521. * @param normal defines the normal to use
  26522. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26523. * @returns the current mesh
  26524. */
  26525. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26526. /** @hidden */
  26527. _checkOcclusionQuery(): boolean;
  26528. /**
  26529. * Disables the mesh edge rendering mode
  26530. * @returns the currentAbstractMesh
  26531. */
  26532. disableEdgesRendering(): AbstractMesh;
  26533. /**
  26534. * Enables the edge rendering mode on the mesh.
  26535. * This mode makes the mesh edges visible
  26536. * @param epsilon defines the maximal distance between two angles to detect a face
  26537. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26538. * @returns the currentAbstractMesh
  26539. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26540. */
  26541. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26542. }
  26543. }
  26544. declare module BABYLON {
  26545. /**
  26546. * Interface used to define ActionEvent
  26547. */
  26548. export interface IActionEvent {
  26549. /** The mesh or sprite that triggered the action */
  26550. source: any;
  26551. /** The X mouse cursor position at the time of the event */
  26552. pointerX: number;
  26553. /** The Y mouse cursor position at the time of the event */
  26554. pointerY: number;
  26555. /** The mesh that is currently pointed at (can be null) */
  26556. meshUnderPointer: Nullable<AbstractMesh>;
  26557. /** the original (browser) event that triggered the ActionEvent */
  26558. sourceEvent?: any;
  26559. /** additional data for the event */
  26560. additionalData?: any;
  26561. }
  26562. /**
  26563. * ActionEvent is the event being sent when an action is triggered.
  26564. */
  26565. export class ActionEvent implements IActionEvent {
  26566. /** The mesh or sprite that triggered the action */
  26567. source: any;
  26568. /** The X mouse cursor position at the time of the event */
  26569. pointerX: number;
  26570. /** The Y mouse cursor position at the time of the event */
  26571. pointerY: number;
  26572. /** The mesh that is currently pointed at (can be null) */
  26573. meshUnderPointer: Nullable<AbstractMesh>;
  26574. /** the original (browser) event that triggered the ActionEvent */
  26575. sourceEvent?: any;
  26576. /** additional data for the event */
  26577. additionalData?: any;
  26578. /**
  26579. * Creates a new ActionEvent
  26580. * @param source The mesh or sprite that triggered the action
  26581. * @param pointerX The X mouse cursor position at the time of the event
  26582. * @param pointerY The Y mouse cursor position at the time of the event
  26583. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26584. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26585. * @param additionalData additional data for the event
  26586. */
  26587. constructor(
  26588. /** The mesh or sprite that triggered the action */
  26589. source: any,
  26590. /** The X mouse cursor position at the time of the event */
  26591. pointerX: number,
  26592. /** The Y mouse cursor position at the time of the event */
  26593. pointerY: number,
  26594. /** The mesh that is currently pointed at (can be null) */
  26595. meshUnderPointer: Nullable<AbstractMesh>,
  26596. /** the original (browser) event that triggered the ActionEvent */
  26597. sourceEvent?: any,
  26598. /** additional data for the event */
  26599. additionalData?: any);
  26600. /**
  26601. * Helper function to auto-create an ActionEvent from a source mesh.
  26602. * @param source The source mesh that triggered the event
  26603. * @param evt The original (browser) event
  26604. * @param additionalData additional data for the event
  26605. * @returns the new ActionEvent
  26606. */
  26607. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26608. /**
  26609. * Helper function to auto-create an ActionEvent from a source sprite
  26610. * @param source The source sprite that triggered the event
  26611. * @param scene Scene associated with the sprite
  26612. * @param evt The original (browser) event
  26613. * @param additionalData additional data for the event
  26614. * @returns the new ActionEvent
  26615. */
  26616. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26617. /**
  26618. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26619. * @param scene the scene where the event occurred
  26620. * @param evt The original (browser) event
  26621. * @returns the new ActionEvent
  26622. */
  26623. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26624. /**
  26625. * Helper function to auto-create an ActionEvent from a primitive
  26626. * @param prim defines the target primitive
  26627. * @param pointerPos defines the pointer position
  26628. * @param evt The original (browser) event
  26629. * @param additionalData additional data for the event
  26630. * @returns the new ActionEvent
  26631. */
  26632. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26633. }
  26634. }
  26635. declare module BABYLON {
  26636. /**
  26637. * Abstract class used to decouple action Manager from scene and meshes.
  26638. * Do not instantiate.
  26639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26640. */
  26641. export abstract class AbstractActionManager implements IDisposable {
  26642. /** Gets the list of active triggers */
  26643. static Triggers: {
  26644. [key: string]: number;
  26645. };
  26646. /** Gets the cursor to use when hovering items */
  26647. hoverCursor: string;
  26648. /** Gets the list of actions */
  26649. actions: IAction[];
  26650. /**
  26651. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26652. */
  26653. isRecursive: boolean;
  26654. /**
  26655. * Releases all associated resources
  26656. */
  26657. abstract dispose(): void;
  26658. /**
  26659. * Does this action manager has pointer triggers
  26660. */
  26661. abstract readonly hasPointerTriggers: boolean;
  26662. /**
  26663. * Does this action manager has pick triggers
  26664. */
  26665. abstract readonly hasPickTriggers: boolean;
  26666. /**
  26667. * Process a specific trigger
  26668. * @param trigger defines the trigger to process
  26669. * @param evt defines the event details to be processed
  26670. */
  26671. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26672. /**
  26673. * Does this action manager handles actions of any of the given triggers
  26674. * @param triggers defines the triggers to be tested
  26675. * @return a boolean indicating whether one (or more) of the triggers is handled
  26676. */
  26677. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26678. /**
  26679. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26680. * speed.
  26681. * @param triggerA defines the trigger to be tested
  26682. * @param triggerB defines the trigger to be tested
  26683. * @return a boolean indicating whether one (or more) of the triggers is handled
  26684. */
  26685. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26686. /**
  26687. * Does this action manager handles actions of a given trigger
  26688. * @param trigger defines the trigger to be tested
  26689. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26690. * @return whether the trigger is handled
  26691. */
  26692. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26693. /**
  26694. * Serialize this manager to a JSON object
  26695. * @param name defines the property name to store this manager
  26696. * @returns a JSON representation of this manager
  26697. */
  26698. abstract serialize(name: string): any;
  26699. /**
  26700. * Registers an action to this action manager
  26701. * @param action defines the action to be registered
  26702. * @return the action amended (prepared) after registration
  26703. */
  26704. abstract registerAction(action: IAction): Nullable<IAction>;
  26705. /**
  26706. * Unregisters an action to this action manager
  26707. * @param action defines the action to be unregistered
  26708. * @return a boolean indicating whether the action has been unregistered
  26709. */
  26710. abstract unregisterAction(action: IAction): Boolean;
  26711. /**
  26712. * Does exist one action manager with at least one trigger
  26713. **/
  26714. static readonly HasTriggers: boolean;
  26715. /**
  26716. * Does exist one action manager with at least one pick trigger
  26717. **/
  26718. static readonly HasPickTriggers: boolean;
  26719. /**
  26720. * Does exist one action manager that handles actions of a given trigger
  26721. * @param trigger defines the trigger to be tested
  26722. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26723. **/
  26724. static HasSpecificTrigger(trigger: number): boolean;
  26725. }
  26726. }
  26727. declare module BABYLON {
  26728. /**
  26729. * Defines how a node can be built from a string name.
  26730. */
  26731. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26732. /**
  26733. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26734. */
  26735. export class Node implements IBehaviorAware<Node> {
  26736. /** @hidden */
  26737. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26738. private static _NodeConstructors;
  26739. /**
  26740. * Add a new node constructor
  26741. * @param type defines the type name of the node to construct
  26742. * @param constructorFunc defines the constructor function
  26743. */
  26744. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26745. /**
  26746. * Returns a node constructor based on type name
  26747. * @param type defines the type name
  26748. * @param name defines the new node name
  26749. * @param scene defines the hosting scene
  26750. * @param options defines optional options to transmit to constructors
  26751. * @returns the new constructor or null
  26752. */
  26753. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26754. /**
  26755. * Gets or sets the name of the node
  26756. */
  26757. name: string;
  26758. /**
  26759. * Gets or sets the id of the node
  26760. */
  26761. id: string;
  26762. /**
  26763. * Gets or sets the unique id of the node
  26764. */
  26765. uniqueId: number;
  26766. /**
  26767. * Gets or sets a string used to store user defined state for the node
  26768. */
  26769. state: string;
  26770. /**
  26771. * Gets or sets an object used to store user defined information for the node
  26772. */
  26773. metadata: any;
  26774. /**
  26775. * For internal use only. Please do not use.
  26776. */
  26777. reservedDataStore: any;
  26778. /**
  26779. * List of inspectable custom properties (used by the Inspector)
  26780. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26781. */
  26782. inspectableCustomProperties: IInspectable[];
  26783. private _doNotSerialize;
  26784. /**
  26785. * Gets or sets a boolean used to define if the node must be serialized
  26786. */
  26787. doNotSerialize: boolean;
  26788. /** @hidden */
  26789. _isDisposed: boolean;
  26790. /**
  26791. * Gets a list of Animations associated with the node
  26792. */
  26793. animations: Animation[];
  26794. protected _ranges: {
  26795. [name: string]: Nullable<AnimationRange>;
  26796. };
  26797. /**
  26798. * Callback raised when the node is ready to be used
  26799. */
  26800. onReady: Nullable<(node: Node) => void>;
  26801. private _isEnabled;
  26802. private _isParentEnabled;
  26803. private _isReady;
  26804. /** @hidden */
  26805. _currentRenderId: number;
  26806. private _parentUpdateId;
  26807. /** @hidden */
  26808. _childUpdateId: number;
  26809. /** @hidden */
  26810. _waitingParentId: Nullable<string>;
  26811. /** @hidden */
  26812. _scene: Scene;
  26813. /** @hidden */
  26814. _cache: any;
  26815. private _parentNode;
  26816. private _children;
  26817. /** @hidden */
  26818. _worldMatrix: Matrix;
  26819. /** @hidden */
  26820. _worldMatrixDeterminant: number;
  26821. /** @hidden */
  26822. _worldMatrixDeterminantIsDirty: boolean;
  26823. /** @hidden */
  26824. private _sceneRootNodesIndex;
  26825. /**
  26826. * Gets a boolean indicating if the node has been disposed
  26827. * @returns true if the node was disposed
  26828. */
  26829. isDisposed(): boolean;
  26830. /**
  26831. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26832. * @see https://doc.babylonjs.com/how_to/parenting
  26833. */
  26834. parent: Nullable<Node>;
  26835. private addToSceneRootNodes;
  26836. private removeFromSceneRootNodes;
  26837. private _animationPropertiesOverride;
  26838. /**
  26839. * Gets or sets the animation properties override
  26840. */
  26841. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26842. /**
  26843. * Gets a string idenfifying the name of the class
  26844. * @returns "Node" string
  26845. */
  26846. getClassName(): string;
  26847. /** @hidden */
  26848. readonly _isNode: boolean;
  26849. /**
  26850. * An event triggered when the mesh is disposed
  26851. */
  26852. onDisposeObservable: Observable<Node>;
  26853. private _onDisposeObserver;
  26854. /**
  26855. * Sets a callback that will be raised when the node will be disposed
  26856. */
  26857. onDispose: () => void;
  26858. /**
  26859. * Creates a new Node
  26860. * @param name the name and id to be given to this node
  26861. * @param scene the scene this node will be added to
  26862. * @param addToRootNodes the node will be added to scene.rootNodes
  26863. */
  26864. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26865. /**
  26866. * Gets the scene of the node
  26867. * @returns a scene
  26868. */
  26869. getScene(): Scene;
  26870. /**
  26871. * Gets the engine of the node
  26872. * @returns a Engine
  26873. */
  26874. getEngine(): Engine;
  26875. private _behaviors;
  26876. /**
  26877. * Attach a behavior to the node
  26878. * @see http://doc.babylonjs.com/features/behaviour
  26879. * @param behavior defines the behavior to attach
  26880. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26881. * @returns the current Node
  26882. */
  26883. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26884. /**
  26885. * Remove an attached behavior
  26886. * @see http://doc.babylonjs.com/features/behaviour
  26887. * @param behavior defines the behavior to attach
  26888. * @returns the current Node
  26889. */
  26890. removeBehavior(behavior: Behavior<Node>): Node;
  26891. /**
  26892. * Gets the list of attached behaviors
  26893. * @see http://doc.babylonjs.com/features/behaviour
  26894. */
  26895. readonly behaviors: Behavior<Node>[];
  26896. /**
  26897. * Gets an attached behavior by name
  26898. * @param name defines the name of the behavior to look for
  26899. * @see http://doc.babylonjs.com/features/behaviour
  26900. * @returns null if behavior was not found else the requested behavior
  26901. */
  26902. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26903. /**
  26904. * Returns the latest update of the World matrix
  26905. * @returns a Matrix
  26906. */
  26907. getWorldMatrix(): Matrix;
  26908. /** @hidden */
  26909. _getWorldMatrixDeterminant(): number;
  26910. /**
  26911. * Returns directly the latest state of the mesh World matrix.
  26912. * A Matrix is returned.
  26913. */
  26914. readonly worldMatrixFromCache: Matrix;
  26915. /** @hidden */
  26916. _initCache(): void;
  26917. /** @hidden */
  26918. updateCache(force?: boolean): void;
  26919. /** @hidden */
  26920. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26921. /** @hidden */
  26922. _updateCache(ignoreParentClass?: boolean): void;
  26923. /** @hidden */
  26924. _isSynchronized(): boolean;
  26925. /** @hidden */
  26926. _markSyncedWithParent(): void;
  26927. /** @hidden */
  26928. isSynchronizedWithParent(): boolean;
  26929. /** @hidden */
  26930. isSynchronized(): boolean;
  26931. /**
  26932. * Is this node ready to be used/rendered
  26933. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26934. * @return true if the node is ready
  26935. */
  26936. isReady(completeCheck?: boolean): boolean;
  26937. /**
  26938. * Is this node enabled?
  26939. * 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
  26940. * @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
  26941. * @return whether this node (and its parent) is enabled
  26942. */
  26943. isEnabled(checkAncestors?: boolean): boolean;
  26944. /** @hidden */
  26945. protected _syncParentEnabledState(): void;
  26946. /**
  26947. * Set the enabled state of this node
  26948. * @param value defines the new enabled state
  26949. */
  26950. setEnabled(value: boolean): void;
  26951. /**
  26952. * Is this node a descendant of the given node?
  26953. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26954. * @param ancestor defines the parent node to inspect
  26955. * @returns a boolean indicating if this node is a descendant of the given node
  26956. */
  26957. isDescendantOf(ancestor: Node): boolean;
  26958. /** @hidden */
  26959. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26960. /**
  26961. * Will return all nodes that have this node as ascendant
  26962. * @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
  26963. * @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
  26964. * @return all children nodes of all types
  26965. */
  26966. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26967. /**
  26968. * Get all child-meshes of this node
  26969. * @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)
  26970. * @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
  26971. * @returns an array of AbstractMesh
  26972. */
  26973. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26974. /**
  26975. * Get all direct children of this node
  26976. * @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
  26977. * @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)
  26978. * @returns an array of Node
  26979. */
  26980. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26981. /** @hidden */
  26982. _setReady(state: boolean): void;
  26983. /**
  26984. * Get an animation by name
  26985. * @param name defines the name of the animation to look for
  26986. * @returns null if not found else the requested animation
  26987. */
  26988. getAnimationByName(name: string): Nullable<Animation>;
  26989. /**
  26990. * Creates an animation range for this node
  26991. * @param name defines the name of the range
  26992. * @param from defines the starting key
  26993. * @param to defines the end key
  26994. */
  26995. createAnimationRange(name: string, from: number, to: number): void;
  26996. /**
  26997. * Delete a specific animation range
  26998. * @param name defines the name of the range to delete
  26999. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27000. */
  27001. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27002. /**
  27003. * Get an animation range by name
  27004. * @param name defines the name of the animation range to look for
  27005. * @returns null if not found else the requested animation range
  27006. */
  27007. getAnimationRange(name: string): Nullable<AnimationRange>;
  27008. /**
  27009. * Gets the list of all animation ranges defined on this node
  27010. * @returns an array
  27011. */
  27012. getAnimationRanges(): Nullable<AnimationRange>[];
  27013. /**
  27014. * Will start the animation sequence
  27015. * @param name defines the range frames for animation sequence
  27016. * @param loop defines if the animation should loop (false by default)
  27017. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27018. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27019. * @returns the object created for this animation. If range does not exist, it will return null
  27020. */
  27021. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27022. /**
  27023. * Serialize animation ranges into a JSON compatible object
  27024. * @returns serialization object
  27025. */
  27026. serializeAnimationRanges(): any;
  27027. /**
  27028. * Computes the world matrix of the node
  27029. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27030. * @returns the world matrix
  27031. */
  27032. computeWorldMatrix(force?: boolean): Matrix;
  27033. /**
  27034. * Releases resources associated with this node.
  27035. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27036. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27037. */
  27038. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27039. /**
  27040. * Parse animation range data from a serialization object and store them into a given node
  27041. * @param node defines where to store the animation ranges
  27042. * @param parsedNode defines the serialization object to read data from
  27043. * @param scene defines the hosting scene
  27044. */
  27045. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27046. /**
  27047. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27048. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27049. * @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
  27050. * @returns the new bounding vectors
  27051. */
  27052. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27053. min: Vector3;
  27054. max: Vector3;
  27055. };
  27056. }
  27057. }
  27058. declare module BABYLON {
  27059. /**
  27060. * @hidden
  27061. */
  27062. export class _IAnimationState {
  27063. key: number;
  27064. repeatCount: number;
  27065. workValue?: any;
  27066. loopMode?: number;
  27067. offsetValue?: any;
  27068. highLimitValue?: any;
  27069. }
  27070. /**
  27071. * Class used to store any kind of animation
  27072. */
  27073. export class Animation {
  27074. /**Name of the animation */
  27075. name: string;
  27076. /**Property to animate */
  27077. targetProperty: string;
  27078. /**The frames per second of the animation */
  27079. framePerSecond: number;
  27080. /**The data type of the animation */
  27081. dataType: number;
  27082. /**The loop mode of the animation */
  27083. loopMode?: number | undefined;
  27084. /**Specifies if blending should be enabled */
  27085. enableBlending?: boolean | undefined;
  27086. /**
  27087. * Use matrix interpolation instead of using direct key value when animating matrices
  27088. */
  27089. static AllowMatricesInterpolation: boolean;
  27090. /**
  27091. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27092. */
  27093. static AllowMatrixDecomposeForInterpolation: boolean;
  27094. /**
  27095. * Stores the key frames of the animation
  27096. */
  27097. private _keys;
  27098. /**
  27099. * Stores the easing function of the animation
  27100. */
  27101. private _easingFunction;
  27102. /**
  27103. * @hidden Internal use only
  27104. */
  27105. _runtimeAnimations: RuntimeAnimation[];
  27106. /**
  27107. * The set of event that will be linked to this animation
  27108. */
  27109. private _events;
  27110. /**
  27111. * Stores an array of target property paths
  27112. */
  27113. targetPropertyPath: string[];
  27114. /**
  27115. * Stores the blending speed of the animation
  27116. */
  27117. blendingSpeed: number;
  27118. /**
  27119. * Stores the animation ranges for the animation
  27120. */
  27121. private _ranges;
  27122. /**
  27123. * @hidden Internal use
  27124. */
  27125. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27126. /**
  27127. * Sets up an animation
  27128. * @param property The property to animate
  27129. * @param animationType The animation type to apply
  27130. * @param framePerSecond The frames per second of the animation
  27131. * @param easingFunction The easing function used in the animation
  27132. * @returns The created animation
  27133. */
  27134. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27135. /**
  27136. * Create and start an animation on a node
  27137. * @param name defines the name of the global animation that will be run on all nodes
  27138. * @param node defines the root node where the animation will take place
  27139. * @param targetProperty defines property to animate
  27140. * @param framePerSecond defines the number of frame per second yo use
  27141. * @param totalFrame defines the number of frames in total
  27142. * @param from defines the initial value
  27143. * @param to defines the final value
  27144. * @param loopMode defines which loop mode you want to use (off by default)
  27145. * @param easingFunction defines the easing function to use (linear by default)
  27146. * @param onAnimationEnd defines the callback to call when animation end
  27147. * @returns the animatable created for this animation
  27148. */
  27149. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27150. /**
  27151. * Create and start an animation on a node and its descendants
  27152. * @param name defines the name of the global animation that will be run on all nodes
  27153. * @param node defines the root node where the animation will take place
  27154. * @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
  27155. * @param targetProperty defines property to animate
  27156. * @param framePerSecond defines the number of frame per second to use
  27157. * @param totalFrame defines the number of frames in total
  27158. * @param from defines the initial value
  27159. * @param to defines the final value
  27160. * @param loopMode defines which loop mode you want to use (off by default)
  27161. * @param easingFunction defines the easing function to use (linear by default)
  27162. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27163. * @returns the list of animatables created for all nodes
  27164. * @example https://www.babylonjs-playground.com/#MH0VLI
  27165. */
  27166. 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[]>;
  27167. /**
  27168. * Creates a new animation, merges it with the existing animations and starts it
  27169. * @param name Name of the animation
  27170. * @param node Node which contains the scene that begins the animations
  27171. * @param targetProperty Specifies which property to animate
  27172. * @param framePerSecond The frames per second of the animation
  27173. * @param totalFrame The total number of frames
  27174. * @param from The frame at the beginning of the animation
  27175. * @param to The frame at the end of the animation
  27176. * @param loopMode Specifies the loop mode of the animation
  27177. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27178. * @param onAnimationEnd Callback to run once the animation is complete
  27179. * @returns Nullable animation
  27180. */
  27181. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27182. /**
  27183. * Transition property of an host to the target Value
  27184. * @param property The property to transition
  27185. * @param targetValue The target Value of the property
  27186. * @param host The object where the property to animate belongs
  27187. * @param scene Scene used to run the animation
  27188. * @param frameRate Framerate (in frame/s) to use
  27189. * @param transition The transition type we want to use
  27190. * @param duration The duration of the animation, in milliseconds
  27191. * @param onAnimationEnd Callback trigger at the end of the animation
  27192. * @returns Nullable animation
  27193. */
  27194. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27195. /**
  27196. * Return the array of runtime animations currently using this animation
  27197. */
  27198. readonly runtimeAnimations: RuntimeAnimation[];
  27199. /**
  27200. * Specifies if any of the runtime animations are currently running
  27201. */
  27202. readonly hasRunningRuntimeAnimations: boolean;
  27203. /**
  27204. * Initializes the animation
  27205. * @param name Name of the animation
  27206. * @param targetProperty Property to animate
  27207. * @param framePerSecond The frames per second of the animation
  27208. * @param dataType The data type of the animation
  27209. * @param loopMode The loop mode of the animation
  27210. * @param enableBlending Specifies if blending should be enabled
  27211. */
  27212. constructor(
  27213. /**Name of the animation */
  27214. name: string,
  27215. /**Property to animate */
  27216. targetProperty: string,
  27217. /**The frames per second of the animation */
  27218. framePerSecond: number,
  27219. /**The data type of the animation */
  27220. dataType: number,
  27221. /**The loop mode of the animation */
  27222. loopMode?: number | undefined,
  27223. /**Specifies if blending should be enabled */
  27224. enableBlending?: boolean | undefined);
  27225. /**
  27226. * Converts the animation to a string
  27227. * @param fullDetails support for multiple levels of logging within scene loading
  27228. * @returns String form of the animation
  27229. */
  27230. toString(fullDetails?: boolean): string;
  27231. /**
  27232. * Add an event to this animation
  27233. * @param event Event to add
  27234. */
  27235. addEvent(event: AnimationEvent): void;
  27236. /**
  27237. * Remove all events found at the given frame
  27238. * @param frame The frame to remove events from
  27239. */
  27240. removeEvents(frame: number): void;
  27241. /**
  27242. * Retrieves all the events from the animation
  27243. * @returns Events from the animation
  27244. */
  27245. getEvents(): AnimationEvent[];
  27246. /**
  27247. * Creates an animation range
  27248. * @param name Name of the animation range
  27249. * @param from Starting frame of the animation range
  27250. * @param to Ending frame of the animation
  27251. */
  27252. createRange(name: string, from: number, to: number): void;
  27253. /**
  27254. * Deletes an animation range by name
  27255. * @param name Name of the animation range to delete
  27256. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27257. */
  27258. deleteRange(name: string, deleteFrames?: boolean): void;
  27259. /**
  27260. * Gets the animation range by name, or null if not defined
  27261. * @param name Name of the animation range
  27262. * @returns Nullable animation range
  27263. */
  27264. getRange(name: string): Nullable<AnimationRange>;
  27265. /**
  27266. * Gets the key frames from the animation
  27267. * @returns The key frames of the animation
  27268. */
  27269. getKeys(): Array<IAnimationKey>;
  27270. /**
  27271. * Gets the highest frame rate of the animation
  27272. * @returns Highest frame rate of the animation
  27273. */
  27274. getHighestFrame(): number;
  27275. /**
  27276. * Gets the easing function of the animation
  27277. * @returns Easing function of the animation
  27278. */
  27279. getEasingFunction(): IEasingFunction;
  27280. /**
  27281. * Sets the easing function of the animation
  27282. * @param easingFunction A custom mathematical formula for animation
  27283. */
  27284. setEasingFunction(easingFunction: EasingFunction): void;
  27285. /**
  27286. * Interpolates a scalar linearly
  27287. * @param startValue Start value of the animation curve
  27288. * @param endValue End value of the animation curve
  27289. * @param gradient Scalar amount to interpolate
  27290. * @returns Interpolated scalar value
  27291. */
  27292. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27293. /**
  27294. * Interpolates a scalar cubically
  27295. * @param startValue Start value of the animation curve
  27296. * @param outTangent End tangent of the animation
  27297. * @param endValue End value of the animation curve
  27298. * @param inTangent Start tangent of the animation curve
  27299. * @param gradient Scalar amount to interpolate
  27300. * @returns Interpolated scalar value
  27301. */
  27302. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27303. /**
  27304. * Interpolates a quaternion using a spherical linear interpolation
  27305. * @param startValue Start value of the animation curve
  27306. * @param endValue End value of the animation curve
  27307. * @param gradient Scalar amount to interpolate
  27308. * @returns Interpolated quaternion value
  27309. */
  27310. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27311. /**
  27312. * Interpolates a quaternion cubically
  27313. * @param startValue Start value of the animation curve
  27314. * @param outTangent End tangent of the animation curve
  27315. * @param endValue End value of the animation curve
  27316. * @param inTangent Start tangent of the animation curve
  27317. * @param gradient Scalar amount to interpolate
  27318. * @returns Interpolated quaternion value
  27319. */
  27320. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27321. /**
  27322. * Interpolates a Vector3 linearl
  27323. * @param startValue Start value of the animation curve
  27324. * @param endValue End value of the animation curve
  27325. * @param gradient Scalar amount to interpolate
  27326. * @returns Interpolated scalar value
  27327. */
  27328. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27329. /**
  27330. * Interpolates a Vector3 cubically
  27331. * @param startValue Start value of the animation curve
  27332. * @param outTangent End tangent of the animation
  27333. * @param endValue End value of the animation curve
  27334. * @param inTangent Start tangent of the animation curve
  27335. * @param gradient Scalar amount to interpolate
  27336. * @returns InterpolatedVector3 value
  27337. */
  27338. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27339. /**
  27340. * Interpolates a Vector2 linearly
  27341. * @param startValue Start value of the animation curve
  27342. * @param endValue End value of the animation curve
  27343. * @param gradient Scalar amount to interpolate
  27344. * @returns Interpolated Vector2 value
  27345. */
  27346. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27347. /**
  27348. * Interpolates a Vector2 cubically
  27349. * @param startValue Start value of the animation curve
  27350. * @param outTangent End tangent of the animation
  27351. * @param endValue End value of the animation curve
  27352. * @param inTangent Start tangent of the animation curve
  27353. * @param gradient Scalar amount to interpolate
  27354. * @returns Interpolated Vector2 value
  27355. */
  27356. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27357. /**
  27358. * Interpolates a size linearly
  27359. * @param startValue Start value of the animation curve
  27360. * @param endValue End value of the animation curve
  27361. * @param gradient Scalar amount to interpolate
  27362. * @returns Interpolated Size value
  27363. */
  27364. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27365. /**
  27366. * Interpolates a Color3 linearly
  27367. * @param startValue Start value of the animation curve
  27368. * @param endValue End value of the animation curve
  27369. * @param gradient Scalar amount to interpolate
  27370. * @returns Interpolated Color3 value
  27371. */
  27372. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27373. /**
  27374. * @hidden Internal use only
  27375. */
  27376. _getKeyValue(value: any): any;
  27377. /**
  27378. * @hidden Internal use only
  27379. */
  27380. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27381. /**
  27382. * Defines the function to use to interpolate matrices
  27383. * @param startValue defines the start matrix
  27384. * @param endValue defines the end matrix
  27385. * @param gradient defines the gradient between both matrices
  27386. * @param result defines an optional target matrix where to store the interpolation
  27387. * @returns the interpolated matrix
  27388. */
  27389. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27390. /**
  27391. * Makes a copy of the animation
  27392. * @returns Cloned animation
  27393. */
  27394. clone(): Animation;
  27395. /**
  27396. * Sets the key frames of the animation
  27397. * @param values The animation key frames to set
  27398. */
  27399. setKeys(values: Array<IAnimationKey>): void;
  27400. /**
  27401. * Serializes the animation to an object
  27402. * @returns Serialized object
  27403. */
  27404. serialize(): any;
  27405. /**
  27406. * Float animation type
  27407. */
  27408. private static _ANIMATIONTYPE_FLOAT;
  27409. /**
  27410. * Vector3 animation type
  27411. */
  27412. private static _ANIMATIONTYPE_VECTOR3;
  27413. /**
  27414. * Quaternion animation type
  27415. */
  27416. private static _ANIMATIONTYPE_QUATERNION;
  27417. /**
  27418. * Matrix animation type
  27419. */
  27420. private static _ANIMATIONTYPE_MATRIX;
  27421. /**
  27422. * Color3 animation type
  27423. */
  27424. private static _ANIMATIONTYPE_COLOR3;
  27425. /**
  27426. * Vector2 animation type
  27427. */
  27428. private static _ANIMATIONTYPE_VECTOR2;
  27429. /**
  27430. * Size animation type
  27431. */
  27432. private static _ANIMATIONTYPE_SIZE;
  27433. /**
  27434. * Relative Loop Mode
  27435. */
  27436. private static _ANIMATIONLOOPMODE_RELATIVE;
  27437. /**
  27438. * Cycle Loop Mode
  27439. */
  27440. private static _ANIMATIONLOOPMODE_CYCLE;
  27441. /**
  27442. * Constant Loop Mode
  27443. */
  27444. private static _ANIMATIONLOOPMODE_CONSTANT;
  27445. /**
  27446. * Get the float animation type
  27447. */
  27448. static readonly ANIMATIONTYPE_FLOAT: number;
  27449. /**
  27450. * Get the Vector3 animation type
  27451. */
  27452. static readonly ANIMATIONTYPE_VECTOR3: number;
  27453. /**
  27454. * Get the Vector2 animation type
  27455. */
  27456. static readonly ANIMATIONTYPE_VECTOR2: number;
  27457. /**
  27458. * Get the Size animation type
  27459. */
  27460. static readonly ANIMATIONTYPE_SIZE: number;
  27461. /**
  27462. * Get the Quaternion animation type
  27463. */
  27464. static readonly ANIMATIONTYPE_QUATERNION: number;
  27465. /**
  27466. * Get the Matrix animation type
  27467. */
  27468. static readonly ANIMATIONTYPE_MATRIX: number;
  27469. /**
  27470. * Get the Color3 animation type
  27471. */
  27472. static readonly ANIMATIONTYPE_COLOR3: number;
  27473. /**
  27474. * Get the Relative Loop Mode
  27475. */
  27476. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27477. /**
  27478. * Get the Cycle Loop Mode
  27479. */
  27480. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27481. /**
  27482. * Get the Constant Loop Mode
  27483. */
  27484. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27485. /** @hidden */
  27486. static _UniversalLerp(left: any, right: any, amount: number): any;
  27487. /**
  27488. * Parses an animation object and creates an animation
  27489. * @param parsedAnimation Parsed animation object
  27490. * @returns Animation object
  27491. */
  27492. static Parse(parsedAnimation: any): Animation;
  27493. /**
  27494. * Appends the serialized animations from the source animations
  27495. * @param source Source containing the animations
  27496. * @param destination Target to store the animations
  27497. */
  27498. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27499. }
  27500. }
  27501. declare module BABYLON {
  27502. /**
  27503. * Interface containing an array of animations
  27504. */
  27505. export interface IAnimatable {
  27506. /**
  27507. * Array of animations
  27508. */
  27509. animations: Nullable<Array<Animation>>;
  27510. }
  27511. }
  27512. declare module BABYLON {
  27513. /**
  27514. * This represents all the required information to add a fresnel effect on a material:
  27515. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27516. */
  27517. export class FresnelParameters {
  27518. private _isEnabled;
  27519. /**
  27520. * Define if the fresnel effect is enable or not.
  27521. */
  27522. isEnabled: boolean;
  27523. /**
  27524. * Define the color used on edges (grazing angle)
  27525. */
  27526. leftColor: Color3;
  27527. /**
  27528. * Define the color used on center
  27529. */
  27530. rightColor: Color3;
  27531. /**
  27532. * Define bias applied to computed fresnel term
  27533. */
  27534. bias: number;
  27535. /**
  27536. * Defined the power exponent applied to fresnel term
  27537. */
  27538. power: number;
  27539. /**
  27540. * Clones the current fresnel and its valuues
  27541. * @returns a clone fresnel configuration
  27542. */
  27543. clone(): FresnelParameters;
  27544. /**
  27545. * Serializes the current fresnel parameters to a JSON representation.
  27546. * @return the JSON serialization
  27547. */
  27548. serialize(): any;
  27549. /**
  27550. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27551. * @param parsedFresnelParameters Define the JSON representation
  27552. * @returns the parsed parameters
  27553. */
  27554. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27555. }
  27556. }
  27557. declare module BABYLON {
  27558. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27559. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27560. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27561. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27562. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27563. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27564. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27565. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27566. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27567. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27568. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27569. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27570. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27571. /**
  27572. * Decorator used to define property that can be serialized as reference to a camera
  27573. * @param sourceName defines the name of the property to decorate
  27574. */
  27575. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27576. /**
  27577. * Class used to help serialization objects
  27578. */
  27579. export class SerializationHelper {
  27580. /** @hidden */
  27581. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27582. /** @hidden */
  27583. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27584. /** @hidden */
  27585. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27586. /** @hidden */
  27587. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27588. /**
  27589. * Appends the serialized animations from the source animations
  27590. * @param source Source containing the animations
  27591. * @param destination Target to store the animations
  27592. */
  27593. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27594. /**
  27595. * Static function used to serialized a specific entity
  27596. * @param entity defines the entity to serialize
  27597. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27598. * @returns a JSON compatible object representing the serialization of the entity
  27599. */
  27600. static Serialize<T>(entity: T, serializationObject?: any): any;
  27601. /**
  27602. * Creates a new entity from a serialization data object
  27603. * @param creationFunction defines a function used to instanciated the new entity
  27604. * @param source defines the source serialization data
  27605. * @param scene defines the hosting scene
  27606. * @param rootUrl defines the root url for resources
  27607. * @returns a new entity
  27608. */
  27609. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27610. /**
  27611. * Clones an object
  27612. * @param creationFunction defines the function used to instanciate the new object
  27613. * @param source defines the source object
  27614. * @returns the cloned object
  27615. */
  27616. static Clone<T>(creationFunction: () => T, source: T): T;
  27617. /**
  27618. * Instanciates a new object based on a source one (some data will be shared between both object)
  27619. * @param creationFunction defines the function used to instanciate the new object
  27620. * @param source defines the source object
  27621. * @returns the new object
  27622. */
  27623. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27624. }
  27625. }
  27626. declare module BABYLON {
  27627. /**
  27628. * Class used to manipulate GUIDs
  27629. */
  27630. export class GUID {
  27631. /**
  27632. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27633. * Be aware Math.random() could cause collisions, but:
  27634. * "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"
  27635. * @returns a pseudo random id
  27636. */
  27637. static RandomId(): string;
  27638. }
  27639. }
  27640. declare module BABYLON {
  27641. /**
  27642. * Base class of all the textures in babylon.
  27643. * It groups all the common properties the materials, post process, lights... might need
  27644. * in order to make a correct use of the texture.
  27645. */
  27646. export class BaseTexture implements IAnimatable {
  27647. /**
  27648. * Default anisotropic filtering level for the application.
  27649. * It is set to 4 as a good tradeoff between perf and quality.
  27650. */
  27651. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27652. /**
  27653. * Gets or sets the unique id of the texture
  27654. */
  27655. uniqueId: number;
  27656. /**
  27657. * Define the name of the texture.
  27658. */
  27659. name: string;
  27660. /**
  27661. * Gets or sets an object used to store user defined information.
  27662. */
  27663. metadata: any;
  27664. /**
  27665. * For internal use only. Please do not use.
  27666. */
  27667. reservedDataStore: any;
  27668. private _hasAlpha;
  27669. /**
  27670. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27671. */
  27672. hasAlpha: boolean;
  27673. /**
  27674. * Defines if the alpha value should be determined via the rgb values.
  27675. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27676. */
  27677. getAlphaFromRGB: boolean;
  27678. /**
  27679. * Intensity or strength of the texture.
  27680. * It is commonly used by materials to fine tune the intensity of the texture
  27681. */
  27682. level: number;
  27683. /**
  27684. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27685. * This is part of the texture as textures usually maps to one uv set.
  27686. */
  27687. coordinatesIndex: number;
  27688. private _coordinatesMode;
  27689. /**
  27690. * How a texture is mapped.
  27691. *
  27692. * | Value | Type | Description |
  27693. * | ----- | ----------------------------------- | ----------- |
  27694. * | 0 | EXPLICIT_MODE | |
  27695. * | 1 | SPHERICAL_MODE | |
  27696. * | 2 | PLANAR_MODE | |
  27697. * | 3 | CUBIC_MODE | |
  27698. * | 4 | PROJECTION_MODE | |
  27699. * | 5 | SKYBOX_MODE | |
  27700. * | 6 | INVCUBIC_MODE | |
  27701. * | 7 | EQUIRECTANGULAR_MODE | |
  27702. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27703. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27704. */
  27705. coordinatesMode: number;
  27706. /**
  27707. * | Value | Type | Description |
  27708. * | ----- | ------------------ | ----------- |
  27709. * | 0 | CLAMP_ADDRESSMODE | |
  27710. * | 1 | WRAP_ADDRESSMODE | |
  27711. * | 2 | MIRROR_ADDRESSMODE | |
  27712. */
  27713. wrapU: number;
  27714. /**
  27715. * | Value | Type | Description |
  27716. * | ----- | ------------------ | ----------- |
  27717. * | 0 | CLAMP_ADDRESSMODE | |
  27718. * | 1 | WRAP_ADDRESSMODE | |
  27719. * | 2 | MIRROR_ADDRESSMODE | |
  27720. */
  27721. wrapV: number;
  27722. /**
  27723. * | Value | Type | Description |
  27724. * | ----- | ------------------ | ----------- |
  27725. * | 0 | CLAMP_ADDRESSMODE | |
  27726. * | 1 | WRAP_ADDRESSMODE | |
  27727. * | 2 | MIRROR_ADDRESSMODE | |
  27728. */
  27729. wrapR: number;
  27730. /**
  27731. * With compliant hardware and browser (supporting anisotropic filtering)
  27732. * this defines the level of anisotropic filtering in the texture.
  27733. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27734. */
  27735. anisotropicFilteringLevel: number;
  27736. /**
  27737. * Define if the texture is a cube texture or if false a 2d texture.
  27738. */
  27739. isCube: boolean;
  27740. /**
  27741. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27742. */
  27743. is3D: boolean;
  27744. /**
  27745. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27746. * HDR texture are usually stored in linear space.
  27747. * This only impacts the PBR and Background materials
  27748. */
  27749. gammaSpace: boolean;
  27750. /**
  27751. * Gets or sets whether or not the texture contains RGBD data.
  27752. */
  27753. isRGBD: boolean;
  27754. /**
  27755. * Is Z inverted in the texture (useful in a cube texture).
  27756. */
  27757. invertZ: boolean;
  27758. /**
  27759. * Are mip maps generated for this texture or not.
  27760. */
  27761. readonly noMipmap: boolean;
  27762. /**
  27763. * @hidden
  27764. */
  27765. lodLevelInAlpha: boolean;
  27766. /**
  27767. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27768. */
  27769. lodGenerationOffset: number;
  27770. /**
  27771. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27772. */
  27773. lodGenerationScale: number;
  27774. /**
  27775. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27776. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27777. * average roughness values.
  27778. */
  27779. linearSpecularLOD: boolean;
  27780. /**
  27781. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27782. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27783. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27784. */
  27785. irradianceTexture: Nullable<BaseTexture>;
  27786. /**
  27787. * Define if the texture is a render target.
  27788. */
  27789. isRenderTarget: boolean;
  27790. /**
  27791. * Define the unique id of the texture in the scene.
  27792. */
  27793. readonly uid: string;
  27794. /**
  27795. * Return a string representation of the texture.
  27796. * @returns the texture as a string
  27797. */
  27798. toString(): string;
  27799. /**
  27800. * Get the class name of the texture.
  27801. * @returns "BaseTexture"
  27802. */
  27803. getClassName(): string;
  27804. /**
  27805. * Define the list of animation attached to the texture.
  27806. */
  27807. animations: Animation[];
  27808. /**
  27809. * An event triggered when the texture is disposed.
  27810. */
  27811. onDisposeObservable: Observable<BaseTexture>;
  27812. private _onDisposeObserver;
  27813. /**
  27814. * Callback triggered when the texture has been disposed.
  27815. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27816. */
  27817. onDispose: () => void;
  27818. /**
  27819. * Define the current state of the loading sequence when in delayed load mode.
  27820. */
  27821. delayLoadState: number;
  27822. private _scene;
  27823. /** @hidden */
  27824. _texture: Nullable<InternalTexture>;
  27825. private _uid;
  27826. /**
  27827. * Define if the texture is preventinga material to render or not.
  27828. * If not and the texture is not ready, the engine will use a default black texture instead.
  27829. */
  27830. readonly isBlocking: boolean;
  27831. /**
  27832. * Instantiates a new BaseTexture.
  27833. * Base class of all the textures in babylon.
  27834. * It groups all the common properties the materials, post process, lights... might need
  27835. * in order to make a correct use of the texture.
  27836. * @param scene Define the scene the texture blongs to
  27837. */
  27838. constructor(scene: Nullable<Scene>);
  27839. /**
  27840. * Get the scene the texture belongs to.
  27841. * @returns the scene or null if undefined
  27842. */
  27843. getScene(): Nullable<Scene>;
  27844. /**
  27845. * Get the texture transform matrix used to offset tile the texture for istance.
  27846. * @returns the transformation matrix
  27847. */
  27848. getTextureMatrix(): Matrix;
  27849. /**
  27850. * Get the texture reflection matrix used to rotate/transform the reflection.
  27851. * @returns the reflection matrix
  27852. */
  27853. getReflectionTextureMatrix(): Matrix;
  27854. /**
  27855. * Get the underlying lower level texture from Babylon.
  27856. * @returns the insternal texture
  27857. */
  27858. getInternalTexture(): Nullable<InternalTexture>;
  27859. /**
  27860. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27861. * @returns true if ready or not blocking
  27862. */
  27863. isReadyOrNotBlocking(): boolean;
  27864. /**
  27865. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27866. * @returns true if fully ready
  27867. */
  27868. isReady(): boolean;
  27869. private _cachedSize;
  27870. /**
  27871. * Get the size of the texture.
  27872. * @returns the texture size.
  27873. */
  27874. getSize(): ISize;
  27875. /**
  27876. * Get the base size of the texture.
  27877. * It can be different from the size if the texture has been resized for POT for instance
  27878. * @returns the base size
  27879. */
  27880. getBaseSize(): ISize;
  27881. /**
  27882. * Update the sampling mode of the texture.
  27883. * Default is Trilinear mode.
  27884. *
  27885. * | Value | Type | Description |
  27886. * | ----- | ------------------ | ----------- |
  27887. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27888. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27889. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27890. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27891. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27892. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27893. * | 7 | NEAREST_LINEAR | |
  27894. * | 8 | NEAREST_NEAREST | |
  27895. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27896. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27897. * | 11 | LINEAR_LINEAR | |
  27898. * | 12 | LINEAR_NEAREST | |
  27899. *
  27900. * > _mag_: magnification filter (close to the viewer)
  27901. * > _min_: minification filter (far from the viewer)
  27902. * > _mip_: filter used between mip map levels
  27903. *@param samplingMode Define the new sampling mode of the texture
  27904. */
  27905. updateSamplingMode(samplingMode: number): void;
  27906. /**
  27907. * Scales the texture if is `canRescale()`
  27908. * @param ratio the resize factor we want to use to rescale
  27909. */
  27910. scale(ratio: number): void;
  27911. /**
  27912. * Get if the texture can rescale.
  27913. */
  27914. readonly canRescale: boolean;
  27915. /** @hidden */
  27916. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27917. /** @hidden */
  27918. _rebuild(): void;
  27919. /**
  27920. * Triggers the load sequence in delayed load mode.
  27921. */
  27922. delayLoad(): void;
  27923. /**
  27924. * Clones the texture.
  27925. * @returns the cloned texture
  27926. */
  27927. clone(): Nullable<BaseTexture>;
  27928. /**
  27929. * Get the texture underlying type (INT, FLOAT...)
  27930. */
  27931. readonly textureType: number;
  27932. /**
  27933. * Get the texture underlying format (RGB, RGBA...)
  27934. */
  27935. readonly textureFormat: number;
  27936. /**
  27937. * Indicates that textures need to be re-calculated for all materials
  27938. */
  27939. protected _markAllSubMeshesAsTexturesDirty(): void;
  27940. /**
  27941. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27942. * This will returns an RGBA array buffer containing either in values (0-255) or
  27943. * float values (0-1) depending of the underlying buffer type.
  27944. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27945. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27946. * @param buffer defines a user defined buffer to fill with data (can be null)
  27947. * @returns The Array buffer containing the pixels data.
  27948. */
  27949. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27950. /**
  27951. * Release and destroy the underlying lower level texture aka internalTexture.
  27952. */
  27953. releaseInternalTexture(): void;
  27954. /** @hidden */
  27955. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27956. /** @hidden */
  27957. readonly _lodTextureMid: Nullable<BaseTexture>;
  27958. /** @hidden */
  27959. readonly _lodTextureLow: Nullable<BaseTexture>;
  27960. /**
  27961. * Dispose the texture and release its associated resources.
  27962. */
  27963. dispose(): void;
  27964. /**
  27965. * Serialize the texture into a JSON representation that can be parsed later on.
  27966. * @returns the JSON representation of the texture
  27967. */
  27968. serialize(): any;
  27969. /**
  27970. * Helper function to be called back once a list of texture contains only ready textures.
  27971. * @param textures Define the list of textures to wait for
  27972. * @param callback Define the callback triggered once the entire list will be ready
  27973. */
  27974. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27975. }
  27976. }
  27977. declare module BABYLON {
  27978. /**
  27979. * Options to be used when creating an effect.
  27980. */
  27981. export interface IEffectCreationOptions {
  27982. /**
  27983. * Atrributes that will be used in the shader.
  27984. */
  27985. attributes: string[];
  27986. /**
  27987. * Uniform varible names that will be set in the shader.
  27988. */
  27989. uniformsNames: string[];
  27990. /**
  27991. * Uniform buffer varible names that will be set in the shader.
  27992. */
  27993. uniformBuffersNames: string[];
  27994. /**
  27995. * Sampler texture variable names that will be set in the shader.
  27996. */
  27997. samplers: string[];
  27998. /**
  27999. * Define statements that will be set in the shader.
  28000. */
  28001. defines: any;
  28002. /**
  28003. * Possible fallbacks for this effect to improve performance when needed.
  28004. */
  28005. fallbacks: Nullable<IEffectFallbacks>;
  28006. /**
  28007. * Callback that will be called when the shader is compiled.
  28008. */
  28009. onCompiled: Nullable<(effect: Effect) => void>;
  28010. /**
  28011. * Callback that will be called if an error occurs during shader compilation.
  28012. */
  28013. onError: Nullable<(effect: Effect, errors: string) => void>;
  28014. /**
  28015. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28016. */
  28017. indexParameters?: any;
  28018. /**
  28019. * Max number of lights that can be used in the shader.
  28020. */
  28021. maxSimultaneousLights?: number;
  28022. /**
  28023. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28024. */
  28025. transformFeedbackVaryings?: Nullable<string[]>;
  28026. }
  28027. /**
  28028. * Effect containing vertex and fragment shader that can be executed on an object.
  28029. */
  28030. export class Effect implements IDisposable {
  28031. /**
  28032. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28033. */
  28034. static ShadersRepository: string;
  28035. /**
  28036. * Name of the effect.
  28037. */
  28038. name: any;
  28039. /**
  28040. * String container all the define statements that should be set on the shader.
  28041. */
  28042. defines: string;
  28043. /**
  28044. * Callback that will be called when the shader is compiled.
  28045. */
  28046. onCompiled: Nullable<(effect: Effect) => void>;
  28047. /**
  28048. * Callback that will be called if an error occurs during shader compilation.
  28049. */
  28050. onError: Nullable<(effect: Effect, errors: string) => void>;
  28051. /**
  28052. * Callback that will be called when effect is bound.
  28053. */
  28054. onBind: Nullable<(effect: Effect) => void>;
  28055. /**
  28056. * Unique ID of the effect.
  28057. */
  28058. uniqueId: number;
  28059. /**
  28060. * Observable that will be called when the shader is compiled.
  28061. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28062. */
  28063. onCompileObservable: Observable<Effect>;
  28064. /**
  28065. * Observable that will be called if an error occurs during shader compilation.
  28066. */
  28067. onErrorObservable: Observable<Effect>;
  28068. /** @hidden */
  28069. _onBindObservable: Nullable<Observable<Effect>>;
  28070. /**
  28071. * Observable that will be called when effect is bound.
  28072. */
  28073. readonly onBindObservable: Observable<Effect>;
  28074. /** @hidden */
  28075. _bonesComputationForcedToCPU: boolean;
  28076. private static _uniqueIdSeed;
  28077. private _engine;
  28078. private _uniformBuffersNames;
  28079. private _uniformsNames;
  28080. private _samplerList;
  28081. private _samplers;
  28082. private _isReady;
  28083. private _compilationError;
  28084. private _allFallbacksProcessed;
  28085. private _attributesNames;
  28086. private _attributes;
  28087. private _uniforms;
  28088. /**
  28089. * Key for the effect.
  28090. * @hidden
  28091. */
  28092. _key: string;
  28093. private _indexParameters;
  28094. private _fallbacks;
  28095. private _vertexSourceCode;
  28096. private _fragmentSourceCode;
  28097. private _vertexSourceCodeOverride;
  28098. private _fragmentSourceCodeOverride;
  28099. private _transformFeedbackVaryings;
  28100. /**
  28101. * Compiled shader to webGL program.
  28102. * @hidden
  28103. */
  28104. _pipelineContext: Nullable<IPipelineContext>;
  28105. private _valueCache;
  28106. private static _baseCache;
  28107. /**
  28108. * Instantiates an effect.
  28109. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28110. * @param baseName Name of the effect.
  28111. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28112. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28113. * @param samplers List of sampler variables that will be passed to the shader.
  28114. * @param engine Engine to be used to render the effect
  28115. * @param defines Define statements to be added to the shader.
  28116. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28117. * @param onCompiled Callback that will be called when the shader is compiled.
  28118. * @param onError Callback that will be called if an error occurs during shader compilation.
  28119. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28120. */
  28121. 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);
  28122. private _useFinalCode;
  28123. /**
  28124. * Unique key for this effect
  28125. */
  28126. readonly key: string;
  28127. /**
  28128. * If the effect has been compiled and prepared.
  28129. * @returns if the effect is compiled and prepared.
  28130. */
  28131. isReady(): boolean;
  28132. private _isReadyInternal;
  28133. /**
  28134. * The engine the effect was initialized with.
  28135. * @returns the engine.
  28136. */
  28137. getEngine(): Engine;
  28138. /**
  28139. * The pipeline context for this effect
  28140. * @returns the associated pipeline context
  28141. */
  28142. getPipelineContext(): Nullable<IPipelineContext>;
  28143. /**
  28144. * The set of names of attribute variables for the shader.
  28145. * @returns An array of attribute names.
  28146. */
  28147. getAttributesNames(): string[];
  28148. /**
  28149. * Returns the attribute at the given index.
  28150. * @param index The index of the attribute.
  28151. * @returns The location of the attribute.
  28152. */
  28153. getAttributeLocation(index: number): number;
  28154. /**
  28155. * Returns the attribute based on the name of the variable.
  28156. * @param name of the attribute to look up.
  28157. * @returns the attribute location.
  28158. */
  28159. getAttributeLocationByName(name: string): number;
  28160. /**
  28161. * The number of attributes.
  28162. * @returns the numnber of attributes.
  28163. */
  28164. getAttributesCount(): number;
  28165. /**
  28166. * Gets the index of a uniform variable.
  28167. * @param uniformName of the uniform to look up.
  28168. * @returns the index.
  28169. */
  28170. getUniformIndex(uniformName: string): number;
  28171. /**
  28172. * Returns the attribute based on the name of the variable.
  28173. * @param uniformName of the uniform to look up.
  28174. * @returns the location of the uniform.
  28175. */
  28176. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28177. /**
  28178. * Returns an array of sampler variable names
  28179. * @returns The array of sampler variable neames.
  28180. */
  28181. getSamplers(): string[];
  28182. /**
  28183. * The error from the last compilation.
  28184. * @returns the error string.
  28185. */
  28186. getCompilationError(): string;
  28187. /**
  28188. * Gets a boolean indicating that all fallbacks were used during compilation
  28189. * @returns true if all fallbacks were used
  28190. */
  28191. allFallbacksProcessed(): boolean;
  28192. /**
  28193. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28194. * @param func The callback to be used.
  28195. */
  28196. executeWhenCompiled(func: (effect: Effect) => void): void;
  28197. private _checkIsReady;
  28198. private _loadShader;
  28199. /**
  28200. * Recompiles the webGL program
  28201. * @param vertexSourceCode The source code for the vertex shader.
  28202. * @param fragmentSourceCode The source code for the fragment shader.
  28203. * @param onCompiled Callback called when completed.
  28204. * @param onError Callback called on error.
  28205. * @hidden
  28206. */
  28207. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28208. /**
  28209. * Prepares the effect
  28210. * @hidden
  28211. */
  28212. _prepareEffect(): void;
  28213. private _processCompilationErrors;
  28214. /**
  28215. * Checks if the effect is supported. (Must be called after compilation)
  28216. */
  28217. readonly isSupported: boolean;
  28218. /**
  28219. * Binds a texture to the engine to be used as output of the shader.
  28220. * @param channel Name of the output variable.
  28221. * @param texture Texture to bind.
  28222. * @hidden
  28223. */
  28224. _bindTexture(channel: string, texture: InternalTexture): void;
  28225. /**
  28226. * Sets a texture on the engine to be used in the shader.
  28227. * @param channel Name of the sampler variable.
  28228. * @param texture Texture to set.
  28229. */
  28230. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28231. /**
  28232. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28233. * @param channel Name of the sampler variable.
  28234. * @param texture Texture to set.
  28235. */
  28236. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28237. /**
  28238. * Sets an array of textures on the engine to be used in the shader.
  28239. * @param channel Name of the variable.
  28240. * @param textures Textures to set.
  28241. */
  28242. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28243. /**
  28244. * 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)
  28245. * @param channel Name of the sampler variable.
  28246. * @param postProcess Post process to get the input texture from.
  28247. */
  28248. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28249. /**
  28250. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28251. * 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)
  28252. * @param channel Name of the sampler variable.
  28253. * @param postProcess Post process to get the output texture from.
  28254. */
  28255. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28256. /** @hidden */
  28257. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28258. /** @hidden */
  28259. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28260. /** @hidden */
  28261. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28262. /** @hidden */
  28263. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28264. /**
  28265. * Binds a buffer to a uniform.
  28266. * @param buffer Buffer to bind.
  28267. * @param name Name of the uniform variable to bind to.
  28268. */
  28269. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28270. /**
  28271. * Binds block to a uniform.
  28272. * @param blockName Name of the block to bind.
  28273. * @param index Index to bind.
  28274. */
  28275. bindUniformBlock(blockName: string, index: number): void;
  28276. /**
  28277. * Sets an interger value on a uniform variable.
  28278. * @param uniformName Name of the variable.
  28279. * @param value Value to be set.
  28280. * @returns this effect.
  28281. */
  28282. setInt(uniformName: string, value: number): Effect;
  28283. /**
  28284. * Sets an int array on a uniform variable.
  28285. * @param uniformName Name of the variable.
  28286. * @param array array to be set.
  28287. * @returns this effect.
  28288. */
  28289. setIntArray(uniformName: string, array: Int32Array): Effect;
  28290. /**
  28291. * 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)
  28292. * @param uniformName Name of the variable.
  28293. * @param array array to be set.
  28294. * @returns this effect.
  28295. */
  28296. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28297. /**
  28298. * 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)
  28299. * @param uniformName Name of the variable.
  28300. * @param array array to be set.
  28301. * @returns this effect.
  28302. */
  28303. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28304. /**
  28305. * 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)
  28306. * @param uniformName Name of the variable.
  28307. * @param array array to be set.
  28308. * @returns this effect.
  28309. */
  28310. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28311. /**
  28312. * Sets an float array on a uniform variable.
  28313. * @param uniformName Name of the variable.
  28314. * @param array array to be set.
  28315. * @returns this effect.
  28316. */
  28317. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28318. /**
  28319. * 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)
  28320. * @param uniformName Name of the variable.
  28321. * @param array array to be set.
  28322. * @returns this effect.
  28323. */
  28324. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28325. /**
  28326. * 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)
  28327. * @param uniformName Name of the variable.
  28328. * @param array array to be set.
  28329. * @returns this effect.
  28330. */
  28331. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28332. /**
  28333. * 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)
  28334. * @param uniformName Name of the variable.
  28335. * @param array array to be set.
  28336. * @returns this effect.
  28337. */
  28338. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28339. /**
  28340. * Sets an array on a uniform variable.
  28341. * @param uniformName Name of the variable.
  28342. * @param array array to be set.
  28343. * @returns this effect.
  28344. */
  28345. setArray(uniformName: string, array: number[]): Effect;
  28346. /**
  28347. * 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)
  28348. * @param uniformName Name of the variable.
  28349. * @param array array to be set.
  28350. * @returns this effect.
  28351. */
  28352. setArray2(uniformName: string, array: number[]): Effect;
  28353. /**
  28354. * 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)
  28355. * @param uniformName Name of the variable.
  28356. * @param array array to be set.
  28357. * @returns this effect.
  28358. */
  28359. setArray3(uniformName: string, array: number[]): Effect;
  28360. /**
  28361. * 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)
  28362. * @param uniformName Name of the variable.
  28363. * @param array array to be set.
  28364. * @returns this effect.
  28365. */
  28366. setArray4(uniformName: string, array: number[]): Effect;
  28367. /**
  28368. * Sets matrices on a uniform variable.
  28369. * @param uniformName Name of the variable.
  28370. * @param matrices matrices to be set.
  28371. * @returns this effect.
  28372. */
  28373. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28374. /**
  28375. * Sets matrix on a uniform variable.
  28376. * @param uniformName Name of the variable.
  28377. * @param matrix matrix to be set.
  28378. * @returns this effect.
  28379. */
  28380. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28381. /**
  28382. * 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)
  28383. * @param uniformName Name of the variable.
  28384. * @param matrix matrix to be set.
  28385. * @returns this effect.
  28386. */
  28387. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28388. /**
  28389. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28390. * @param uniformName Name of the variable.
  28391. * @param matrix matrix to be set.
  28392. * @returns this effect.
  28393. */
  28394. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28395. /**
  28396. * Sets a float on a uniform variable.
  28397. * @param uniformName Name of the variable.
  28398. * @param value value to be set.
  28399. * @returns this effect.
  28400. */
  28401. setFloat(uniformName: string, value: number): Effect;
  28402. /**
  28403. * Sets a boolean on a uniform variable.
  28404. * @param uniformName Name of the variable.
  28405. * @param bool value to be set.
  28406. * @returns this effect.
  28407. */
  28408. setBool(uniformName: string, bool: boolean): Effect;
  28409. /**
  28410. * Sets a Vector2 on a uniform variable.
  28411. * @param uniformName Name of the variable.
  28412. * @param vector2 vector2 to be set.
  28413. * @returns this effect.
  28414. */
  28415. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28416. /**
  28417. * Sets a float2 on a uniform variable.
  28418. * @param uniformName Name of the variable.
  28419. * @param x First float in float2.
  28420. * @param y Second float in float2.
  28421. * @returns this effect.
  28422. */
  28423. setFloat2(uniformName: string, x: number, y: number): Effect;
  28424. /**
  28425. * Sets a Vector3 on a uniform variable.
  28426. * @param uniformName Name of the variable.
  28427. * @param vector3 Value to be set.
  28428. * @returns this effect.
  28429. */
  28430. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28431. /**
  28432. * Sets a float3 on a uniform variable.
  28433. * @param uniformName Name of the variable.
  28434. * @param x First float in float3.
  28435. * @param y Second float in float3.
  28436. * @param z Third float in float3.
  28437. * @returns this effect.
  28438. */
  28439. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28440. /**
  28441. * Sets a Vector4 on a uniform variable.
  28442. * @param uniformName Name of the variable.
  28443. * @param vector4 Value to be set.
  28444. * @returns this effect.
  28445. */
  28446. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28447. /**
  28448. * Sets a float4 on a uniform variable.
  28449. * @param uniformName Name of the variable.
  28450. * @param x First float in float4.
  28451. * @param y Second float in float4.
  28452. * @param z Third float in float4.
  28453. * @param w Fourth float in float4.
  28454. * @returns this effect.
  28455. */
  28456. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28457. /**
  28458. * Sets a Color3 on a uniform variable.
  28459. * @param uniformName Name of the variable.
  28460. * @param color3 Value to be set.
  28461. * @returns this effect.
  28462. */
  28463. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28464. /**
  28465. * Sets a Color4 on a uniform variable.
  28466. * @param uniformName Name of the variable.
  28467. * @param color3 Value to be set.
  28468. * @param alpha Alpha value to be set.
  28469. * @returns this effect.
  28470. */
  28471. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28472. /**
  28473. * Sets a Color4 on a uniform variable
  28474. * @param uniformName defines the name of the variable
  28475. * @param color4 defines the value to be set
  28476. * @returns this effect.
  28477. */
  28478. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28479. /** Release all associated resources */
  28480. dispose(): void;
  28481. /**
  28482. * This function will add a new shader to the shader store
  28483. * @param name the name of the shader
  28484. * @param pixelShader optional pixel shader content
  28485. * @param vertexShader optional vertex shader content
  28486. */
  28487. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28488. /**
  28489. * Store of each shader (The can be looked up using effect.key)
  28490. */
  28491. static ShadersStore: {
  28492. [key: string]: string;
  28493. };
  28494. /**
  28495. * Store of each included file for a shader (The can be looked up using effect.key)
  28496. */
  28497. static IncludesShadersStore: {
  28498. [key: string]: string;
  28499. };
  28500. /**
  28501. * Resets the cache of effects.
  28502. */
  28503. static ResetCache(): void;
  28504. }
  28505. }
  28506. declare module BABYLON {
  28507. /**
  28508. * Class used to describe the capabilities of the engine relatively to the current browser
  28509. */
  28510. export class EngineCapabilities {
  28511. /** Maximum textures units per fragment shader */
  28512. maxTexturesImageUnits: number;
  28513. /** Maximum texture units per vertex shader */
  28514. maxVertexTextureImageUnits: number;
  28515. /** Maximum textures units in the entire pipeline */
  28516. maxCombinedTexturesImageUnits: number;
  28517. /** Maximum texture size */
  28518. maxTextureSize: number;
  28519. /** Maximum cube texture size */
  28520. maxCubemapTextureSize: number;
  28521. /** Maximum render texture size */
  28522. maxRenderTextureSize: number;
  28523. /** Maximum number of vertex attributes */
  28524. maxVertexAttribs: number;
  28525. /** Maximum number of varyings */
  28526. maxVaryingVectors: number;
  28527. /** Maximum number of uniforms per vertex shader */
  28528. maxVertexUniformVectors: number;
  28529. /** Maximum number of uniforms per fragment shader */
  28530. maxFragmentUniformVectors: number;
  28531. /** Defines if standard derivates (dx/dy) are supported */
  28532. standardDerivatives: boolean;
  28533. /** Defines if s3tc texture compression is supported */
  28534. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28535. /** Defines if pvrtc texture compression is supported */
  28536. pvrtc: any;
  28537. /** Defines if etc1 texture compression is supported */
  28538. etc1: any;
  28539. /** Defines if etc2 texture compression is supported */
  28540. etc2: any;
  28541. /** Defines if astc texture compression is supported */
  28542. astc: any;
  28543. /** Defines if float textures are supported */
  28544. textureFloat: boolean;
  28545. /** Defines if vertex array objects are supported */
  28546. vertexArrayObject: boolean;
  28547. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28548. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28549. /** Gets the maximum level of anisotropy supported */
  28550. maxAnisotropy: number;
  28551. /** Defines if instancing is supported */
  28552. instancedArrays: boolean;
  28553. /** Defines if 32 bits indices are supported */
  28554. uintIndices: boolean;
  28555. /** Defines if high precision shaders are supported */
  28556. highPrecisionShaderSupported: boolean;
  28557. /** Defines if depth reading in the fragment shader is supported */
  28558. fragmentDepthSupported: boolean;
  28559. /** Defines if float texture linear filtering is supported*/
  28560. textureFloatLinearFiltering: boolean;
  28561. /** Defines if rendering to float textures is supported */
  28562. textureFloatRender: boolean;
  28563. /** Defines if half float textures are supported*/
  28564. textureHalfFloat: boolean;
  28565. /** Defines if half float texture linear filtering is supported*/
  28566. textureHalfFloatLinearFiltering: boolean;
  28567. /** Defines if rendering to half float textures is supported */
  28568. textureHalfFloatRender: boolean;
  28569. /** Defines if textureLOD shader command is supported */
  28570. textureLOD: boolean;
  28571. /** Defines if draw buffers extension is supported */
  28572. drawBuffersExtension: boolean;
  28573. /** Defines if depth textures are supported */
  28574. depthTextureExtension: boolean;
  28575. /** Defines if float color buffer are supported */
  28576. colorBufferFloat: boolean;
  28577. /** Gets disjoint timer query extension (null if not supported) */
  28578. timerQuery: EXT_disjoint_timer_query;
  28579. /** Defines if timestamp can be used with timer query */
  28580. canUseTimestampForTimerQuery: boolean;
  28581. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28582. multiview: any;
  28583. /** Function used to let the system compiles shaders in background */
  28584. parallelShaderCompile: {
  28585. COMPLETION_STATUS_KHR: number;
  28586. };
  28587. /** Max number of texture samples for MSAA */
  28588. maxMSAASamples: number;
  28589. /** Defines if the blend min max extension is supported */
  28590. blendMinMax: boolean;
  28591. }
  28592. }
  28593. declare module BABYLON {
  28594. /**
  28595. * @hidden
  28596. **/
  28597. export class DepthCullingState {
  28598. private _isDepthTestDirty;
  28599. private _isDepthMaskDirty;
  28600. private _isDepthFuncDirty;
  28601. private _isCullFaceDirty;
  28602. private _isCullDirty;
  28603. private _isZOffsetDirty;
  28604. private _isFrontFaceDirty;
  28605. private _depthTest;
  28606. private _depthMask;
  28607. private _depthFunc;
  28608. private _cull;
  28609. private _cullFace;
  28610. private _zOffset;
  28611. private _frontFace;
  28612. /**
  28613. * Initializes the state.
  28614. */
  28615. constructor();
  28616. readonly isDirty: boolean;
  28617. zOffset: number;
  28618. cullFace: Nullable<number>;
  28619. cull: Nullable<boolean>;
  28620. depthFunc: Nullable<number>;
  28621. depthMask: boolean;
  28622. depthTest: boolean;
  28623. frontFace: Nullable<number>;
  28624. reset(): void;
  28625. apply(gl: WebGLRenderingContext): void;
  28626. }
  28627. }
  28628. declare module BABYLON {
  28629. /**
  28630. * @hidden
  28631. **/
  28632. export class StencilState {
  28633. /** 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 */
  28634. static readonly ALWAYS: number;
  28635. /** Passed to stencilOperation to specify that stencil value must be kept */
  28636. static readonly KEEP: number;
  28637. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28638. static readonly REPLACE: number;
  28639. private _isStencilTestDirty;
  28640. private _isStencilMaskDirty;
  28641. private _isStencilFuncDirty;
  28642. private _isStencilOpDirty;
  28643. private _stencilTest;
  28644. private _stencilMask;
  28645. private _stencilFunc;
  28646. private _stencilFuncRef;
  28647. private _stencilFuncMask;
  28648. private _stencilOpStencilFail;
  28649. private _stencilOpDepthFail;
  28650. private _stencilOpStencilDepthPass;
  28651. readonly isDirty: boolean;
  28652. stencilFunc: number;
  28653. stencilFuncRef: number;
  28654. stencilFuncMask: number;
  28655. stencilOpStencilFail: number;
  28656. stencilOpDepthFail: number;
  28657. stencilOpStencilDepthPass: number;
  28658. stencilMask: number;
  28659. stencilTest: boolean;
  28660. constructor();
  28661. reset(): void;
  28662. apply(gl: WebGLRenderingContext): void;
  28663. }
  28664. }
  28665. declare module BABYLON {
  28666. /**
  28667. * @hidden
  28668. **/
  28669. export class AlphaState {
  28670. private _isAlphaBlendDirty;
  28671. private _isBlendFunctionParametersDirty;
  28672. private _isBlendEquationParametersDirty;
  28673. private _isBlendConstantsDirty;
  28674. private _alphaBlend;
  28675. private _blendFunctionParameters;
  28676. private _blendEquationParameters;
  28677. private _blendConstants;
  28678. /**
  28679. * Initializes the state.
  28680. */
  28681. constructor();
  28682. readonly isDirty: boolean;
  28683. alphaBlend: boolean;
  28684. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28685. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28686. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28687. reset(): void;
  28688. apply(gl: WebGLRenderingContext): void;
  28689. }
  28690. }
  28691. declare module BABYLON {
  28692. /** @hidden */
  28693. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28694. attributeProcessor(attribute: string): string;
  28695. varyingProcessor(varying: string, isFragment: boolean): string;
  28696. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28697. }
  28698. }
  28699. declare module BABYLON {
  28700. /**
  28701. * Interface for attribute information associated with buffer instanciation
  28702. */
  28703. export class InstancingAttributeInfo {
  28704. /**
  28705. * Index/offset of the attribute in the vertex shader
  28706. */
  28707. index: number;
  28708. /**
  28709. * size of the attribute, 1, 2, 3 or 4
  28710. */
  28711. attributeSize: number;
  28712. /**
  28713. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28714. * default is FLOAT
  28715. */
  28716. attribyteType: number;
  28717. /**
  28718. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28719. */
  28720. normalized: boolean;
  28721. /**
  28722. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28723. */
  28724. offset: number;
  28725. /**
  28726. * Name of the GLSL attribute, for debugging purpose only
  28727. */
  28728. attributeName: string;
  28729. }
  28730. }
  28731. declare module BABYLON {
  28732. interface ThinEngine {
  28733. /**
  28734. * Update a video texture
  28735. * @param texture defines the texture to update
  28736. * @param video defines the video element to use
  28737. * @param invertY defines if data must be stored with Y axis inverted
  28738. */
  28739. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28740. }
  28741. }
  28742. declare module BABYLON {
  28743. /**
  28744. * Settings for finer control over video usage
  28745. */
  28746. export interface VideoTextureSettings {
  28747. /**
  28748. * Applies `autoplay` to video, if specified
  28749. */
  28750. autoPlay?: boolean;
  28751. /**
  28752. * Applies `loop` to video, if specified
  28753. */
  28754. loop?: boolean;
  28755. /**
  28756. * Automatically updates internal texture from video at every frame in the render loop
  28757. */
  28758. autoUpdateTexture: boolean;
  28759. /**
  28760. * Image src displayed during the video loading or until the user interacts with the video.
  28761. */
  28762. poster?: string;
  28763. }
  28764. /**
  28765. * If you want to display a video in your scene, this is the special texture for that.
  28766. * This special texture works similar to other textures, with the exception of a few parameters.
  28767. * @see https://doc.babylonjs.com/how_to/video_texture
  28768. */
  28769. export class VideoTexture extends Texture {
  28770. /**
  28771. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28772. */
  28773. readonly autoUpdateTexture: boolean;
  28774. /**
  28775. * The video instance used by the texture internally
  28776. */
  28777. readonly video: HTMLVideoElement;
  28778. private _onUserActionRequestedObservable;
  28779. /**
  28780. * Event triggerd when a dom action is required by the user to play the video.
  28781. * This happens due to recent changes in browser policies preventing video to auto start.
  28782. */
  28783. readonly onUserActionRequestedObservable: Observable<Texture>;
  28784. private _generateMipMaps;
  28785. private _engine;
  28786. private _stillImageCaptured;
  28787. private _displayingPosterTexture;
  28788. private _settings;
  28789. private _createInternalTextureOnEvent;
  28790. private _frameId;
  28791. /**
  28792. * Creates a video texture.
  28793. * If you want to display a video in your scene, this is the special texture for that.
  28794. * This special texture works similar to other textures, with the exception of a few parameters.
  28795. * @see https://doc.babylonjs.com/how_to/video_texture
  28796. * @param name optional name, will detect from video source, if not defined
  28797. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28798. * @param scene is obviously the current scene.
  28799. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28800. * @param invertY is false by default but can be used to invert video on Y axis
  28801. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28802. * @param settings allows finer control over video usage
  28803. */
  28804. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28805. private _getName;
  28806. private _getVideo;
  28807. private _createInternalTexture;
  28808. private reset;
  28809. /**
  28810. * @hidden Internal method to initiate `update`.
  28811. */
  28812. _rebuild(): void;
  28813. /**
  28814. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28815. */
  28816. update(): void;
  28817. /**
  28818. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28819. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28820. */
  28821. updateTexture(isVisible: boolean): void;
  28822. protected _updateInternalTexture: () => void;
  28823. /**
  28824. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28825. * @param url New url.
  28826. */
  28827. updateURL(url: string): void;
  28828. /**
  28829. * Dispose the texture and release its associated resources.
  28830. */
  28831. dispose(): void;
  28832. /**
  28833. * Creates a video texture straight from a stream.
  28834. * @param scene Define the scene the texture should be created in
  28835. * @param stream Define the stream the texture should be created from
  28836. * @returns The created video texture as a promise
  28837. */
  28838. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28839. /**
  28840. * Creates a video texture straight from your WebCam video feed.
  28841. * @param scene Define the scene the texture should be created in
  28842. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28843. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28844. * @returns The created video texture as a promise
  28845. */
  28846. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28847. minWidth: number;
  28848. maxWidth: number;
  28849. minHeight: number;
  28850. maxHeight: number;
  28851. deviceId: string;
  28852. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28853. /**
  28854. * Creates a video texture straight from your WebCam video feed.
  28855. * @param scene Define the scene the texture should be created in
  28856. * @param onReady Define a callback to triggered once the texture will be ready
  28857. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28858. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28859. */
  28860. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28861. minWidth: number;
  28862. maxWidth: number;
  28863. minHeight: number;
  28864. maxHeight: number;
  28865. deviceId: string;
  28866. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28867. }
  28868. }
  28869. declare module BABYLON {
  28870. /**
  28871. * Defines the interface used by objects working like Scene
  28872. * @hidden
  28873. */
  28874. interface ISceneLike {
  28875. _addPendingData(data: any): void;
  28876. _removePendingData(data: any): void;
  28877. offlineProvider: IOfflineProvider;
  28878. }
  28879. /** Interface defining initialization parameters for Engine class */
  28880. export interface EngineOptions extends WebGLContextAttributes {
  28881. /**
  28882. * Defines if the engine should no exceed a specified device ratio
  28883. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28884. */
  28885. limitDeviceRatio?: number;
  28886. /**
  28887. * Defines if webvr should be enabled automatically
  28888. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28889. */
  28890. autoEnableWebVR?: boolean;
  28891. /**
  28892. * Defines if webgl2 should be turned off even if supported
  28893. * @see http://doc.babylonjs.com/features/webgl2
  28894. */
  28895. disableWebGL2Support?: boolean;
  28896. /**
  28897. * Defines if webaudio should be initialized as well
  28898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28899. */
  28900. audioEngine?: boolean;
  28901. /**
  28902. * Defines if animations should run using a deterministic lock step
  28903. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28904. */
  28905. deterministicLockstep?: boolean;
  28906. /** Defines the maximum steps to use with deterministic lock step mode */
  28907. lockstepMaxSteps?: number;
  28908. /**
  28909. * Defines that engine should ignore context lost events
  28910. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28911. */
  28912. doNotHandleContextLost?: boolean;
  28913. /**
  28914. * Defines that engine should ignore modifying touch action attribute and style
  28915. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28916. */
  28917. doNotHandleTouchAction?: boolean;
  28918. /**
  28919. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28920. */
  28921. useHighPrecisionFloats?: boolean;
  28922. }
  28923. /**
  28924. * The base engine class (root of all engines)
  28925. */
  28926. export class ThinEngine {
  28927. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28928. static ExceptionList: ({
  28929. key: string;
  28930. capture: string;
  28931. captureConstraint: number;
  28932. targets: string[];
  28933. } | {
  28934. key: string;
  28935. capture: null;
  28936. captureConstraint: null;
  28937. targets: string[];
  28938. })[];
  28939. /** @hidden */
  28940. static _TextureLoaders: IInternalTextureLoader[];
  28941. /**
  28942. * Returns the current npm package of the sdk
  28943. */
  28944. static readonly NpmPackage: string;
  28945. /**
  28946. * Returns the current version of the framework
  28947. */
  28948. static readonly Version: string;
  28949. /**
  28950. * Returns a string describing the current engine
  28951. */
  28952. readonly description: string;
  28953. /**
  28954. * Gets or sets the epsilon value used by collision engine
  28955. */
  28956. static CollisionsEpsilon: number;
  28957. /**
  28958. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28959. */
  28960. static ShadersRepository: string;
  28961. /** @hidden */
  28962. _shaderProcessor: IShaderProcessor;
  28963. /**
  28964. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28965. */
  28966. forcePOTTextures: boolean;
  28967. /**
  28968. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28969. */
  28970. isFullscreen: boolean;
  28971. /**
  28972. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28973. */
  28974. cullBackFaces: boolean;
  28975. /**
  28976. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28977. */
  28978. renderEvenInBackground: boolean;
  28979. /**
  28980. * Gets or sets a boolean indicating that cache can be kept between frames
  28981. */
  28982. preventCacheWipeBetweenFrames: boolean;
  28983. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28984. validateShaderPrograms: boolean;
  28985. /**
  28986. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28987. */
  28988. disableUniformBuffers: boolean;
  28989. /** @hidden */
  28990. _uniformBuffers: UniformBuffer[];
  28991. /**
  28992. * Gets a boolean indicating that the engine supports uniform buffers
  28993. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28994. */
  28995. readonly supportsUniformBuffers: boolean;
  28996. /** @hidden */
  28997. _gl: WebGLRenderingContext;
  28998. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  28999. protected _windowIsBackground: boolean;
  29000. protected _webGLVersion: number;
  29001. protected _highPrecisionShadersAllowed: boolean;
  29002. /** @hidden */
  29003. readonly _shouldUseHighPrecisionShader: boolean;
  29004. /**
  29005. * Gets a boolean indicating that only power of 2 textures are supported
  29006. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29007. */
  29008. readonly needPOTTextures: boolean;
  29009. /** @hidden */
  29010. _badOS: boolean;
  29011. /** @hidden */
  29012. _badDesktopOS: boolean;
  29013. private _hardwareScalingLevel;
  29014. /** @hidden */
  29015. _caps: EngineCapabilities;
  29016. private _isStencilEnable;
  29017. protected _colorWrite: boolean;
  29018. private _glVersion;
  29019. private _glRenderer;
  29020. private _glVendor;
  29021. /** @hidden */
  29022. _videoTextureSupported: boolean;
  29023. protected _renderingQueueLaunched: boolean;
  29024. protected _activeRenderLoops: (() => void)[];
  29025. /**
  29026. * Observable signaled when a context lost event is raised
  29027. */
  29028. onContextLostObservable: Observable<ThinEngine>;
  29029. /**
  29030. * Observable signaled when a context restored event is raised
  29031. */
  29032. onContextRestoredObservable: Observable<ThinEngine>;
  29033. private _onContextLost;
  29034. private _onContextRestored;
  29035. protected _contextWasLost: boolean;
  29036. /** @hidden */
  29037. _doNotHandleContextLost: boolean;
  29038. /**
  29039. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29041. */
  29042. doNotHandleContextLost: boolean;
  29043. /**
  29044. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29045. */
  29046. disableVertexArrayObjects: boolean;
  29047. /** @hidden */
  29048. protected _depthCullingState: DepthCullingState;
  29049. /** @hidden */
  29050. protected _stencilState: StencilState;
  29051. /** @hidden */
  29052. protected _alphaState: AlphaState;
  29053. /** @hidden */
  29054. _internalTexturesCache: InternalTexture[];
  29055. /** @hidden */
  29056. protected _activeChannel: number;
  29057. private _currentTextureChannel;
  29058. /** @hidden */
  29059. protected _boundTexturesCache: {
  29060. [key: string]: Nullable<InternalTexture>;
  29061. };
  29062. /** @hidden */
  29063. protected _currentEffect: Nullable<Effect>;
  29064. /** @hidden */
  29065. protected _currentProgram: Nullable<WebGLProgram>;
  29066. private _compiledEffects;
  29067. private _vertexAttribArraysEnabled;
  29068. /** @hidden */
  29069. protected _cachedViewport: Nullable<IViewportLike>;
  29070. private _cachedVertexArrayObject;
  29071. /** @hidden */
  29072. protected _cachedVertexBuffers: any;
  29073. /** @hidden */
  29074. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29075. /** @hidden */
  29076. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29077. /** @hidden */
  29078. _currentRenderTarget: Nullable<InternalTexture>;
  29079. private _uintIndicesCurrentlySet;
  29080. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29081. /** @hidden */
  29082. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29083. private _currentBufferPointers;
  29084. private _currentInstanceLocations;
  29085. private _currentInstanceBuffers;
  29086. private _textureUnits;
  29087. /** @hidden */
  29088. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29089. /** @hidden */
  29090. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29091. /** @hidden */
  29092. _bindedRenderFunction: any;
  29093. private _vaoRecordInProgress;
  29094. private _mustWipeVertexAttributes;
  29095. private _emptyTexture;
  29096. private _emptyCubeTexture;
  29097. private _emptyTexture3D;
  29098. /** @hidden */
  29099. _frameHandler: number;
  29100. private _nextFreeTextureSlots;
  29101. private _maxSimultaneousTextures;
  29102. private _activeRequests;
  29103. protected _texturesSupported: string[];
  29104. /** @hidden */
  29105. _textureFormatInUse: Nullable<string>;
  29106. protected readonly _supportsHardwareTextureRescaling: boolean;
  29107. /**
  29108. * Gets the list of texture formats supported
  29109. */
  29110. readonly texturesSupported: Array<string>;
  29111. /**
  29112. * Gets the list of texture formats in use
  29113. */
  29114. readonly textureFormatInUse: Nullable<string>;
  29115. /**
  29116. * Gets the current viewport
  29117. */
  29118. readonly currentViewport: Nullable<IViewportLike>;
  29119. /**
  29120. * Gets the default empty texture
  29121. */
  29122. readonly emptyTexture: InternalTexture;
  29123. /**
  29124. * Gets the default empty 3D texture
  29125. */
  29126. readonly emptyTexture3D: InternalTexture;
  29127. /**
  29128. * Gets the default empty cube texture
  29129. */
  29130. readonly emptyCubeTexture: InternalTexture;
  29131. /**
  29132. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29133. */
  29134. readonly premultipliedAlpha: boolean;
  29135. /**
  29136. * Observable event triggered before each texture is initialized
  29137. */
  29138. onBeforeTextureInitObservable: Observable<Texture>;
  29139. /**
  29140. * Creates a new engine
  29141. * @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
  29142. * @param antialias defines enable antialiasing (default: false)
  29143. * @param options defines further options to be sent to the getContext() function
  29144. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29145. */
  29146. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29147. private _rebuildInternalTextures;
  29148. private _rebuildEffects;
  29149. /**
  29150. * Gets a boolean indicating if all created effects are ready
  29151. * @returns true if all effects are ready
  29152. */
  29153. areAllEffectsReady(): boolean;
  29154. protected _rebuildBuffers(): void;
  29155. private _initGLContext;
  29156. /**
  29157. * Gets version of the current webGL context
  29158. */
  29159. readonly webGLVersion: number;
  29160. /**
  29161. * Gets a string idenfifying the name of the class
  29162. * @returns "Engine" string
  29163. */
  29164. getClassName(): string;
  29165. /**
  29166. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29167. */
  29168. readonly isStencilEnable: boolean;
  29169. /** @hidden */
  29170. _prepareWorkingCanvas(): void;
  29171. /**
  29172. * Reset the texture cache to empty state
  29173. */
  29174. resetTextureCache(): void;
  29175. /**
  29176. * Gets an object containing information about the current webGL context
  29177. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29178. */
  29179. getGlInfo(): {
  29180. vendor: string;
  29181. renderer: string;
  29182. version: string;
  29183. };
  29184. /**
  29185. * Defines the hardware scaling level.
  29186. * By default the hardware scaling level is computed from the window device ratio.
  29187. * 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.
  29188. * @param level defines the level to use
  29189. */
  29190. setHardwareScalingLevel(level: number): void;
  29191. /**
  29192. * Gets the current hardware scaling level.
  29193. * By default the hardware scaling level is computed from the window device ratio.
  29194. * 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.
  29195. * @returns a number indicating the current hardware scaling level
  29196. */
  29197. getHardwareScalingLevel(): number;
  29198. /**
  29199. * Gets the list of loaded textures
  29200. * @returns an array containing all loaded textures
  29201. */
  29202. getLoadedTexturesCache(): InternalTexture[];
  29203. /**
  29204. * Gets the object containing all engine capabilities
  29205. * @returns the EngineCapabilities object
  29206. */
  29207. getCaps(): EngineCapabilities;
  29208. /**
  29209. * stop executing a render loop function and remove it from the execution array
  29210. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29211. */
  29212. stopRenderLoop(renderFunction?: () => void): void;
  29213. /** @hidden */
  29214. _renderLoop(): void;
  29215. /**
  29216. * Gets the HTML canvas attached with the current webGL context
  29217. * @returns a HTML canvas
  29218. */
  29219. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29220. /**
  29221. * Gets host window
  29222. * @returns the host window object
  29223. */
  29224. getHostWindow(): Nullable<Window>;
  29225. /**
  29226. * Gets the current render width
  29227. * @param useScreen defines if screen size must be used (or the current render target if any)
  29228. * @returns a number defining the current render width
  29229. */
  29230. getRenderWidth(useScreen?: boolean): number;
  29231. /**
  29232. * Gets the current render height
  29233. * @param useScreen defines if screen size must be used (or the current render target if any)
  29234. * @returns a number defining the current render height
  29235. */
  29236. getRenderHeight(useScreen?: boolean): number;
  29237. /**
  29238. * Can be used to override the current requestAnimationFrame requester.
  29239. * @hidden
  29240. */
  29241. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29242. /**
  29243. * Register and execute a render loop. The engine can have more than one render function
  29244. * @param renderFunction defines the function to continuously execute
  29245. */
  29246. runRenderLoop(renderFunction: () => void): void;
  29247. /**
  29248. * Clear the current render buffer or the current render target (if any is set up)
  29249. * @param color defines the color to use
  29250. * @param backBuffer defines if the back buffer must be cleared
  29251. * @param depth defines if the depth buffer must be cleared
  29252. * @param stencil defines if the stencil buffer must be cleared
  29253. */
  29254. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29255. private _viewportCached;
  29256. /** @hidden */
  29257. _viewport(x: number, y: number, width: number, height: number): void;
  29258. /**
  29259. * Set the WebGL's viewport
  29260. * @param viewport defines the viewport element to be used
  29261. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29262. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29263. */
  29264. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29265. /**
  29266. * Begin a new frame
  29267. */
  29268. beginFrame(): void;
  29269. /**
  29270. * Enf the current frame
  29271. */
  29272. endFrame(): void;
  29273. /**
  29274. * Resize the view according to the canvas' size
  29275. */
  29276. resize(): void;
  29277. /**
  29278. * Force a specific size of the canvas
  29279. * @param width defines the new canvas' width
  29280. * @param height defines the new canvas' height
  29281. */
  29282. setSize(width: number, height: number): void;
  29283. /**
  29284. * Binds the frame buffer to the specified texture.
  29285. * @param texture The texture to render to or null for the default canvas
  29286. * @param faceIndex The face of the texture to render to in case of cube texture
  29287. * @param requiredWidth The width of the target to render to
  29288. * @param requiredHeight The height of the target to render to
  29289. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29290. * @param depthStencilTexture The depth stencil texture to use to render
  29291. * @param lodLevel defines le lod level to bind to the frame buffer
  29292. */
  29293. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29294. /** @hidden */
  29295. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29296. /**
  29297. * Unbind the current render target texture from the webGL context
  29298. * @param texture defines the render target texture to unbind
  29299. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29300. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29301. */
  29302. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29303. /**
  29304. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29305. */
  29306. flushFramebuffer(): void;
  29307. /**
  29308. * Unbind the current render target and bind the default framebuffer
  29309. */
  29310. restoreDefaultFramebuffer(): void;
  29311. private _resetVertexBufferBinding;
  29312. /**
  29313. * Creates a vertex buffer
  29314. * @param data the data for the vertex buffer
  29315. * @returns the new WebGL static buffer
  29316. */
  29317. createVertexBuffer(data: DataArray): DataBuffer;
  29318. private _createVertexBuffer;
  29319. /**
  29320. * Creates a dynamic vertex buffer
  29321. * @param data the data for the dynamic vertex buffer
  29322. * @returns the new WebGL dynamic buffer
  29323. */
  29324. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29325. /**
  29326. * Updates a dynamic vertex buffer.
  29327. * @param vertexBuffer the vertex buffer to update
  29328. * @param data the data used to update the vertex buffer
  29329. * @param byteOffset the byte offset of the data
  29330. * @param byteLength the byte length of the data
  29331. */
  29332. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29333. protected _resetIndexBufferBinding(): void;
  29334. /**
  29335. * Creates a new index buffer
  29336. * @param indices defines the content of the index buffer
  29337. * @param updatable defines if the index buffer must be updatable
  29338. * @returns a new webGL buffer
  29339. */
  29340. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29341. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29342. /**
  29343. * Bind a webGL buffer to the webGL context
  29344. * @param buffer defines the buffer to bind
  29345. */
  29346. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29347. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29348. private bindBuffer;
  29349. /**
  29350. * update the bound buffer with the given data
  29351. * @param data defines the data to update
  29352. */
  29353. updateArrayBuffer(data: Float32Array): void;
  29354. private _vertexAttribPointer;
  29355. private _bindIndexBufferWithCache;
  29356. private _bindVertexBuffersAttributes;
  29357. /**
  29358. * Records a vertex array object
  29359. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29360. * @param vertexBuffers defines the list of vertex buffers to store
  29361. * @param indexBuffer defines the index buffer to store
  29362. * @param effect defines the effect to store
  29363. * @returns the new vertex array object
  29364. */
  29365. recordVertexArrayObject(vertexBuffers: {
  29366. [key: string]: VertexBuffer;
  29367. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29368. /**
  29369. * Bind a specific vertex array object
  29370. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29371. * @param vertexArrayObject defines the vertex array object to bind
  29372. * @param indexBuffer defines the index buffer to bind
  29373. */
  29374. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29375. /**
  29376. * Bind webGl buffers directly to the webGL context
  29377. * @param vertexBuffer defines the vertex buffer to bind
  29378. * @param indexBuffer defines the index buffer to bind
  29379. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29380. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29381. * @param effect defines the effect associated with the vertex buffer
  29382. */
  29383. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29384. private _unbindVertexArrayObject;
  29385. /**
  29386. * Bind a list of vertex buffers to the webGL context
  29387. * @param vertexBuffers defines the list of vertex buffers to bind
  29388. * @param indexBuffer defines the index buffer to bind
  29389. * @param effect defines the effect associated with the vertex buffers
  29390. */
  29391. bindBuffers(vertexBuffers: {
  29392. [key: string]: Nullable<VertexBuffer>;
  29393. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29394. /**
  29395. * Unbind all instance attributes
  29396. */
  29397. unbindInstanceAttributes(): void;
  29398. /**
  29399. * Release and free the memory of a vertex array object
  29400. * @param vao defines the vertex array object to delete
  29401. */
  29402. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29403. /** @hidden */
  29404. _releaseBuffer(buffer: DataBuffer): boolean;
  29405. protected _deleteBuffer(buffer: DataBuffer): void;
  29406. /**
  29407. * Creates a webGL buffer to use with instanciation
  29408. * @param capacity defines the size of the buffer
  29409. * @returns the webGL buffer
  29410. */
  29411. createInstancesBuffer(capacity: number): DataBuffer;
  29412. /**
  29413. * Delete a webGL buffer used with instanciation
  29414. * @param buffer defines the webGL buffer to delete
  29415. */
  29416. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29417. /**
  29418. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29419. * @param instancesBuffer defines the webGL buffer to update and bind
  29420. * @param data defines the data to store in the buffer
  29421. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29422. */
  29423. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29424. /**
  29425. * Apply all cached states (depth, culling, stencil and alpha)
  29426. */
  29427. applyStates(): void;
  29428. /**
  29429. * Send a draw order
  29430. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29431. * @param indexStart defines the starting index
  29432. * @param indexCount defines the number of index to draw
  29433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29434. */
  29435. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29436. /**
  29437. * Draw a list of points
  29438. * @param verticesStart defines the index of first vertex to draw
  29439. * @param verticesCount defines the count of vertices to draw
  29440. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29441. */
  29442. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29443. /**
  29444. * Draw a list of unindexed primitives
  29445. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29446. * @param verticesStart defines the index of first vertex to draw
  29447. * @param verticesCount defines the count of vertices to draw
  29448. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29449. */
  29450. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29451. /**
  29452. * Draw a list of indexed primitives
  29453. * @param fillMode defines the primitive to use
  29454. * @param indexStart defines the starting index
  29455. * @param indexCount defines the number of index to draw
  29456. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29457. */
  29458. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29459. /**
  29460. * Draw a list of unindexed primitives
  29461. * @param fillMode defines the primitive to use
  29462. * @param verticesStart defines the index of first vertex to draw
  29463. * @param verticesCount defines the count of vertices to draw
  29464. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29465. */
  29466. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29467. private _drawMode;
  29468. /** @hidden */
  29469. protected _reportDrawCall(): void;
  29470. /** @hidden */
  29471. _releaseEffect(effect: Effect): void;
  29472. /** @hidden */
  29473. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29474. /**
  29475. * Create a new effect (used to store vertex/fragment shaders)
  29476. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29477. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29478. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29479. * @param samplers defines an array of string used to represent textures
  29480. * @param defines defines the string containing the defines to use to compile the shaders
  29481. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29482. * @param onCompiled defines a function to call when the effect creation is successful
  29483. * @param onError defines a function to call when the effect creation has failed
  29484. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29485. * @returns the new Effect
  29486. */
  29487. 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;
  29488. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29489. private _compileShader;
  29490. private _compileRawShader;
  29491. /**
  29492. * Directly creates a webGL program
  29493. * @param pipelineContext defines the pipeline context to attach to
  29494. * @param vertexCode defines the vertex shader code to use
  29495. * @param fragmentCode defines the fragment shader code to use
  29496. * @param context defines the webGL context to use (if not set, the current one will be used)
  29497. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29498. * @returns the new webGL program
  29499. */
  29500. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29501. /**
  29502. * Creates a webGL program
  29503. * @param pipelineContext defines the pipeline context to attach to
  29504. * @param vertexCode defines the vertex shader code to use
  29505. * @param fragmentCode defines the fragment shader code to use
  29506. * @param defines defines the string containing the defines to use to compile the shaders
  29507. * @param context defines the webGL context to use (if not set, the current one will be used)
  29508. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29509. * @returns the new webGL program
  29510. */
  29511. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29512. /**
  29513. * Creates a new pipeline context
  29514. * @returns the new pipeline
  29515. */
  29516. createPipelineContext(): IPipelineContext;
  29517. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29518. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29519. /** @hidden */
  29520. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29521. /** @hidden */
  29522. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29523. /** @hidden */
  29524. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29525. /**
  29526. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29527. * @param pipelineContext defines the pipeline context to use
  29528. * @param uniformsNames defines the list of uniform names
  29529. * @returns an array of webGL uniform locations
  29530. */
  29531. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29532. /**
  29533. * Gets the lsit of active attributes for a given webGL program
  29534. * @param pipelineContext defines the pipeline context to use
  29535. * @param attributesNames defines the list of attribute names to get
  29536. * @returns an array of indices indicating the offset of each attribute
  29537. */
  29538. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29539. /**
  29540. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29541. * @param effect defines the effect to activate
  29542. */
  29543. enableEffect(effect: Nullable<Effect>): void;
  29544. /**
  29545. * Set the value of an uniform to an array of int32
  29546. * @param uniform defines the webGL uniform location where to store the value
  29547. * @param array defines the array of int32 to store
  29548. */
  29549. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29550. /**
  29551. * Set the value of an uniform to an array of int32 (stored as vec2)
  29552. * @param uniform defines the webGL uniform location where to store the value
  29553. * @param array defines the array of int32 to store
  29554. */
  29555. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29556. /**
  29557. * Set the value of an uniform to an array of int32 (stored as vec3)
  29558. * @param uniform defines the webGL uniform location where to store the value
  29559. * @param array defines the array of int32 to store
  29560. */
  29561. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29562. /**
  29563. * Set the value of an uniform to an array of int32 (stored as vec4)
  29564. * @param uniform defines the webGL uniform location where to store the value
  29565. * @param array defines the array of int32 to store
  29566. */
  29567. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29568. /**
  29569. * Set the value of an uniform to an array of float32
  29570. * @param uniform defines the webGL uniform location where to store the value
  29571. * @param array defines the array of float32 to store
  29572. */
  29573. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29574. /**
  29575. * Set the value of an uniform to an array of float32 (stored as vec2)
  29576. * @param uniform defines the webGL uniform location where to store the value
  29577. * @param array defines the array of float32 to store
  29578. */
  29579. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29580. /**
  29581. * Set the value of an uniform to an array of float32 (stored as vec3)
  29582. * @param uniform defines the webGL uniform location where to store the value
  29583. * @param array defines the array of float32 to store
  29584. */
  29585. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29586. /**
  29587. * Set the value of an uniform to an array of float32 (stored as vec4)
  29588. * @param uniform defines the webGL uniform location where to store the value
  29589. * @param array defines the array of float32 to store
  29590. */
  29591. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29592. /**
  29593. * Set the value of an uniform to an array of number
  29594. * @param uniform defines the webGL uniform location where to store the value
  29595. * @param array defines the array of number to store
  29596. */
  29597. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29598. /**
  29599. * Set the value of an uniform to an array of number (stored as vec2)
  29600. * @param uniform defines the webGL uniform location where to store the value
  29601. * @param array defines the array of number to store
  29602. */
  29603. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29604. /**
  29605. * Set the value of an uniform to an array of number (stored as vec3)
  29606. * @param uniform defines the webGL uniform location where to store the value
  29607. * @param array defines the array of number to store
  29608. */
  29609. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29610. /**
  29611. * Set the value of an uniform to an array of number (stored as vec4)
  29612. * @param uniform defines the webGL uniform location where to store the value
  29613. * @param array defines the array of number to store
  29614. */
  29615. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29616. /**
  29617. * Set the value of an uniform to an array of float32 (stored as matrices)
  29618. * @param uniform defines the webGL uniform location where to store the value
  29619. * @param matrices defines the array of float32 to store
  29620. */
  29621. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29622. /**
  29623. * Set the value of an uniform to a matrix (3x3)
  29624. * @param uniform defines the webGL uniform location where to store the value
  29625. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29626. */
  29627. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29628. /**
  29629. * Set the value of an uniform to a matrix (2x2)
  29630. * @param uniform defines the webGL uniform location where to store the value
  29631. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29632. */
  29633. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29634. /**
  29635. * Set the value of an uniform to a number (int)
  29636. * @param uniform defines the webGL uniform location where to store the value
  29637. * @param value defines the int number to store
  29638. */
  29639. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29640. /**
  29641. * Set the value of an uniform to a number (float)
  29642. * @param uniform defines the webGL uniform location where to store the value
  29643. * @param value defines the float number to store
  29644. */
  29645. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29646. /**
  29647. * Set the value of an uniform to a vec2
  29648. * @param uniform defines the webGL uniform location where to store the value
  29649. * @param x defines the 1st component of the value
  29650. * @param y defines the 2nd component of the value
  29651. */
  29652. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29653. /**
  29654. * Set the value of an uniform to a vec3
  29655. * @param uniform defines the webGL uniform location where to store the value
  29656. * @param x defines the 1st component of the value
  29657. * @param y defines the 2nd component of the value
  29658. * @param z defines the 3rd component of the value
  29659. */
  29660. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29661. /**
  29662. * Set the value of an uniform to a boolean
  29663. * @param uniform defines the webGL uniform location where to store the value
  29664. * @param bool defines the boolean to store
  29665. */
  29666. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29667. /**
  29668. * Set the value of an uniform to a vec4
  29669. * @param uniform defines the webGL uniform location where to store the value
  29670. * @param x defines the 1st component of the value
  29671. * @param y defines the 2nd component of the value
  29672. * @param z defines the 3rd component of the value
  29673. * @param w defines the 4th component of the value
  29674. */
  29675. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29676. /**
  29677. * Sets a Color4 on a uniform variable
  29678. * @param uniform defines the uniform location
  29679. * @param color4 defines the value to be set
  29680. */
  29681. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29682. /**
  29683. * Gets the depth culling state manager
  29684. */
  29685. readonly depthCullingState: DepthCullingState;
  29686. /**
  29687. * Gets the alpha state manager
  29688. */
  29689. readonly alphaState: AlphaState;
  29690. /**
  29691. * Gets the stencil state manager
  29692. */
  29693. readonly stencilState: StencilState;
  29694. /**
  29695. * Clears the list of texture accessible through engine.
  29696. * This can help preventing texture load conflict due to name collision.
  29697. */
  29698. clearInternalTexturesCache(): void;
  29699. /**
  29700. * Force the entire cache to be cleared
  29701. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29702. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29703. */
  29704. wipeCaches(bruteForce?: boolean): void;
  29705. /** @hidden */
  29706. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29707. min: number;
  29708. mag: number;
  29709. };
  29710. /** @hidden */
  29711. _createTexture(): WebGLTexture;
  29712. /**
  29713. * Usually called from Texture.ts.
  29714. * Passed information to create a WebGLTexture
  29715. * @param urlArg defines a value which contains one of the following:
  29716. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29717. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29718. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29719. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29720. * @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)
  29721. * @param scene needed for loading to the correct scene
  29722. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29723. * @param onLoad optional callback to be called upon successful completion
  29724. * @param onError optional callback to be called upon failure
  29725. * @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
  29726. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29727. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29728. * @param forcedExtension defines the extension to use to pick the right loader
  29729. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29730. * @param mimeType defines an optional mime type
  29731. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29732. */
  29733. 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;
  29734. /**
  29735. * @hidden
  29736. */
  29737. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29738. /**
  29739. * Creates a raw texture
  29740. * @param data defines the data to store in the texture
  29741. * @param width defines the width of the texture
  29742. * @param height defines the height of the texture
  29743. * @param format defines the format of the data
  29744. * @param generateMipMaps defines if the engine should generate the mip levels
  29745. * @param invertY defines if data must be stored with Y axis inverted
  29746. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29747. * @param compression defines the compression used (null by default)
  29748. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29749. * @returns the raw texture inside an InternalTexture
  29750. */
  29751. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29752. /**
  29753. * Creates a new raw cube texture
  29754. * @param data defines the array of data to use to create each face
  29755. * @param size defines the size of the textures
  29756. * @param format defines the format of the data
  29757. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29758. * @param generateMipMaps defines if the engine should generate the mip levels
  29759. * @param invertY defines if data must be stored with Y axis inverted
  29760. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29761. * @param compression defines the compression used (null by default)
  29762. * @returns the cube texture as an InternalTexture
  29763. */
  29764. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29765. /**
  29766. * Creates a new raw 3D texture
  29767. * @param data defines the data used to create the texture
  29768. * @param width defines the width of the texture
  29769. * @param height defines the height of the texture
  29770. * @param depth defines the depth of the texture
  29771. * @param format defines the format of the texture
  29772. * @param generateMipMaps defines if the engine must generate mip levels
  29773. * @param invertY defines if data must be stored with Y axis inverted
  29774. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29775. * @param compression defines the compressed used (can be null)
  29776. * @param textureType defines the compressed used (can be null)
  29777. * @returns a new raw 3D texture (stored in an InternalTexture)
  29778. */
  29779. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29780. private _unpackFlipYCached;
  29781. /**
  29782. * In case you are sharing the context with other applications, it might
  29783. * be interested to not cache the unpack flip y state to ensure a consistent
  29784. * value would be set.
  29785. */
  29786. enableUnpackFlipYCached: boolean;
  29787. /** @hidden */
  29788. _unpackFlipY(value: boolean): void;
  29789. /** @hidden */
  29790. _getUnpackAlignement(): number;
  29791. /**
  29792. * Update the sampling mode of a given texture
  29793. * @param samplingMode defines the required sampling mode
  29794. * @param texture defines the texture to update
  29795. */
  29796. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29797. /**
  29798. * Updates a depth texture Comparison Mode and Function.
  29799. * If the comparison Function is equal to 0, the mode will be set to none.
  29800. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29801. * @param texture The texture to set the comparison function for
  29802. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29803. */
  29804. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29805. /** @hidden */
  29806. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29807. width: number;
  29808. height: number;
  29809. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29810. /**
  29811. * Creates a depth stencil texture.
  29812. * This is only available in WebGL 2 or with the depth texture extension available.
  29813. * @param size The size of face edge in the texture.
  29814. * @param options The options defining the texture.
  29815. * @returns The texture
  29816. */
  29817. createDepthStencilTexture(size: number | {
  29818. width: number;
  29819. height: number;
  29820. }, options: DepthTextureCreationOptions): InternalTexture;
  29821. /**
  29822. * Creates a depth stencil texture.
  29823. * This is only available in WebGL 2 or with the depth texture extension available.
  29824. * @param size The size of face edge in the texture.
  29825. * @param options The options defining the texture.
  29826. * @returns The texture
  29827. */
  29828. private _createDepthStencilTexture;
  29829. /** @hidden */
  29830. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29831. /** @hidden */
  29832. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29833. /** @hidden */
  29834. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29835. /** @hidden */
  29836. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  29837. /**
  29838. * @hidden
  29839. */
  29840. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29841. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29842. private _prepareWebGLTexture;
  29843. /** @hidden */
  29844. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29845. /** @hidden */
  29846. _releaseFramebufferObjects(texture: InternalTexture): void;
  29847. /** @hidden */
  29848. _releaseTexture(texture: InternalTexture): void;
  29849. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29850. protected _setProgram(program: WebGLProgram): void;
  29851. protected _boundUniforms: {
  29852. [key: number]: WebGLUniformLocation;
  29853. };
  29854. /**
  29855. * Binds an effect to the webGL context
  29856. * @param effect defines the effect to bind
  29857. */
  29858. bindSamplers(effect: Effect): void;
  29859. private _activateCurrentTexture;
  29860. /** @hidden */
  29861. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29862. /** @hidden */
  29863. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29864. /**
  29865. * Unbind all textures from the webGL context
  29866. */
  29867. unbindAllTextures(): void;
  29868. /**
  29869. * Sets a texture to the according uniform.
  29870. * @param channel The texture channel
  29871. * @param uniform The uniform to set
  29872. * @param texture The texture to apply
  29873. */
  29874. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29875. private _bindSamplerUniformToChannel;
  29876. private _getTextureWrapMode;
  29877. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  29878. /**
  29879. * Sets an array of texture to the webGL context
  29880. * @param channel defines the channel where the texture array must be set
  29881. * @param uniform defines the associated uniform location
  29882. * @param textures defines the array of textures to bind
  29883. */
  29884. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29885. /** @hidden */
  29886. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29887. private _setTextureParameterFloat;
  29888. private _setTextureParameterInteger;
  29889. /**
  29890. * Unbind all vertex attributes from the webGL context
  29891. */
  29892. unbindAllAttributes(): void;
  29893. /**
  29894. * 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
  29895. */
  29896. releaseEffects(): void;
  29897. /**
  29898. * Dispose and release all associated resources
  29899. */
  29900. dispose(): void;
  29901. /**
  29902. * Attach a new callback raised when context lost event is fired
  29903. * @param callback defines the callback to call
  29904. */
  29905. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29906. /**
  29907. * Attach a new callback raised when context restored event is fired
  29908. * @param callback defines the callback to call
  29909. */
  29910. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29911. /**
  29912. * Get the current error code of the webGL context
  29913. * @returns the error code
  29914. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29915. */
  29916. getError(): number;
  29917. private _canRenderToFloatFramebuffer;
  29918. private _canRenderToHalfFloatFramebuffer;
  29919. private _canRenderToFramebuffer;
  29920. /** @hidden */
  29921. _getWebGLTextureType(type: number): number;
  29922. /** @hidden */
  29923. _getInternalFormat(format: number): number;
  29924. /** @hidden */
  29925. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29926. /** @hidden */
  29927. _getRGBAMultiSampleBufferFormat(type: number): number;
  29928. /** @hidden */
  29929. _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;
  29930. /**
  29931. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29932. * @returns true if the engine can be created
  29933. * @ignorenaming
  29934. */
  29935. static isSupported(): boolean;
  29936. /**
  29937. * Find the next highest power of two.
  29938. * @param x Number to start search from.
  29939. * @return Next highest power of two.
  29940. */
  29941. static CeilingPOT(x: number): number;
  29942. /**
  29943. * Find the next lowest power of two.
  29944. * @param x Number to start search from.
  29945. * @return Next lowest power of two.
  29946. */
  29947. static FloorPOT(x: number): number;
  29948. /**
  29949. * Find the nearest power of two.
  29950. * @param x Number to start search from.
  29951. * @return Next nearest power of two.
  29952. */
  29953. static NearestPOT(x: number): number;
  29954. /**
  29955. * Get the closest exponent of two
  29956. * @param value defines the value to approximate
  29957. * @param max defines the maximum value to return
  29958. * @param mode defines how to define the closest value
  29959. * @returns closest exponent of two of the given value
  29960. */
  29961. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29962. /**
  29963. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  29964. * @param func - the function to be called
  29965. * @param requester - the object that will request the next frame. Falls back to window.
  29966. * @returns frame number
  29967. */
  29968. static QueueNewFrame(func: () => void, requester?: any): number;
  29969. }
  29970. }
  29971. declare module BABYLON {
  29972. /**
  29973. * Class representing spherical harmonics coefficients to the 3rd degree
  29974. */
  29975. export class SphericalHarmonics {
  29976. /**
  29977. * Defines whether or not the harmonics have been prescaled for rendering.
  29978. */
  29979. preScaled: boolean;
  29980. /**
  29981. * The l0,0 coefficients of the spherical harmonics
  29982. */
  29983. l00: Vector3;
  29984. /**
  29985. * The l1,-1 coefficients of the spherical harmonics
  29986. */
  29987. l1_1: Vector3;
  29988. /**
  29989. * The l1,0 coefficients of the spherical harmonics
  29990. */
  29991. l10: Vector3;
  29992. /**
  29993. * The l1,1 coefficients of the spherical harmonics
  29994. */
  29995. l11: Vector3;
  29996. /**
  29997. * The l2,-2 coefficients of the spherical harmonics
  29998. */
  29999. l2_2: Vector3;
  30000. /**
  30001. * The l2,-1 coefficients of the spherical harmonics
  30002. */
  30003. l2_1: Vector3;
  30004. /**
  30005. * The l2,0 coefficients of the spherical harmonics
  30006. */
  30007. l20: Vector3;
  30008. /**
  30009. * The l2,1 coefficients of the spherical harmonics
  30010. */
  30011. l21: Vector3;
  30012. /**
  30013. * The l2,2 coefficients of the spherical harmonics
  30014. */
  30015. l22: Vector3;
  30016. /**
  30017. * Adds a light to the spherical harmonics
  30018. * @param direction the direction of the light
  30019. * @param color the color of the light
  30020. * @param deltaSolidAngle the delta solid angle of the light
  30021. */
  30022. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30023. /**
  30024. * Scales the spherical harmonics by the given amount
  30025. * @param scale the amount to scale
  30026. */
  30027. scaleInPlace(scale: number): void;
  30028. /**
  30029. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30030. *
  30031. * ```
  30032. * E_lm = A_l * L_lm
  30033. * ```
  30034. *
  30035. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30036. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30037. * the scaling factors are given in equation 9.
  30038. */
  30039. convertIncidentRadianceToIrradiance(): void;
  30040. /**
  30041. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30042. *
  30043. * ```
  30044. * L = (1/pi) * E * rho
  30045. * ```
  30046. *
  30047. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30048. */
  30049. convertIrradianceToLambertianRadiance(): void;
  30050. /**
  30051. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30052. * required operations at run time.
  30053. *
  30054. * This is simply done by scaling back the SH with Ylm constants parameter.
  30055. * The trigonometric part being applied by the shader at run time.
  30056. */
  30057. preScaleForRendering(): void;
  30058. /**
  30059. * Constructs a spherical harmonics from an array.
  30060. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30061. * @returns the spherical harmonics
  30062. */
  30063. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30064. /**
  30065. * Gets the spherical harmonics from polynomial
  30066. * @param polynomial the spherical polynomial
  30067. * @returns the spherical harmonics
  30068. */
  30069. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30070. }
  30071. /**
  30072. * Class representing spherical polynomial coefficients to the 3rd degree
  30073. */
  30074. export class SphericalPolynomial {
  30075. private _harmonics;
  30076. /**
  30077. * The spherical harmonics used to create the polynomials.
  30078. */
  30079. readonly preScaledHarmonics: SphericalHarmonics;
  30080. /**
  30081. * The x coefficients of the spherical polynomial
  30082. */
  30083. x: Vector3;
  30084. /**
  30085. * The y coefficients of the spherical polynomial
  30086. */
  30087. y: Vector3;
  30088. /**
  30089. * The z coefficients of the spherical polynomial
  30090. */
  30091. z: Vector3;
  30092. /**
  30093. * The xx coefficients of the spherical polynomial
  30094. */
  30095. xx: Vector3;
  30096. /**
  30097. * The yy coefficients of the spherical polynomial
  30098. */
  30099. yy: Vector3;
  30100. /**
  30101. * The zz coefficients of the spherical polynomial
  30102. */
  30103. zz: Vector3;
  30104. /**
  30105. * The xy coefficients of the spherical polynomial
  30106. */
  30107. xy: Vector3;
  30108. /**
  30109. * The yz coefficients of the spherical polynomial
  30110. */
  30111. yz: Vector3;
  30112. /**
  30113. * The zx coefficients of the spherical polynomial
  30114. */
  30115. zx: Vector3;
  30116. /**
  30117. * Adds an ambient color to the spherical polynomial
  30118. * @param color the color to add
  30119. */
  30120. addAmbient(color: Color3): void;
  30121. /**
  30122. * Scales the spherical polynomial by the given amount
  30123. * @param scale the amount to scale
  30124. */
  30125. scaleInPlace(scale: number): void;
  30126. /**
  30127. * Gets the spherical polynomial from harmonics
  30128. * @param harmonics the spherical harmonics
  30129. * @returns the spherical polynomial
  30130. */
  30131. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30132. /**
  30133. * Constructs a spherical polynomial from an array.
  30134. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30135. * @returns the spherical polynomial
  30136. */
  30137. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30138. }
  30139. }
  30140. declare module BABYLON {
  30141. /**
  30142. * Defines the source of the internal texture
  30143. */
  30144. export enum InternalTextureSource {
  30145. /**
  30146. * The source of the texture data is unknown
  30147. */
  30148. Unknown = 0,
  30149. /**
  30150. * Texture data comes from an URL
  30151. */
  30152. Url = 1,
  30153. /**
  30154. * Texture data is only used for temporary storage
  30155. */
  30156. Temp = 2,
  30157. /**
  30158. * Texture data comes from raw data (ArrayBuffer)
  30159. */
  30160. Raw = 3,
  30161. /**
  30162. * Texture content is dynamic (video or dynamic texture)
  30163. */
  30164. Dynamic = 4,
  30165. /**
  30166. * Texture content is generated by rendering to it
  30167. */
  30168. RenderTarget = 5,
  30169. /**
  30170. * Texture content is part of a multi render target process
  30171. */
  30172. MultiRenderTarget = 6,
  30173. /**
  30174. * Texture data comes from a cube data file
  30175. */
  30176. Cube = 7,
  30177. /**
  30178. * Texture data comes from a raw cube data
  30179. */
  30180. CubeRaw = 8,
  30181. /**
  30182. * Texture data come from a prefiltered cube data file
  30183. */
  30184. CubePrefiltered = 9,
  30185. /**
  30186. * Texture content is raw 3D data
  30187. */
  30188. Raw3D = 10,
  30189. /**
  30190. * Texture content is a depth texture
  30191. */
  30192. Depth = 11,
  30193. /**
  30194. * Texture data comes from a raw cube data encoded with RGBD
  30195. */
  30196. CubeRawRGBD = 12
  30197. }
  30198. /**
  30199. * Class used to store data associated with WebGL texture data for the engine
  30200. * This class should not be used directly
  30201. */
  30202. export class InternalTexture {
  30203. /** @hidden */
  30204. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30205. /**
  30206. * Defines if the texture is ready
  30207. */
  30208. isReady: boolean;
  30209. /**
  30210. * Defines if the texture is a cube texture
  30211. */
  30212. isCube: boolean;
  30213. /**
  30214. * Defines if the texture contains 3D data
  30215. */
  30216. is3D: boolean;
  30217. /**
  30218. * Defines if the texture contains multiview data
  30219. */
  30220. isMultiview: boolean;
  30221. /**
  30222. * Gets the URL used to load this texture
  30223. */
  30224. url: string;
  30225. /**
  30226. * Gets the sampling mode of the texture
  30227. */
  30228. samplingMode: number;
  30229. /**
  30230. * Gets a boolean indicating if the texture needs mipmaps generation
  30231. */
  30232. generateMipMaps: boolean;
  30233. /**
  30234. * Gets the number of samples used by the texture (WebGL2+ only)
  30235. */
  30236. samples: number;
  30237. /**
  30238. * Gets the type of the texture (int, float...)
  30239. */
  30240. type: number;
  30241. /**
  30242. * Gets the format of the texture (RGB, RGBA...)
  30243. */
  30244. format: number;
  30245. /**
  30246. * Observable called when the texture is loaded
  30247. */
  30248. onLoadedObservable: Observable<InternalTexture>;
  30249. /**
  30250. * Gets the width of the texture
  30251. */
  30252. width: number;
  30253. /**
  30254. * Gets the height of the texture
  30255. */
  30256. height: number;
  30257. /**
  30258. * Gets the depth of the texture
  30259. */
  30260. depth: number;
  30261. /**
  30262. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30263. */
  30264. baseWidth: number;
  30265. /**
  30266. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30267. */
  30268. baseHeight: number;
  30269. /**
  30270. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30271. */
  30272. baseDepth: number;
  30273. /**
  30274. * Gets a boolean indicating if the texture is inverted on Y axis
  30275. */
  30276. invertY: boolean;
  30277. /** @hidden */
  30278. _invertVScale: boolean;
  30279. /** @hidden */
  30280. _associatedChannel: number;
  30281. /** @hidden */
  30282. _source: InternalTextureSource;
  30283. /** @hidden */
  30284. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  30285. /** @hidden */
  30286. _bufferView: Nullable<ArrayBufferView>;
  30287. /** @hidden */
  30288. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30289. /** @hidden */
  30290. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30291. /** @hidden */
  30292. _size: number;
  30293. /** @hidden */
  30294. _extension: string;
  30295. /** @hidden */
  30296. _files: Nullable<string[]>;
  30297. /** @hidden */
  30298. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30299. /** @hidden */
  30300. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30301. /** @hidden */
  30302. _framebuffer: Nullable<WebGLFramebuffer>;
  30303. /** @hidden */
  30304. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30305. /** @hidden */
  30306. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30307. /** @hidden */
  30308. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30309. /** @hidden */
  30310. _attachments: Nullable<number[]>;
  30311. /** @hidden */
  30312. _cachedCoordinatesMode: Nullable<number>;
  30313. /** @hidden */
  30314. _cachedWrapU: Nullable<number>;
  30315. /** @hidden */
  30316. _cachedWrapV: Nullable<number>;
  30317. /** @hidden */
  30318. _cachedWrapR: Nullable<number>;
  30319. /** @hidden */
  30320. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30321. /** @hidden */
  30322. _isDisabled: boolean;
  30323. /** @hidden */
  30324. _compression: Nullable<string>;
  30325. /** @hidden */
  30326. _generateStencilBuffer: boolean;
  30327. /** @hidden */
  30328. _generateDepthBuffer: boolean;
  30329. /** @hidden */
  30330. _comparisonFunction: number;
  30331. /** @hidden */
  30332. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30333. /** @hidden */
  30334. _lodGenerationScale: number;
  30335. /** @hidden */
  30336. _lodGenerationOffset: number;
  30337. /** @hidden */
  30338. _colorTextureArray: Nullable<WebGLTexture>;
  30339. /** @hidden */
  30340. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30341. /** @hidden */
  30342. _lodTextureHigh: Nullable<BaseTexture>;
  30343. /** @hidden */
  30344. _lodTextureMid: Nullable<BaseTexture>;
  30345. /** @hidden */
  30346. _lodTextureLow: Nullable<BaseTexture>;
  30347. /** @hidden */
  30348. _isRGBD: boolean;
  30349. /** @hidden */
  30350. _linearSpecularLOD: boolean;
  30351. /** @hidden */
  30352. _irradianceTexture: Nullable<BaseTexture>;
  30353. /** @hidden */
  30354. _webGLTexture: Nullable<WebGLTexture>;
  30355. /** @hidden */
  30356. _references: number;
  30357. private _engine;
  30358. /**
  30359. * Gets the Engine the texture belongs to.
  30360. * @returns The babylon engine
  30361. */
  30362. getEngine(): ThinEngine;
  30363. /**
  30364. * Gets the data source type of the texture
  30365. */
  30366. readonly source: InternalTextureSource;
  30367. /**
  30368. * Creates a new InternalTexture
  30369. * @param engine defines the engine to use
  30370. * @param source defines the type of data that will be used
  30371. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30372. */
  30373. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30374. /**
  30375. * Increments the number of references (ie. the number of Texture that point to it)
  30376. */
  30377. incrementReferences(): void;
  30378. /**
  30379. * Change the size of the texture (not the size of the content)
  30380. * @param width defines the new width
  30381. * @param height defines the new height
  30382. * @param depth defines the new depth (1 by default)
  30383. */
  30384. updateSize(width: int, height: int, depth?: int): void;
  30385. /** @hidden */
  30386. _rebuild(): void;
  30387. /** @hidden */
  30388. _swapAndDie(target: InternalTexture): void;
  30389. /**
  30390. * Dispose the current allocated resources
  30391. */
  30392. dispose(): void;
  30393. }
  30394. }
  30395. declare module BABYLON {
  30396. /**
  30397. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30399. */
  30400. export class Analyser {
  30401. /**
  30402. * Gets or sets the smoothing
  30403. * @ignorenaming
  30404. */
  30405. SMOOTHING: number;
  30406. /**
  30407. * Gets or sets the FFT table size
  30408. * @ignorenaming
  30409. */
  30410. FFT_SIZE: number;
  30411. /**
  30412. * Gets or sets the bar graph amplitude
  30413. * @ignorenaming
  30414. */
  30415. BARGRAPHAMPLITUDE: number;
  30416. /**
  30417. * Gets or sets the position of the debug canvas
  30418. * @ignorenaming
  30419. */
  30420. DEBUGCANVASPOS: {
  30421. x: number;
  30422. y: number;
  30423. };
  30424. /**
  30425. * Gets or sets the debug canvas size
  30426. * @ignorenaming
  30427. */
  30428. DEBUGCANVASSIZE: {
  30429. width: number;
  30430. height: number;
  30431. };
  30432. private _byteFreqs;
  30433. private _byteTime;
  30434. private _floatFreqs;
  30435. private _webAudioAnalyser;
  30436. private _debugCanvas;
  30437. private _debugCanvasContext;
  30438. private _scene;
  30439. private _registerFunc;
  30440. private _audioEngine;
  30441. /**
  30442. * Creates a new analyser
  30443. * @param scene defines hosting scene
  30444. */
  30445. constructor(scene: Scene);
  30446. /**
  30447. * Get the number of data values you will have to play with for the visualization
  30448. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30449. * @returns a number
  30450. */
  30451. getFrequencyBinCount(): number;
  30452. /**
  30453. * Gets the current frequency data as a byte array
  30454. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30455. * @returns a Uint8Array
  30456. */
  30457. getByteFrequencyData(): Uint8Array;
  30458. /**
  30459. * Gets the current waveform as a byte array
  30460. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30461. * @returns a Uint8Array
  30462. */
  30463. getByteTimeDomainData(): Uint8Array;
  30464. /**
  30465. * Gets the current frequency data as a float array
  30466. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30467. * @returns a Float32Array
  30468. */
  30469. getFloatFrequencyData(): Float32Array;
  30470. /**
  30471. * Renders the debug canvas
  30472. */
  30473. drawDebugCanvas(): void;
  30474. /**
  30475. * Stops rendering the debug canvas and removes it
  30476. */
  30477. stopDebugCanvas(): void;
  30478. /**
  30479. * Connects two audio nodes
  30480. * @param inputAudioNode defines first node to connect
  30481. * @param outputAudioNode defines second node to connect
  30482. */
  30483. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30484. /**
  30485. * Releases all associated resources
  30486. */
  30487. dispose(): void;
  30488. }
  30489. }
  30490. declare module BABYLON {
  30491. /**
  30492. * This represents an audio engine and it is responsible
  30493. * to play, synchronize and analyse sounds throughout the application.
  30494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30495. */
  30496. export interface IAudioEngine extends IDisposable {
  30497. /**
  30498. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30499. */
  30500. readonly canUseWebAudio: boolean;
  30501. /**
  30502. * Gets the current AudioContext if available.
  30503. */
  30504. readonly audioContext: Nullable<AudioContext>;
  30505. /**
  30506. * The master gain node defines the global audio volume of your audio engine.
  30507. */
  30508. readonly masterGain: GainNode;
  30509. /**
  30510. * Gets whether or not mp3 are supported by your browser.
  30511. */
  30512. readonly isMP3supported: boolean;
  30513. /**
  30514. * Gets whether or not ogg are supported by your browser.
  30515. */
  30516. readonly isOGGsupported: boolean;
  30517. /**
  30518. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30519. * @ignoreNaming
  30520. */
  30521. WarnedWebAudioUnsupported: boolean;
  30522. /**
  30523. * Defines if the audio engine relies on a custom unlocked button.
  30524. * In this case, the embedded button will not be displayed.
  30525. */
  30526. useCustomUnlockedButton: boolean;
  30527. /**
  30528. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30529. */
  30530. readonly unlocked: boolean;
  30531. /**
  30532. * Event raised when audio has been unlocked on the browser.
  30533. */
  30534. onAudioUnlockedObservable: Observable<AudioEngine>;
  30535. /**
  30536. * Event raised when audio has been locked on the browser.
  30537. */
  30538. onAudioLockedObservable: Observable<AudioEngine>;
  30539. /**
  30540. * Flags the audio engine in Locked state.
  30541. * This happens due to new browser policies preventing audio to autoplay.
  30542. */
  30543. lock(): void;
  30544. /**
  30545. * Unlocks the audio engine once a user action has been done on the dom.
  30546. * This is helpful to resume play once browser policies have been satisfied.
  30547. */
  30548. unlock(): void;
  30549. }
  30550. /**
  30551. * This represents the default audio engine used in babylon.
  30552. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30554. */
  30555. export class AudioEngine implements IAudioEngine {
  30556. private _audioContext;
  30557. private _audioContextInitialized;
  30558. private _muteButton;
  30559. private _hostElement;
  30560. /**
  30561. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30562. */
  30563. canUseWebAudio: boolean;
  30564. /**
  30565. * The master gain node defines the global audio volume of your audio engine.
  30566. */
  30567. masterGain: GainNode;
  30568. /**
  30569. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30570. * @ignoreNaming
  30571. */
  30572. WarnedWebAudioUnsupported: boolean;
  30573. /**
  30574. * Gets whether or not mp3 are supported by your browser.
  30575. */
  30576. isMP3supported: boolean;
  30577. /**
  30578. * Gets whether or not ogg are supported by your browser.
  30579. */
  30580. isOGGsupported: boolean;
  30581. /**
  30582. * Gets whether audio has been unlocked on the device.
  30583. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30584. * a user interaction has happened.
  30585. */
  30586. unlocked: boolean;
  30587. /**
  30588. * Defines if the audio engine relies on a custom unlocked button.
  30589. * In this case, the embedded button will not be displayed.
  30590. */
  30591. useCustomUnlockedButton: boolean;
  30592. /**
  30593. * Event raised when audio has been unlocked on the browser.
  30594. */
  30595. onAudioUnlockedObservable: Observable<AudioEngine>;
  30596. /**
  30597. * Event raised when audio has been locked on the browser.
  30598. */
  30599. onAudioLockedObservable: Observable<AudioEngine>;
  30600. /**
  30601. * Gets the current AudioContext if available.
  30602. */
  30603. readonly audioContext: Nullable<AudioContext>;
  30604. private _connectedAnalyser;
  30605. /**
  30606. * Instantiates a new audio engine.
  30607. *
  30608. * There should be only one per page as some browsers restrict the number
  30609. * of audio contexts you can create.
  30610. * @param hostElement defines the host element where to display the mute icon if necessary
  30611. */
  30612. constructor(hostElement?: Nullable<HTMLElement>);
  30613. /**
  30614. * Flags the audio engine in Locked state.
  30615. * This happens due to new browser policies preventing audio to autoplay.
  30616. */
  30617. lock(): void;
  30618. /**
  30619. * Unlocks the audio engine once a user action has been done on the dom.
  30620. * This is helpful to resume play once browser policies have been satisfied.
  30621. */
  30622. unlock(): void;
  30623. private _resumeAudioContext;
  30624. private _initializeAudioContext;
  30625. private _tryToRun;
  30626. private _triggerRunningState;
  30627. private _triggerSuspendedState;
  30628. private _displayMuteButton;
  30629. private _moveButtonToTopLeft;
  30630. private _onResize;
  30631. private _hideMuteButton;
  30632. /**
  30633. * Destroy and release the resources associated with the audio ccontext.
  30634. */
  30635. dispose(): void;
  30636. /**
  30637. * Gets the global volume sets on the master gain.
  30638. * @returns the global volume if set or -1 otherwise
  30639. */
  30640. getGlobalVolume(): number;
  30641. /**
  30642. * Sets the global volume of your experience (sets on the master gain).
  30643. * @param newVolume Defines the new global volume of the application
  30644. */
  30645. setGlobalVolume(newVolume: number): void;
  30646. /**
  30647. * Connect the audio engine to an audio analyser allowing some amazing
  30648. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30650. * @param analyser The analyser to connect to the engine
  30651. */
  30652. connectToAnalyser(analyser: Analyser): void;
  30653. }
  30654. }
  30655. declare module BABYLON {
  30656. /**
  30657. * Interface used to present a loading screen while loading a scene
  30658. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30659. */
  30660. export interface ILoadingScreen {
  30661. /**
  30662. * Function called to display the loading screen
  30663. */
  30664. displayLoadingUI: () => void;
  30665. /**
  30666. * Function called to hide the loading screen
  30667. */
  30668. hideLoadingUI: () => void;
  30669. /**
  30670. * Gets or sets the color to use for the background
  30671. */
  30672. loadingUIBackgroundColor: string;
  30673. /**
  30674. * Gets or sets the text to display while loading
  30675. */
  30676. loadingUIText: string;
  30677. }
  30678. /**
  30679. * Class used for the default loading screen
  30680. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30681. */
  30682. export class DefaultLoadingScreen implements ILoadingScreen {
  30683. private _renderingCanvas;
  30684. private _loadingText;
  30685. private _loadingDivBackgroundColor;
  30686. private _loadingDiv;
  30687. private _loadingTextDiv;
  30688. /** Gets or sets the logo url to use for the default loading screen */
  30689. static DefaultLogoUrl: string;
  30690. /** Gets or sets the spinner url to use for the default loading screen */
  30691. static DefaultSpinnerUrl: string;
  30692. /**
  30693. * Creates a new default loading screen
  30694. * @param _renderingCanvas defines the canvas used to render the scene
  30695. * @param _loadingText defines the default text to display
  30696. * @param _loadingDivBackgroundColor defines the default background color
  30697. */
  30698. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30699. /**
  30700. * Function called to display the loading screen
  30701. */
  30702. displayLoadingUI(): void;
  30703. /**
  30704. * Function called to hide the loading screen
  30705. */
  30706. hideLoadingUI(): void;
  30707. /**
  30708. * Gets or sets the text to display while loading
  30709. */
  30710. loadingUIText: string;
  30711. /**
  30712. * Gets or sets the color to use for the background
  30713. */
  30714. loadingUIBackgroundColor: string;
  30715. private _resizeLoadingUI;
  30716. }
  30717. }
  30718. declare module BABYLON {
  30719. /**
  30720. * Interface for any object that can request an animation frame
  30721. */
  30722. export interface ICustomAnimationFrameRequester {
  30723. /**
  30724. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30725. */
  30726. renderFunction?: Function;
  30727. /**
  30728. * Called to request the next frame to render to
  30729. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30730. */
  30731. requestAnimationFrame: Function;
  30732. /**
  30733. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30734. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30735. */
  30736. requestID?: number;
  30737. }
  30738. }
  30739. declare module BABYLON {
  30740. /**
  30741. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30742. */
  30743. export class PerformanceMonitor {
  30744. private _enabled;
  30745. private _rollingFrameTime;
  30746. private _lastFrameTimeMs;
  30747. /**
  30748. * constructor
  30749. * @param frameSampleSize The number of samples required to saturate the sliding window
  30750. */
  30751. constructor(frameSampleSize?: number);
  30752. /**
  30753. * Samples current frame
  30754. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30755. */
  30756. sampleFrame(timeMs?: number): void;
  30757. /**
  30758. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30759. */
  30760. readonly averageFrameTime: number;
  30761. /**
  30762. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30763. */
  30764. readonly averageFrameTimeVariance: number;
  30765. /**
  30766. * Returns the frame time of the most recent frame
  30767. */
  30768. readonly instantaneousFrameTime: number;
  30769. /**
  30770. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30771. */
  30772. readonly averageFPS: number;
  30773. /**
  30774. * Returns the average framerate in frames per second using the most recent frame time
  30775. */
  30776. readonly instantaneousFPS: number;
  30777. /**
  30778. * Returns true if enough samples have been taken to completely fill the sliding window
  30779. */
  30780. readonly isSaturated: boolean;
  30781. /**
  30782. * Enables contributions to the sliding window sample set
  30783. */
  30784. enable(): void;
  30785. /**
  30786. * Disables contributions to the sliding window sample set
  30787. * Samples will not be interpolated over the disabled period
  30788. */
  30789. disable(): void;
  30790. /**
  30791. * Returns true if sampling is enabled
  30792. */
  30793. readonly isEnabled: boolean;
  30794. /**
  30795. * Resets performance monitor
  30796. */
  30797. reset(): void;
  30798. }
  30799. /**
  30800. * RollingAverage
  30801. *
  30802. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30803. */
  30804. export class RollingAverage {
  30805. /**
  30806. * Current average
  30807. */
  30808. average: number;
  30809. /**
  30810. * Current variance
  30811. */
  30812. variance: number;
  30813. protected _samples: Array<number>;
  30814. protected _sampleCount: number;
  30815. protected _pos: number;
  30816. protected _m2: number;
  30817. /**
  30818. * constructor
  30819. * @param length The number of samples required to saturate the sliding window
  30820. */
  30821. constructor(length: number);
  30822. /**
  30823. * Adds a sample to the sample set
  30824. * @param v The sample value
  30825. */
  30826. add(v: number): void;
  30827. /**
  30828. * Returns previously added values or null if outside of history or outside the sliding window domain
  30829. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30830. * @return Value previously recorded with add() or null if outside of range
  30831. */
  30832. history(i: number): number;
  30833. /**
  30834. * Returns true if enough samples have been taken to completely fill the sliding window
  30835. * @return true if sample-set saturated
  30836. */
  30837. isSaturated(): boolean;
  30838. /**
  30839. * Resets the rolling average (equivalent to 0 samples taken so far)
  30840. */
  30841. reset(): void;
  30842. /**
  30843. * Wraps a value around the sample range boundaries
  30844. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30845. * @return Wrapped position in sample range
  30846. */
  30847. protected _wrapPosition(i: number): number;
  30848. }
  30849. }
  30850. declare module BABYLON {
  30851. /**
  30852. * This class is used to track a performance counter which is number based.
  30853. * The user has access to many properties which give statistics of different nature.
  30854. *
  30855. * The implementer can track two kinds of Performance Counter: time and count.
  30856. * 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.
  30857. * 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.
  30858. */
  30859. export class PerfCounter {
  30860. /**
  30861. * Gets or sets a global boolean to turn on and off all the counters
  30862. */
  30863. static Enabled: boolean;
  30864. /**
  30865. * Returns the smallest value ever
  30866. */
  30867. readonly min: number;
  30868. /**
  30869. * Returns the biggest value ever
  30870. */
  30871. readonly max: number;
  30872. /**
  30873. * Returns the average value since the performance counter is running
  30874. */
  30875. readonly average: number;
  30876. /**
  30877. * Returns the average value of the last second the counter was monitored
  30878. */
  30879. readonly lastSecAverage: number;
  30880. /**
  30881. * Returns the current value
  30882. */
  30883. readonly current: number;
  30884. /**
  30885. * Gets the accumulated total
  30886. */
  30887. readonly total: number;
  30888. /**
  30889. * Gets the total value count
  30890. */
  30891. readonly count: number;
  30892. /**
  30893. * Creates a new counter
  30894. */
  30895. constructor();
  30896. /**
  30897. * Call this method to start monitoring a new frame.
  30898. * 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.
  30899. */
  30900. fetchNewFrame(): void;
  30901. /**
  30902. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30903. * @param newCount the count value to add to the monitored count
  30904. * @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.
  30905. */
  30906. addCount(newCount: number, fetchResult: boolean): void;
  30907. /**
  30908. * Start monitoring this performance counter
  30909. */
  30910. beginMonitoring(): void;
  30911. /**
  30912. * Compute the time lapsed since the previous beginMonitoring() call.
  30913. * @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
  30914. */
  30915. endMonitoring(newFrame?: boolean): void;
  30916. private _fetchResult;
  30917. private _startMonitoringTime;
  30918. private _min;
  30919. private _max;
  30920. private _average;
  30921. private _current;
  30922. private _totalValueCount;
  30923. private _totalAccumulated;
  30924. private _lastSecAverage;
  30925. private _lastSecAccumulated;
  30926. private _lastSecTime;
  30927. private _lastSecValueCount;
  30928. }
  30929. }
  30930. declare module BABYLON {
  30931. /**
  30932. * Defines the interface used by display changed events
  30933. */
  30934. export interface IDisplayChangedEventArgs {
  30935. /** Gets the vrDisplay object (if any) */
  30936. vrDisplay: Nullable<any>;
  30937. /** Gets a boolean indicating if webVR is supported */
  30938. vrSupported: boolean;
  30939. }
  30940. /**
  30941. * Defines the interface used by objects containing a viewport (like a camera)
  30942. */
  30943. interface IViewportOwnerLike {
  30944. /**
  30945. * Gets or sets the viewport
  30946. */
  30947. viewport: IViewportLike;
  30948. }
  30949. /**
  30950. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30951. */
  30952. export class Engine extends ThinEngine {
  30953. /** Defines that alpha blending is disabled */
  30954. static readonly ALPHA_DISABLE: number;
  30955. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30956. static readonly ALPHA_ADD: number;
  30957. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30958. static readonly ALPHA_COMBINE: number;
  30959. /** Defines that alpha blending to DEST - SRC * DEST */
  30960. static readonly ALPHA_SUBTRACT: number;
  30961. /** Defines that alpha blending to SRC * DEST */
  30962. static readonly ALPHA_MULTIPLY: number;
  30963. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30964. static readonly ALPHA_MAXIMIZED: number;
  30965. /** Defines that alpha blending to SRC + DEST */
  30966. static readonly ALPHA_ONEONE: number;
  30967. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30968. static readonly ALPHA_PREMULTIPLIED: number;
  30969. /**
  30970. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30971. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30972. */
  30973. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30974. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30975. static readonly ALPHA_INTERPOLATE: number;
  30976. /**
  30977. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30978. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30979. */
  30980. static readonly ALPHA_SCREENMODE: number;
  30981. /** Defines that the ressource is not delayed*/
  30982. static readonly DELAYLOADSTATE_NONE: number;
  30983. /** Defines that the ressource was successfully delay loaded */
  30984. static readonly DELAYLOADSTATE_LOADED: number;
  30985. /** Defines that the ressource is currently delay loading */
  30986. static readonly DELAYLOADSTATE_LOADING: number;
  30987. /** Defines that the ressource is delayed and has not started loading */
  30988. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30989. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30990. static readonly NEVER: number;
  30991. /** 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 */
  30992. static readonly ALWAYS: number;
  30993. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30994. static readonly LESS: number;
  30995. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30996. static readonly EQUAL: number;
  30997. /** 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 */
  30998. static readonly LEQUAL: number;
  30999. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31000. static readonly GREATER: number;
  31001. /** 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 */
  31002. static readonly GEQUAL: number;
  31003. /** 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 */
  31004. static readonly NOTEQUAL: number;
  31005. /** Passed to stencilOperation to specify that stencil value must be kept */
  31006. static readonly KEEP: number;
  31007. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31008. static readonly REPLACE: number;
  31009. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31010. static readonly INCR: number;
  31011. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31012. static readonly DECR: number;
  31013. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31014. static readonly INVERT: number;
  31015. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31016. static readonly INCR_WRAP: number;
  31017. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31018. static readonly DECR_WRAP: number;
  31019. /** Texture is not repeating outside of 0..1 UVs */
  31020. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31021. /** Texture is repeating outside of 0..1 UVs */
  31022. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31023. /** Texture is repeating and mirrored */
  31024. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31025. /** ALPHA */
  31026. static readonly TEXTUREFORMAT_ALPHA: number;
  31027. /** LUMINANCE */
  31028. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31029. /** LUMINANCE_ALPHA */
  31030. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31031. /** RGB */
  31032. static readonly TEXTUREFORMAT_RGB: number;
  31033. /** RGBA */
  31034. static readonly TEXTUREFORMAT_RGBA: number;
  31035. /** RED */
  31036. static readonly TEXTUREFORMAT_RED: number;
  31037. /** RED (2nd reference) */
  31038. static readonly TEXTUREFORMAT_R: number;
  31039. /** RG */
  31040. static readonly TEXTUREFORMAT_RG: number;
  31041. /** RED_INTEGER */
  31042. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31043. /** RED_INTEGER (2nd reference) */
  31044. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31045. /** RG_INTEGER */
  31046. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31047. /** RGB_INTEGER */
  31048. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31049. /** RGBA_INTEGER */
  31050. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31051. /** UNSIGNED_BYTE */
  31052. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31053. /** UNSIGNED_BYTE (2nd reference) */
  31054. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31055. /** FLOAT */
  31056. static readonly TEXTURETYPE_FLOAT: number;
  31057. /** HALF_FLOAT */
  31058. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31059. /** BYTE */
  31060. static readonly TEXTURETYPE_BYTE: number;
  31061. /** SHORT */
  31062. static readonly TEXTURETYPE_SHORT: number;
  31063. /** UNSIGNED_SHORT */
  31064. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31065. /** INT */
  31066. static readonly TEXTURETYPE_INT: number;
  31067. /** UNSIGNED_INT */
  31068. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31069. /** UNSIGNED_SHORT_4_4_4_4 */
  31070. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31071. /** UNSIGNED_SHORT_5_5_5_1 */
  31072. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31073. /** UNSIGNED_SHORT_5_6_5 */
  31074. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31075. /** UNSIGNED_INT_2_10_10_10_REV */
  31076. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31077. /** UNSIGNED_INT_24_8 */
  31078. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31079. /** UNSIGNED_INT_10F_11F_11F_REV */
  31080. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31081. /** UNSIGNED_INT_5_9_9_9_REV */
  31082. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31083. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31084. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31085. /** nearest is mag = nearest and min = nearest and mip = linear */
  31086. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31087. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31088. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31089. /** Trilinear is mag = linear and min = linear and mip = linear */
  31090. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31091. /** nearest is mag = nearest and min = nearest and mip = linear */
  31092. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31093. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31094. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31095. /** Trilinear is mag = linear and min = linear and mip = linear */
  31096. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31097. /** mag = nearest and min = nearest and mip = nearest */
  31098. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31099. /** mag = nearest and min = linear and mip = nearest */
  31100. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31101. /** mag = nearest and min = linear and mip = linear */
  31102. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31103. /** mag = nearest and min = linear and mip = none */
  31104. static readonly TEXTURE_NEAREST_LINEAR: number;
  31105. /** mag = nearest and min = nearest and mip = none */
  31106. static readonly TEXTURE_NEAREST_NEAREST: number;
  31107. /** mag = linear and min = nearest and mip = nearest */
  31108. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31109. /** mag = linear and min = nearest and mip = linear */
  31110. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31111. /** mag = linear and min = linear and mip = none */
  31112. static readonly TEXTURE_LINEAR_LINEAR: number;
  31113. /** mag = linear and min = nearest and mip = none */
  31114. static readonly TEXTURE_LINEAR_NEAREST: number;
  31115. /** Explicit coordinates mode */
  31116. static readonly TEXTURE_EXPLICIT_MODE: number;
  31117. /** Spherical coordinates mode */
  31118. static readonly TEXTURE_SPHERICAL_MODE: number;
  31119. /** Planar coordinates mode */
  31120. static readonly TEXTURE_PLANAR_MODE: number;
  31121. /** Cubic coordinates mode */
  31122. static readonly TEXTURE_CUBIC_MODE: number;
  31123. /** Projection coordinates mode */
  31124. static readonly TEXTURE_PROJECTION_MODE: number;
  31125. /** Skybox coordinates mode */
  31126. static readonly TEXTURE_SKYBOX_MODE: number;
  31127. /** Inverse Cubic coordinates mode */
  31128. static readonly TEXTURE_INVCUBIC_MODE: number;
  31129. /** Equirectangular coordinates mode */
  31130. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31131. /** Equirectangular Fixed coordinates mode */
  31132. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31133. /** Equirectangular Fixed Mirrored coordinates mode */
  31134. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31135. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31136. static readonly SCALEMODE_FLOOR: number;
  31137. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31138. static readonly SCALEMODE_NEAREST: number;
  31139. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31140. static readonly SCALEMODE_CEILING: number;
  31141. /**
  31142. * Returns the current npm package of the sdk
  31143. */
  31144. static readonly NpmPackage: string;
  31145. /**
  31146. * Returns the current version of the framework
  31147. */
  31148. static readonly Version: string;
  31149. /** Gets the list of created engines */
  31150. static readonly Instances: Engine[];
  31151. /**
  31152. * Gets the latest created engine
  31153. */
  31154. static readonly LastCreatedEngine: Nullable<Engine>;
  31155. /**
  31156. * Gets the latest created scene
  31157. */
  31158. static readonly LastCreatedScene: Nullable<Scene>;
  31159. /**
  31160. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31161. * @param flag defines which part of the materials must be marked as dirty
  31162. * @param predicate defines a predicate used to filter which materials should be affected
  31163. */
  31164. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31165. /**
  31166. * Method called to create the default loading screen.
  31167. * This can be overriden in your own app.
  31168. * @param canvas The rendering canvas element
  31169. * @returns The loading screen
  31170. */
  31171. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31172. /**
  31173. * Method called to create the default rescale post process on each engine.
  31174. */
  31175. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31176. /**
  31177. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31178. **/
  31179. enableOfflineSupport: boolean;
  31180. /**
  31181. * 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)
  31182. **/
  31183. disableManifestCheck: boolean;
  31184. /**
  31185. * Gets the list of created scenes
  31186. */
  31187. scenes: Scene[];
  31188. /**
  31189. * Event raised when a new scene is created
  31190. */
  31191. onNewSceneAddedObservable: Observable<Scene>;
  31192. /**
  31193. * Gets the list of created postprocesses
  31194. */
  31195. postProcesses: PostProcess[];
  31196. /**
  31197. * Gets a boolean indicating if the pointer is currently locked
  31198. */
  31199. isPointerLock: boolean;
  31200. /**
  31201. * Observable event triggered each time the rendering canvas is resized
  31202. */
  31203. onResizeObservable: Observable<Engine>;
  31204. /**
  31205. * Observable event triggered each time the canvas loses focus
  31206. */
  31207. onCanvasBlurObservable: Observable<Engine>;
  31208. /**
  31209. * Observable event triggered each time the canvas gains focus
  31210. */
  31211. onCanvasFocusObservable: Observable<Engine>;
  31212. /**
  31213. * Observable event triggered each time the canvas receives pointerout event
  31214. */
  31215. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31216. /**
  31217. * Observable raised when the engine begins a new frame
  31218. */
  31219. onBeginFrameObservable: Observable<Engine>;
  31220. /**
  31221. * If set, will be used to request the next animation frame for the render loop
  31222. */
  31223. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31224. /**
  31225. * Observable raised when the engine ends the current frame
  31226. */
  31227. onEndFrameObservable: Observable<Engine>;
  31228. /**
  31229. * Observable raised when the engine is about to compile a shader
  31230. */
  31231. onBeforeShaderCompilationObservable: Observable<Engine>;
  31232. /**
  31233. * Observable raised when the engine has jsut compiled a shader
  31234. */
  31235. onAfterShaderCompilationObservable: Observable<Engine>;
  31236. /**
  31237. * Gets the audio engine
  31238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31239. * @ignorenaming
  31240. */
  31241. static audioEngine: IAudioEngine;
  31242. /**
  31243. * Default AudioEngine factory responsible of creating the Audio Engine.
  31244. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31245. */
  31246. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31247. /**
  31248. * Default offline support factory responsible of creating a tool used to store data locally.
  31249. * By default, this will create a Database object if the workload has been embedded.
  31250. */
  31251. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31252. private _loadingScreen;
  31253. private _pointerLockRequested;
  31254. private _dummyFramebuffer;
  31255. private _rescalePostProcess;
  31256. /** @hidden */
  31257. protected _alphaMode: number;
  31258. /** @hidden */
  31259. protected _alphaEquation: number;
  31260. private _deterministicLockstep;
  31261. private _lockstepMaxSteps;
  31262. protected readonly _supportsHardwareTextureRescaling: boolean;
  31263. private _fps;
  31264. private _deltaTime;
  31265. /** @hidden */
  31266. _drawCalls: PerfCounter;
  31267. /**
  31268. * Turn this value on if you want to pause FPS computation when in background
  31269. */
  31270. disablePerformanceMonitorInBackground: boolean;
  31271. private _performanceMonitor;
  31272. /**
  31273. * Gets the performance monitor attached to this engine
  31274. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31275. */
  31276. readonly performanceMonitor: PerformanceMonitor;
  31277. private _onFocus;
  31278. private _onBlur;
  31279. private _onCanvasPointerOut;
  31280. private _onCanvasBlur;
  31281. private _onCanvasFocus;
  31282. private _onFullscreenChange;
  31283. private _onPointerLockChange;
  31284. /**
  31285. * Creates a new engine
  31286. * @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
  31287. * @param antialias defines enable antialiasing (default: false)
  31288. * @param options defines further options to be sent to the getContext() function
  31289. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31290. */
  31291. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31292. /**
  31293. * Gets current aspect ratio
  31294. * @param viewportOwner defines the camera to use to get the aspect ratio
  31295. * @param useScreen defines if screen size must be used (or the current render target if any)
  31296. * @returns a number defining the aspect ratio
  31297. */
  31298. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31299. /**
  31300. * Gets current screen aspect ratio
  31301. * @returns a number defining the aspect ratio
  31302. */
  31303. getScreenAspectRatio(): number;
  31304. /**
  31305. * Gets host document
  31306. * @returns the host document object
  31307. */
  31308. getHostDocument(): Document;
  31309. /**
  31310. * Gets the client rect of the HTML canvas attached with the current webGL context
  31311. * @returns a client rectanglee
  31312. */
  31313. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31314. /**
  31315. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31316. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31317. * @returns true if engine is in deterministic lock step mode
  31318. */
  31319. isDeterministicLockStep(): boolean;
  31320. /**
  31321. * Gets the max steps when engine is running in deterministic lock step
  31322. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31323. * @returns the max steps
  31324. */
  31325. getLockstepMaxSteps(): number;
  31326. /**
  31327. * Force the mipmap generation for the given render target texture
  31328. * @param texture defines the render target texture to use
  31329. */
  31330. generateMipMapsForCubemap(texture: InternalTexture): void;
  31331. /** States */
  31332. /**
  31333. * Set various states to the webGL context
  31334. * @param culling defines backface culling state
  31335. * @param zOffset defines the value to apply to zOffset (0 by default)
  31336. * @param force defines if states must be applied even if cache is up to date
  31337. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31338. */
  31339. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31340. /**
  31341. * Set the z offset to apply to current rendering
  31342. * @param value defines the offset to apply
  31343. */
  31344. setZOffset(value: number): void;
  31345. /**
  31346. * Gets the current value of the zOffset
  31347. * @returns the current zOffset state
  31348. */
  31349. getZOffset(): number;
  31350. /**
  31351. * Enable or disable depth buffering
  31352. * @param enable defines the state to set
  31353. */
  31354. setDepthBuffer(enable: boolean): void;
  31355. /**
  31356. * Gets a boolean indicating if depth writing is enabled
  31357. * @returns the current depth writing state
  31358. */
  31359. getDepthWrite(): boolean;
  31360. /**
  31361. * Enable or disable depth writing
  31362. * @param enable defines the state to set
  31363. */
  31364. setDepthWrite(enable: boolean): void;
  31365. /**
  31366. * Enable or disable color writing
  31367. * @param enable defines the state to set
  31368. */
  31369. setColorWrite(enable: boolean): void;
  31370. /**
  31371. * Gets a boolean indicating if color writing is enabled
  31372. * @returns the current color writing state
  31373. */
  31374. getColorWrite(): boolean;
  31375. /**
  31376. * Sets alpha constants used by some alpha blending modes
  31377. * @param r defines the red component
  31378. * @param g defines the green component
  31379. * @param b defines the blue component
  31380. * @param a defines the alpha component
  31381. */
  31382. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31383. /**
  31384. * Sets the current alpha mode
  31385. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31386. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31387. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31388. */
  31389. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31390. /**
  31391. * Gets the current alpha mode
  31392. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31393. * @returns the current alpha mode
  31394. */
  31395. getAlphaMode(): number;
  31396. /**
  31397. * Sets the current alpha equation
  31398. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31399. */
  31400. setAlphaEquation(equation: number): void;
  31401. /**
  31402. * Gets the current alpha equation.
  31403. * @returns the current alpha equation
  31404. */
  31405. getAlphaEquation(): number;
  31406. /**
  31407. * Gets a boolean indicating if stencil buffer is enabled
  31408. * @returns the current stencil buffer state
  31409. */
  31410. getStencilBuffer(): boolean;
  31411. /**
  31412. * Enable or disable the stencil buffer
  31413. * @param enable defines if the stencil buffer must be enabled or disabled
  31414. */
  31415. setStencilBuffer(enable: boolean): void;
  31416. /**
  31417. * Gets the current stencil mask
  31418. * @returns a number defining the new stencil mask to use
  31419. */
  31420. getStencilMask(): number;
  31421. /**
  31422. * Sets the current stencil mask
  31423. * @param mask defines the new stencil mask to use
  31424. */
  31425. setStencilMask(mask: number): void;
  31426. /**
  31427. * Gets the current stencil function
  31428. * @returns a number defining the stencil function to use
  31429. */
  31430. getStencilFunction(): number;
  31431. /**
  31432. * Gets the current stencil reference value
  31433. * @returns a number defining the stencil reference value to use
  31434. */
  31435. getStencilFunctionReference(): number;
  31436. /**
  31437. * Gets the current stencil mask
  31438. * @returns a number defining the stencil mask to use
  31439. */
  31440. getStencilFunctionMask(): number;
  31441. /**
  31442. * Sets the current stencil function
  31443. * @param stencilFunc defines the new stencil function to use
  31444. */
  31445. setStencilFunction(stencilFunc: number): void;
  31446. /**
  31447. * Sets the current stencil reference
  31448. * @param reference defines the new stencil reference to use
  31449. */
  31450. setStencilFunctionReference(reference: number): void;
  31451. /**
  31452. * Sets the current stencil mask
  31453. * @param mask defines the new stencil mask to use
  31454. */
  31455. setStencilFunctionMask(mask: number): void;
  31456. /**
  31457. * Gets the current stencil operation when stencil fails
  31458. * @returns a number defining stencil operation to use when stencil fails
  31459. */
  31460. getStencilOperationFail(): number;
  31461. /**
  31462. * Gets the current stencil operation when depth fails
  31463. * @returns a number defining stencil operation to use when depth fails
  31464. */
  31465. getStencilOperationDepthFail(): number;
  31466. /**
  31467. * Gets the current stencil operation when stencil passes
  31468. * @returns a number defining stencil operation to use when stencil passes
  31469. */
  31470. getStencilOperationPass(): number;
  31471. /**
  31472. * Sets the stencil operation to use when stencil fails
  31473. * @param operation defines the stencil operation to use when stencil fails
  31474. */
  31475. setStencilOperationFail(operation: number): void;
  31476. /**
  31477. * Sets the stencil operation to use when depth fails
  31478. * @param operation defines the stencil operation to use when depth fails
  31479. */
  31480. setStencilOperationDepthFail(operation: number): void;
  31481. /**
  31482. * Sets the stencil operation to use when stencil passes
  31483. * @param operation defines the stencil operation to use when stencil passes
  31484. */
  31485. setStencilOperationPass(operation: number): void;
  31486. /**
  31487. * Sets a boolean indicating if the dithering state is enabled or disabled
  31488. * @param value defines the dithering state
  31489. */
  31490. setDitheringState(value: boolean): void;
  31491. /**
  31492. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31493. * @param value defines the rasterizer state
  31494. */
  31495. setRasterizerState(value: boolean): void;
  31496. /**
  31497. * Gets the current depth function
  31498. * @returns a number defining the depth function
  31499. */
  31500. getDepthFunction(): Nullable<number>;
  31501. /**
  31502. * Sets the current depth function
  31503. * @param depthFunc defines the function to use
  31504. */
  31505. setDepthFunction(depthFunc: number): void;
  31506. /**
  31507. * Sets the current depth function to GREATER
  31508. */
  31509. setDepthFunctionToGreater(): void;
  31510. /**
  31511. * Sets the current depth function to GEQUAL
  31512. */
  31513. setDepthFunctionToGreaterOrEqual(): void;
  31514. /**
  31515. * Sets the current depth function to LESS
  31516. */
  31517. setDepthFunctionToLess(): void;
  31518. /**
  31519. * Sets the current depth function to LEQUAL
  31520. */
  31521. setDepthFunctionToLessOrEqual(): void;
  31522. private _cachedStencilBuffer;
  31523. private _cachedStencilFunction;
  31524. private _cachedStencilMask;
  31525. private _cachedStencilOperationPass;
  31526. private _cachedStencilOperationFail;
  31527. private _cachedStencilOperationDepthFail;
  31528. private _cachedStencilReference;
  31529. /**
  31530. * Caches the the state of the stencil buffer
  31531. */
  31532. cacheStencilState(): void;
  31533. /**
  31534. * Restores the state of the stencil buffer
  31535. */
  31536. restoreStencilState(): void;
  31537. /**
  31538. * Directly set the WebGL Viewport
  31539. * @param x defines the x coordinate of the viewport (in screen space)
  31540. * @param y defines the y coordinate of the viewport (in screen space)
  31541. * @param width defines the width of the viewport (in screen space)
  31542. * @param height defines the height of the viewport (in screen space)
  31543. * @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
  31544. */
  31545. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31546. /**
  31547. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31548. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31549. * @param y defines the y-coordinate of the corner of the clear rectangle
  31550. * @param width defines the width of the clear rectangle
  31551. * @param height defines the height of the clear rectangle
  31552. * @param clearColor defines the clear color
  31553. */
  31554. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31555. /**
  31556. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31557. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31558. * @param y defines the y-coordinate of the corner of the clear rectangle
  31559. * @param width defines the width of the clear rectangle
  31560. * @param height defines the height of the clear rectangle
  31561. */
  31562. enableScissor(x: number, y: number, width: number, height: number): void;
  31563. /**
  31564. * Disable previously set scissor test rectangle
  31565. */
  31566. disableScissor(): void;
  31567. protected _reportDrawCall(): void;
  31568. /**
  31569. * Initializes a webVR display and starts listening to display change events
  31570. * The onVRDisplayChangedObservable will be notified upon these changes
  31571. * @returns The onVRDisplayChangedObservable
  31572. */
  31573. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31574. /** @hidden */
  31575. _prepareVRComponent(): void;
  31576. /** @hidden */
  31577. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31578. /** @hidden */
  31579. _submitVRFrame(): void;
  31580. /**
  31581. * Call this function to leave webVR mode
  31582. * Will do nothing if webVR is not supported or if there is no webVR device
  31583. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31584. */
  31585. disableVR(): void;
  31586. /**
  31587. * Gets a boolean indicating that the system is in VR mode and is presenting
  31588. * @returns true if VR mode is engaged
  31589. */
  31590. isVRPresenting(): boolean;
  31591. /** @hidden */
  31592. _requestVRFrame(): void;
  31593. /** @hidden */
  31594. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31595. /**
  31596. * Gets the source code of the vertex shader associated with a specific webGL program
  31597. * @param program defines the program to use
  31598. * @returns a string containing the source code of the vertex shader associated with the program
  31599. */
  31600. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31601. /**
  31602. * Gets the source code of the fragment shader associated with a specific webGL program
  31603. * @param program defines the program to use
  31604. * @returns a string containing the source code of the fragment shader associated with the program
  31605. */
  31606. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31607. /**
  31608. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31609. * @param x defines the x coordinate of the rectangle where pixels must be read
  31610. * @param y defines the y coordinate of the rectangle where pixels must be read
  31611. * @param width defines the width of the rectangle where pixels must be read
  31612. * @param height defines the height of the rectangle where pixels must be read
  31613. * @returns a Uint8Array containing RGBA colors
  31614. */
  31615. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31616. /**
  31617. * Sets a depth stencil texture from a render target to the according uniform.
  31618. * @param channel The texture channel
  31619. * @param uniform The uniform to set
  31620. * @param texture The render target texture containing the depth stencil texture to apply
  31621. */
  31622. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31623. /**
  31624. * Sets a texture to the webGL context from a postprocess
  31625. * @param channel defines the channel to use
  31626. * @param postProcess defines the source postprocess
  31627. */
  31628. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31629. /**
  31630. * Binds the output of the passed in post process to the texture channel specified
  31631. * @param channel The channel the texture should be bound to
  31632. * @param postProcess The post process which's output should be bound
  31633. */
  31634. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31635. /** @hidden */
  31636. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31637. protected _rebuildBuffers(): void;
  31638. _renderLoop(): void;
  31639. /**
  31640. * Toggle full screen mode
  31641. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31642. */
  31643. switchFullscreen(requestPointerLock: boolean): void;
  31644. /**
  31645. * Enters full screen mode
  31646. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31647. */
  31648. enterFullscreen(requestPointerLock: boolean): void;
  31649. /**
  31650. * Exits full screen mode
  31651. */
  31652. exitFullscreen(): void;
  31653. /**
  31654. * Enters Pointerlock mode
  31655. */
  31656. enterPointerlock(): void;
  31657. /**
  31658. * Exits Pointerlock mode
  31659. */
  31660. exitPointerlock(): void;
  31661. /**
  31662. * Begin a new frame
  31663. */
  31664. beginFrame(): void;
  31665. /**
  31666. * Enf the current frame
  31667. */
  31668. endFrame(): void;
  31669. resize(): void;
  31670. /**
  31671. * Set the compressed texture format to use, based on the formats you have, and the formats
  31672. * supported by the hardware / browser.
  31673. *
  31674. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31675. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31676. * to API arguments needed to compressed textures. This puts the burden on the container
  31677. * generator to house the arcane code for determining these for current & future formats.
  31678. *
  31679. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31680. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31681. *
  31682. * Note: The result of this call is not taken into account when a texture is base64.
  31683. *
  31684. * @param formatsAvailable defines the list of those format families you have created
  31685. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31686. *
  31687. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31688. * @returns The extension selected.
  31689. */
  31690. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31691. /**
  31692. * Force a specific size of the canvas
  31693. * @param width defines the new canvas' width
  31694. * @param height defines the new canvas' height
  31695. */
  31696. setSize(width: number, height: number): void;
  31697. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31698. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31699. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31700. _releaseTexture(texture: InternalTexture): void;
  31701. /**
  31702. * @hidden
  31703. * Rescales a texture
  31704. * @param source input texutre
  31705. * @param destination destination texture
  31706. * @param scene scene to use to render the resize
  31707. * @param internalFormat format to use when resizing
  31708. * @param onComplete callback to be called when resize has completed
  31709. */
  31710. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31711. /**
  31712. * Gets the current framerate
  31713. * @returns a number representing the framerate
  31714. */
  31715. getFps(): number;
  31716. /**
  31717. * Gets the time spent between current and previous frame
  31718. * @returns a number representing the delta time in ms
  31719. */
  31720. getDeltaTime(): number;
  31721. private _measureFps;
  31722. /**
  31723. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31724. * @param renderTarget The render target to set the frame buffer for
  31725. */
  31726. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31727. /**
  31728. * Update a dynamic index buffer
  31729. * @param indexBuffer defines the target index buffer
  31730. * @param indices defines the data to update
  31731. * @param offset defines the offset in the target index buffer where update should start
  31732. */
  31733. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31734. /**
  31735. * Updates the sample count of a render target texture
  31736. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31737. * @param texture defines the texture to update
  31738. * @param samples defines the sample count to set
  31739. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31740. */
  31741. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31742. /** @hidden */
  31743. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31744. dispose(): void;
  31745. private _disableTouchAction;
  31746. /**
  31747. * Display the loading screen
  31748. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31749. */
  31750. displayLoadingUI(): void;
  31751. /**
  31752. * Hide the loading screen
  31753. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31754. */
  31755. hideLoadingUI(): void;
  31756. /**
  31757. * Gets the current loading screen object
  31758. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31759. */
  31760. /**
  31761. * Sets the current loading screen object
  31762. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31763. */
  31764. loadingScreen: ILoadingScreen;
  31765. /**
  31766. * Sets the current loading screen text
  31767. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31768. */
  31769. loadingUIText: string;
  31770. /**
  31771. * Sets the current loading screen background color
  31772. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31773. */
  31774. loadingUIBackgroundColor: string;
  31775. /** Pointerlock and fullscreen */
  31776. /**
  31777. * Ask the browser to promote the current element to pointerlock mode
  31778. * @param element defines the DOM element to promote
  31779. */
  31780. static _RequestPointerlock(element: HTMLElement): void;
  31781. /**
  31782. * Asks the browser to exit pointerlock mode
  31783. */
  31784. static _ExitPointerlock(): void;
  31785. /**
  31786. * Ask the browser to promote the current element to fullscreen rendering mode
  31787. * @param element defines the DOM element to promote
  31788. */
  31789. static _RequestFullscreen(element: HTMLElement): void;
  31790. /**
  31791. * Asks the browser to exit fullscreen mode
  31792. */
  31793. static _ExitFullscreen(): void;
  31794. }
  31795. }
  31796. declare module BABYLON {
  31797. /**
  31798. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31799. * during the life time of the application.
  31800. */
  31801. export class EngineStore {
  31802. /** Gets the list of created engines */
  31803. static Instances: Engine[];
  31804. /** @hidden */
  31805. static _LastCreatedScene: Nullable<Scene>;
  31806. /**
  31807. * Gets the latest created engine
  31808. */
  31809. static readonly LastCreatedEngine: Nullable<Engine>;
  31810. /**
  31811. * Gets the latest created scene
  31812. */
  31813. static readonly LastCreatedScene: Nullable<Scene>;
  31814. /**
  31815. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31816. * @ignorenaming
  31817. */
  31818. static UseFallbackTexture: boolean;
  31819. /**
  31820. * Texture content used if a texture cannot loaded
  31821. * @ignorenaming
  31822. */
  31823. static FallbackTexture: string;
  31824. }
  31825. }
  31826. declare module BABYLON {
  31827. /**
  31828. * Helper class that provides a small promise polyfill
  31829. */
  31830. export class PromisePolyfill {
  31831. /**
  31832. * Static function used to check if the polyfill is required
  31833. * If this is the case then the function will inject the polyfill to window.Promise
  31834. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31835. */
  31836. static Apply(force?: boolean): void;
  31837. }
  31838. }
  31839. declare module BABYLON {
  31840. /**
  31841. * Interface for screenshot methods with describe argument called `size` as object with options
  31842. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31843. */
  31844. export interface IScreenshotSize {
  31845. /**
  31846. * number in pixels for canvas height
  31847. */
  31848. height?: number;
  31849. /**
  31850. * multiplier allowing render at a higher or lower resolution
  31851. * If value is defined then height and width will be ignored and taken from camera
  31852. */
  31853. precision?: number;
  31854. /**
  31855. * number in pixels for canvas width
  31856. */
  31857. width?: number;
  31858. }
  31859. }
  31860. declare module BABYLON {
  31861. interface IColor4Like {
  31862. r: float;
  31863. g: float;
  31864. b: float;
  31865. a: float;
  31866. }
  31867. /**
  31868. * Class containing a set of static utilities functions
  31869. */
  31870. export class Tools {
  31871. /**
  31872. * Gets or sets the base URL to use to load assets
  31873. */
  31874. static BaseUrl: string;
  31875. /**
  31876. * Enable/Disable Custom HTTP Request Headers globally.
  31877. * default = false
  31878. * @see CustomRequestHeaders
  31879. */
  31880. static UseCustomRequestHeaders: boolean;
  31881. /**
  31882. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31883. * i.e. when loading files, where the server/service expects an Authorization header
  31884. */
  31885. static CustomRequestHeaders: {
  31886. [key: string]: string;
  31887. };
  31888. /**
  31889. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31890. */
  31891. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31892. /**
  31893. * Default behaviour for cors in the application.
  31894. * It can be a string if the expected behavior is identical in the entire app.
  31895. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31896. */
  31897. static CorsBehavior: string | ((url: string | string[]) => string);
  31898. /**
  31899. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31900. * @ignorenaming
  31901. */
  31902. static UseFallbackTexture: boolean;
  31903. /**
  31904. * Use this object to register external classes like custom textures or material
  31905. * to allow the laoders to instantiate them
  31906. */
  31907. static RegisteredExternalClasses: {
  31908. [key: string]: Object;
  31909. };
  31910. /**
  31911. * Texture content used if a texture cannot loaded
  31912. * @ignorenaming
  31913. */
  31914. static fallbackTexture: string;
  31915. /**
  31916. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31917. * @param u defines the coordinate on X axis
  31918. * @param v defines the coordinate on Y axis
  31919. * @param width defines the width of the source data
  31920. * @param height defines the height of the source data
  31921. * @param pixels defines the source byte array
  31922. * @param color defines the output color
  31923. */
  31924. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31925. /**
  31926. * Interpolates between a and b via alpha
  31927. * @param a The lower value (returned when alpha = 0)
  31928. * @param b The upper value (returned when alpha = 1)
  31929. * @param alpha The interpolation-factor
  31930. * @return The mixed value
  31931. */
  31932. static Mix(a: number, b: number, alpha: number): number;
  31933. /**
  31934. * Tries to instantiate a new object from a given class name
  31935. * @param className defines the class name to instantiate
  31936. * @returns the new object or null if the system was not able to do the instantiation
  31937. */
  31938. static Instantiate(className: string): any;
  31939. /**
  31940. * Provides a slice function that will work even on IE
  31941. * @param data defines the array to slice
  31942. * @param start defines the start of the data (optional)
  31943. * @param end defines the end of the data (optional)
  31944. * @returns the new sliced array
  31945. */
  31946. static Slice<T>(data: T, start?: number, end?: number): T;
  31947. /**
  31948. * Polyfill for setImmediate
  31949. * @param action defines the action to execute after the current execution block
  31950. */
  31951. static SetImmediate(action: () => void): void;
  31952. /**
  31953. * Function indicating if a number is an exponent of 2
  31954. * @param value defines the value to test
  31955. * @returns true if the value is an exponent of 2
  31956. */
  31957. static IsExponentOfTwo(value: number): boolean;
  31958. private static _tmpFloatArray;
  31959. /**
  31960. * Returns the nearest 32-bit single precision float representation of a Number
  31961. * @param value A Number. If the parameter is of a different type, it will get converted
  31962. * to a number or to NaN if it cannot be converted
  31963. * @returns number
  31964. */
  31965. static FloatRound(value: number): number;
  31966. /**
  31967. * Extracts the filename from a path
  31968. * @param path defines the path to use
  31969. * @returns the filename
  31970. */
  31971. static GetFilename(path: string): string;
  31972. /**
  31973. * Extracts the "folder" part of a path (everything before the filename).
  31974. * @param uri The URI to extract the info from
  31975. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31976. * @returns The "folder" part of the path
  31977. */
  31978. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31979. /**
  31980. * Extracts text content from a DOM element hierarchy
  31981. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31982. */
  31983. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31984. /**
  31985. * Convert an angle in radians to degrees
  31986. * @param angle defines the angle to convert
  31987. * @returns the angle in degrees
  31988. */
  31989. static ToDegrees(angle: number): number;
  31990. /**
  31991. * Convert an angle in degrees to radians
  31992. * @param angle defines the angle to convert
  31993. * @returns the angle in radians
  31994. */
  31995. static ToRadians(angle: number): number;
  31996. /**
  31997. * Encode a buffer to a base64 string
  31998. * @param buffer defines the buffer to encode
  31999. * @returns the encoded string
  32000. */
  32001. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32002. /**
  32003. * Returns an array if obj is not an array
  32004. * @param obj defines the object to evaluate as an array
  32005. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32006. * @returns either obj directly if obj is an array or a new array containing obj
  32007. */
  32008. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32009. /**
  32010. * Gets the pointer prefix to use
  32011. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32012. */
  32013. static GetPointerPrefix(): string;
  32014. /**
  32015. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32016. * @param url define the url we are trying
  32017. * @param element define the dom element where to configure the cors policy
  32018. */
  32019. static SetCorsBehavior(url: string | string[], element: {
  32020. crossOrigin: string | null;
  32021. }): void;
  32022. /**
  32023. * Removes unwanted characters from an url
  32024. * @param url defines the url to clean
  32025. * @returns the cleaned url
  32026. */
  32027. static CleanUrl(url: string): string;
  32028. /**
  32029. * Gets or sets a function used to pre-process url before using them to load assets
  32030. */
  32031. static PreprocessUrl: (url: string) => string;
  32032. /**
  32033. * Loads an image as an HTMLImageElement.
  32034. * @param input url string, ArrayBuffer, or Blob to load
  32035. * @param onLoad callback called when the image successfully loads
  32036. * @param onError callback called when the image fails to load
  32037. * @param offlineProvider offline provider for caching
  32038. * @param mimeType optional mime type
  32039. * @returns the HTMLImageElement of the loaded image
  32040. */
  32041. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32042. /**
  32043. * Loads a file
  32044. * @param url url string, ArrayBuffer, or Blob to load
  32045. * @param onSuccess callback called when the file successfully loads
  32046. * @param onProgress callback called while file is loading (if the server supports this mode)
  32047. * @param offlineProvider defines the offline provider for caching
  32048. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32049. * @param onError callback called when the file fails to load
  32050. * @returns a file request object
  32051. */
  32052. 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;
  32053. /**
  32054. * Loads a file from a url
  32055. * @param url the file url to load
  32056. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32057. */
  32058. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32059. /**
  32060. * Load a script (identified by an url). When the url returns, the
  32061. * content of this file is added into a new script element, attached to the DOM (body element)
  32062. * @param scriptUrl defines the url of the script to laod
  32063. * @param onSuccess defines the callback called when the script is loaded
  32064. * @param onError defines the callback to call if an error occurs
  32065. * @param scriptId defines the id of the script element
  32066. */
  32067. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32068. /**
  32069. * Load an asynchronous script (identified by an url). When the url returns, the
  32070. * content of this file is added into a new script element, attached to the DOM (body element)
  32071. * @param scriptUrl defines the url of the script to laod
  32072. * @param scriptId defines the id of the script element
  32073. * @returns a promise request object
  32074. */
  32075. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32076. /**
  32077. * Loads a file from a blob
  32078. * @param fileToLoad defines the blob to use
  32079. * @param callback defines the callback to call when data is loaded
  32080. * @param progressCallback defines the callback to call during loading process
  32081. * @returns a file request object
  32082. */
  32083. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32084. /**
  32085. * Loads a file
  32086. * @param fileToLoad defines the file to load
  32087. * @param callback defines the callback to call when data is loaded
  32088. * @param progressCallBack defines the callback to call during loading process
  32089. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32090. * @returns a file request object
  32091. */
  32092. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32093. /**
  32094. * Creates a data url from a given string content
  32095. * @param content defines the content to convert
  32096. * @returns the new data url link
  32097. */
  32098. static FileAsURL(content: string): string;
  32099. /**
  32100. * Format the given number to a specific decimal format
  32101. * @param value defines the number to format
  32102. * @param decimals defines the number of decimals to use
  32103. * @returns the formatted string
  32104. */
  32105. static Format(value: number, decimals?: number): string;
  32106. /**
  32107. * Tries to copy an object by duplicating every property
  32108. * @param source defines the source object
  32109. * @param destination defines the target object
  32110. * @param doNotCopyList defines a list of properties to avoid
  32111. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32112. */
  32113. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32114. /**
  32115. * Gets a boolean indicating if the given object has no own property
  32116. * @param obj defines the object to test
  32117. * @returns true if object has no own property
  32118. */
  32119. static IsEmpty(obj: any): boolean;
  32120. /**
  32121. * Function used to register events at window level
  32122. * @param windowElement defines the Window object to use
  32123. * @param events defines the events to register
  32124. */
  32125. static RegisterTopRootEvents(windowElement: Window, events: {
  32126. name: string;
  32127. handler: Nullable<(e: FocusEvent) => any>;
  32128. }[]): void;
  32129. /**
  32130. * Function used to unregister events from window level
  32131. * @param windowElement defines the Window object to use
  32132. * @param events defines the events to unregister
  32133. */
  32134. static UnregisterTopRootEvents(windowElement: Window, events: {
  32135. name: string;
  32136. handler: Nullable<(e: FocusEvent) => any>;
  32137. }[]): void;
  32138. /**
  32139. * @ignore
  32140. */
  32141. static _ScreenshotCanvas: HTMLCanvasElement;
  32142. /**
  32143. * Dumps the current bound framebuffer
  32144. * @param width defines the rendering width
  32145. * @param height defines the rendering height
  32146. * @param engine defines the hosting engine
  32147. * @param successCallback defines the callback triggered once the data are available
  32148. * @param mimeType defines the mime type of the result
  32149. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32150. */
  32151. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32152. /**
  32153. * Converts the canvas data to blob.
  32154. * This acts as a polyfill for browsers not supporting the to blob function.
  32155. * @param canvas Defines the canvas to extract the data from
  32156. * @param successCallback Defines the callback triggered once the data are available
  32157. * @param mimeType Defines the mime type of the result
  32158. */
  32159. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32160. /**
  32161. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32162. * @param successCallback defines the callback triggered once the data are available
  32163. * @param mimeType defines the mime type of the result
  32164. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32165. */
  32166. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32167. /**
  32168. * Downloads a blob in the browser
  32169. * @param blob defines the blob to download
  32170. * @param fileName defines the name of the downloaded file
  32171. */
  32172. static Download(blob: Blob, fileName: string): void;
  32173. /**
  32174. * Captures a screenshot of the current rendering
  32175. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32176. * @param engine defines the rendering engine
  32177. * @param camera defines the source camera
  32178. * @param size This parameter can be set to a single number or to an object with the
  32179. * following (optional) properties: precision, width, height. If a single number is passed,
  32180. * it will be used for both width and height. If an object is passed, the screenshot size
  32181. * will be derived from the parameters. The precision property is a multiplier allowing
  32182. * rendering at a higher or lower resolution
  32183. * @param successCallback defines the callback receives a single parameter which contains the
  32184. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32185. * src parameter of an <img> to display it
  32186. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32187. * Check your browser for supported MIME types
  32188. */
  32189. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32190. /**
  32191. * Captures a screenshot of the current rendering
  32192. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32193. * @param engine defines the rendering engine
  32194. * @param camera defines the source camera
  32195. * @param size This parameter can be set to a single number or to an object with the
  32196. * following (optional) properties: precision, width, height. If a single number is passed,
  32197. * it will be used for both width and height. If an object is passed, the screenshot size
  32198. * will be derived from the parameters. The precision property is a multiplier allowing
  32199. * rendering at a higher or lower resolution
  32200. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32201. * Check your browser for supported MIME types
  32202. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32203. * to the src parameter of an <img> to display it
  32204. */
  32205. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32206. /**
  32207. * Generates an image screenshot from the specified camera.
  32208. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32209. * @param engine The engine to use for rendering
  32210. * @param camera The camera to use for rendering
  32211. * @param size This parameter can be set to a single number or to an object with the
  32212. * following (optional) properties: precision, width, height. If a single number is passed,
  32213. * it will be used for both width and height. If an object is passed, the screenshot size
  32214. * will be derived from the parameters. The precision property is a multiplier allowing
  32215. * rendering at a higher or lower resolution
  32216. * @param successCallback The callback receives a single parameter which contains the
  32217. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32218. * src parameter of an <img> to display it
  32219. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32220. * Check your browser for supported MIME types
  32221. * @param samples Texture samples (default: 1)
  32222. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32223. * @param fileName A name for for the downloaded file.
  32224. */
  32225. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32226. /**
  32227. * Generates an image screenshot from the specified camera.
  32228. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32229. * @param engine The engine to use for rendering
  32230. * @param camera The camera to use for rendering
  32231. * @param size This parameter can be set to a single number or to an object with the
  32232. * following (optional) properties: precision, width, height. If a single number is passed,
  32233. * it will be used for both width and height. If an object is passed, the screenshot size
  32234. * will be derived from the parameters. The precision property is a multiplier allowing
  32235. * rendering at a higher or lower resolution
  32236. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32237. * Check your browser for supported MIME types
  32238. * @param samples Texture samples (default: 1)
  32239. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32240. * @param fileName A name for for the downloaded file.
  32241. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32242. * to the src parameter of an <img> to display it
  32243. */
  32244. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32245. /**
  32246. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32247. * Be aware Math.random() could cause collisions, but:
  32248. * "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"
  32249. * @returns a pseudo random id
  32250. */
  32251. static RandomId(): string;
  32252. /**
  32253. * Test if the given uri is a base64 string
  32254. * @param uri The uri to test
  32255. * @return True if the uri is a base64 string or false otherwise
  32256. */
  32257. static IsBase64(uri: string): boolean;
  32258. /**
  32259. * Decode the given base64 uri.
  32260. * @param uri The uri to decode
  32261. * @return The decoded base64 data.
  32262. */
  32263. static DecodeBase64(uri: string): ArrayBuffer;
  32264. /**
  32265. * Gets the absolute url.
  32266. * @param url the input url
  32267. * @return the absolute url
  32268. */
  32269. static GetAbsoluteUrl(url: string): string;
  32270. /**
  32271. * No log
  32272. */
  32273. static readonly NoneLogLevel: number;
  32274. /**
  32275. * Only message logs
  32276. */
  32277. static readonly MessageLogLevel: number;
  32278. /**
  32279. * Only warning logs
  32280. */
  32281. static readonly WarningLogLevel: number;
  32282. /**
  32283. * Only error logs
  32284. */
  32285. static readonly ErrorLogLevel: number;
  32286. /**
  32287. * All logs
  32288. */
  32289. static readonly AllLogLevel: number;
  32290. /**
  32291. * Gets a value indicating the number of loading errors
  32292. * @ignorenaming
  32293. */
  32294. static readonly errorsCount: number;
  32295. /**
  32296. * Callback called when a new log is added
  32297. */
  32298. static OnNewCacheEntry: (entry: string) => void;
  32299. /**
  32300. * Log a message to the console
  32301. * @param message defines the message to log
  32302. */
  32303. static Log(message: string): void;
  32304. /**
  32305. * Write a warning message to the console
  32306. * @param message defines the message to log
  32307. */
  32308. static Warn(message: string): void;
  32309. /**
  32310. * Write an error message to the console
  32311. * @param message defines the message to log
  32312. */
  32313. static Error(message: string): void;
  32314. /**
  32315. * Gets current log cache (list of logs)
  32316. */
  32317. static readonly LogCache: string;
  32318. /**
  32319. * Clears the log cache
  32320. */
  32321. static ClearLogCache(): void;
  32322. /**
  32323. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32324. */
  32325. static LogLevels: number;
  32326. /**
  32327. * Checks if the window object exists
  32328. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32329. */
  32330. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32331. /**
  32332. * No performance log
  32333. */
  32334. static readonly PerformanceNoneLogLevel: number;
  32335. /**
  32336. * Use user marks to log performance
  32337. */
  32338. static readonly PerformanceUserMarkLogLevel: number;
  32339. /**
  32340. * Log performance to the console
  32341. */
  32342. static readonly PerformanceConsoleLogLevel: number;
  32343. private static _performance;
  32344. /**
  32345. * Sets the current performance log level
  32346. */
  32347. static PerformanceLogLevel: number;
  32348. private static _StartPerformanceCounterDisabled;
  32349. private static _EndPerformanceCounterDisabled;
  32350. private static _StartUserMark;
  32351. private static _EndUserMark;
  32352. private static _StartPerformanceConsole;
  32353. private static _EndPerformanceConsole;
  32354. /**
  32355. * Starts a performance counter
  32356. */
  32357. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32358. /**
  32359. * Ends a specific performance coutner
  32360. */
  32361. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32362. /**
  32363. * Gets either window.performance.now() if supported or Date.now() else
  32364. */
  32365. static readonly Now: number;
  32366. /**
  32367. * This method will return the name of the class used to create the instance of the given object.
  32368. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32369. * @param object the object to get the class name from
  32370. * @param isType defines if the object is actually a type
  32371. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32372. */
  32373. static GetClassName(object: any, isType?: boolean): string;
  32374. /**
  32375. * Gets the first element of an array satisfying a given predicate
  32376. * @param array defines the array to browse
  32377. * @param predicate defines the predicate to use
  32378. * @returns null if not found or the element
  32379. */
  32380. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32381. /**
  32382. * This method will return the name of the full name of the class, including its owning module (if any).
  32383. * 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).
  32384. * @param object the object to get the class name from
  32385. * @param isType defines if the object is actually a type
  32386. * @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.
  32387. * @ignorenaming
  32388. */
  32389. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32390. /**
  32391. * Returns a promise that resolves after the given amount of time.
  32392. * @param delay Number of milliseconds to delay
  32393. * @returns Promise that resolves after the given amount of time
  32394. */
  32395. static DelayAsync(delay: number): Promise<void>;
  32396. }
  32397. /**
  32398. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32399. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32400. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32401. * @param name The name of the class, case should be preserved
  32402. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32403. */
  32404. export function className(name: string, module?: string): (target: Object) => void;
  32405. /**
  32406. * An implementation of a loop for asynchronous functions.
  32407. */
  32408. export class AsyncLoop {
  32409. /**
  32410. * Defines the number of iterations for the loop
  32411. */
  32412. iterations: number;
  32413. /**
  32414. * Defines the current index of the loop.
  32415. */
  32416. index: number;
  32417. private _done;
  32418. private _fn;
  32419. private _successCallback;
  32420. /**
  32421. * Constructor.
  32422. * @param iterations the number of iterations.
  32423. * @param func the function to run each iteration
  32424. * @param successCallback the callback that will be called upon succesful execution
  32425. * @param offset starting offset.
  32426. */
  32427. constructor(
  32428. /**
  32429. * Defines the number of iterations for the loop
  32430. */
  32431. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32432. /**
  32433. * Execute the next iteration. Must be called after the last iteration was finished.
  32434. */
  32435. executeNext(): void;
  32436. /**
  32437. * Break the loop and run the success callback.
  32438. */
  32439. breakLoop(): void;
  32440. /**
  32441. * Create and run an async loop.
  32442. * @param iterations the number of iterations.
  32443. * @param fn the function to run each iteration
  32444. * @param successCallback the callback that will be called upon succesful execution
  32445. * @param offset starting offset.
  32446. * @returns the created async loop object
  32447. */
  32448. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32449. /**
  32450. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32451. * @param iterations total number of iterations
  32452. * @param syncedIterations number of synchronous iterations in each async iteration.
  32453. * @param fn the function to call each iteration.
  32454. * @param callback a success call back that will be called when iterating stops.
  32455. * @param breakFunction a break condition (optional)
  32456. * @param timeout timeout settings for the setTimeout function. default - 0.
  32457. * @returns the created async loop object
  32458. */
  32459. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32460. }
  32461. }
  32462. declare module BABYLON {
  32463. /**
  32464. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32465. * The underlying implementation relies on an associative array to ensure the best performances.
  32466. * The value can be anything including 'null' but except 'undefined'
  32467. */
  32468. export class StringDictionary<T> {
  32469. /**
  32470. * This will clear this dictionary and copy the content from the 'source' one.
  32471. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32472. * @param source the dictionary to take the content from and copy to this dictionary
  32473. */
  32474. copyFrom(source: StringDictionary<T>): void;
  32475. /**
  32476. * Get a value based from its key
  32477. * @param key the given key to get the matching value from
  32478. * @return the value if found, otherwise undefined is returned
  32479. */
  32480. get(key: string): T | undefined;
  32481. /**
  32482. * Get a value from its key or add it if it doesn't exist.
  32483. * This method will ensure you that a given key/data will be present in the dictionary.
  32484. * @param key the given key to get the matching value from
  32485. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32486. * The factory will only be invoked if there's no data for the given key.
  32487. * @return the value corresponding to the key.
  32488. */
  32489. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32490. /**
  32491. * Get a value from its key if present in the dictionary otherwise add it
  32492. * @param key the key to get the value from
  32493. * @param val if there's no such key/value pair in the dictionary add it with this value
  32494. * @return the value corresponding to the key
  32495. */
  32496. getOrAdd(key: string, val: T): T;
  32497. /**
  32498. * Check if there's a given key in the dictionary
  32499. * @param key the key to check for
  32500. * @return true if the key is present, false otherwise
  32501. */
  32502. contains(key: string): boolean;
  32503. /**
  32504. * Add a new key and its corresponding value
  32505. * @param key the key to add
  32506. * @param value the value corresponding to the key
  32507. * @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
  32508. */
  32509. add(key: string, value: T): boolean;
  32510. /**
  32511. * Update a specific value associated to a key
  32512. * @param key defines the key to use
  32513. * @param value defines the value to store
  32514. * @returns true if the value was updated (or false if the key was not found)
  32515. */
  32516. set(key: string, value: T): boolean;
  32517. /**
  32518. * Get the element of the given key and remove it from the dictionary
  32519. * @param key defines the key to search
  32520. * @returns the value associated with the key or null if not found
  32521. */
  32522. getAndRemove(key: string): Nullable<T>;
  32523. /**
  32524. * Remove a key/value from the dictionary.
  32525. * @param key the key to remove
  32526. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32527. */
  32528. remove(key: string): boolean;
  32529. /**
  32530. * Clear the whole content of the dictionary
  32531. */
  32532. clear(): void;
  32533. /**
  32534. * Gets the current count
  32535. */
  32536. readonly count: number;
  32537. /**
  32538. * Execute a callback on each key/val of the dictionary.
  32539. * Note that you can remove any element in this dictionary in the callback implementation
  32540. * @param callback the callback to execute on a given key/value pair
  32541. */
  32542. forEach(callback: (key: string, val: T) => void): void;
  32543. /**
  32544. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32545. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32546. * Note that you can remove any element in this dictionary in the callback implementation
  32547. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32548. * @returns the first item
  32549. */
  32550. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32551. private _count;
  32552. private _data;
  32553. }
  32554. }
  32555. declare module BABYLON {
  32556. /** @hidden */
  32557. export interface ICollisionCoordinator {
  32558. createCollider(): Collider;
  32559. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32560. init(scene: Scene): void;
  32561. }
  32562. /** @hidden */
  32563. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32564. private _scene;
  32565. private _scaledPosition;
  32566. private _scaledVelocity;
  32567. private _finalPosition;
  32568. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32569. createCollider(): Collider;
  32570. init(scene: Scene): void;
  32571. private _collideWithWorld;
  32572. }
  32573. }
  32574. declare module BABYLON {
  32575. /**
  32576. * Class used to manage all inputs for the scene.
  32577. */
  32578. export class InputManager {
  32579. /** The distance in pixel that you have to move to prevent some events */
  32580. static DragMovementThreshold: number;
  32581. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32582. static LongPressDelay: number;
  32583. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32584. static DoubleClickDelay: number;
  32585. /** If you need to check double click without raising a single click at first click, enable this flag */
  32586. static ExclusiveDoubleClickMode: boolean;
  32587. private _wheelEventName;
  32588. private _onPointerMove;
  32589. private _onPointerDown;
  32590. private _onPointerUp;
  32591. private _initClickEvent;
  32592. private _initActionManager;
  32593. private _delayedSimpleClick;
  32594. private _delayedSimpleClickTimeout;
  32595. private _previousDelayedSimpleClickTimeout;
  32596. private _meshPickProceed;
  32597. private _previousButtonPressed;
  32598. private _currentPickResult;
  32599. private _previousPickResult;
  32600. private _totalPointersPressed;
  32601. private _doubleClickOccured;
  32602. private _pointerOverMesh;
  32603. private _pickedDownMesh;
  32604. private _pickedUpMesh;
  32605. private _pointerX;
  32606. private _pointerY;
  32607. private _unTranslatedPointerX;
  32608. private _unTranslatedPointerY;
  32609. private _startingPointerPosition;
  32610. private _previousStartingPointerPosition;
  32611. private _startingPointerTime;
  32612. private _previousStartingPointerTime;
  32613. private _pointerCaptures;
  32614. private _onKeyDown;
  32615. private _onKeyUp;
  32616. private _onCanvasFocusObserver;
  32617. private _onCanvasBlurObserver;
  32618. private _scene;
  32619. /**
  32620. * Creates a new InputManager
  32621. * @param scene defines the hosting scene
  32622. */
  32623. constructor(scene: Scene);
  32624. /**
  32625. * Gets the mesh that is currently under the pointer
  32626. */
  32627. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32628. /**
  32629. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32630. */
  32631. readonly unTranslatedPointer: Vector2;
  32632. /**
  32633. * Gets or sets the current on-screen X position of the pointer
  32634. */
  32635. pointerX: number;
  32636. /**
  32637. * Gets or sets the current on-screen Y position of the pointer
  32638. */
  32639. pointerY: number;
  32640. private _updatePointerPosition;
  32641. private _processPointerMove;
  32642. private _setRayOnPointerInfo;
  32643. private _checkPrePointerObservable;
  32644. /**
  32645. * Use this method to simulate a pointer move on a mesh
  32646. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32647. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32648. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32649. */
  32650. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32651. /**
  32652. * Use this method to simulate a pointer down on a mesh
  32653. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32654. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32655. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32656. */
  32657. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32658. private _processPointerDown;
  32659. /** @hidden */
  32660. _isPointerSwiping(): boolean;
  32661. /**
  32662. * Use this method to simulate a pointer up on a mesh
  32663. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32664. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32665. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32666. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32667. */
  32668. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32669. private _processPointerUp;
  32670. /**
  32671. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32672. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32673. * @returns true if the pointer was captured
  32674. */
  32675. isPointerCaptured(pointerId?: number): boolean;
  32676. /**
  32677. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32678. * @param attachUp defines if you want to attach events to pointerup
  32679. * @param attachDown defines if you want to attach events to pointerdown
  32680. * @param attachMove defines if you want to attach events to pointermove
  32681. */
  32682. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32683. /**
  32684. * Detaches all event handlers
  32685. */
  32686. detachControl(): void;
  32687. /**
  32688. * Force the value of meshUnderPointer
  32689. * @param mesh defines the mesh to use
  32690. */
  32691. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32692. /**
  32693. * Gets the mesh under the pointer
  32694. * @returns a Mesh or null if no mesh is under the pointer
  32695. */
  32696. getPointerOverMesh(): Nullable<AbstractMesh>;
  32697. }
  32698. }
  32699. declare module BABYLON {
  32700. /**
  32701. * Helper class used to generate session unique ID
  32702. */
  32703. export class UniqueIdGenerator {
  32704. private static _UniqueIdCounter;
  32705. /**
  32706. * Gets an unique (relatively to the current scene) Id
  32707. */
  32708. static readonly UniqueId: number;
  32709. }
  32710. }
  32711. declare module BABYLON {
  32712. /**
  32713. * This class defines the direct association between an animation and a target
  32714. */
  32715. export class TargetedAnimation {
  32716. /**
  32717. * Animation to perform
  32718. */
  32719. animation: Animation;
  32720. /**
  32721. * Target to animate
  32722. */
  32723. target: any;
  32724. /**
  32725. * Serialize the object
  32726. * @returns the JSON object representing the current entity
  32727. */
  32728. serialize(): any;
  32729. }
  32730. /**
  32731. * Use this class to create coordinated animations on multiple targets
  32732. */
  32733. export class AnimationGroup implements IDisposable {
  32734. /** The name of the animation group */
  32735. name: string;
  32736. private _scene;
  32737. private _targetedAnimations;
  32738. private _animatables;
  32739. private _from;
  32740. private _to;
  32741. private _isStarted;
  32742. private _isPaused;
  32743. private _speedRatio;
  32744. private _loopAnimation;
  32745. /**
  32746. * Gets or sets the unique id of the node
  32747. */
  32748. uniqueId: number;
  32749. /**
  32750. * This observable will notify when one animation have ended
  32751. */
  32752. onAnimationEndObservable: Observable<TargetedAnimation>;
  32753. /**
  32754. * Observer raised when one animation loops
  32755. */
  32756. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32757. /**
  32758. * This observable will notify when all animations have ended.
  32759. */
  32760. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32761. /**
  32762. * This observable will notify when all animations have paused.
  32763. */
  32764. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32765. /**
  32766. * This observable will notify when all animations are playing.
  32767. */
  32768. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32769. /**
  32770. * Gets the first frame
  32771. */
  32772. readonly from: number;
  32773. /**
  32774. * Gets the last frame
  32775. */
  32776. readonly to: number;
  32777. /**
  32778. * Define if the animations are started
  32779. */
  32780. readonly isStarted: boolean;
  32781. /**
  32782. * Gets a value indicating that the current group is playing
  32783. */
  32784. readonly isPlaying: boolean;
  32785. /**
  32786. * Gets or sets the speed ratio to use for all animations
  32787. */
  32788. /**
  32789. * Gets or sets the speed ratio to use for all animations
  32790. */
  32791. speedRatio: number;
  32792. /**
  32793. * Gets or sets if all animations should loop or not
  32794. */
  32795. loopAnimation: boolean;
  32796. /**
  32797. * Gets the targeted animations for this animation group
  32798. */
  32799. readonly targetedAnimations: Array<TargetedAnimation>;
  32800. /**
  32801. * returning the list of animatables controlled by this animation group.
  32802. */
  32803. readonly animatables: Array<Animatable>;
  32804. /**
  32805. * Instantiates a new Animation Group.
  32806. * This helps managing several animations at once.
  32807. * @see http://doc.babylonjs.com/how_to/group
  32808. * @param name Defines the name of the group
  32809. * @param scene Defines the scene the group belongs to
  32810. */
  32811. constructor(
  32812. /** The name of the animation group */
  32813. name: string, scene?: Nullable<Scene>);
  32814. /**
  32815. * Add an animation (with its target) in the group
  32816. * @param animation defines the animation we want to add
  32817. * @param target defines the target of the animation
  32818. * @returns the TargetedAnimation object
  32819. */
  32820. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32821. /**
  32822. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32823. * It can add constant keys at begin or end
  32824. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32825. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32826. * @returns the animation group
  32827. */
  32828. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32829. /**
  32830. * Start all animations on given targets
  32831. * @param loop defines if animations must loop
  32832. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32833. * @param from defines the from key (optional)
  32834. * @param to defines the to key (optional)
  32835. * @returns the current animation group
  32836. */
  32837. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32838. /**
  32839. * Pause all animations
  32840. * @returns the animation group
  32841. */
  32842. pause(): AnimationGroup;
  32843. /**
  32844. * Play all animations to initial state
  32845. * This function will start() the animations if they were not started or will restart() them if they were paused
  32846. * @param loop defines if animations must loop
  32847. * @returns the animation group
  32848. */
  32849. play(loop?: boolean): AnimationGroup;
  32850. /**
  32851. * Reset all animations to initial state
  32852. * @returns the animation group
  32853. */
  32854. reset(): AnimationGroup;
  32855. /**
  32856. * Restart animations from key 0
  32857. * @returns the animation group
  32858. */
  32859. restart(): AnimationGroup;
  32860. /**
  32861. * Stop all animations
  32862. * @returns the animation group
  32863. */
  32864. stop(): AnimationGroup;
  32865. /**
  32866. * Set animation weight for all animatables
  32867. * @param weight defines the weight to use
  32868. * @return the animationGroup
  32869. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32870. */
  32871. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32872. /**
  32873. * Synchronize and normalize all animatables with a source animatable
  32874. * @param root defines the root animatable to synchronize with
  32875. * @return the animationGroup
  32876. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32877. */
  32878. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32879. /**
  32880. * Goes to a specific frame in this animation group
  32881. * @param frame the frame number to go to
  32882. * @return the animationGroup
  32883. */
  32884. goToFrame(frame: number): AnimationGroup;
  32885. /**
  32886. * Dispose all associated resources
  32887. */
  32888. dispose(): void;
  32889. private _checkAnimationGroupEnded;
  32890. /**
  32891. * Clone the current animation group and returns a copy
  32892. * @param newName defines the name of the new group
  32893. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32894. * @returns the new aniamtion group
  32895. */
  32896. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32897. /**
  32898. * Serializes the animationGroup to an object
  32899. * @returns Serialized object
  32900. */
  32901. serialize(): any;
  32902. /**
  32903. * Returns a new AnimationGroup object parsed from the source provided.
  32904. * @param parsedAnimationGroup defines the source
  32905. * @param scene defines the scene that will receive the animationGroup
  32906. * @returns a new AnimationGroup
  32907. */
  32908. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32909. /**
  32910. * Returns the string "AnimationGroup"
  32911. * @returns "AnimationGroup"
  32912. */
  32913. getClassName(): string;
  32914. /**
  32915. * Creates a detailled string about the object
  32916. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32917. * @returns a string representing the object
  32918. */
  32919. toString(fullDetails?: boolean): string;
  32920. }
  32921. }
  32922. declare module BABYLON {
  32923. /**
  32924. * Define an interface for all classes that will hold resources
  32925. */
  32926. export interface IDisposable {
  32927. /**
  32928. * Releases all held resources
  32929. */
  32930. dispose(): void;
  32931. }
  32932. /** Interface defining initialization parameters for Scene class */
  32933. export interface SceneOptions {
  32934. /**
  32935. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32936. * It will improve performance when the number of geometries becomes important.
  32937. */
  32938. useGeometryUniqueIdsMap?: boolean;
  32939. /**
  32940. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32941. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32942. */
  32943. useMaterialMeshMap?: boolean;
  32944. /**
  32945. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32946. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32947. */
  32948. useClonedMeshhMap?: boolean;
  32949. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32950. virtual?: boolean;
  32951. }
  32952. /**
  32953. * Represents a scene to be rendered by the engine.
  32954. * @see http://doc.babylonjs.com/features/scene
  32955. */
  32956. export class Scene extends AbstractScene implements IAnimatable {
  32957. /** The fog is deactivated */
  32958. static readonly FOGMODE_NONE: number;
  32959. /** The fog density is following an exponential function */
  32960. static readonly FOGMODE_EXP: number;
  32961. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32962. static readonly FOGMODE_EXP2: number;
  32963. /** The fog density is following a linear function. */
  32964. static readonly FOGMODE_LINEAR: number;
  32965. /**
  32966. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32967. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32968. */
  32969. static MinDeltaTime: number;
  32970. /**
  32971. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32972. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32973. */
  32974. static MaxDeltaTime: number;
  32975. /**
  32976. * Factory used to create the default material.
  32977. * @param name The name of the material to create
  32978. * @param scene The scene to create the material for
  32979. * @returns The default material
  32980. */
  32981. static DefaultMaterialFactory(scene: Scene): Material;
  32982. /**
  32983. * Factory used to create the a collision coordinator.
  32984. * @returns The collision coordinator
  32985. */
  32986. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32987. /** @hidden */
  32988. _inputManager: InputManager;
  32989. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32990. cameraToUseForPointers: Nullable<Camera>;
  32991. /** @hidden */
  32992. readonly _isScene: boolean;
  32993. /**
  32994. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32995. */
  32996. autoClear: boolean;
  32997. /**
  32998. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32999. */
  33000. autoClearDepthAndStencil: boolean;
  33001. /**
  33002. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33003. */
  33004. clearColor: Color4;
  33005. /**
  33006. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33007. */
  33008. ambientColor: Color3;
  33009. /**
  33010. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33011. * It should only be one of the following (if not the default embedded one):
  33012. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33013. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33014. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33015. * The material properties need to be setup according to the type of texture in use.
  33016. */
  33017. environmentBRDFTexture: BaseTexture;
  33018. /** @hidden */
  33019. protected _environmentTexture: Nullable<BaseTexture>;
  33020. /**
  33021. * Texture used in all pbr material as the reflection texture.
  33022. * As in the majority of the scene they are the same (exception for multi room and so on),
  33023. * this is easier to reference from here than from all the materials.
  33024. */
  33025. /**
  33026. * Texture used in all pbr material as the reflection texture.
  33027. * As in the majority of the scene they are the same (exception for multi room and so on),
  33028. * this is easier to set here than in all the materials.
  33029. */
  33030. environmentTexture: Nullable<BaseTexture>;
  33031. /** @hidden */
  33032. protected _environmentIntensity: number;
  33033. /**
  33034. * Intensity of the environment in all pbr material.
  33035. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33036. * As in the majority of the scene they are the same (exception for multi room and so on),
  33037. * this is easier to reference from here than from all the materials.
  33038. */
  33039. /**
  33040. * Intensity of the environment in all pbr material.
  33041. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33042. * As in the majority of the scene they are the same (exception for multi room and so on),
  33043. * this is easier to set here than in all the materials.
  33044. */
  33045. environmentIntensity: number;
  33046. /** @hidden */
  33047. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33048. /**
  33049. * Default image processing configuration used either in the rendering
  33050. * Forward main pass or through the imageProcessingPostProcess if present.
  33051. * As in the majority of the scene they are the same (exception for multi camera),
  33052. * this is easier to reference from here than from all the materials and post process.
  33053. *
  33054. * No setter as we it is a shared configuration, you can set the values instead.
  33055. */
  33056. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33057. private _forceWireframe;
  33058. /**
  33059. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33060. */
  33061. forceWireframe: boolean;
  33062. private _forcePointsCloud;
  33063. /**
  33064. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33065. */
  33066. forcePointsCloud: boolean;
  33067. /**
  33068. * Gets or sets the active clipplane 1
  33069. */
  33070. clipPlane: Nullable<Plane>;
  33071. /**
  33072. * Gets or sets the active clipplane 2
  33073. */
  33074. clipPlane2: Nullable<Plane>;
  33075. /**
  33076. * Gets or sets the active clipplane 3
  33077. */
  33078. clipPlane3: Nullable<Plane>;
  33079. /**
  33080. * Gets or sets the active clipplane 4
  33081. */
  33082. clipPlane4: Nullable<Plane>;
  33083. /**
  33084. * Gets or sets a boolean indicating if animations are enabled
  33085. */
  33086. animationsEnabled: boolean;
  33087. private _animationPropertiesOverride;
  33088. /**
  33089. * Gets or sets the animation properties override
  33090. */
  33091. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33092. /**
  33093. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33094. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33095. */
  33096. useConstantAnimationDeltaTime: boolean;
  33097. /**
  33098. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33099. * Please note that it requires to run a ray cast through the scene on every frame
  33100. */
  33101. constantlyUpdateMeshUnderPointer: boolean;
  33102. /**
  33103. * Defines the HTML cursor to use when hovering over interactive elements
  33104. */
  33105. hoverCursor: string;
  33106. /**
  33107. * Defines the HTML default cursor to use (empty by default)
  33108. */
  33109. defaultCursor: string;
  33110. /**
  33111. * This is used to call preventDefault() on pointer down
  33112. * in order to block unwanted artifacts like system double clicks
  33113. */
  33114. preventDefaultOnPointerDown: boolean;
  33115. /**
  33116. * This is used to call preventDefault() on pointer up
  33117. * in order to block unwanted artifacts like system double clicks
  33118. */
  33119. preventDefaultOnPointerUp: boolean;
  33120. /**
  33121. * Gets or sets user defined metadata
  33122. */
  33123. metadata: any;
  33124. /**
  33125. * For internal use only. Please do not use.
  33126. */
  33127. reservedDataStore: any;
  33128. /**
  33129. * Gets the name of the plugin used to load this scene (null by default)
  33130. */
  33131. loadingPluginName: string;
  33132. /**
  33133. * Use this array to add regular expressions used to disable offline support for specific urls
  33134. */
  33135. disableOfflineSupportExceptionRules: RegExp[];
  33136. /**
  33137. * An event triggered when the scene is disposed.
  33138. */
  33139. onDisposeObservable: Observable<Scene>;
  33140. private _onDisposeObserver;
  33141. /** Sets a function to be executed when this scene is disposed. */
  33142. onDispose: () => void;
  33143. /**
  33144. * An event triggered before rendering the scene (right after animations and physics)
  33145. */
  33146. onBeforeRenderObservable: Observable<Scene>;
  33147. private _onBeforeRenderObserver;
  33148. /** Sets a function to be executed before rendering this scene */
  33149. beforeRender: Nullable<() => void>;
  33150. /**
  33151. * An event triggered after rendering the scene
  33152. */
  33153. onAfterRenderObservable: Observable<Scene>;
  33154. /**
  33155. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33156. */
  33157. onAfterRenderCameraObservable: Observable<Camera>;
  33158. private _onAfterRenderObserver;
  33159. /** Sets a function to be executed after rendering this scene */
  33160. afterRender: Nullable<() => void>;
  33161. /**
  33162. * An event triggered before animating the scene
  33163. */
  33164. onBeforeAnimationsObservable: Observable<Scene>;
  33165. /**
  33166. * An event triggered after animations processing
  33167. */
  33168. onAfterAnimationsObservable: Observable<Scene>;
  33169. /**
  33170. * An event triggered before draw calls are ready to be sent
  33171. */
  33172. onBeforeDrawPhaseObservable: Observable<Scene>;
  33173. /**
  33174. * An event triggered after draw calls have been sent
  33175. */
  33176. onAfterDrawPhaseObservable: Observable<Scene>;
  33177. /**
  33178. * An event triggered when the scene is ready
  33179. */
  33180. onReadyObservable: Observable<Scene>;
  33181. /**
  33182. * An event triggered before rendering a camera
  33183. */
  33184. onBeforeCameraRenderObservable: Observable<Camera>;
  33185. private _onBeforeCameraRenderObserver;
  33186. /** Sets a function to be executed before rendering a camera*/
  33187. beforeCameraRender: () => void;
  33188. /**
  33189. * An event triggered after rendering a camera
  33190. */
  33191. onAfterCameraRenderObservable: Observable<Camera>;
  33192. private _onAfterCameraRenderObserver;
  33193. /** Sets a function to be executed after rendering a camera*/
  33194. afterCameraRender: () => void;
  33195. /**
  33196. * An event triggered when active meshes evaluation is about to start
  33197. */
  33198. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33199. /**
  33200. * An event triggered when active meshes evaluation is done
  33201. */
  33202. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33203. /**
  33204. * An event triggered when particles rendering is about to start
  33205. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33206. */
  33207. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33208. /**
  33209. * An event triggered when particles rendering is done
  33210. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33211. */
  33212. onAfterParticlesRenderingObservable: Observable<Scene>;
  33213. /**
  33214. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33215. */
  33216. onDataLoadedObservable: Observable<Scene>;
  33217. /**
  33218. * An event triggered when a camera is created
  33219. */
  33220. onNewCameraAddedObservable: Observable<Camera>;
  33221. /**
  33222. * An event triggered when a camera is removed
  33223. */
  33224. onCameraRemovedObservable: Observable<Camera>;
  33225. /**
  33226. * An event triggered when a light is created
  33227. */
  33228. onNewLightAddedObservable: Observable<Light>;
  33229. /**
  33230. * An event triggered when a light is removed
  33231. */
  33232. onLightRemovedObservable: Observable<Light>;
  33233. /**
  33234. * An event triggered when a geometry is created
  33235. */
  33236. onNewGeometryAddedObservable: Observable<Geometry>;
  33237. /**
  33238. * An event triggered when a geometry is removed
  33239. */
  33240. onGeometryRemovedObservable: Observable<Geometry>;
  33241. /**
  33242. * An event triggered when a transform node is created
  33243. */
  33244. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33245. /**
  33246. * An event triggered when a transform node is removed
  33247. */
  33248. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33249. /**
  33250. * An event triggered when a mesh is created
  33251. */
  33252. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33253. /**
  33254. * An event triggered when a mesh is removed
  33255. */
  33256. onMeshRemovedObservable: Observable<AbstractMesh>;
  33257. /**
  33258. * An event triggered when a skeleton is created
  33259. */
  33260. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33261. /**
  33262. * An event triggered when a skeleton is removed
  33263. */
  33264. onSkeletonRemovedObservable: Observable<Skeleton>;
  33265. /**
  33266. * An event triggered when a material is created
  33267. */
  33268. onNewMaterialAddedObservable: Observable<Material>;
  33269. /**
  33270. * An event triggered when a material is removed
  33271. */
  33272. onMaterialRemovedObservable: Observable<Material>;
  33273. /**
  33274. * An event triggered when a texture is created
  33275. */
  33276. onNewTextureAddedObservable: Observable<BaseTexture>;
  33277. /**
  33278. * An event triggered when a texture is removed
  33279. */
  33280. onTextureRemovedObservable: Observable<BaseTexture>;
  33281. /**
  33282. * An event triggered when render targets are about to be rendered
  33283. * Can happen multiple times per frame.
  33284. */
  33285. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33286. /**
  33287. * An event triggered when render targets were rendered.
  33288. * Can happen multiple times per frame.
  33289. */
  33290. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33291. /**
  33292. * An event triggered before calculating deterministic simulation step
  33293. */
  33294. onBeforeStepObservable: Observable<Scene>;
  33295. /**
  33296. * An event triggered after calculating deterministic simulation step
  33297. */
  33298. onAfterStepObservable: Observable<Scene>;
  33299. /**
  33300. * An event triggered when the activeCamera property is updated
  33301. */
  33302. onActiveCameraChanged: Observable<Scene>;
  33303. /**
  33304. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33305. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33306. * 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)
  33307. */
  33308. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33309. /**
  33310. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33311. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33312. * 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)
  33313. */
  33314. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33315. /**
  33316. * This Observable will when a mesh has been imported into the scene.
  33317. */
  33318. onMeshImportedObservable: Observable<AbstractMesh>;
  33319. /**
  33320. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33321. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33322. */
  33323. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33324. /** @hidden */
  33325. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33326. /**
  33327. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33328. */
  33329. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33330. /**
  33331. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33332. */
  33333. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33334. /**
  33335. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33336. */
  33337. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33338. /** Callback called when a pointer move is detected */
  33339. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33340. /** Callback called when a pointer down is detected */
  33341. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33342. /** Callback called when a pointer up is detected */
  33343. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33344. /** Callback called when a pointer pick is detected */
  33345. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33346. /**
  33347. * 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).
  33348. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33349. */
  33350. onPrePointerObservable: Observable<PointerInfoPre>;
  33351. /**
  33352. * Observable event triggered each time an input event is received from the rendering canvas
  33353. */
  33354. onPointerObservable: Observable<PointerInfo>;
  33355. /**
  33356. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33357. */
  33358. readonly unTranslatedPointer: Vector2;
  33359. /**
  33360. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33361. */
  33362. static DragMovementThreshold: number;
  33363. /**
  33364. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33365. */
  33366. static LongPressDelay: number;
  33367. /**
  33368. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33369. */
  33370. static DoubleClickDelay: number;
  33371. /** If you need to check double click without raising a single click at first click, enable this flag */
  33372. static ExclusiveDoubleClickMode: boolean;
  33373. /** @hidden */
  33374. _mirroredCameraPosition: Nullable<Vector3>;
  33375. /**
  33376. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33377. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33378. */
  33379. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33380. /**
  33381. * Observable event triggered each time an keyboard event is received from the hosting window
  33382. */
  33383. onKeyboardObservable: Observable<KeyboardInfo>;
  33384. private _useRightHandedSystem;
  33385. /**
  33386. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33387. */
  33388. useRightHandedSystem: boolean;
  33389. private _timeAccumulator;
  33390. private _currentStepId;
  33391. private _currentInternalStep;
  33392. /**
  33393. * Sets the step Id used by deterministic lock step
  33394. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33395. * @param newStepId defines the step Id
  33396. */
  33397. setStepId(newStepId: number): void;
  33398. /**
  33399. * Gets the step Id used by deterministic lock step
  33400. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33401. * @returns the step Id
  33402. */
  33403. getStepId(): number;
  33404. /**
  33405. * Gets the internal step used by deterministic lock step
  33406. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33407. * @returns the internal step
  33408. */
  33409. getInternalStep(): number;
  33410. private _fogEnabled;
  33411. /**
  33412. * Gets or sets a boolean indicating if fog is enabled on this scene
  33413. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33414. * (Default is true)
  33415. */
  33416. fogEnabled: boolean;
  33417. private _fogMode;
  33418. /**
  33419. * Gets or sets the fog mode to use
  33420. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33421. * | mode | value |
  33422. * | --- | --- |
  33423. * | FOGMODE_NONE | 0 |
  33424. * | FOGMODE_EXP | 1 |
  33425. * | FOGMODE_EXP2 | 2 |
  33426. * | FOGMODE_LINEAR | 3 |
  33427. */
  33428. fogMode: number;
  33429. /**
  33430. * Gets or sets the fog color to use
  33431. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33432. * (Default is Color3(0.2, 0.2, 0.3))
  33433. */
  33434. fogColor: Color3;
  33435. /**
  33436. * Gets or sets the fog density to use
  33437. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33438. * (Default is 0.1)
  33439. */
  33440. fogDensity: number;
  33441. /**
  33442. * Gets or sets the fog start distance to use
  33443. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33444. * (Default is 0)
  33445. */
  33446. fogStart: number;
  33447. /**
  33448. * Gets or sets the fog end distance to use
  33449. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33450. * (Default is 1000)
  33451. */
  33452. fogEnd: number;
  33453. private _shadowsEnabled;
  33454. /**
  33455. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33456. */
  33457. shadowsEnabled: boolean;
  33458. private _lightsEnabled;
  33459. /**
  33460. * Gets or sets a boolean indicating if lights are enabled on this scene
  33461. */
  33462. lightsEnabled: boolean;
  33463. /** All of the active cameras added to this scene. */
  33464. activeCameras: Camera[];
  33465. /** @hidden */
  33466. _activeCamera: Nullable<Camera>;
  33467. /** Gets or sets the current active camera */
  33468. activeCamera: Nullable<Camera>;
  33469. private _defaultMaterial;
  33470. /** The default material used on meshes when no material is affected */
  33471. /** The default material used on meshes when no material is affected */
  33472. defaultMaterial: Material;
  33473. private _texturesEnabled;
  33474. /**
  33475. * Gets or sets a boolean indicating if textures are enabled on this scene
  33476. */
  33477. texturesEnabled: boolean;
  33478. /**
  33479. * Gets or sets a boolean indicating if particles are enabled on this scene
  33480. */
  33481. particlesEnabled: boolean;
  33482. /**
  33483. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33484. */
  33485. spritesEnabled: boolean;
  33486. private _skeletonsEnabled;
  33487. /**
  33488. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33489. */
  33490. skeletonsEnabled: boolean;
  33491. /**
  33492. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33493. */
  33494. lensFlaresEnabled: boolean;
  33495. /**
  33496. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33497. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33498. */
  33499. collisionsEnabled: boolean;
  33500. private _collisionCoordinator;
  33501. /** @hidden */
  33502. readonly collisionCoordinator: ICollisionCoordinator;
  33503. /**
  33504. * Defines the gravity applied to this scene (used only for collisions)
  33505. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33506. */
  33507. gravity: Vector3;
  33508. /**
  33509. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33510. */
  33511. postProcessesEnabled: boolean;
  33512. /**
  33513. * The list of postprocesses added to the scene
  33514. */
  33515. postProcesses: PostProcess[];
  33516. /**
  33517. * Gets the current postprocess manager
  33518. */
  33519. postProcessManager: PostProcessManager;
  33520. /**
  33521. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33522. */
  33523. renderTargetsEnabled: boolean;
  33524. /**
  33525. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33526. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33527. */
  33528. dumpNextRenderTargets: boolean;
  33529. /**
  33530. * The list of user defined render targets added to the scene
  33531. */
  33532. customRenderTargets: RenderTargetTexture[];
  33533. /**
  33534. * Defines if texture loading must be delayed
  33535. * If true, textures will only be loaded when they need to be rendered
  33536. */
  33537. useDelayedTextureLoading: boolean;
  33538. /**
  33539. * Gets the list of meshes imported to the scene through SceneLoader
  33540. */
  33541. importedMeshesFiles: String[];
  33542. /**
  33543. * Gets or sets a boolean indicating if probes are enabled on this scene
  33544. */
  33545. probesEnabled: boolean;
  33546. /**
  33547. * Gets or sets the current offline provider to use to store scene data
  33548. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33549. */
  33550. offlineProvider: IOfflineProvider;
  33551. /**
  33552. * Gets or sets the action manager associated with the scene
  33553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33554. */
  33555. actionManager: AbstractActionManager;
  33556. private _meshesForIntersections;
  33557. /**
  33558. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33559. */
  33560. proceduralTexturesEnabled: boolean;
  33561. private _engine;
  33562. private _totalVertices;
  33563. /** @hidden */
  33564. _activeIndices: PerfCounter;
  33565. /** @hidden */
  33566. _activeParticles: PerfCounter;
  33567. /** @hidden */
  33568. _activeBones: PerfCounter;
  33569. private _animationRatio;
  33570. /** @hidden */
  33571. _animationTimeLast: number;
  33572. /** @hidden */
  33573. _animationTime: number;
  33574. /**
  33575. * Gets or sets a general scale for animation speed
  33576. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33577. */
  33578. animationTimeScale: number;
  33579. /** @hidden */
  33580. _cachedMaterial: Nullable<Material>;
  33581. /** @hidden */
  33582. _cachedEffect: Nullable<Effect>;
  33583. /** @hidden */
  33584. _cachedVisibility: Nullable<number>;
  33585. private _renderId;
  33586. private _frameId;
  33587. private _executeWhenReadyTimeoutId;
  33588. private _intermediateRendering;
  33589. private _viewUpdateFlag;
  33590. private _projectionUpdateFlag;
  33591. /** @hidden */
  33592. _toBeDisposed: Nullable<IDisposable>[];
  33593. private _activeRequests;
  33594. /** @hidden */
  33595. _pendingData: any[];
  33596. private _isDisposed;
  33597. /**
  33598. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33599. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33600. */
  33601. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33602. private _activeMeshes;
  33603. private _processedMaterials;
  33604. private _renderTargets;
  33605. /** @hidden */
  33606. _activeParticleSystems: SmartArray<IParticleSystem>;
  33607. private _activeSkeletons;
  33608. private _softwareSkinnedMeshes;
  33609. private _renderingManager;
  33610. /** @hidden */
  33611. _activeAnimatables: Animatable[];
  33612. private _transformMatrix;
  33613. private _sceneUbo;
  33614. /** @hidden */
  33615. _viewMatrix: Matrix;
  33616. private _projectionMatrix;
  33617. /** @hidden */
  33618. _forcedViewPosition: Nullable<Vector3>;
  33619. /** @hidden */
  33620. _frustumPlanes: Plane[];
  33621. /**
  33622. * Gets the list of frustum planes (built from the active camera)
  33623. */
  33624. readonly frustumPlanes: Plane[];
  33625. /**
  33626. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33627. * This is useful if there are more lights that the maximum simulteanous authorized
  33628. */
  33629. requireLightSorting: boolean;
  33630. /** @hidden */
  33631. readonly useMaterialMeshMap: boolean;
  33632. /** @hidden */
  33633. readonly useClonedMeshhMap: boolean;
  33634. private _externalData;
  33635. private _uid;
  33636. /**
  33637. * @hidden
  33638. * Backing store of defined scene components.
  33639. */
  33640. _components: ISceneComponent[];
  33641. /**
  33642. * @hidden
  33643. * Backing store of defined scene components.
  33644. */
  33645. _serializableComponents: ISceneSerializableComponent[];
  33646. /**
  33647. * List of components to register on the next registration step.
  33648. */
  33649. private _transientComponents;
  33650. /**
  33651. * Registers the transient components if needed.
  33652. */
  33653. private _registerTransientComponents;
  33654. /**
  33655. * @hidden
  33656. * Add a component to the scene.
  33657. * Note that the ccomponent could be registered on th next frame if this is called after
  33658. * the register component stage.
  33659. * @param component Defines the component to add to the scene
  33660. */
  33661. _addComponent(component: ISceneComponent): void;
  33662. /**
  33663. * @hidden
  33664. * Gets a component from the scene.
  33665. * @param name defines the name of the component to retrieve
  33666. * @returns the component or null if not present
  33667. */
  33668. _getComponent(name: string): Nullable<ISceneComponent>;
  33669. /**
  33670. * @hidden
  33671. * Defines the actions happening before camera updates.
  33672. */
  33673. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33674. /**
  33675. * @hidden
  33676. * Defines the actions happening before clear the canvas.
  33677. */
  33678. _beforeClearStage: Stage<SimpleStageAction>;
  33679. /**
  33680. * @hidden
  33681. * Defines the actions when collecting render targets for the frame.
  33682. */
  33683. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33684. /**
  33685. * @hidden
  33686. * Defines the actions happening for one camera in the frame.
  33687. */
  33688. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33689. /**
  33690. * @hidden
  33691. * Defines the actions happening during the per mesh ready checks.
  33692. */
  33693. _isReadyForMeshStage: Stage<MeshStageAction>;
  33694. /**
  33695. * @hidden
  33696. * Defines the actions happening before evaluate active mesh checks.
  33697. */
  33698. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33699. /**
  33700. * @hidden
  33701. * Defines the actions happening during the evaluate sub mesh checks.
  33702. */
  33703. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33704. /**
  33705. * @hidden
  33706. * Defines the actions happening during the active mesh stage.
  33707. */
  33708. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33709. /**
  33710. * @hidden
  33711. * Defines the actions happening during the per camera render target step.
  33712. */
  33713. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33714. /**
  33715. * @hidden
  33716. * Defines the actions happening just before the active camera is drawing.
  33717. */
  33718. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33719. /**
  33720. * @hidden
  33721. * Defines the actions happening just before a render target is drawing.
  33722. */
  33723. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33724. /**
  33725. * @hidden
  33726. * Defines the actions happening just before a rendering group is drawing.
  33727. */
  33728. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33729. /**
  33730. * @hidden
  33731. * Defines the actions happening just before a mesh is drawing.
  33732. */
  33733. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33734. /**
  33735. * @hidden
  33736. * Defines the actions happening just after a mesh has been drawn.
  33737. */
  33738. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33739. /**
  33740. * @hidden
  33741. * Defines the actions happening just after a rendering group has been drawn.
  33742. */
  33743. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33744. /**
  33745. * @hidden
  33746. * Defines the actions happening just after the active camera has been drawn.
  33747. */
  33748. _afterCameraDrawStage: Stage<CameraStageAction>;
  33749. /**
  33750. * @hidden
  33751. * Defines the actions happening just after a render target has been drawn.
  33752. */
  33753. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33754. /**
  33755. * @hidden
  33756. * Defines the actions happening just after rendering all cameras and computing intersections.
  33757. */
  33758. _afterRenderStage: Stage<SimpleStageAction>;
  33759. /**
  33760. * @hidden
  33761. * Defines the actions happening when a pointer move event happens.
  33762. */
  33763. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33764. /**
  33765. * @hidden
  33766. * Defines the actions happening when a pointer down event happens.
  33767. */
  33768. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33769. /**
  33770. * @hidden
  33771. * Defines the actions happening when a pointer up event happens.
  33772. */
  33773. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33774. /**
  33775. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33776. */
  33777. private geometriesByUniqueId;
  33778. /**
  33779. * Creates a new Scene
  33780. * @param engine defines the engine to use to render this scene
  33781. * @param options defines the scene options
  33782. */
  33783. constructor(engine: Engine, options?: SceneOptions);
  33784. /**
  33785. * Gets a string idenfifying the name of the class
  33786. * @returns "Scene" string
  33787. */
  33788. getClassName(): string;
  33789. private _defaultMeshCandidates;
  33790. /**
  33791. * @hidden
  33792. */
  33793. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33794. private _defaultSubMeshCandidates;
  33795. /**
  33796. * @hidden
  33797. */
  33798. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33799. /**
  33800. * Sets the default candidate providers for the scene.
  33801. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33802. * and getCollidingSubMeshCandidates to their default function
  33803. */
  33804. setDefaultCandidateProviders(): void;
  33805. /**
  33806. * Gets the mesh that is currently under the pointer
  33807. */
  33808. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33809. /**
  33810. * Gets or sets the current on-screen X position of the pointer
  33811. */
  33812. pointerX: number;
  33813. /**
  33814. * Gets or sets the current on-screen Y position of the pointer
  33815. */
  33816. pointerY: number;
  33817. /**
  33818. * Gets the cached material (ie. the latest rendered one)
  33819. * @returns the cached material
  33820. */
  33821. getCachedMaterial(): Nullable<Material>;
  33822. /**
  33823. * Gets the cached effect (ie. the latest rendered one)
  33824. * @returns the cached effect
  33825. */
  33826. getCachedEffect(): Nullable<Effect>;
  33827. /**
  33828. * Gets the cached visibility state (ie. the latest rendered one)
  33829. * @returns the cached visibility state
  33830. */
  33831. getCachedVisibility(): Nullable<number>;
  33832. /**
  33833. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33834. * @param material defines the current material
  33835. * @param effect defines the current effect
  33836. * @param visibility defines the current visibility state
  33837. * @returns true if one parameter is not cached
  33838. */
  33839. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33840. /**
  33841. * Gets the engine associated with the scene
  33842. * @returns an Engine
  33843. */
  33844. getEngine(): Engine;
  33845. /**
  33846. * Gets the total number of vertices rendered per frame
  33847. * @returns the total number of vertices rendered per frame
  33848. */
  33849. getTotalVertices(): number;
  33850. /**
  33851. * Gets the performance counter for total vertices
  33852. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33853. */
  33854. readonly totalVerticesPerfCounter: PerfCounter;
  33855. /**
  33856. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33857. * @returns the total number of active indices rendered per frame
  33858. */
  33859. getActiveIndices(): number;
  33860. /**
  33861. * Gets the performance counter for active indices
  33862. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33863. */
  33864. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33865. /**
  33866. * Gets the total number of active particles rendered per frame
  33867. * @returns the total number of active particles rendered per frame
  33868. */
  33869. getActiveParticles(): number;
  33870. /**
  33871. * Gets the performance counter for active particles
  33872. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33873. */
  33874. readonly activeParticlesPerfCounter: PerfCounter;
  33875. /**
  33876. * Gets the total number of active bones rendered per frame
  33877. * @returns the total number of active bones rendered per frame
  33878. */
  33879. getActiveBones(): number;
  33880. /**
  33881. * Gets the performance counter for active bones
  33882. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33883. */
  33884. readonly activeBonesPerfCounter: PerfCounter;
  33885. /**
  33886. * Gets the array of active meshes
  33887. * @returns an array of AbstractMesh
  33888. */
  33889. getActiveMeshes(): SmartArray<AbstractMesh>;
  33890. /**
  33891. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33892. * @returns a number
  33893. */
  33894. getAnimationRatio(): number;
  33895. /**
  33896. * Gets an unique Id for the current render phase
  33897. * @returns a number
  33898. */
  33899. getRenderId(): number;
  33900. /**
  33901. * Gets an unique Id for the current frame
  33902. * @returns a number
  33903. */
  33904. getFrameId(): number;
  33905. /** Call this function if you want to manually increment the render Id*/
  33906. incrementRenderId(): void;
  33907. private _createUbo;
  33908. /**
  33909. * Use this method to simulate a pointer move on a mesh
  33910. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33911. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33912. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33913. * @returns the current scene
  33914. */
  33915. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33916. /**
  33917. * Use this method to simulate a pointer down 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. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33924. /**
  33925. * Use this method to simulate a pointer up 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. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33930. * @returns the current scene
  33931. */
  33932. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33933. /**
  33934. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33935. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33936. * @returns true if the pointer was captured
  33937. */
  33938. isPointerCaptured(pointerId?: number): boolean;
  33939. /**
  33940. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33941. * @param attachUp defines if you want to attach events to pointerup
  33942. * @param attachDown defines if you want to attach events to pointerdown
  33943. * @param attachMove defines if you want to attach events to pointermove
  33944. */
  33945. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33946. /** Detaches all event handlers*/
  33947. detachControl(): void;
  33948. /**
  33949. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33950. * Delay loaded resources are not taking in account
  33951. * @return true if all required resources are ready
  33952. */
  33953. isReady(): boolean;
  33954. /** Resets all cached information relative to material (including effect and visibility) */
  33955. resetCachedMaterial(): void;
  33956. /**
  33957. * Registers a function to be called before every frame render
  33958. * @param func defines the function to register
  33959. */
  33960. registerBeforeRender(func: () => void): void;
  33961. /**
  33962. * Unregisters a function called before every frame render
  33963. * @param func defines the function to unregister
  33964. */
  33965. unregisterBeforeRender(func: () => void): void;
  33966. /**
  33967. * Registers a function to be called after every frame render
  33968. * @param func defines the function to register
  33969. */
  33970. registerAfterRender(func: () => void): void;
  33971. /**
  33972. * Unregisters a function called after every frame render
  33973. * @param func defines the function to unregister
  33974. */
  33975. unregisterAfterRender(func: () => void): void;
  33976. private _executeOnceBeforeRender;
  33977. /**
  33978. * The provided function will run before render once and will be disposed afterwards.
  33979. * A timeout delay can be provided so that the function will be executed in N ms.
  33980. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33981. * @param func The function to be executed.
  33982. * @param timeout optional delay in ms
  33983. */
  33984. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33985. /** @hidden */
  33986. _addPendingData(data: any): void;
  33987. /** @hidden */
  33988. _removePendingData(data: any): void;
  33989. /**
  33990. * Returns the number of items waiting to be loaded
  33991. * @returns the number of items waiting to be loaded
  33992. */
  33993. getWaitingItemsCount(): number;
  33994. /**
  33995. * Returns a boolean indicating if the scene is still loading data
  33996. */
  33997. readonly isLoading: boolean;
  33998. /**
  33999. * Registers a function to be executed when the scene is ready
  34000. * @param {Function} func - the function to be executed
  34001. */
  34002. executeWhenReady(func: () => void): void;
  34003. /**
  34004. * Returns a promise that resolves when the scene is ready
  34005. * @returns A promise that resolves when the scene is ready
  34006. */
  34007. whenReadyAsync(): Promise<void>;
  34008. /** @hidden */
  34009. _checkIsReady(): void;
  34010. /**
  34011. * Gets all animatable attached to the scene
  34012. */
  34013. readonly animatables: Animatable[];
  34014. /**
  34015. * Resets the last animation time frame.
  34016. * Useful to override when animations start running when loading a scene for the first time.
  34017. */
  34018. resetLastAnimationTimeFrame(): void;
  34019. /**
  34020. * Gets the current view matrix
  34021. * @returns a Matrix
  34022. */
  34023. getViewMatrix(): Matrix;
  34024. /**
  34025. * Gets the current projection matrix
  34026. * @returns a Matrix
  34027. */
  34028. getProjectionMatrix(): Matrix;
  34029. /**
  34030. * Gets the current transform matrix
  34031. * @returns a Matrix made of View * Projection
  34032. */
  34033. getTransformMatrix(): Matrix;
  34034. /**
  34035. * Sets the current transform matrix
  34036. * @param viewL defines the View matrix to use
  34037. * @param projectionL defines the Projection matrix to use
  34038. * @param viewR defines the right View matrix to use (if provided)
  34039. * @param projectionR defines the right Projection matrix to use (if provided)
  34040. */
  34041. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34042. /**
  34043. * Gets the uniform buffer used to store scene data
  34044. * @returns a UniformBuffer
  34045. */
  34046. getSceneUniformBuffer(): UniformBuffer;
  34047. /**
  34048. * Gets an unique (relatively to the current scene) Id
  34049. * @returns an unique number for the scene
  34050. */
  34051. getUniqueId(): number;
  34052. /**
  34053. * Add a mesh to the list of scene's meshes
  34054. * @param newMesh defines the mesh to add
  34055. * @param recursive if all child meshes should also be added to the scene
  34056. */
  34057. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34058. /**
  34059. * Remove a mesh for the list of scene's meshes
  34060. * @param toRemove defines the mesh to remove
  34061. * @param recursive if all child meshes should also be removed from the scene
  34062. * @returns the index where the mesh was in the mesh list
  34063. */
  34064. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34065. /**
  34066. * Add a transform node to the list of scene's transform nodes
  34067. * @param newTransformNode defines the transform node to add
  34068. */
  34069. addTransformNode(newTransformNode: TransformNode): void;
  34070. /**
  34071. * Remove a transform node for the list of scene's transform nodes
  34072. * @param toRemove defines the transform node to remove
  34073. * @returns the index where the transform node was in the transform node list
  34074. */
  34075. removeTransformNode(toRemove: TransformNode): number;
  34076. /**
  34077. * Remove a skeleton for the list of scene's skeletons
  34078. * @param toRemove defines the skeleton to remove
  34079. * @returns the index where the skeleton was in the skeleton list
  34080. */
  34081. removeSkeleton(toRemove: Skeleton): number;
  34082. /**
  34083. * Remove a morph target for the list of scene's morph targets
  34084. * @param toRemove defines the morph target to remove
  34085. * @returns the index where the morph target was in the morph target list
  34086. */
  34087. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34088. /**
  34089. * Remove a light for the list of scene's lights
  34090. * @param toRemove defines the light to remove
  34091. * @returns the index where the light was in the light list
  34092. */
  34093. removeLight(toRemove: Light): number;
  34094. /**
  34095. * Remove a camera for the list of scene's cameras
  34096. * @param toRemove defines the camera to remove
  34097. * @returns the index where the camera was in the camera list
  34098. */
  34099. removeCamera(toRemove: Camera): number;
  34100. /**
  34101. * Remove a particle system for the list of scene's particle systems
  34102. * @param toRemove defines the particle system to remove
  34103. * @returns the index where the particle system was in the particle system list
  34104. */
  34105. removeParticleSystem(toRemove: IParticleSystem): number;
  34106. /**
  34107. * Remove a animation for the list of scene's animations
  34108. * @param toRemove defines the animation to remove
  34109. * @returns the index where the animation was in the animation list
  34110. */
  34111. removeAnimation(toRemove: Animation): number;
  34112. /**
  34113. * Will stop the animation of the given target
  34114. * @param target - the target
  34115. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34116. * @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)
  34117. */
  34118. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34119. /**
  34120. * Removes the given animation group from this scene.
  34121. * @param toRemove The animation group to remove
  34122. * @returns The index of the removed animation group
  34123. */
  34124. removeAnimationGroup(toRemove: AnimationGroup): number;
  34125. /**
  34126. * Removes the given multi-material from this scene.
  34127. * @param toRemove The multi-material to remove
  34128. * @returns The index of the removed multi-material
  34129. */
  34130. removeMultiMaterial(toRemove: MultiMaterial): number;
  34131. /**
  34132. * Removes the given material from this scene.
  34133. * @param toRemove The material to remove
  34134. * @returns The index of the removed material
  34135. */
  34136. removeMaterial(toRemove: Material): number;
  34137. /**
  34138. * Removes the given action manager from this scene.
  34139. * @param toRemove The action manager to remove
  34140. * @returns The index of the removed action manager
  34141. */
  34142. removeActionManager(toRemove: AbstractActionManager): number;
  34143. /**
  34144. * Removes the given texture from this scene.
  34145. * @param toRemove The texture to remove
  34146. * @returns The index of the removed texture
  34147. */
  34148. removeTexture(toRemove: BaseTexture): number;
  34149. /**
  34150. * Adds the given light to this scene
  34151. * @param newLight The light to add
  34152. */
  34153. addLight(newLight: Light): void;
  34154. /**
  34155. * Sorts the list list based on light priorities
  34156. */
  34157. sortLightsByPriority(): void;
  34158. /**
  34159. * Adds the given camera to this scene
  34160. * @param newCamera The camera to add
  34161. */
  34162. addCamera(newCamera: Camera): void;
  34163. /**
  34164. * Adds the given skeleton to this scene
  34165. * @param newSkeleton The skeleton to add
  34166. */
  34167. addSkeleton(newSkeleton: Skeleton): void;
  34168. /**
  34169. * Adds the given particle system to this scene
  34170. * @param newParticleSystem The particle system to add
  34171. */
  34172. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34173. /**
  34174. * Adds the given animation to this scene
  34175. * @param newAnimation The animation to add
  34176. */
  34177. addAnimation(newAnimation: Animation): void;
  34178. /**
  34179. * Adds the given animation group to this scene.
  34180. * @param newAnimationGroup The animation group to add
  34181. */
  34182. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34183. /**
  34184. * Adds the given multi-material to this scene
  34185. * @param newMultiMaterial The multi-material to add
  34186. */
  34187. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34188. /**
  34189. * Adds the given material to this scene
  34190. * @param newMaterial The material to add
  34191. */
  34192. addMaterial(newMaterial: Material): void;
  34193. /**
  34194. * Adds the given morph target to this scene
  34195. * @param newMorphTargetManager The morph target to add
  34196. */
  34197. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34198. /**
  34199. * Adds the given geometry to this scene
  34200. * @param newGeometry The geometry to add
  34201. */
  34202. addGeometry(newGeometry: Geometry): void;
  34203. /**
  34204. * Adds the given action manager to this scene
  34205. * @param newActionManager The action manager to add
  34206. */
  34207. addActionManager(newActionManager: AbstractActionManager): void;
  34208. /**
  34209. * Adds the given texture to this scene.
  34210. * @param newTexture The texture to add
  34211. */
  34212. addTexture(newTexture: BaseTexture): void;
  34213. /**
  34214. * Switch active camera
  34215. * @param newCamera defines the new active camera
  34216. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34217. */
  34218. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34219. /**
  34220. * sets the active camera of the scene using its ID
  34221. * @param id defines the camera's ID
  34222. * @return the new active camera or null if none found.
  34223. */
  34224. setActiveCameraByID(id: string): Nullable<Camera>;
  34225. /**
  34226. * sets the active camera of the scene using its name
  34227. * @param name defines the camera's name
  34228. * @returns the new active camera or null if none found.
  34229. */
  34230. setActiveCameraByName(name: string): Nullable<Camera>;
  34231. /**
  34232. * get an animation group using its name
  34233. * @param name defines the material's name
  34234. * @return the animation group or null if none found.
  34235. */
  34236. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34237. /**
  34238. * Get a material using its unique id
  34239. * @param uniqueId defines the material's unique id
  34240. * @return the material or null if none found.
  34241. */
  34242. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34243. /**
  34244. * get a material using its id
  34245. * @param id defines the material's ID
  34246. * @return the material or null if none found.
  34247. */
  34248. getMaterialByID(id: string): Nullable<Material>;
  34249. /**
  34250. * Gets a the last added material using a given id
  34251. * @param id defines the material's ID
  34252. * @return the last material with the given id or null if none found.
  34253. */
  34254. getLastMaterialByID(id: string): Nullable<Material>;
  34255. /**
  34256. * Gets a material using its name
  34257. * @param name defines the material's name
  34258. * @return the material or null if none found.
  34259. */
  34260. getMaterialByName(name: string): Nullable<Material>;
  34261. /**
  34262. * Get a texture using its unique id
  34263. * @param uniqueId defines the texture's unique id
  34264. * @return the texture or null if none found.
  34265. */
  34266. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34267. /**
  34268. * Gets a camera using its id
  34269. * @param id defines the id to look for
  34270. * @returns the camera or null if not found
  34271. */
  34272. getCameraByID(id: string): Nullable<Camera>;
  34273. /**
  34274. * Gets a camera using its unique id
  34275. * @param uniqueId defines the unique id to look for
  34276. * @returns the camera or null if not found
  34277. */
  34278. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34279. /**
  34280. * Gets a camera using its name
  34281. * @param name defines the camera's name
  34282. * @return the camera or null if none found.
  34283. */
  34284. getCameraByName(name: string): Nullable<Camera>;
  34285. /**
  34286. * Gets a bone using its id
  34287. * @param id defines the bone's id
  34288. * @return the bone or null if not found
  34289. */
  34290. getBoneByID(id: string): Nullable<Bone>;
  34291. /**
  34292. * Gets a bone using its id
  34293. * @param name defines the bone's name
  34294. * @return the bone or null if not found
  34295. */
  34296. getBoneByName(name: string): Nullable<Bone>;
  34297. /**
  34298. * Gets a light node using its name
  34299. * @param name defines the the light's name
  34300. * @return the light or null if none found.
  34301. */
  34302. getLightByName(name: string): Nullable<Light>;
  34303. /**
  34304. * Gets a light node using its id
  34305. * @param id defines the light's id
  34306. * @return the light or null if none found.
  34307. */
  34308. getLightByID(id: string): Nullable<Light>;
  34309. /**
  34310. * Gets a light node using its scene-generated unique ID
  34311. * @param uniqueId defines the light's unique id
  34312. * @return the light or null if none found.
  34313. */
  34314. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34315. /**
  34316. * Gets a particle system by id
  34317. * @param id defines the particle system id
  34318. * @return the corresponding system or null if none found
  34319. */
  34320. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34321. /**
  34322. * Gets a geometry using its ID
  34323. * @param id defines the geometry's id
  34324. * @return the geometry or null if none found.
  34325. */
  34326. getGeometryByID(id: string): Nullable<Geometry>;
  34327. private _getGeometryByUniqueID;
  34328. /**
  34329. * Add a new geometry to this scene
  34330. * @param geometry defines the geometry to be added to the scene.
  34331. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34332. * @return a boolean defining if the geometry was added or not
  34333. */
  34334. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34335. /**
  34336. * Removes an existing geometry
  34337. * @param geometry defines the geometry to be removed from the scene
  34338. * @return a boolean defining if the geometry was removed or not
  34339. */
  34340. removeGeometry(geometry: Geometry): boolean;
  34341. /**
  34342. * Gets the list of geometries attached to the scene
  34343. * @returns an array of Geometry
  34344. */
  34345. getGeometries(): Geometry[];
  34346. /**
  34347. * Gets the first added mesh found of a given ID
  34348. * @param id defines the id to search for
  34349. * @return the mesh found or null if not found at all
  34350. */
  34351. getMeshByID(id: string): Nullable<AbstractMesh>;
  34352. /**
  34353. * Gets a list of meshes using their id
  34354. * @param id defines the id to search for
  34355. * @returns a list of meshes
  34356. */
  34357. getMeshesByID(id: string): Array<AbstractMesh>;
  34358. /**
  34359. * Gets the first added transform node found of a given ID
  34360. * @param id defines the id to search for
  34361. * @return the found transform node or null if not found at all.
  34362. */
  34363. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34364. /**
  34365. * Gets a transform node with its auto-generated unique id
  34366. * @param uniqueId efines the unique id to search for
  34367. * @return the found transform node or null if not found at all.
  34368. */
  34369. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34370. /**
  34371. * Gets a list of transform nodes using their id
  34372. * @param id defines the id to search for
  34373. * @returns a list of transform nodes
  34374. */
  34375. getTransformNodesByID(id: string): Array<TransformNode>;
  34376. /**
  34377. * Gets a mesh with its auto-generated unique id
  34378. * @param uniqueId defines the unique id to search for
  34379. * @return the found mesh or null if not found at all.
  34380. */
  34381. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34382. /**
  34383. * Gets a the last added mesh using a given id
  34384. * @param id defines the id to search for
  34385. * @return the found mesh or null if not found at all.
  34386. */
  34387. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34388. /**
  34389. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34390. * @param id defines the id to search for
  34391. * @return the found node or null if not found at all
  34392. */
  34393. getLastEntryByID(id: string): Nullable<Node>;
  34394. /**
  34395. * Gets a node (Mesh, Camera, Light) using a given id
  34396. * @param id defines the id to search for
  34397. * @return the found node or null if not found at all
  34398. */
  34399. getNodeByID(id: string): Nullable<Node>;
  34400. /**
  34401. * Gets a node (Mesh, Camera, Light) using a given name
  34402. * @param name defines the name to search for
  34403. * @return the found node or null if not found at all.
  34404. */
  34405. getNodeByName(name: string): Nullable<Node>;
  34406. /**
  34407. * Gets a mesh using a given name
  34408. * @param name defines the name to search for
  34409. * @return the found mesh or null if not found at all.
  34410. */
  34411. getMeshByName(name: string): Nullable<AbstractMesh>;
  34412. /**
  34413. * Gets a transform node using a given name
  34414. * @param name defines the name to search for
  34415. * @return the found transform node or null if not found at all.
  34416. */
  34417. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34418. /**
  34419. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34420. * @param id defines the id to search for
  34421. * @return the found skeleton or null if not found at all.
  34422. */
  34423. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34424. /**
  34425. * Gets a skeleton using a given auto generated unique id
  34426. * @param uniqueId defines the unique id to search for
  34427. * @return the found skeleton or null if not found at all.
  34428. */
  34429. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34430. /**
  34431. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34432. * @param id defines the id to search for
  34433. * @return the found skeleton or null if not found at all.
  34434. */
  34435. getSkeletonById(id: string): Nullable<Skeleton>;
  34436. /**
  34437. * Gets a skeleton using a given name
  34438. * @param name defines the name to search for
  34439. * @return the found skeleton or null if not found at all.
  34440. */
  34441. getSkeletonByName(name: string): Nullable<Skeleton>;
  34442. /**
  34443. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34444. * @param id defines the id to search for
  34445. * @return the found morph target manager or null if not found at all.
  34446. */
  34447. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34448. /**
  34449. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34450. * @param id defines the id to search for
  34451. * @return the found morph target or null if not found at all.
  34452. */
  34453. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34454. /**
  34455. * Gets a boolean indicating if the given mesh is active
  34456. * @param mesh defines the mesh to look for
  34457. * @returns true if the mesh is in the active list
  34458. */
  34459. isActiveMesh(mesh: AbstractMesh): boolean;
  34460. /**
  34461. * Return a unique id as a string which can serve as an identifier for the scene
  34462. */
  34463. readonly uid: string;
  34464. /**
  34465. * Add an externaly attached data from its key.
  34466. * This method call will fail and return false, if such key already exists.
  34467. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34468. * @param key the unique key that identifies the data
  34469. * @param data the data object to associate to the key for this Engine instance
  34470. * @return true if no such key were already present and the data was added successfully, false otherwise
  34471. */
  34472. addExternalData<T>(key: string, data: T): boolean;
  34473. /**
  34474. * Get an externaly attached data from its key
  34475. * @param key the unique key that identifies the data
  34476. * @return the associated data, if present (can be null), or undefined if not present
  34477. */
  34478. getExternalData<T>(key: string): Nullable<T>;
  34479. /**
  34480. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34481. * @param key the unique key that identifies the data
  34482. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34483. * @return the associated data, can be null if the factory returned null.
  34484. */
  34485. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34486. /**
  34487. * Remove an externaly attached data from the Engine instance
  34488. * @param key the unique key that identifies the data
  34489. * @return true if the data was successfully removed, false if it doesn't exist
  34490. */
  34491. removeExternalData(key: string): boolean;
  34492. private _evaluateSubMesh;
  34493. /**
  34494. * Clear the processed materials smart array preventing retention point in material dispose.
  34495. */
  34496. freeProcessedMaterials(): void;
  34497. private _preventFreeActiveMeshesAndRenderingGroups;
  34498. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34499. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34500. * when disposing several meshes in a row or a hierarchy of meshes.
  34501. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34502. */
  34503. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34504. /**
  34505. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34506. */
  34507. freeActiveMeshes(): void;
  34508. /**
  34509. * Clear the info related to rendering groups preventing retention points during dispose.
  34510. */
  34511. freeRenderingGroups(): void;
  34512. /** @hidden */
  34513. _isInIntermediateRendering(): boolean;
  34514. /**
  34515. * Lambda returning the list of potentially active meshes.
  34516. */
  34517. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34518. /**
  34519. * Lambda returning the list of potentially active sub meshes.
  34520. */
  34521. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34522. /**
  34523. * Lambda returning the list of potentially intersecting sub meshes.
  34524. */
  34525. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34526. /**
  34527. * Lambda returning the list of potentially colliding sub meshes.
  34528. */
  34529. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34530. private _activeMeshesFrozen;
  34531. /**
  34532. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34533. * @returns the current scene
  34534. */
  34535. freezeActiveMeshes(): Scene;
  34536. /**
  34537. * Use this function to restart evaluating active meshes on every frame
  34538. * @returns the current scene
  34539. */
  34540. unfreezeActiveMeshes(): Scene;
  34541. private _evaluateActiveMeshes;
  34542. private _activeMesh;
  34543. /**
  34544. * Update the transform matrix to update from the current active camera
  34545. * @param force defines a boolean used to force the update even if cache is up to date
  34546. */
  34547. updateTransformMatrix(force?: boolean): void;
  34548. private _bindFrameBuffer;
  34549. /** @hidden */
  34550. _allowPostProcessClearColor: boolean;
  34551. /** @hidden */
  34552. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34553. private _processSubCameras;
  34554. private _checkIntersections;
  34555. /** @hidden */
  34556. _advancePhysicsEngineStep(step: number): void;
  34557. /**
  34558. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34559. */
  34560. getDeterministicFrameTime: () => number;
  34561. /** @hidden */
  34562. _animate(): void;
  34563. /** Execute all animations (for a frame) */
  34564. animate(): void;
  34565. /**
  34566. * Render the scene
  34567. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34568. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34569. */
  34570. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34571. /**
  34572. * Freeze all materials
  34573. * A frozen material will not be updatable but should be faster to render
  34574. */
  34575. freezeMaterials(): void;
  34576. /**
  34577. * Unfreeze all materials
  34578. * A frozen material will not be updatable but should be faster to render
  34579. */
  34580. unfreezeMaterials(): void;
  34581. /**
  34582. * Releases all held ressources
  34583. */
  34584. dispose(): void;
  34585. /**
  34586. * Gets if the scene is already disposed
  34587. */
  34588. readonly isDisposed: boolean;
  34589. /**
  34590. * Call this function to reduce memory footprint of the scene.
  34591. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34592. */
  34593. clearCachedVertexData(): void;
  34594. /**
  34595. * This function will remove the local cached buffer data from texture.
  34596. * It will save memory but will prevent the texture from being rebuilt
  34597. */
  34598. cleanCachedTextureBuffer(): void;
  34599. /**
  34600. * Get the world extend vectors with an optional filter
  34601. *
  34602. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34603. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34604. */
  34605. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34606. min: Vector3;
  34607. max: Vector3;
  34608. };
  34609. /**
  34610. * Creates a ray that can be used to pick in the scene
  34611. * @param x defines the x coordinate of the origin (on-screen)
  34612. * @param y defines the y coordinate of the origin (on-screen)
  34613. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34614. * @param camera defines the camera to use for the picking
  34615. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34616. * @returns a Ray
  34617. */
  34618. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34619. /**
  34620. * Creates a ray that can be used to pick in the scene
  34621. * @param x defines the x coordinate of the origin (on-screen)
  34622. * @param y defines the y coordinate of the origin (on-screen)
  34623. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34624. * @param result defines the ray where to store the picking ray
  34625. * @param camera defines the camera to use for the picking
  34626. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34627. * @returns the current scene
  34628. */
  34629. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34630. /**
  34631. * Creates a ray that can be used to pick in the scene
  34632. * @param x defines the x coordinate of the origin (on-screen)
  34633. * @param y defines the y coordinate of the origin (on-screen)
  34634. * @param camera defines the camera to use for the picking
  34635. * @returns a Ray
  34636. */
  34637. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  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 result defines the ray where to store the picking ray
  34643. * @param camera defines the camera to use for the picking
  34644. * @returns the current scene
  34645. */
  34646. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34647. /** Launch a ray to try to pick a mesh in the scene
  34648. * @param x position on screen
  34649. * @param y position on screen
  34650. * @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
  34651. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34652. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34653. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34654. * @returns a PickingInfo
  34655. */
  34656. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34657. /** Use the given ray to pick a mesh in the scene
  34658. * @param ray The ray to use to pick meshes
  34659. * @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
  34660. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34661. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34662. * @returns a PickingInfo
  34663. */
  34664. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34665. /**
  34666. * Launch a ray to try to pick a mesh in the scene
  34667. * @param x X position on screen
  34668. * @param y Y position on screen
  34669. * @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
  34670. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34671. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34672. * @returns an array of PickingInfo
  34673. */
  34674. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34675. /**
  34676. * Launch a ray to try to pick a mesh in the scene
  34677. * @param ray Ray to use
  34678. * @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
  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. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34683. /**
  34684. * Force the value of meshUnderPointer
  34685. * @param mesh defines the mesh to use
  34686. */
  34687. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34688. /**
  34689. * Gets the mesh under the pointer
  34690. * @returns a Mesh or null if no mesh is under the pointer
  34691. */
  34692. getPointerOverMesh(): Nullable<AbstractMesh>;
  34693. /** @hidden */
  34694. _rebuildGeometries(): void;
  34695. /** @hidden */
  34696. _rebuildTextures(): void;
  34697. private _getByTags;
  34698. /**
  34699. * Get a list of meshes by tags
  34700. * @param tagsQuery defines the tags query to use
  34701. * @param forEach defines a predicate used to filter results
  34702. * @returns an array of Mesh
  34703. */
  34704. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34705. /**
  34706. * Get a list of cameras by tags
  34707. * @param tagsQuery defines the tags query to use
  34708. * @param forEach defines a predicate used to filter results
  34709. * @returns an array of Camera
  34710. */
  34711. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34712. /**
  34713. * Get a list of lights by tags
  34714. * @param tagsQuery defines the tags query to use
  34715. * @param forEach defines a predicate used to filter results
  34716. * @returns an array of Light
  34717. */
  34718. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34719. /**
  34720. * Get a list of materials by tags
  34721. * @param tagsQuery defines the tags query to use
  34722. * @param forEach defines a predicate used to filter results
  34723. * @returns an array of Material
  34724. */
  34725. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34726. /**
  34727. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34728. * This allowed control for front to back rendering or reversly depending of the special needs.
  34729. *
  34730. * @param renderingGroupId The rendering group id corresponding to its index
  34731. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34732. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34733. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34734. */
  34735. 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;
  34736. /**
  34737. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34738. *
  34739. * @param renderingGroupId The rendering group id corresponding to its index
  34740. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34741. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34742. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34743. */
  34744. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34745. /**
  34746. * Gets the current auto clear configuration for one rendering group of the rendering
  34747. * manager.
  34748. * @param index the rendering group index to get the information for
  34749. * @returns The auto clear setup for the requested rendering group
  34750. */
  34751. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34752. private _blockMaterialDirtyMechanism;
  34753. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34754. blockMaterialDirtyMechanism: boolean;
  34755. /**
  34756. * Will flag all materials as dirty to trigger new shader compilation
  34757. * @param flag defines the flag used to specify which material part must be marked as dirty
  34758. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34759. */
  34760. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34761. /** @hidden */
  34762. _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;
  34763. /** @hidden */
  34764. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34765. }
  34766. }
  34767. declare module BABYLON {
  34768. /**
  34769. * Set of assets to keep when moving a scene into an asset container.
  34770. */
  34771. export class KeepAssets extends AbstractScene {
  34772. }
  34773. /**
  34774. * Container with a set of assets that can be added or removed from a scene.
  34775. */
  34776. export class AssetContainer extends AbstractScene {
  34777. /**
  34778. * The scene the AssetContainer belongs to.
  34779. */
  34780. scene: Scene;
  34781. /**
  34782. * Instantiates an AssetContainer.
  34783. * @param scene The scene the AssetContainer belongs to.
  34784. */
  34785. constructor(scene: Scene);
  34786. /**
  34787. * Adds all the assets from the container to the scene.
  34788. */
  34789. addAllToScene(): void;
  34790. /**
  34791. * Removes all the assets in the container from the scene
  34792. */
  34793. removeAllFromScene(): void;
  34794. /**
  34795. * Disposes all the assets in the container
  34796. */
  34797. dispose(): void;
  34798. private _moveAssets;
  34799. /**
  34800. * Removes all the assets contained in the scene and adds them to the container.
  34801. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34802. */
  34803. moveAllFromScene(keepAssets?: KeepAssets): void;
  34804. /**
  34805. * 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.
  34806. * @returns the root mesh
  34807. */
  34808. createRootMesh(): Mesh;
  34809. }
  34810. }
  34811. declare module BABYLON {
  34812. /**
  34813. * Defines how the parser contract is defined.
  34814. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34815. */
  34816. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34817. /**
  34818. * Defines how the individual parser contract is defined.
  34819. * These parser can parse an individual asset
  34820. */
  34821. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34822. /**
  34823. * Base class of the scene acting as a container for the different elements composing a scene.
  34824. * This class is dynamically extended by the different components of the scene increasing
  34825. * flexibility and reducing coupling
  34826. */
  34827. export abstract class AbstractScene {
  34828. /**
  34829. * Stores the list of available parsers in the application.
  34830. */
  34831. private static _BabylonFileParsers;
  34832. /**
  34833. * Stores the list of available individual parsers in the application.
  34834. */
  34835. private static _IndividualBabylonFileParsers;
  34836. /**
  34837. * Adds a parser in the list of available ones
  34838. * @param name Defines the name of the parser
  34839. * @param parser Defines the parser to add
  34840. */
  34841. static AddParser(name: string, parser: BabylonFileParser): void;
  34842. /**
  34843. * Gets a general parser from the list of avaialble ones
  34844. * @param name Defines the name of the parser
  34845. * @returns the requested parser or null
  34846. */
  34847. static GetParser(name: string): Nullable<BabylonFileParser>;
  34848. /**
  34849. * Adds n individual parser in the list of available ones
  34850. * @param name Defines the name of the parser
  34851. * @param parser Defines the parser to add
  34852. */
  34853. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34854. /**
  34855. * Gets an individual parser from the list of avaialble ones
  34856. * @param name Defines the name of the parser
  34857. * @returns the requested parser or null
  34858. */
  34859. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34860. /**
  34861. * Parser json data and populate both a scene and its associated container object
  34862. * @param jsonData Defines the data to parse
  34863. * @param scene Defines the scene to parse the data for
  34864. * @param container Defines the container attached to the parsing sequence
  34865. * @param rootUrl Defines the root url of the data
  34866. */
  34867. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34868. /**
  34869. * Gets the list of root nodes (ie. nodes with no parent)
  34870. */
  34871. rootNodes: Node[];
  34872. /** All of the cameras added to this scene
  34873. * @see http://doc.babylonjs.com/babylon101/cameras
  34874. */
  34875. cameras: Camera[];
  34876. /**
  34877. * All of the lights added to this scene
  34878. * @see http://doc.babylonjs.com/babylon101/lights
  34879. */
  34880. lights: Light[];
  34881. /**
  34882. * All of the (abstract) meshes added to this scene
  34883. */
  34884. meshes: AbstractMesh[];
  34885. /**
  34886. * The list of skeletons added to the scene
  34887. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34888. */
  34889. skeletons: Skeleton[];
  34890. /**
  34891. * All of the particle systems added to this scene
  34892. * @see http://doc.babylonjs.com/babylon101/particles
  34893. */
  34894. particleSystems: IParticleSystem[];
  34895. /**
  34896. * Gets a list of Animations associated with the scene
  34897. */
  34898. animations: Animation[];
  34899. /**
  34900. * All of the animation groups added to this scene
  34901. * @see http://doc.babylonjs.com/how_to/group
  34902. */
  34903. animationGroups: AnimationGroup[];
  34904. /**
  34905. * All of the multi-materials added to this scene
  34906. * @see http://doc.babylonjs.com/how_to/multi_materials
  34907. */
  34908. multiMaterials: MultiMaterial[];
  34909. /**
  34910. * All of the materials added to this scene
  34911. * In the context of a Scene, it is not supposed to be modified manually.
  34912. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34913. * Note also that the order of the Material wihin the array is not significant and might change.
  34914. * @see http://doc.babylonjs.com/babylon101/materials
  34915. */
  34916. materials: Material[];
  34917. /**
  34918. * The list of morph target managers added to the scene
  34919. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34920. */
  34921. morphTargetManagers: MorphTargetManager[];
  34922. /**
  34923. * The list of geometries used in the scene.
  34924. */
  34925. geometries: Geometry[];
  34926. /**
  34927. * All of the tranform nodes added to this scene
  34928. * In the context of a Scene, it is not supposed to be modified manually.
  34929. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34930. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34931. * @see http://doc.babylonjs.com/how_to/transformnode
  34932. */
  34933. transformNodes: TransformNode[];
  34934. /**
  34935. * ActionManagers available on the scene.
  34936. */
  34937. actionManagers: AbstractActionManager[];
  34938. /**
  34939. * Textures to keep.
  34940. */
  34941. textures: BaseTexture[];
  34942. /**
  34943. * Environment texture for the scene
  34944. */
  34945. environmentTexture: Nullable<BaseTexture>;
  34946. }
  34947. }
  34948. declare module BABYLON {
  34949. /**
  34950. * Interface used to define options for Sound class
  34951. */
  34952. export interface ISoundOptions {
  34953. /**
  34954. * Does the sound autoplay once loaded.
  34955. */
  34956. autoplay?: boolean;
  34957. /**
  34958. * Does the sound loop after it finishes playing once.
  34959. */
  34960. loop?: boolean;
  34961. /**
  34962. * Sound's volume
  34963. */
  34964. volume?: number;
  34965. /**
  34966. * Is it a spatial sound?
  34967. */
  34968. spatialSound?: boolean;
  34969. /**
  34970. * Maximum distance to hear that sound
  34971. */
  34972. maxDistance?: number;
  34973. /**
  34974. * Uses user defined attenuation function
  34975. */
  34976. useCustomAttenuation?: boolean;
  34977. /**
  34978. * Define the roll off factor of spatial sounds.
  34979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34980. */
  34981. rolloffFactor?: number;
  34982. /**
  34983. * Define the reference distance the sound should be heard perfectly.
  34984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34985. */
  34986. refDistance?: number;
  34987. /**
  34988. * Define the distance attenuation model the sound will follow.
  34989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34990. */
  34991. distanceModel?: string;
  34992. /**
  34993. * Defines the playback speed (1 by default)
  34994. */
  34995. playbackRate?: number;
  34996. /**
  34997. * Defines if the sound is from a streaming source
  34998. */
  34999. streaming?: boolean;
  35000. /**
  35001. * Defines an optional length (in seconds) inside the sound file
  35002. */
  35003. length?: number;
  35004. /**
  35005. * Defines an optional offset (in seconds) inside the sound file
  35006. */
  35007. offset?: number;
  35008. /**
  35009. * If true, URLs will not be required to state the audio file codec to use.
  35010. */
  35011. skipCodecCheck?: boolean;
  35012. }
  35013. /**
  35014. * Defines a sound that can be played in the application.
  35015. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35017. */
  35018. export class Sound {
  35019. /**
  35020. * The name of the sound in the scene.
  35021. */
  35022. name: string;
  35023. /**
  35024. * Does the sound autoplay once loaded.
  35025. */
  35026. autoplay: boolean;
  35027. /**
  35028. * Does the sound loop after it finishes playing once.
  35029. */
  35030. loop: boolean;
  35031. /**
  35032. * Does the sound use a custom attenuation curve to simulate the falloff
  35033. * happening when the source gets further away from the camera.
  35034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35035. */
  35036. useCustomAttenuation: boolean;
  35037. /**
  35038. * The sound track id this sound belongs to.
  35039. */
  35040. soundTrackId: number;
  35041. /**
  35042. * Is this sound currently played.
  35043. */
  35044. isPlaying: boolean;
  35045. /**
  35046. * Is this sound currently paused.
  35047. */
  35048. isPaused: boolean;
  35049. /**
  35050. * Does this sound enables spatial sound.
  35051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35052. */
  35053. spatialSound: boolean;
  35054. /**
  35055. * Define the reference distance the sound should be heard perfectly.
  35056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35057. */
  35058. refDistance: number;
  35059. /**
  35060. * Define the roll off factor of spatial sounds.
  35061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35062. */
  35063. rolloffFactor: number;
  35064. /**
  35065. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35067. */
  35068. maxDistance: number;
  35069. /**
  35070. * Define the distance attenuation model the sound will follow.
  35071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35072. */
  35073. distanceModel: string;
  35074. /**
  35075. * @hidden
  35076. * Back Compat
  35077. **/
  35078. onended: () => any;
  35079. /**
  35080. * Observable event when the current playing sound finishes.
  35081. */
  35082. onEndedObservable: Observable<Sound>;
  35083. private _panningModel;
  35084. private _playbackRate;
  35085. private _streaming;
  35086. private _startTime;
  35087. private _startOffset;
  35088. private _position;
  35089. /** @hidden */
  35090. _positionInEmitterSpace: boolean;
  35091. private _localDirection;
  35092. private _volume;
  35093. private _isReadyToPlay;
  35094. private _isDirectional;
  35095. private _readyToPlayCallback;
  35096. private _audioBuffer;
  35097. private _soundSource;
  35098. private _streamingSource;
  35099. private _soundPanner;
  35100. private _soundGain;
  35101. private _inputAudioNode;
  35102. private _outputAudioNode;
  35103. private _coneInnerAngle;
  35104. private _coneOuterAngle;
  35105. private _coneOuterGain;
  35106. private _scene;
  35107. private _connectedTransformNode;
  35108. private _customAttenuationFunction;
  35109. private _registerFunc;
  35110. private _isOutputConnected;
  35111. private _htmlAudioElement;
  35112. private _urlType;
  35113. private _length?;
  35114. private _offset?;
  35115. /** @hidden */
  35116. static _SceneComponentInitialization: (scene: Scene) => void;
  35117. /**
  35118. * Create a sound and attach it to a scene
  35119. * @param name Name of your sound
  35120. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35121. * @param scene defines the scene the sound belongs to
  35122. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35123. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35124. */
  35125. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35126. /**
  35127. * Release the sound and its associated resources
  35128. */
  35129. dispose(): void;
  35130. /**
  35131. * Gets if the sounds is ready to be played or not.
  35132. * @returns true if ready, otherwise false
  35133. */
  35134. isReady(): boolean;
  35135. private _soundLoaded;
  35136. /**
  35137. * Sets the data of the sound from an audiobuffer
  35138. * @param audioBuffer The audioBuffer containing the data
  35139. */
  35140. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35141. /**
  35142. * Updates the current sounds options such as maxdistance, loop...
  35143. * @param options A JSON object containing values named as the object properties
  35144. */
  35145. updateOptions(options: ISoundOptions): void;
  35146. private _createSpatialParameters;
  35147. private _updateSpatialParameters;
  35148. /**
  35149. * Switch the panning model to HRTF:
  35150. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35152. */
  35153. switchPanningModelToHRTF(): void;
  35154. /**
  35155. * Switch the panning model to Equal Power:
  35156. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35158. */
  35159. switchPanningModelToEqualPower(): void;
  35160. private _switchPanningModel;
  35161. /**
  35162. * Connect this sound to a sound track audio node like gain...
  35163. * @param soundTrackAudioNode the sound track audio node to connect to
  35164. */
  35165. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35166. /**
  35167. * Transform this sound into a directional source
  35168. * @param coneInnerAngle Size of the inner cone in degree
  35169. * @param coneOuterAngle Size of the outer cone in degree
  35170. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35171. */
  35172. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35173. /**
  35174. * Gets or sets the inner angle for the directional cone.
  35175. */
  35176. /**
  35177. * Gets or sets the inner angle for the directional cone.
  35178. */
  35179. directionalConeInnerAngle: number;
  35180. /**
  35181. * Gets or sets the outer angle for the directional cone.
  35182. */
  35183. /**
  35184. * Gets or sets the outer angle for the directional cone.
  35185. */
  35186. directionalConeOuterAngle: number;
  35187. /**
  35188. * Sets the position of the emitter if spatial sound is enabled
  35189. * @param newPosition Defines the new posisiton
  35190. */
  35191. setPosition(newPosition: Vector3): void;
  35192. /**
  35193. * Sets the local direction of the emitter if spatial sound is enabled
  35194. * @param newLocalDirection Defines the new local direction
  35195. */
  35196. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35197. private _updateDirection;
  35198. /** @hidden */
  35199. updateDistanceFromListener(): void;
  35200. /**
  35201. * Sets a new custom attenuation function for the sound.
  35202. * @param callback Defines the function used for the attenuation
  35203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35204. */
  35205. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35206. /**
  35207. * Play the sound
  35208. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35209. * @param offset (optional) Start the sound at a specific time in seconds
  35210. * @param length (optional) Sound duration (in seconds)
  35211. */
  35212. play(time?: number, offset?: number, length?: number): void;
  35213. private _onended;
  35214. /**
  35215. * Stop the sound
  35216. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35217. */
  35218. stop(time?: number): void;
  35219. /**
  35220. * Put the sound in pause
  35221. */
  35222. pause(): void;
  35223. /**
  35224. * Sets a dedicated volume for this sounds
  35225. * @param newVolume Define the new volume of the sound
  35226. * @param time Define time for gradual change to new volume
  35227. */
  35228. setVolume(newVolume: number, time?: number): void;
  35229. /**
  35230. * Set the sound play back rate
  35231. * @param newPlaybackRate Define the playback rate the sound should be played at
  35232. */
  35233. setPlaybackRate(newPlaybackRate: number): void;
  35234. /**
  35235. * Gets the volume of the sound.
  35236. * @returns the volume of the sound
  35237. */
  35238. getVolume(): number;
  35239. /**
  35240. * Attach the sound to a dedicated mesh
  35241. * @param transformNode The transform node to connect the sound with
  35242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35243. */
  35244. attachToMesh(transformNode: TransformNode): void;
  35245. /**
  35246. * Detach the sound from the previously attached mesh
  35247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35248. */
  35249. detachFromMesh(): void;
  35250. private _onRegisterAfterWorldMatrixUpdate;
  35251. /**
  35252. * Clone the current sound in the scene.
  35253. * @returns the new sound clone
  35254. */
  35255. clone(): Nullable<Sound>;
  35256. /**
  35257. * Gets the current underlying audio buffer containing the data
  35258. * @returns the audio buffer
  35259. */
  35260. getAudioBuffer(): Nullable<AudioBuffer>;
  35261. /**
  35262. * Serializes the Sound in a JSON representation
  35263. * @returns the JSON representation of the sound
  35264. */
  35265. serialize(): any;
  35266. /**
  35267. * Parse a JSON representation of a sound to innstantiate in a given scene
  35268. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35269. * @param scene Define the scene the new parsed sound should be created in
  35270. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35271. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35272. * @returns the newly parsed sound
  35273. */
  35274. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35275. }
  35276. }
  35277. declare module BABYLON {
  35278. /**
  35279. * This defines an action helpful to play a defined sound on a triggered action.
  35280. */
  35281. export class PlaySoundAction extends Action {
  35282. private _sound;
  35283. /**
  35284. * Instantiate the action
  35285. * @param triggerOptions defines the trigger options
  35286. * @param sound defines the sound to play
  35287. * @param condition defines the trigger related conditions
  35288. */
  35289. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35290. /** @hidden */
  35291. _prepare(): void;
  35292. /**
  35293. * Execute the action and play the sound.
  35294. */
  35295. execute(): void;
  35296. /**
  35297. * Serializes the actions and its related information.
  35298. * @param parent defines the object to serialize in
  35299. * @returns the serialized object
  35300. */
  35301. serialize(parent: any): any;
  35302. }
  35303. /**
  35304. * This defines an action helpful to stop a defined sound on a triggered action.
  35305. */
  35306. export class StopSoundAction extends Action {
  35307. private _sound;
  35308. /**
  35309. * Instantiate the action
  35310. * @param triggerOptions defines the trigger options
  35311. * @param sound defines the sound to stop
  35312. * @param condition defines the trigger related conditions
  35313. */
  35314. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35315. /** @hidden */
  35316. _prepare(): void;
  35317. /**
  35318. * Execute the action and stop the sound.
  35319. */
  35320. execute(): void;
  35321. /**
  35322. * Serializes the actions and its related information.
  35323. * @param parent defines the object to serialize in
  35324. * @returns the serialized object
  35325. */
  35326. serialize(parent: any): any;
  35327. }
  35328. }
  35329. declare module BABYLON {
  35330. /**
  35331. * This defines an action responsible to change the value of a property
  35332. * by interpolating between its current value and the newly set one once triggered.
  35333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35334. */
  35335. export class InterpolateValueAction extends Action {
  35336. /**
  35337. * Defines the path of the property where the value should be interpolated
  35338. */
  35339. propertyPath: string;
  35340. /**
  35341. * Defines the target value at the end of the interpolation.
  35342. */
  35343. value: any;
  35344. /**
  35345. * Defines the time it will take for the property to interpolate to the value.
  35346. */
  35347. duration: number;
  35348. /**
  35349. * Defines if the other scene animations should be stopped when the action has been triggered
  35350. */
  35351. stopOtherAnimations?: boolean;
  35352. /**
  35353. * Defines a callback raised once the interpolation animation has been done.
  35354. */
  35355. onInterpolationDone?: () => void;
  35356. /**
  35357. * Observable triggered once the interpolation animation has been done.
  35358. */
  35359. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35360. private _target;
  35361. private _effectiveTarget;
  35362. private _property;
  35363. /**
  35364. * Instantiate the action
  35365. * @param triggerOptions defines the trigger options
  35366. * @param target defines the object containing the value to interpolate
  35367. * @param propertyPath defines the path to the property in the target object
  35368. * @param value defines the target value at the end of the interpolation
  35369. * @param duration deines the time it will take for the property to interpolate to the value.
  35370. * @param condition defines the trigger related conditions
  35371. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35372. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35373. */
  35374. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35375. /** @hidden */
  35376. _prepare(): void;
  35377. /**
  35378. * Execute the action starts the value interpolation.
  35379. */
  35380. execute(): void;
  35381. /**
  35382. * Serializes the actions and its related information.
  35383. * @param parent defines the object to serialize in
  35384. * @returns the serialized object
  35385. */
  35386. serialize(parent: any): any;
  35387. }
  35388. }
  35389. declare module BABYLON {
  35390. /**
  35391. * Options allowed during the creation of a sound track.
  35392. */
  35393. export interface ISoundTrackOptions {
  35394. /**
  35395. * The volume the sound track should take during creation
  35396. */
  35397. volume?: number;
  35398. /**
  35399. * Define if the sound track is the main sound track of the scene
  35400. */
  35401. mainTrack?: boolean;
  35402. }
  35403. /**
  35404. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35405. * It will be also used in a future release to apply effects on a specific track.
  35406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35407. */
  35408. export class SoundTrack {
  35409. /**
  35410. * The unique identifier of the sound track in the scene.
  35411. */
  35412. id: number;
  35413. /**
  35414. * The list of sounds included in the sound track.
  35415. */
  35416. soundCollection: Array<Sound>;
  35417. private _outputAudioNode;
  35418. private _scene;
  35419. private _isMainTrack;
  35420. private _connectedAnalyser;
  35421. private _options;
  35422. private _isInitialized;
  35423. /**
  35424. * Creates a new sound track.
  35425. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35426. * @param scene Define the scene the sound track belongs to
  35427. * @param options
  35428. */
  35429. constructor(scene: Scene, options?: ISoundTrackOptions);
  35430. private _initializeSoundTrackAudioGraph;
  35431. /**
  35432. * Release the sound track and its associated resources
  35433. */
  35434. dispose(): void;
  35435. /**
  35436. * Adds a sound to this sound track
  35437. * @param sound define the cound to add
  35438. * @ignoreNaming
  35439. */
  35440. AddSound(sound: Sound): void;
  35441. /**
  35442. * Removes a sound to this sound track
  35443. * @param sound define the cound to remove
  35444. * @ignoreNaming
  35445. */
  35446. RemoveSound(sound: Sound): void;
  35447. /**
  35448. * Set a global volume for the full sound track.
  35449. * @param newVolume Define the new volume of the sound track
  35450. */
  35451. setVolume(newVolume: number): void;
  35452. /**
  35453. * Switch the panning model to HRTF:
  35454. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35456. */
  35457. switchPanningModelToHRTF(): void;
  35458. /**
  35459. * Switch the panning model to Equal Power:
  35460. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35462. */
  35463. switchPanningModelToEqualPower(): void;
  35464. /**
  35465. * Connect the sound track to an audio analyser allowing some amazing
  35466. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35468. * @param analyser The analyser to connect to the engine
  35469. */
  35470. connectToAnalyser(analyser: Analyser): void;
  35471. }
  35472. }
  35473. declare module BABYLON {
  35474. interface AbstractScene {
  35475. /**
  35476. * The list of sounds used in the scene.
  35477. */
  35478. sounds: Nullable<Array<Sound>>;
  35479. }
  35480. interface Scene {
  35481. /**
  35482. * @hidden
  35483. * Backing field
  35484. */
  35485. _mainSoundTrack: SoundTrack;
  35486. /**
  35487. * The main sound track played by the scene.
  35488. * It cotains your primary collection of sounds.
  35489. */
  35490. mainSoundTrack: SoundTrack;
  35491. /**
  35492. * The list of sound tracks added to the scene
  35493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35494. */
  35495. soundTracks: Nullable<Array<SoundTrack>>;
  35496. /**
  35497. * Gets a sound using a given name
  35498. * @param name defines the name to search for
  35499. * @return the found sound or null if not found at all.
  35500. */
  35501. getSoundByName(name: string): Nullable<Sound>;
  35502. /**
  35503. * Gets or sets if audio support is enabled
  35504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35505. */
  35506. audioEnabled: boolean;
  35507. /**
  35508. * Gets or sets if audio will be output to headphones
  35509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35510. */
  35511. headphone: boolean;
  35512. /**
  35513. * Gets or sets custom audio listener position provider
  35514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35515. */
  35516. audioListenerPositionProvider: Nullable<() => Vector3>;
  35517. }
  35518. /**
  35519. * Defines the sound scene component responsible to manage any sounds
  35520. * in a given scene.
  35521. */
  35522. export class AudioSceneComponent implements ISceneSerializableComponent {
  35523. /**
  35524. * The component name helpfull to identify the component in the list of scene components.
  35525. */
  35526. readonly name: string;
  35527. /**
  35528. * The scene the component belongs to.
  35529. */
  35530. scene: Scene;
  35531. private _audioEnabled;
  35532. /**
  35533. * Gets whether audio is enabled or not.
  35534. * Please use related enable/disable method to switch state.
  35535. */
  35536. readonly audioEnabled: boolean;
  35537. private _headphone;
  35538. /**
  35539. * Gets whether audio is outputing to headphone or not.
  35540. * Please use the according Switch methods to change output.
  35541. */
  35542. readonly headphone: boolean;
  35543. private _audioListenerPositionProvider;
  35544. /**
  35545. * Gets the current audio listener position provider
  35546. */
  35547. /**
  35548. * Sets a custom listener position for all sounds in the scene
  35549. * By default, this is the position of the first active camera
  35550. */
  35551. audioListenerPositionProvider: Nullable<() => Vector3>;
  35552. /**
  35553. * Creates a new instance of the component for the given scene
  35554. * @param scene Defines the scene to register the component in
  35555. */
  35556. constructor(scene: Scene);
  35557. /**
  35558. * Registers the component in a given scene
  35559. */
  35560. register(): void;
  35561. /**
  35562. * Rebuilds the elements related to this component in case of
  35563. * context lost for instance.
  35564. */
  35565. rebuild(): void;
  35566. /**
  35567. * Serializes the component data to the specified json object
  35568. * @param serializationObject The object to serialize to
  35569. */
  35570. serialize(serializationObject: any): void;
  35571. /**
  35572. * Adds all the elements from the container to the scene
  35573. * @param container the container holding the elements
  35574. */
  35575. addFromContainer(container: AbstractScene): void;
  35576. /**
  35577. * Removes all the elements in the container from the scene
  35578. * @param container contains the elements to remove
  35579. * @param dispose if the removed element should be disposed (default: false)
  35580. */
  35581. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35582. /**
  35583. * Disposes the component and the associated ressources.
  35584. */
  35585. dispose(): void;
  35586. /**
  35587. * Disables audio in the associated scene.
  35588. */
  35589. disableAudio(): void;
  35590. /**
  35591. * Enables audio in the associated scene.
  35592. */
  35593. enableAudio(): void;
  35594. /**
  35595. * Switch audio to headphone output.
  35596. */
  35597. switchAudioModeForHeadphones(): void;
  35598. /**
  35599. * Switch audio to normal speakers.
  35600. */
  35601. switchAudioModeForNormalSpeakers(): void;
  35602. private _afterRender;
  35603. }
  35604. }
  35605. declare module BABYLON {
  35606. /**
  35607. * Wraps one or more Sound objects and selects one with random weight for playback.
  35608. */
  35609. export class WeightedSound {
  35610. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35611. loop: boolean;
  35612. private _coneInnerAngle;
  35613. private _coneOuterAngle;
  35614. private _volume;
  35615. /** A Sound is currently playing. */
  35616. isPlaying: boolean;
  35617. /** A Sound is currently paused. */
  35618. isPaused: boolean;
  35619. private _sounds;
  35620. private _weights;
  35621. private _currentIndex?;
  35622. /**
  35623. * Creates a new WeightedSound from the list of sounds given.
  35624. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35625. * @param sounds Array of Sounds that will be selected from.
  35626. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35627. */
  35628. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35629. /**
  35630. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35631. */
  35632. /**
  35633. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35634. */
  35635. directionalConeInnerAngle: number;
  35636. /**
  35637. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35638. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35639. */
  35640. /**
  35641. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35642. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35643. */
  35644. directionalConeOuterAngle: number;
  35645. /**
  35646. * Playback volume.
  35647. */
  35648. /**
  35649. * Playback volume.
  35650. */
  35651. volume: number;
  35652. private _onended;
  35653. /**
  35654. * Suspend playback
  35655. */
  35656. pause(): void;
  35657. /**
  35658. * Stop playback
  35659. */
  35660. stop(): void;
  35661. /**
  35662. * Start playback.
  35663. * @param startOffset Position the clip head at a specific time in seconds.
  35664. */
  35665. play(startOffset?: number): void;
  35666. }
  35667. }
  35668. declare module BABYLON {
  35669. /**
  35670. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35671. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35672. */
  35673. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35674. /**
  35675. * Gets the name of the behavior.
  35676. */
  35677. readonly name: string;
  35678. /**
  35679. * The easing function used by animations
  35680. */
  35681. static EasingFunction: BackEase;
  35682. /**
  35683. * The easing mode used by animations
  35684. */
  35685. static EasingMode: number;
  35686. /**
  35687. * The duration of the animation, in milliseconds
  35688. */
  35689. transitionDuration: number;
  35690. /**
  35691. * Length of the distance animated by the transition when lower radius is reached
  35692. */
  35693. lowerRadiusTransitionRange: number;
  35694. /**
  35695. * Length of the distance animated by the transition when upper radius is reached
  35696. */
  35697. upperRadiusTransitionRange: number;
  35698. private _autoTransitionRange;
  35699. /**
  35700. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35701. */
  35702. /**
  35703. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35704. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35705. */
  35706. autoTransitionRange: boolean;
  35707. private _attachedCamera;
  35708. private _onAfterCheckInputsObserver;
  35709. private _onMeshTargetChangedObserver;
  35710. /**
  35711. * Initializes the behavior.
  35712. */
  35713. init(): void;
  35714. /**
  35715. * Attaches the behavior to its arc rotate camera.
  35716. * @param camera Defines the camera to attach the behavior to
  35717. */
  35718. attach(camera: ArcRotateCamera): void;
  35719. /**
  35720. * Detaches the behavior from its current arc rotate camera.
  35721. */
  35722. detach(): void;
  35723. private _radiusIsAnimating;
  35724. private _radiusBounceTransition;
  35725. private _animatables;
  35726. private _cachedWheelPrecision;
  35727. /**
  35728. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35729. * @param radiusLimit The limit to check against.
  35730. * @return Bool to indicate if at limit.
  35731. */
  35732. private _isRadiusAtLimit;
  35733. /**
  35734. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35735. * @param radiusDelta The delta by which to animate to. Can be negative.
  35736. */
  35737. private _applyBoundRadiusAnimation;
  35738. /**
  35739. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35740. */
  35741. protected _clearAnimationLocks(): void;
  35742. /**
  35743. * Stops and removes all animations that have been applied to the camera
  35744. */
  35745. stopAllAnimations(): void;
  35746. }
  35747. }
  35748. declare module BABYLON {
  35749. /**
  35750. * 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.
  35751. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35752. */
  35753. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35754. /**
  35755. * Gets the name of the behavior.
  35756. */
  35757. readonly name: string;
  35758. private _mode;
  35759. private _radiusScale;
  35760. private _positionScale;
  35761. private _defaultElevation;
  35762. private _elevationReturnTime;
  35763. private _elevationReturnWaitTime;
  35764. private _zoomStopsAnimation;
  35765. private _framingTime;
  35766. /**
  35767. * The easing function used by animations
  35768. */
  35769. static EasingFunction: ExponentialEase;
  35770. /**
  35771. * The easing mode used by animations
  35772. */
  35773. static EasingMode: number;
  35774. /**
  35775. * Sets the current mode used by the behavior
  35776. */
  35777. /**
  35778. * Gets current mode used by the behavior.
  35779. */
  35780. mode: number;
  35781. /**
  35782. * Sets the scale applied to the radius (1 by default)
  35783. */
  35784. /**
  35785. * Gets the scale applied to the radius
  35786. */
  35787. radiusScale: number;
  35788. /**
  35789. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35790. */
  35791. /**
  35792. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35793. */
  35794. positionScale: number;
  35795. /**
  35796. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35797. * behaviour is triggered, in radians.
  35798. */
  35799. /**
  35800. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35801. * behaviour is triggered, in radians.
  35802. */
  35803. defaultElevation: number;
  35804. /**
  35805. * Sets the time (in milliseconds) taken to return to the default beta position.
  35806. * Negative value indicates camera should not return to default.
  35807. */
  35808. /**
  35809. * Gets the time (in milliseconds) taken to return to the default beta position.
  35810. * Negative value indicates camera should not return to default.
  35811. */
  35812. elevationReturnTime: number;
  35813. /**
  35814. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35815. */
  35816. /**
  35817. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35818. */
  35819. elevationReturnWaitTime: number;
  35820. /**
  35821. * Sets the flag that indicates if user zooming should stop animation.
  35822. */
  35823. /**
  35824. * Gets the flag that indicates if user zooming should stop animation.
  35825. */
  35826. zoomStopsAnimation: boolean;
  35827. /**
  35828. * Sets the transition time when framing the mesh, in milliseconds
  35829. */
  35830. /**
  35831. * Gets the transition time when framing the mesh, in milliseconds
  35832. */
  35833. framingTime: number;
  35834. /**
  35835. * Define if the behavior should automatically change the configured
  35836. * camera limits and sensibilities.
  35837. */
  35838. autoCorrectCameraLimitsAndSensibility: boolean;
  35839. private _onPrePointerObservableObserver;
  35840. private _onAfterCheckInputsObserver;
  35841. private _onMeshTargetChangedObserver;
  35842. private _attachedCamera;
  35843. private _isPointerDown;
  35844. private _lastInteractionTime;
  35845. /**
  35846. * Initializes the behavior.
  35847. */
  35848. init(): void;
  35849. /**
  35850. * Attaches the behavior to its arc rotate camera.
  35851. * @param camera Defines the camera to attach the behavior to
  35852. */
  35853. attach(camera: ArcRotateCamera): void;
  35854. /**
  35855. * Detaches the behavior from its current arc rotate camera.
  35856. */
  35857. detach(): void;
  35858. private _animatables;
  35859. private _betaIsAnimating;
  35860. private _betaTransition;
  35861. private _radiusTransition;
  35862. private _vectorTransition;
  35863. /**
  35864. * Targets the given mesh and updates zoom level accordingly.
  35865. * @param mesh The mesh to target.
  35866. * @param radius Optional. If a cached radius position already exists, overrides default.
  35867. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35868. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35869. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35870. */
  35871. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35872. /**
  35873. * Targets the given mesh with its children and updates zoom level accordingly.
  35874. * @param mesh The mesh to target.
  35875. * @param radius Optional. If a cached radius position already exists, overrides default.
  35876. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35877. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35878. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35879. */
  35880. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35881. /**
  35882. * Targets the given meshes with their children and updates zoom level accordingly.
  35883. * @param meshes The mesh to target.
  35884. * @param radius Optional. If a cached radius position already exists, overrides default.
  35885. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35886. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35887. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35888. */
  35889. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35890. /**
  35891. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35892. * @param minimumWorld Determines the smaller position of the bounding box extend
  35893. * @param maximumWorld Determines the bigger position of the bounding box extend
  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. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35898. /**
  35899. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35900. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35901. * frustum width.
  35902. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35903. * to fully enclose the mesh in the viewing frustum.
  35904. */
  35905. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35906. /**
  35907. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35908. * is automatically returned to its default position (expected to be above ground plane).
  35909. */
  35910. private _maintainCameraAboveGround;
  35911. /**
  35912. * Returns the frustum slope based on the canvas ratio and camera FOV
  35913. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35914. */
  35915. private _getFrustumSlope;
  35916. /**
  35917. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35918. */
  35919. private _clearAnimationLocks;
  35920. /**
  35921. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35922. */
  35923. private _applyUserInteraction;
  35924. /**
  35925. * Stops and removes all animations that have been applied to the camera
  35926. */
  35927. stopAllAnimations(): void;
  35928. /**
  35929. * Gets a value indicating if the user is moving the camera
  35930. */
  35931. readonly isUserIsMoving: boolean;
  35932. /**
  35933. * The camera can move all the way towards the mesh.
  35934. */
  35935. static IgnoreBoundsSizeMode: number;
  35936. /**
  35937. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35938. */
  35939. static FitFrustumSidesMode: number;
  35940. }
  35941. }
  35942. declare module BABYLON {
  35943. /**
  35944. * Base class for Camera Pointer Inputs.
  35945. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35946. * for example usage.
  35947. */
  35948. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35949. /**
  35950. * Defines the camera the input is attached to.
  35951. */
  35952. abstract camera: Camera;
  35953. /**
  35954. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35955. */
  35956. protected _altKey: boolean;
  35957. protected _ctrlKey: boolean;
  35958. protected _metaKey: boolean;
  35959. protected _shiftKey: boolean;
  35960. /**
  35961. * Which mouse buttons were pressed at time of last mouse event.
  35962. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35963. */
  35964. protected _buttonsPressed: number;
  35965. /**
  35966. * Defines the buttons associated with the input to handle camera move.
  35967. */
  35968. buttons: number[];
  35969. /**
  35970. * Attach the input controls to a specific dom element to get the input from.
  35971. * @param element Defines the element the controls should be listened from
  35972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35973. */
  35974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35975. /**
  35976. * Detach the current controls from the specified dom element.
  35977. * @param element Defines the element to stop listening the inputs from
  35978. */
  35979. detachControl(element: Nullable<HTMLElement>): void;
  35980. /**
  35981. * Gets the class name of the current input.
  35982. * @returns the class name
  35983. */
  35984. getClassName(): string;
  35985. /**
  35986. * Get the friendly name associated with the input class.
  35987. * @returns the input friendly name
  35988. */
  35989. getSimpleName(): string;
  35990. /**
  35991. * Called on pointer POINTERDOUBLETAP event.
  35992. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35993. */
  35994. protected onDoubleTap(type: string): void;
  35995. /**
  35996. * Called on pointer POINTERMOVE event if only a single touch is active.
  35997. * Override this method to provide functionality.
  35998. */
  35999. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36000. /**
  36001. * Called on pointer POINTERMOVE event if multiple touches are active.
  36002. * Override this method to provide functionality.
  36003. */
  36004. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36005. /**
  36006. * Called on JS contextmenu event.
  36007. * Override this method to provide functionality.
  36008. */
  36009. protected onContextMenu(evt: PointerEvent): void;
  36010. /**
  36011. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36012. * press.
  36013. * Override this method to provide functionality.
  36014. */
  36015. protected onButtonDown(evt: PointerEvent): void;
  36016. /**
  36017. * Called each time a new POINTERUP event occurs. Ie, for each button
  36018. * release.
  36019. * Override this method to provide functionality.
  36020. */
  36021. protected onButtonUp(evt: PointerEvent): void;
  36022. /**
  36023. * Called when window becomes inactive.
  36024. * Override this method to provide functionality.
  36025. */
  36026. protected onLostFocus(): void;
  36027. private _pointerInput;
  36028. private _observer;
  36029. private _onLostFocus;
  36030. private pointA;
  36031. private pointB;
  36032. }
  36033. }
  36034. declare module BABYLON {
  36035. /**
  36036. * Manage the pointers inputs to control an arc rotate camera.
  36037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36038. */
  36039. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36040. /**
  36041. * Defines the camera the input is attached to.
  36042. */
  36043. camera: ArcRotateCamera;
  36044. /**
  36045. * Gets the class name of the current input.
  36046. * @returns the class name
  36047. */
  36048. getClassName(): string;
  36049. /**
  36050. * Defines the buttons associated with the input to handle camera move.
  36051. */
  36052. buttons: number[];
  36053. /**
  36054. * Defines the pointer angular sensibility along the X axis or how fast is
  36055. * the camera rotating.
  36056. */
  36057. angularSensibilityX: number;
  36058. /**
  36059. * Defines the pointer angular sensibility along the Y axis or how fast is
  36060. * the camera rotating.
  36061. */
  36062. angularSensibilityY: number;
  36063. /**
  36064. * Defines the pointer pinch precision or how fast is the camera zooming.
  36065. */
  36066. pinchPrecision: number;
  36067. /**
  36068. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36069. * from 0.
  36070. * It defines the percentage of current camera.radius to use as delta when
  36071. * pinch zoom is used.
  36072. */
  36073. pinchDeltaPercentage: number;
  36074. /**
  36075. * Defines the pointer panning sensibility or how fast is the camera moving.
  36076. */
  36077. panningSensibility: number;
  36078. /**
  36079. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36080. */
  36081. multiTouchPanning: boolean;
  36082. /**
  36083. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36084. * zoom (pinch) through multitouch.
  36085. */
  36086. multiTouchPanAndZoom: boolean;
  36087. /**
  36088. * Revers pinch action direction.
  36089. */
  36090. pinchInwards: boolean;
  36091. private _isPanClick;
  36092. private _twoFingerActivityCount;
  36093. private _isPinching;
  36094. /**
  36095. * Called on pointer POINTERMOVE event if only a single touch is active.
  36096. */
  36097. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36098. /**
  36099. * Called on pointer POINTERDOUBLETAP event.
  36100. */
  36101. protected onDoubleTap(type: string): void;
  36102. /**
  36103. * Called on pointer POINTERMOVE event if multiple touches are active.
  36104. */
  36105. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36106. /**
  36107. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36108. * press.
  36109. */
  36110. protected onButtonDown(evt: PointerEvent): void;
  36111. /**
  36112. * Called each time a new POINTERUP event occurs. Ie, for each button
  36113. * release.
  36114. */
  36115. protected onButtonUp(evt: PointerEvent): void;
  36116. /**
  36117. * Called when window becomes inactive.
  36118. */
  36119. protected onLostFocus(): void;
  36120. }
  36121. }
  36122. declare module BABYLON {
  36123. /**
  36124. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36126. */
  36127. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36128. /**
  36129. * Defines the camera the input is attached to.
  36130. */
  36131. camera: ArcRotateCamera;
  36132. /**
  36133. * Defines the list of key codes associated with the up action (increase alpha)
  36134. */
  36135. keysUp: number[];
  36136. /**
  36137. * Defines the list of key codes associated with the down action (decrease alpha)
  36138. */
  36139. keysDown: number[];
  36140. /**
  36141. * Defines the list of key codes associated with the left action (increase beta)
  36142. */
  36143. keysLeft: number[];
  36144. /**
  36145. * Defines the list of key codes associated with the right action (decrease beta)
  36146. */
  36147. keysRight: number[];
  36148. /**
  36149. * Defines the list of key codes associated with the reset action.
  36150. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36151. */
  36152. keysReset: number[];
  36153. /**
  36154. * Defines the panning sensibility of the inputs.
  36155. * (How fast is the camera paning)
  36156. */
  36157. panningSensibility: number;
  36158. /**
  36159. * Defines the zooming sensibility of the inputs.
  36160. * (How fast is the camera zooming)
  36161. */
  36162. zoomingSensibility: number;
  36163. /**
  36164. * Defines wether maintaining the alt key down switch the movement mode from
  36165. * orientation to zoom.
  36166. */
  36167. useAltToZoom: boolean;
  36168. /**
  36169. * Rotation speed of the camera
  36170. */
  36171. angularSpeed: number;
  36172. private _keys;
  36173. private _ctrlPressed;
  36174. private _altPressed;
  36175. private _onCanvasBlurObserver;
  36176. private _onKeyboardObserver;
  36177. private _engine;
  36178. private _scene;
  36179. /**
  36180. * Attach the input controls to a specific dom element to get the input from.
  36181. * @param element Defines the element the controls should be listened from
  36182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36183. */
  36184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36185. /**
  36186. * Detach the current controls from the specified dom element.
  36187. * @param element Defines the element to stop listening the inputs from
  36188. */
  36189. detachControl(element: Nullable<HTMLElement>): void;
  36190. /**
  36191. * Update the current camera state depending on the inputs that have been used this frame.
  36192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36193. */
  36194. checkInputs(): void;
  36195. /**
  36196. * Gets the class name of the current intput.
  36197. * @returns the class name
  36198. */
  36199. getClassName(): string;
  36200. /**
  36201. * Get the friendly name associated with the input class.
  36202. * @returns the input friendly name
  36203. */
  36204. getSimpleName(): string;
  36205. }
  36206. }
  36207. declare module BABYLON {
  36208. /**
  36209. * Manage the mouse wheel inputs to control an arc rotate camera.
  36210. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36211. */
  36212. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36213. /**
  36214. * Defines the camera the input is attached to.
  36215. */
  36216. camera: ArcRotateCamera;
  36217. /**
  36218. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36219. */
  36220. wheelPrecision: number;
  36221. /**
  36222. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36223. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36224. */
  36225. wheelDeltaPercentage: number;
  36226. private _wheel;
  36227. private _observer;
  36228. private computeDeltaFromMouseWheelLegacyEvent;
  36229. /**
  36230. * Attach the input controls to a specific dom element to get the input from.
  36231. * @param element Defines the element the controls should be listened from
  36232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36233. */
  36234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36235. /**
  36236. * Detach the current controls from the specified dom element.
  36237. * @param element Defines the element to stop listening the inputs from
  36238. */
  36239. detachControl(element: Nullable<HTMLElement>): void;
  36240. /**
  36241. * Gets the class name of the current intput.
  36242. * @returns the class name
  36243. */
  36244. getClassName(): string;
  36245. /**
  36246. * Get the friendly name associated with the input class.
  36247. * @returns the input friendly name
  36248. */
  36249. getSimpleName(): string;
  36250. }
  36251. }
  36252. declare module BABYLON {
  36253. /**
  36254. * Default Inputs manager for the ArcRotateCamera.
  36255. * It groups all the default supported inputs for ease of use.
  36256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36257. */
  36258. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36259. /**
  36260. * Instantiates a new ArcRotateCameraInputsManager.
  36261. * @param camera Defines the camera the inputs belong to
  36262. */
  36263. constructor(camera: ArcRotateCamera);
  36264. /**
  36265. * Add mouse wheel input support to the input manager.
  36266. * @returns the current input manager
  36267. */
  36268. addMouseWheel(): ArcRotateCameraInputsManager;
  36269. /**
  36270. * Add pointers input support to the input manager.
  36271. * @returns the current input manager
  36272. */
  36273. addPointers(): ArcRotateCameraInputsManager;
  36274. /**
  36275. * Add keyboard input support to the input manager.
  36276. * @returns the current input manager
  36277. */
  36278. addKeyboard(): ArcRotateCameraInputsManager;
  36279. }
  36280. }
  36281. declare module BABYLON {
  36282. /**
  36283. * This represents an orbital type of camera.
  36284. *
  36285. * 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.
  36286. * 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.
  36287. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36288. */
  36289. export class ArcRotateCamera extends TargetCamera {
  36290. /**
  36291. * Defines the rotation angle of the camera along the longitudinal axis.
  36292. */
  36293. alpha: number;
  36294. /**
  36295. * Defines the rotation angle of the camera along the latitudinal axis.
  36296. */
  36297. beta: number;
  36298. /**
  36299. * Defines the radius of the camera from it s target point.
  36300. */
  36301. radius: number;
  36302. protected _target: Vector3;
  36303. protected _targetHost: Nullable<AbstractMesh>;
  36304. /**
  36305. * Defines the target point of the camera.
  36306. * The camera looks towards it form the radius distance.
  36307. */
  36308. target: Vector3;
  36309. /**
  36310. * Define the current local position of the camera in the scene
  36311. */
  36312. position: Vector3;
  36313. protected _upVector: Vector3;
  36314. protected _upToYMatrix: Matrix;
  36315. protected _YToUpMatrix: Matrix;
  36316. /**
  36317. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36318. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36319. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36320. */
  36321. upVector: Vector3;
  36322. /**
  36323. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36324. */
  36325. setMatUp(): void;
  36326. /**
  36327. * Current inertia value on the longitudinal axis.
  36328. * The bigger this number the longer it will take for the camera to stop.
  36329. */
  36330. inertialAlphaOffset: number;
  36331. /**
  36332. * Current inertia value on the latitudinal axis.
  36333. * The bigger this number the longer it will take for the camera to stop.
  36334. */
  36335. inertialBetaOffset: number;
  36336. /**
  36337. * Current inertia value on the radius axis.
  36338. * The bigger this number the longer it will take for the camera to stop.
  36339. */
  36340. inertialRadiusOffset: number;
  36341. /**
  36342. * Minimum allowed angle on the longitudinal axis.
  36343. * This can help limiting how the Camera is able to move in the scene.
  36344. */
  36345. lowerAlphaLimit: Nullable<number>;
  36346. /**
  36347. * Maximum allowed angle on the longitudinal axis.
  36348. * This can help limiting how the Camera is able to move in the scene.
  36349. */
  36350. upperAlphaLimit: Nullable<number>;
  36351. /**
  36352. * Minimum allowed angle on the latitudinal axis.
  36353. * This can help limiting how the Camera is able to move in the scene.
  36354. */
  36355. lowerBetaLimit: number;
  36356. /**
  36357. * Maximum allowed angle on the latitudinal axis.
  36358. * This can help limiting how the Camera is able to move in the scene.
  36359. */
  36360. upperBetaLimit: number;
  36361. /**
  36362. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36363. * This can help limiting how the Camera is able to move in the scene.
  36364. */
  36365. lowerRadiusLimit: Nullable<number>;
  36366. /**
  36367. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36368. * This can help limiting how the Camera is able to move in the scene.
  36369. */
  36370. upperRadiusLimit: Nullable<number>;
  36371. /**
  36372. * Defines the current inertia value used during panning of the camera along the X axis.
  36373. */
  36374. inertialPanningX: number;
  36375. /**
  36376. * Defines the current inertia value used during panning of the camera along the Y axis.
  36377. */
  36378. inertialPanningY: number;
  36379. /**
  36380. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36381. * Basically if your fingers moves away from more than this distance you will be considered
  36382. * in pinch mode.
  36383. */
  36384. pinchToPanMaxDistance: number;
  36385. /**
  36386. * Defines the maximum distance the camera can pan.
  36387. * This could help keeping the cammera always in your scene.
  36388. */
  36389. panningDistanceLimit: Nullable<number>;
  36390. /**
  36391. * Defines the target of the camera before paning.
  36392. */
  36393. panningOriginTarget: Vector3;
  36394. /**
  36395. * Defines the value of the inertia used during panning.
  36396. * 0 would mean stop inertia and one would mean no decelleration at all.
  36397. */
  36398. panningInertia: number;
  36399. /**
  36400. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36401. */
  36402. angularSensibilityX: number;
  36403. /**
  36404. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36405. */
  36406. angularSensibilityY: number;
  36407. /**
  36408. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36409. */
  36410. pinchPrecision: number;
  36411. /**
  36412. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36413. * It will be used instead of pinchDeltaPrecision if different from 0.
  36414. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36415. */
  36416. pinchDeltaPercentage: number;
  36417. /**
  36418. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36419. */
  36420. panningSensibility: number;
  36421. /**
  36422. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36423. */
  36424. keysUp: number[];
  36425. /**
  36426. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36427. */
  36428. keysDown: number[];
  36429. /**
  36430. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36431. */
  36432. keysLeft: number[];
  36433. /**
  36434. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36435. */
  36436. keysRight: number[];
  36437. /**
  36438. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36439. */
  36440. wheelPrecision: number;
  36441. /**
  36442. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36443. * It will be used instead of pinchDeltaPrecision if different from 0.
  36444. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36445. */
  36446. wheelDeltaPercentage: number;
  36447. /**
  36448. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36449. */
  36450. zoomOnFactor: number;
  36451. /**
  36452. * Defines a screen offset for the camera position.
  36453. */
  36454. targetScreenOffset: Vector2;
  36455. /**
  36456. * Allows the camera to be completely reversed.
  36457. * If false the camera can not arrive upside down.
  36458. */
  36459. allowUpsideDown: boolean;
  36460. /**
  36461. * Define if double tap/click is used to restore the previously saved state of the camera.
  36462. */
  36463. useInputToRestoreState: boolean;
  36464. /** @hidden */
  36465. _viewMatrix: Matrix;
  36466. /** @hidden */
  36467. _useCtrlForPanning: boolean;
  36468. /** @hidden */
  36469. _panningMouseButton: number;
  36470. /**
  36471. * Defines the input associated to the camera.
  36472. */
  36473. inputs: ArcRotateCameraInputsManager;
  36474. /** @hidden */
  36475. _reset: () => void;
  36476. /**
  36477. * Defines the allowed panning axis.
  36478. */
  36479. panningAxis: Vector3;
  36480. protected _localDirection: Vector3;
  36481. protected _transformedDirection: Vector3;
  36482. private _bouncingBehavior;
  36483. /**
  36484. * Gets the bouncing behavior of the camera if it has been enabled.
  36485. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36486. */
  36487. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36488. /**
  36489. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36490. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36491. */
  36492. useBouncingBehavior: boolean;
  36493. private _framingBehavior;
  36494. /**
  36495. * Gets the framing behavior of the camera if it has been enabled.
  36496. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36497. */
  36498. readonly framingBehavior: Nullable<FramingBehavior>;
  36499. /**
  36500. * Defines if the framing behavior of the camera is enabled on the camera.
  36501. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36502. */
  36503. useFramingBehavior: boolean;
  36504. private _autoRotationBehavior;
  36505. /**
  36506. * Gets the auto rotation behavior of the camera if it has been enabled.
  36507. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36508. */
  36509. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36510. /**
  36511. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36512. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36513. */
  36514. useAutoRotationBehavior: boolean;
  36515. /**
  36516. * Observable triggered when the mesh target has been changed on the camera.
  36517. */
  36518. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36519. /**
  36520. * Event raised when the camera is colliding with a mesh.
  36521. */
  36522. onCollide: (collidedMesh: AbstractMesh) => void;
  36523. /**
  36524. * Defines whether the camera should check collision with the objects oh the scene.
  36525. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36526. */
  36527. checkCollisions: boolean;
  36528. /**
  36529. * Defines the collision radius of the camera.
  36530. * This simulates a sphere around the camera.
  36531. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36532. */
  36533. collisionRadius: Vector3;
  36534. protected _collider: Collider;
  36535. protected _previousPosition: Vector3;
  36536. protected _collisionVelocity: Vector3;
  36537. protected _newPosition: Vector3;
  36538. protected _previousAlpha: number;
  36539. protected _previousBeta: number;
  36540. protected _previousRadius: number;
  36541. protected _collisionTriggered: boolean;
  36542. protected _targetBoundingCenter: Nullable<Vector3>;
  36543. private _computationVector;
  36544. /**
  36545. * Instantiates a new ArcRotateCamera in a given scene
  36546. * @param name Defines the name of the camera
  36547. * @param alpha Defines the camera rotation along the logitudinal axis
  36548. * @param beta Defines the camera rotation along the latitudinal axis
  36549. * @param radius Defines the camera distance from its target
  36550. * @param target Defines the camera target
  36551. * @param scene Defines the scene the camera belongs to
  36552. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36553. */
  36554. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36555. /** @hidden */
  36556. _initCache(): void;
  36557. /** @hidden */
  36558. _updateCache(ignoreParentClass?: boolean): void;
  36559. protected _getTargetPosition(): Vector3;
  36560. private _storedAlpha;
  36561. private _storedBeta;
  36562. private _storedRadius;
  36563. private _storedTarget;
  36564. private _storedTargetScreenOffset;
  36565. /**
  36566. * Stores the current state of the camera (alpha, beta, radius and target)
  36567. * @returns the camera itself
  36568. */
  36569. storeState(): Camera;
  36570. /**
  36571. * @hidden
  36572. * Restored camera state. You must call storeState() first
  36573. */
  36574. _restoreStateValues(): boolean;
  36575. /** @hidden */
  36576. _isSynchronizedViewMatrix(): boolean;
  36577. /**
  36578. * Attached controls to the current camera.
  36579. * @param element Defines the element the controls should be listened from
  36580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36581. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36582. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36583. */
  36584. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36585. /**
  36586. * Detach the current controls from the camera.
  36587. * The camera will stop reacting to inputs.
  36588. * @param element Defines the element to stop listening the inputs from
  36589. */
  36590. detachControl(element: HTMLElement): void;
  36591. /** @hidden */
  36592. _checkInputs(): void;
  36593. protected _checkLimits(): void;
  36594. /**
  36595. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36596. */
  36597. rebuildAnglesAndRadius(): void;
  36598. /**
  36599. * Use a position to define the current camera related information like alpha, beta and radius
  36600. * @param position Defines the position to set the camera at
  36601. */
  36602. setPosition(position: Vector3): void;
  36603. /**
  36604. * Defines the target the camera should look at.
  36605. * This will automatically adapt alpha beta and radius to fit within the new target.
  36606. * @param target Defines the new target as a Vector or a mesh
  36607. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36608. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36609. */
  36610. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36611. /** @hidden */
  36612. _getViewMatrix(): Matrix;
  36613. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36614. /**
  36615. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36616. * @param meshes Defines the mesh to zoom on
  36617. * @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)
  36618. */
  36619. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36620. /**
  36621. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36622. * The target will be changed but the radius
  36623. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36624. * @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)
  36625. */
  36626. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36627. min: Vector3;
  36628. max: Vector3;
  36629. distance: number;
  36630. }, doNotUpdateMaxZ?: boolean): void;
  36631. /**
  36632. * @override
  36633. * Override Camera.createRigCamera
  36634. */
  36635. createRigCamera(name: string, cameraIndex: number): Camera;
  36636. /**
  36637. * @hidden
  36638. * @override
  36639. * Override Camera._updateRigCameras
  36640. */
  36641. _updateRigCameras(): void;
  36642. /**
  36643. * Destroy the camera and release the current resources hold by it.
  36644. */
  36645. dispose(): void;
  36646. /**
  36647. * Gets the current object class name.
  36648. * @return the class name
  36649. */
  36650. getClassName(): string;
  36651. }
  36652. }
  36653. declare module BABYLON {
  36654. /**
  36655. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36656. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36657. */
  36658. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36659. /**
  36660. * Gets the name of the behavior.
  36661. */
  36662. readonly name: string;
  36663. private _zoomStopsAnimation;
  36664. private _idleRotationSpeed;
  36665. private _idleRotationWaitTime;
  36666. private _idleRotationSpinupTime;
  36667. /**
  36668. * Sets the flag that indicates if user zooming should stop animation.
  36669. */
  36670. /**
  36671. * Gets the flag that indicates if user zooming should stop animation.
  36672. */
  36673. zoomStopsAnimation: boolean;
  36674. /**
  36675. * Sets the default speed at which the camera rotates around the model.
  36676. */
  36677. /**
  36678. * Gets the default speed at which the camera rotates around the model.
  36679. */
  36680. idleRotationSpeed: number;
  36681. /**
  36682. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36683. */
  36684. /**
  36685. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36686. */
  36687. idleRotationWaitTime: number;
  36688. /**
  36689. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36690. */
  36691. /**
  36692. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36693. */
  36694. idleRotationSpinupTime: number;
  36695. /**
  36696. * Gets a value indicating if the camera is currently rotating because of this behavior
  36697. */
  36698. readonly rotationInProgress: boolean;
  36699. private _onPrePointerObservableObserver;
  36700. private _onAfterCheckInputsObserver;
  36701. private _attachedCamera;
  36702. private _isPointerDown;
  36703. private _lastFrameTime;
  36704. private _lastInteractionTime;
  36705. private _cameraRotationSpeed;
  36706. /**
  36707. * Initializes the behavior.
  36708. */
  36709. init(): void;
  36710. /**
  36711. * Attaches the behavior to its arc rotate camera.
  36712. * @param camera Defines the camera to attach the behavior to
  36713. */
  36714. attach(camera: ArcRotateCamera): void;
  36715. /**
  36716. * Detaches the behavior from its current arc rotate camera.
  36717. */
  36718. detach(): void;
  36719. /**
  36720. * Returns true if user is scrolling.
  36721. * @return true if user is scrolling.
  36722. */
  36723. private _userIsZooming;
  36724. private _lastFrameRadius;
  36725. private _shouldAnimationStopForInteraction;
  36726. /**
  36727. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36728. */
  36729. private _applyUserInteraction;
  36730. private _userIsMoving;
  36731. }
  36732. }
  36733. declare module BABYLON {
  36734. /**
  36735. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36736. */
  36737. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36738. private ui;
  36739. /**
  36740. * The name of the behavior
  36741. */
  36742. name: string;
  36743. /**
  36744. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36745. */
  36746. distanceAwayFromFace: number;
  36747. /**
  36748. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36749. */
  36750. distanceAwayFromBottomOfFace: number;
  36751. private _faceVectors;
  36752. private _target;
  36753. private _scene;
  36754. private _onRenderObserver;
  36755. private _tmpMatrix;
  36756. private _tmpVector;
  36757. /**
  36758. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36759. * @param ui The transform node that should be attched to the mesh
  36760. */
  36761. constructor(ui: TransformNode);
  36762. /**
  36763. * Initializes the behavior
  36764. */
  36765. init(): void;
  36766. private _closestFace;
  36767. private _zeroVector;
  36768. private _lookAtTmpMatrix;
  36769. private _lookAtToRef;
  36770. /**
  36771. * Attaches the AttachToBoxBehavior to the passed in mesh
  36772. * @param target The mesh that the specified node will be attached to
  36773. */
  36774. attach(target: Mesh): void;
  36775. /**
  36776. * Detaches the behavior from the mesh
  36777. */
  36778. detach(): void;
  36779. }
  36780. }
  36781. declare module BABYLON {
  36782. /**
  36783. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36784. */
  36785. export class FadeInOutBehavior implements Behavior<Mesh> {
  36786. /**
  36787. * Time in milliseconds to delay before fading in (Default: 0)
  36788. */
  36789. delay: number;
  36790. /**
  36791. * Time in milliseconds for the mesh to fade in (Default: 300)
  36792. */
  36793. fadeInTime: number;
  36794. private _millisecondsPerFrame;
  36795. private _hovered;
  36796. private _hoverValue;
  36797. private _ownerNode;
  36798. /**
  36799. * Instatiates the FadeInOutBehavior
  36800. */
  36801. constructor();
  36802. /**
  36803. * The name of the behavior
  36804. */
  36805. readonly name: string;
  36806. /**
  36807. * Initializes the behavior
  36808. */
  36809. init(): void;
  36810. /**
  36811. * Attaches the fade behavior on the passed in mesh
  36812. * @param ownerNode The mesh that will be faded in/out once attached
  36813. */
  36814. attach(ownerNode: Mesh): void;
  36815. /**
  36816. * Detaches the behavior from the mesh
  36817. */
  36818. detach(): void;
  36819. /**
  36820. * Triggers the mesh to begin fading in or out
  36821. * @param value if the object should fade in or out (true to fade in)
  36822. */
  36823. fadeIn(value: boolean): void;
  36824. private _update;
  36825. private _setAllVisibility;
  36826. }
  36827. }
  36828. declare module BABYLON {
  36829. /**
  36830. * Class containing a set of static utilities functions for managing Pivots
  36831. * @hidden
  36832. */
  36833. export class PivotTools {
  36834. private static _PivotCached;
  36835. private static _OldPivotPoint;
  36836. private static _PivotTranslation;
  36837. private static _PivotTmpVector;
  36838. /** @hidden */
  36839. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36840. /** @hidden */
  36841. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36842. }
  36843. }
  36844. declare module BABYLON {
  36845. /**
  36846. * Class containing static functions to help procedurally build meshes
  36847. */
  36848. export class PlaneBuilder {
  36849. /**
  36850. * Creates a plane mesh
  36851. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36852. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36853. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36855. * * 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
  36856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36857. * @param name defines the name of the mesh
  36858. * @param options defines the options used to create the mesh
  36859. * @param scene defines the hosting scene
  36860. * @returns the plane mesh
  36861. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36862. */
  36863. static CreatePlane(name: string, options: {
  36864. size?: number;
  36865. width?: number;
  36866. height?: number;
  36867. sideOrientation?: number;
  36868. frontUVs?: Vector4;
  36869. backUVs?: Vector4;
  36870. updatable?: boolean;
  36871. sourcePlane?: Plane;
  36872. }, scene?: Nullable<Scene>): Mesh;
  36873. }
  36874. }
  36875. declare module BABYLON {
  36876. /**
  36877. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36878. */
  36879. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36880. private static _AnyMouseID;
  36881. /**
  36882. * Abstract mesh the behavior is set on
  36883. */
  36884. attachedNode: AbstractMesh;
  36885. private _dragPlane;
  36886. private _scene;
  36887. private _pointerObserver;
  36888. private _beforeRenderObserver;
  36889. private static _planeScene;
  36890. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36891. /**
  36892. * 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)
  36893. */
  36894. maxDragAngle: number;
  36895. /**
  36896. * @hidden
  36897. */
  36898. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36899. /**
  36900. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36901. */
  36902. currentDraggingPointerID: number;
  36903. /**
  36904. * The last position where the pointer hit the drag plane in world space
  36905. */
  36906. lastDragPosition: Vector3;
  36907. /**
  36908. * If the behavior is currently in a dragging state
  36909. */
  36910. dragging: boolean;
  36911. /**
  36912. * 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)
  36913. */
  36914. dragDeltaRatio: number;
  36915. /**
  36916. * If the drag plane orientation should be updated during the dragging (Default: true)
  36917. */
  36918. updateDragPlane: boolean;
  36919. private _debugMode;
  36920. private _moving;
  36921. /**
  36922. * Fires each time the attached mesh is dragged with the pointer
  36923. * * delta between last drag position and current drag position in world space
  36924. * * dragDistance along the drag axis
  36925. * * dragPlaneNormal normal of the current drag plane used during the drag
  36926. * * dragPlanePoint in world space where the drag intersects the drag plane
  36927. */
  36928. onDragObservable: Observable<{
  36929. delta: Vector3;
  36930. dragPlanePoint: Vector3;
  36931. dragPlaneNormal: Vector3;
  36932. dragDistance: number;
  36933. pointerId: number;
  36934. }>;
  36935. /**
  36936. * Fires each time a drag begins (eg. mouse down on mesh)
  36937. */
  36938. onDragStartObservable: Observable<{
  36939. dragPlanePoint: Vector3;
  36940. pointerId: number;
  36941. }>;
  36942. /**
  36943. * Fires each time a drag ends (eg. mouse release after drag)
  36944. */
  36945. onDragEndObservable: Observable<{
  36946. dragPlanePoint: Vector3;
  36947. pointerId: number;
  36948. }>;
  36949. /**
  36950. * If the attached mesh should be moved when dragged
  36951. */
  36952. moveAttached: boolean;
  36953. /**
  36954. * If the drag behavior will react to drag events (Default: true)
  36955. */
  36956. enabled: boolean;
  36957. /**
  36958. * If pointer events should start and release the drag (Default: true)
  36959. */
  36960. startAndReleaseDragOnPointerEvents: boolean;
  36961. /**
  36962. * If camera controls should be detached during the drag
  36963. */
  36964. detachCameraControls: boolean;
  36965. /**
  36966. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36967. */
  36968. useObjectOrienationForDragging: boolean;
  36969. private _options;
  36970. /**
  36971. * Creates a pointer drag behavior that can be attached to a mesh
  36972. * @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)
  36973. */
  36974. constructor(options?: {
  36975. dragAxis?: Vector3;
  36976. dragPlaneNormal?: Vector3;
  36977. });
  36978. /**
  36979. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36980. */
  36981. validateDrag: (targetPosition: Vector3) => boolean;
  36982. /**
  36983. * The name of the behavior
  36984. */
  36985. readonly name: string;
  36986. /**
  36987. * Initializes the behavior
  36988. */
  36989. init(): void;
  36990. private _tmpVector;
  36991. private _alternatePickedPoint;
  36992. private _worldDragAxis;
  36993. private _targetPosition;
  36994. private _attachedElement;
  36995. /**
  36996. * Attaches the drag behavior the passed in mesh
  36997. * @param ownerNode The mesh that will be dragged around once attached
  36998. * @param predicate Predicate to use for pick filtering
  36999. */
  37000. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37001. /**
  37002. * Force relase the drag action by code.
  37003. */
  37004. releaseDrag(): void;
  37005. private _startDragRay;
  37006. private _lastPointerRay;
  37007. /**
  37008. * Simulates the start of a pointer drag event on the behavior
  37009. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37010. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37011. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37012. */
  37013. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37014. private _startDrag;
  37015. private _dragDelta;
  37016. private _moveDrag;
  37017. private _pickWithRayOnDragPlane;
  37018. private _pointA;
  37019. private _pointB;
  37020. private _pointC;
  37021. private _lineA;
  37022. private _lineB;
  37023. private _localAxis;
  37024. private _lookAt;
  37025. private _updateDragPlanePosition;
  37026. /**
  37027. * Detaches the behavior from the mesh
  37028. */
  37029. detach(): void;
  37030. }
  37031. }
  37032. declare module BABYLON {
  37033. /**
  37034. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37035. */
  37036. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37037. private _dragBehaviorA;
  37038. private _dragBehaviorB;
  37039. private _startDistance;
  37040. private _initialScale;
  37041. private _targetScale;
  37042. private _ownerNode;
  37043. private _sceneRenderObserver;
  37044. /**
  37045. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37046. */
  37047. constructor();
  37048. /**
  37049. * The name of the behavior
  37050. */
  37051. readonly name: string;
  37052. /**
  37053. * Initializes the behavior
  37054. */
  37055. init(): void;
  37056. private _getCurrentDistance;
  37057. /**
  37058. * Attaches the scale behavior the passed in mesh
  37059. * @param ownerNode The mesh that will be scaled around once attached
  37060. */
  37061. attach(ownerNode: Mesh): void;
  37062. /**
  37063. * Detaches the behavior from the mesh
  37064. */
  37065. detach(): void;
  37066. }
  37067. }
  37068. declare module BABYLON {
  37069. /**
  37070. * 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
  37071. */
  37072. export class SixDofDragBehavior implements Behavior<Mesh> {
  37073. private static _virtualScene;
  37074. private _ownerNode;
  37075. private _sceneRenderObserver;
  37076. private _scene;
  37077. private _targetPosition;
  37078. private _virtualOriginMesh;
  37079. private _virtualDragMesh;
  37080. private _pointerObserver;
  37081. private _moving;
  37082. private _startingOrientation;
  37083. /**
  37084. * 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)
  37085. */
  37086. private zDragFactor;
  37087. /**
  37088. * If the object should rotate to face the drag origin
  37089. */
  37090. rotateDraggedObject: boolean;
  37091. /**
  37092. * If the behavior is currently in a dragging state
  37093. */
  37094. dragging: boolean;
  37095. /**
  37096. * 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)
  37097. */
  37098. dragDeltaRatio: number;
  37099. /**
  37100. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37101. */
  37102. currentDraggingPointerID: number;
  37103. /**
  37104. * If camera controls should be detached during the drag
  37105. */
  37106. detachCameraControls: boolean;
  37107. /**
  37108. * Fires each time a drag starts
  37109. */
  37110. onDragStartObservable: Observable<{}>;
  37111. /**
  37112. * Fires each time a drag ends (eg. mouse release after drag)
  37113. */
  37114. onDragEndObservable: Observable<{}>;
  37115. /**
  37116. * 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
  37117. */
  37118. constructor();
  37119. /**
  37120. * The name of the behavior
  37121. */
  37122. readonly name: string;
  37123. /**
  37124. * Initializes the behavior
  37125. */
  37126. init(): void;
  37127. /**
  37128. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37129. */
  37130. private readonly _pointerCamera;
  37131. /**
  37132. * Attaches the scale behavior the passed in mesh
  37133. * @param ownerNode The mesh that will be scaled around once attached
  37134. */
  37135. attach(ownerNode: Mesh): void;
  37136. /**
  37137. * Detaches the behavior from the mesh
  37138. */
  37139. detach(): void;
  37140. }
  37141. }
  37142. declare module BABYLON {
  37143. /**
  37144. * Class used to apply inverse kinematics to bones
  37145. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37146. */
  37147. export class BoneIKController {
  37148. private static _tmpVecs;
  37149. private static _tmpQuat;
  37150. private static _tmpMats;
  37151. /**
  37152. * Gets or sets the target mesh
  37153. */
  37154. targetMesh: AbstractMesh;
  37155. /** Gets or sets the mesh used as pole */
  37156. poleTargetMesh: AbstractMesh;
  37157. /**
  37158. * Gets or sets the bone used as pole
  37159. */
  37160. poleTargetBone: Nullable<Bone>;
  37161. /**
  37162. * Gets or sets the target position
  37163. */
  37164. targetPosition: Vector3;
  37165. /**
  37166. * Gets or sets the pole target position
  37167. */
  37168. poleTargetPosition: Vector3;
  37169. /**
  37170. * Gets or sets the pole target local offset
  37171. */
  37172. poleTargetLocalOffset: Vector3;
  37173. /**
  37174. * Gets or sets the pole angle
  37175. */
  37176. poleAngle: number;
  37177. /**
  37178. * Gets or sets the mesh associated with the controller
  37179. */
  37180. mesh: AbstractMesh;
  37181. /**
  37182. * 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)
  37183. */
  37184. slerpAmount: number;
  37185. private _bone1Quat;
  37186. private _bone1Mat;
  37187. private _bone2Ang;
  37188. private _bone1;
  37189. private _bone2;
  37190. private _bone1Length;
  37191. private _bone2Length;
  37192. private _maxAngle;
  37193. private _maxReach;
  37194. private _rightHandedSystem;
  37195. private _bendAxis;
  37196. private _slerping;
  37197. private _adjustRoll;
  37198. /**
  37199. * Gets or sets maximum allowed angle
  37200. */
  37201. maxAngle: number;
  37202. /**
  37203. * Creates a new BoneIKController
  37204. * @param mesh defines the mesh to control
  37205. * @param bone defines the bone to control
  37206. * @param options defines options to set up the controller
  37207. */
  37208. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37209. targetMesh?: AbstractMesh;
  37210. poleTargetMesh?: AbstractMesh;
  37211. poleTargetBone?: Bone;
  37212. poleTargetLocalOffset?: Vector3;
  37213. poleAngle?: number;
  37214. bendAxis?: Vector3;
  37215. maxAngle?: number;
  37216. slerpAmount?: number;
  37217. });
  37218. private _setMaxAngle;
  37219. /**
  37220. * Force the controller to update the bones
  37221. */
  37222. update(): void;
  37223. }
  37224. }
  37225. declare module BABYLON {
  37226. /**
  37227. * Class used to make a bone look toward a point in space
  37228. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37229. */
  37230. export class BoneLookController {
  37231. private static _tmpVecs;
  37232. private static _tmpQuat;
  37233. private static _tmpMats;
  37234. /**
  37235. * The target Vector3 that the bone will look at
  37236. */
  37237. target: Vector3;
  37238. /**
  37239. * The mesh that the bone is attached to
  37240. */
  37241. mesh: AbstractMesh;
  37242. /**
  37243. * The bone that will be looking to the target
  37244. */
  37245. bone: Bone;
  37246. /**
  37247. * The up axis of the coordinate system that is used when the bone is rotated
  37248. */
  37249. upAxis: Vector3;
  37250. /**
  37251. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37252. */
  37253. upAxisSpace: Space;
  37254. /**
  37255. * Used to make an adjustment to the yaw of the bone
  37256. */
  37257. adjustYaw: number;
  37258. /**
  37259. * Used to make an adjustment to the pitch of the bone
  37260. */
  37261. adjustPitch: number;
  37262. /**
  37263. * Used to make an adjustment to the roll of the bone
  37264. */
  37265. adjustRoll: number;
  37266. /**
  37267. * 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)
  37268. */
  37269. slerpAmount: number;
  37270. private _minYaw;
  37271. private _maxYaw;
  37272. private _minPitch;
  37273. private _maxPitch;
  37274. private _minYawSin;
  37275. private _minYawCos;
  37276. private _maxYawSin;
  37277. private _maxYawCos;
  37278. private _midYawConstraint;
  37279. private _minPitchTan;
  37280. private _maxPitchTan;
  37281. private _boneQuat;
  37282. private _slerping;
  37283. private _transformYawPitch;
  37284. private _transformYawPitchInv;
  37285. private _firstFrameSkipped;
  37286. private _yawRange;
  37287. private _fowardAxis;
  37288. /**
  37289. * Gets or sets the minimum yaw angle that the bone can look to
  37290. */
  37291. minYaw: number;
  37292. /**
  37293. * Gets or sets the maximum yaw angle that the bone can look to
  37294. */
  37295. maxYaw: number;
  37296. /**
  37297. * Gets or sets the minimum pitch angle that the bone can look to
  37298. */
  37299. minPitch: number;
  37300. /**
  37301. * Gets or sets the maximum pitch angle that the bone can look to
  37302. */
  37303. maxPitch: number;
  37304. /**
  37305. * Create a BoneLookController
  37306. * @param mesh the mesh that the bone belongs to
  37307. * @param bone the bone that will be looking to the target
  37308. * @param target the target Vector3 to look at
  37309. * @param options optional settings:
  37310. * * maxYaw: the maximum angle the bone will yaw to
  37311. * * minYaw: the minimum angle the bone will yaw to
  37312. * * maxPitch: the maximum angle the bone will pitch to
  37313. * * minPitch: the minimum angle the bone will yaw to
  37314. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37315. * * upAxis: the up axis of the coordinate system
  37316. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37317. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37318. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37319. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37320. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37321. * * adjustRoll: used to make an adjustment to the roll of the bone
  37322. **/
  37323. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37324. maxYaw?: number;
  37325. minYaw?: number;
  37326. maxPitch?: number;
  37327. minPitch?: number;
  37328. slerpAmount?: number;
  37329. upAxis?: Vector3;
  37330. upAxisSpace?: Space;
  37331. yawAxis?: Vector3;
  37332. pitchAxis?: Vector3;
  37333. adjustYaw?: number;
  37334. adjustPitch?: number;
  37335. adjustRoll?: number;
  37336. });
  37337. /**
  37338. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37339. */
  37340. update(): void;
  37341. private _getAngleDiff;
  37342. private _getAngleBetween;
  37343. private _isAngleBetween;
  37344. }
  37345. }
  37346. declare module BABYLON {
  37347. /**
  37348. * Manage the gamepad inputs to control an arc rotate camera.
  37349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37350. */
  37351. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37352. /**
  37353. * Defines the camera the input is attached to.
  37354. */
  37355. camera: ArcRotateCamera;
  37356. /**
  37357. * Defines the gamepad the input is gathering event from.
  37358. */
  37359. gamepad: Nullable<Gamepad>;
  37360. /**
  37361. * Defines the gamepad rotation sensiblity.
  37362. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37363. */
  37364. gamepadRotationSensibility: number;
  37365. /**
  37366. * Defines the gamepad move sensiblity.
  37367. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37368. */
  37369. gamepadMoveSensibility: number;
  37370. private _yAxisScale;
  37371. /**
  37372. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37373. */
  37374. invertYAxis: boolean;
  37375. private _onGamepadConnectedObserver;
  37376. private _onGamepadDisconnectedObserver;
  37377. /**
  37378. * Attach the input controls to a specific dom element to get the input from.
  37379. * @param element Defines the element the controls should be listened from
  37380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37381. */
  37382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37383. /**
  37384. * Detach the current controls from the specified dom element.
  37385. * @param element Defines the element to stop listening the inputs from
  37386. */
  37387. detachControl(element: Nullable<HTMLElement>): void;
  37388. /**
  37389. * Update the current camera state depending on the inputs that have been used this frame.
  37390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37391. */
  37392. checkInputs(): void;
  37393. /**
  37394. * Gets the class name of the current intput.
  37395. * @returns the class name
  37396. */
  37397. getClassName(): string;
  37398. /**
  37399. * Get the friendly name associated with the input class.
  37400. * @returns the input friendly name
  37401. */
  37402. getSimpleName(): string;
  37403. }
  37404. }
  37405. declare module BABYLON {
  37406. interface ArcRotateCameraInputsManager {
  37407. /**
  37408. * Add orientation input support to the input manager.
  37409. * @returns the current input manager
  37410. */
  37411. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37412. }
  37413. /**
  37414. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37416. */
  37417. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37418. /**
  37419. * Defines the camera the input is attached to.
  37420. */
  37421. camera: ArcRotateCamera;
  37422. /**
  37423. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37424. */
  37425. alphaCorrection: number;
  37426. /**
  37427. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37428. */
  37429. gammaCorrection: number;
  37430. private _alpha;
  37431. private _gamma;
  37432. private _dirty;
  37433. private _deviceOrientationHandler;
  37434. /**
  37435. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37436. */
  37437. constructor();
  37438. /**
  37439. * Attach the input controls to a specific dom element to get the input from.
  37440. * @param element Defines the element the controls should be listened from
  37441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37442. */
  37443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37444. /** @hidden */
  37445. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37446. /**
  37447. * Update the current camera state depending on the inputs that have been used this frame.
  37448. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37449. */
  37450. checkInputs(): void;
  37451. /**
  37452. * Detach the current controls from the specified dom element.
  37453. * @param element Defines the element to stop listening the inputs from
  37454. */
  37455. detachControl(element: Nullable<HTMLElement>): void;
  37456. /**
  37457. * Gets the class name of the current intput.
  37458. * @returns the class name
  37459. */
  37460. getClassName(): string;
  37461. /**
  37462. * Get the friendly name associated with the input class.
  37463. * @returns the input friendly name
  37464. */
  37465. getSimpleName(): string;
  37466. }
  37467. }
  37468. declare module BABYLON {
  37469. /**
  37470. * Listen to mouse events to control the camera.
  37471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37472. */
  37473. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37474. /**
  37475. * Defines the camera the input is attached to.
  37476. */
  37477. camera: FlyCamera;
  37478. /**
  37479. * Defines if touch is enabled. (Default is true.)
  37480. */
  37481. touchEnabled: boolean;
  37482. /**
  37483. * Defines the buttons associated with the input to handle camera rotation.
  37484. */
  37485. buttons: number[];
  37486. /**
  37487. * Assign buttons for Yaw control.
  37488. */
  37489. buttonsYaw: number[];
  37490. /**
  37491. * Assign buttons for Pitch control.
  37492. */
  37493. buttonsPitch: number[];
  37494. /**
  37495. * Assign buttons for Roll control.
  37496. */
  37497. buttonsRoll: number[];
  37498. /**
  37499. * Detect if any button is being pressed while mouse is moved.
  37500. * -1 = Mouse locked.
  37501. * 0 = Left button.
  37502. * 1 = Middle Button.
  37503. * 2 = Right Button.
  37504. */
  37505. activeButton: number;
  37506. /**
  37507. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37508. * Higher values reduce its sensitivity.
  37509. */
  37510. angularSensibility: number;
  37511. private _mousemoveCallback;
  37512. private _observer;
  37513. private _rollObserver;
  37514. private previousPosition;
  37515. private noPreventDefault;
  37516. private element;
  37517. /**
  37518. * Listen to mouse events to control the camera.
  37519. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37520. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37521. */
  37522. constructor(touchEnabled?: boolean);
  37523. /**
  37524. * Attach the mouse control to the HTML DOM element.
  37525. * @param element Defines the element that listens to the input events.
  37526. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37527. */
  37528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37529. /**
  37530. * Detach the current controls from the specified dom element.
  37531. * @param element Defines the element to stop listening the inputs from
  37532. */
  37533. detachControl(element: Nullable<HTMLElement>): void;
  37534. /**
  37535. * Gets the class name of the current input.
  37536. * @returns the class name.
  37537. */
  37538. getClassName(): string;
  37539. /**
  37540. * Get the friendly name associated with the input class.
  37541. * @returns the input's friendly name.
  37542. */
  37543. getSimpleName(): string;
  37544. private _pointerInput;
  37545. private _onMouseMove;
  37546. /**
  37547. * Rotate camera by mouse offset.
  37548. */
  37549. private rotateCamera;
  37550. }
  37551. }
  37552. declare module BABYLON {
  37553. /**
  37554. * Default Inputs manager for the FlyCamera.
  37555. * It groups all the default supported inputs for ease of use.
  37556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37557. */
  37558. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37559. /**
  37560. * Instantiates a new FlyCameraInputsManager.
  37561. * @param camera Defines the camera the inputs belong to.
  37562. */
  37563. constructor(camera: FlyCamera);
  37564. /**
  37565. * Add keyboard input support to the input manager.
  37566. * @returns the new FlyCameraKeyboardMoveInput().
  37567. */
  37568. addKeyboard(): FlyCameraInputsManager;
  37569. /**
  37570. * Add mouse input support to the input manager.
  37571. * @param touchEnabled Enable touch screen support.
  37572. * @returns the new FlyCameraMouseInput().
  37573. */
  37574. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37575. }
  37576. }
  37577. declare module BABYLON {
  37578. /**
  37579. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37580. * such as in a 3D Space Shooter or a Flight Simulator.
  37581. */
  37582. export class FlyCamera extends TargetCamera {
  37583. /**
  37584. * Define the collision ellipsoid of the camera.
  37585. * This is helpful for simulating a camera body, like a player's body.
  37586. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37587. */
  37588. ellipsoid: Vector3;
  37589. /**
  37590. * Define an offset for the position of the ellipsoid around the camera.
  37591. * This can be helpful if the camera is attached away from the player's body center,
  37592. * such as at its head.
  37593. */
  37594. ellipsoidOffset: Vector3;
  37595. /**
  37596. * Enable or disable collisions of the camera with the rest of the scene objects.
  37597. */
  37598. checkCollisions: boolean;
  37599. /**
  37600. * Enable or disable gravity on the camera.
  37601. */
  37602. applyGravity: boolean;
  37603. /**
  37604. * Define the current direction the camera is moving to.
  37605. */
  37606. cameraDirection: Vector3;
  37607. /**
  37608. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37609. * This overrides and empties cameraRotation.
  37610. */
  37611. rotationQuaternion: Quaternion;
  37612. /**
  37613. * Track Roll to maintain the wanted Rolling when looking around.
  37614. */
  37615. _trackRoll: number;
  37616. /**
  37617. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37618. */
  37619. rollCorrect: number;
  37620. /**
  37621. * Mimic a banked turn, Rolling the camera when Yawing.
  37622. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37623. */
  37624. bankedTurn: boolean;
  37625. /**
  37626. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37627. */
  37628. bankedTurnLimit: number;
  37629. /**
  37630. * Value of 0 disables the banked Roll.
  37631. * Value of 1 is equal to the Yaw angle in radians.
  37632. */
  37633. bankedTurnMultiplier: number;
  37634. /**
  37635. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37636. */
  37637. inputs: FlyCameraInputsManager;
  37638. /**
  37639. * Gets the input sensibility for mouse input.
  37640. * Higher values reduce sensitivity.
  37641. */
  37642. /**
  37643. * Sets the input sensibility for a mouse input.
  37644. * Higher values reduce sensitivity.
  37645. */
  37646. angularSensibility: number;
  37647. /**
  37648. * Get the keys for camera movement forward.
  37649. */
  37650. /**
  37651. * Set the keys for camera movement forward.
  37652. */
  37653. keysForward: number[];
  37654. /**
  37655. * Get the keys for camera movement backward.
  37656. */
  37657. keysBackward: number[];
  37658. /**
  37659. * Get the keys for camera movement up.
  37660. */
  37661. /**
  37662. * Set the keys for camera movement up.
  37663. */
  37664. keysUp: number[];
  37665. /**
  37666. * Get the keys for camera movement down.
  37667. */
  37668. /**
  37669. * Set the keys for camera movement down.
  37670. */
  37671. keysDown: number[];
  37672. /**
  37673. * Get the keys for camera movement left.
  37674. */
  37675. /**
  37676. * Set the keys for camera movement left.
  37677. */
  37678. keysLeft: number[];
  37679. /**
  37680. * Set the keys for camera movement right.
  37681. */
  37682. /**
  37683. * Set the keys for camera movement right.
  37684. */
  37685. keysRight: number[];
  37686. /**
  37687. * Event raised when the camera collides with a mesh in the scene.
  37688. */
  37689. onCollide: (collidedMesh: AbstractMesh) => void;
  37690. private _collider;
  37691. private _needMoveForGravity;
  37692. private _oldPosition;
  37693. private _diffPosition;
  37694. private _newPosition;
  37695. /** @hidden */
  37696. _localDirection: Vector3;
  37697. /** @hidden */
  37698. _transformedDirection: Vector3;
  37699. /**
  37700. * Instantiates a FlyCamera.
  37701. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37702. * such as in a 3D Space Shooter or a Flight Simulator.
  37703. * @param name Define the name of the camera in the scene.
  37704. * @param position Define the starting position of the camera in the scene.
  37705. * @param scene Define the scene the camera belongs to.
  37706. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37707. */
  37708. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37709. /**
  37710. * Attach a control to the HTML DOM element.
  37711. * @param element Defines the element that listens to the input events.
  37712. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37713. */
  37714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37715. /**
  37716. * Detach a control from the HTML DOM element.
  37717. * The camera will stop reacting to that input.
  37718. * @param element Defines the element that listens to the input events.
  37719. */
  37720. detachControl(element: HTMLElement): void;
  37721. private _collisionMask;
  37722. /**
  37723. * Get the mask that the camera ignores in collision events.
  37724. */
  37725. /**
  37726. * Set the mask that the camera ignores in collision events.
  37727. */
  37728. collisionMask: number;
  37729. /** @hidden */
  37730. _collideWithWorld(displacement: Vector3): void;
  37731. /** @hidden */
  37732. private _onCollisionPositionChange;
  37733. /** @hidden */
  37734. _checkInputs(): void;
  37735. /** @hidden */
  37736. _decideIfNeedsToMove(): boolean;
  37737. /** @hidden */
  37738. _updatePosition(): void;
  37739. /**
  37740. * Restore the Roll to its target value at the rate specified.
  37741. * @param rate - Higher means slower restoring.
  37742. * @hidden
  37743. */
  37744. restoreRoll(rate: number): void;
  37745. /**
  37746. * Destroy the camera and release the current resources held by it.
  37747. */
  37748. dispose(): void;
  37749. /**
  37750. * Get the current object class name.
  37751. * @returns the class name.
  37752. */
  37753. getClassName(): string;
  37754. }
  37755. }
  37756. declare module BABYLON {
  37757. /**
  37758. * Listen to keyboard events to control the camera.
  37759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37760. */
  37761. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37762. /**
  37763. * Defines the camera the input is attached to.
  37764. */
  37765. camera: FlyCamera;
  37766. /**
  37767. * The list of keyboard keys used to control the forward move of the camera.
  37768. */
  37769. keysForward: number[];
  37770. /**
  37771. * The list of keyboard keys used to control the backward move of the camera.
  37772. */
  37773. keysBackward: number[];
  37774. /**
  37775. * The list of keyboard keys used to control the forward move of the camera.
  37776. */
  37777. keysUp: number[];
  37778. /**
  37779. * The list of keyboard keys used to control the backward move of the camera.
  37780. */
  37781. keysDown: number[];
  37782. /**
  37783. * The list of keyboard keys used to control the right strafe move of the camera.
  37784. */
  37785. keysRight: number[];
  37786. /**
  37787. * The list of keyboard keys used to control the left strafe move of the camera.
  37788. */
  37789. keysLeft: number[];
  37790. private _keys;
  37791. private _onCanvasBlurObserver;
  37792. private _onKeyboardObserver;
  37793. private _engine;
  37794. private _scene;
  37795. /**
  37796. * Attach the input controls to a specific dom element to get the input from.
  37797. * @param element Defines the element the controls should be listened from
  37798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37799. */
  37800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37801. /**
  37802. * Detach the current controls from the specified dom element.
  37803. * @param element Defines the element to stop listening the inputs from
  37804. */
  37805. detachControl(element: Nullable<HTMLElement>): void;
  37806. /**
  37807. * Gets the class name of the current intput.
  37808. * @returns the class name
  37809. */
  37810. getClassName(): string;
  37811. /** @hidden */
  37812. _onLostFocus(e: FocusEvent): void;
  37813. /**
  37814. * Get the friendly name associated with the input class.
  37815. * @returns the input friendly name
  37816. */
  37817. getSimpleName(): string;
  37818. /**
  37819. * Update the current camera state depending on the inputs that have been used this frame.
  37820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37821. */
  37822. checkInputs(): void;
  37823. }
  37824. }
  37825. declare module BABYLON {
  37826. /**
  37827. * Manage the mouse wheel inputs to control a follow camera.
  37828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37829. */
  37830. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37831. /**
  37832. * Defines the camera the input is attached to.
  37833. */
  37834. camera: FollowCamera;
  37835. /**
  37836. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37837. */
  37838. axisControlRadius: boolean;
  37839. /**
  37840. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37841. */
  37842. axisControlHeight: boolean;
  37843. /**
  37844. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37845. */
  37846. axisControlRotation: boolean;
  37847. /**
  37848. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37849. * relation to mouseWheel events.
  37850. */
  37851. wheelPrecision: number;
  37852. /**
  37853. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37854. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37855. */
  37856. wheelDeltaPercentage: number;
  37857. private _wheel;
  37858. private _observer;
  37859. /**
  37860. * Attach the input controls to a specific dom element to get the input from.
  37861. * @param element Defines the element the controls should be listened from
  37862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37863. */
  37864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37865. /**
  37866. * Detach the current controls from the specified dom element.
  37867. * @param element Defines the element to stop listening the inputs from
  37868. */
  37869. detachControl(element: Nullable<HTMLElement>): void;
  37870. /**
  37871. * Gets the class name of the current intput.
  37872. * @returns the class name
  37873. */
  37874. getClassName(): string;
  37875. /**
  37876. * Get the friendly name associated with the input class.
  37877. * @returns the input friendly name
  37878. */
  37879. getSimpleName(): string;
  37880. }
  37881. }
  37882. declare module BABYLON {
  37883. /**
  37884. * Manage the pointers inputs to control an follow camera.
  37885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37886. */
  37887. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37888. /**
  37889. * Defines the camera the input is attached to.
  37890. */
  37891. camera: FollowCamera;
  37892. /**
  37893. * Gets the class name of the current input.
  37894. * @returns the class name
  37895. */
  37896. getClassName(): string;
  37897. /**
  37898. * Defines the pointer angular sensibility along the X axis or how fast is
  37899. * the camera rotating.
  37900. * A negative number will reverse the axis direction.
  37901. */
  37902. angularSensibilityX: number;
  37903. /**
  37904. * Defines the pointer angular sensibility along the Y axis or how fast is
  37905. * the camera rotating.
  37906. * A negative number will reverse the axis direction.
  37907. */
  37908. angularSensibilityY: number;
  37909. /**
  37910. * Defines the pointer pinch precision or how fast is the camera zooming.
  37911. * A negative number will reverse the axis direction.
  37912. */
  37913. pinchPrecision: number;
  37914. /**
  37915. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37916. * from 0.
  37917. * It defines the percentage of current camera.radius to use as delta when
  37918. * pinch zoom is used.
  37919. */
  37920. pinchDeltaPercentage: number;
  37921. /**
  37922. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37923. */
  37924. axisXControlRadius: boolean;
  37925. /**
  37926. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37927. */
  37928. axisXControlHeight: boolean;
  37929. /**
  37930. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37931. */
  37932. axisXControlRotation: boolean;
  37933. /**
  37934. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37935. */
  37936. axisYControlRadius: boolean;
  37937. /**
  37938. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37939. */
  37940. axisYControlHeight: boolean;
  37941. /**
  37942. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37943. */
  37944. axisYControlRotation: boolean;
  37945. /**
  37946. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37947. */
  37948. axisPinchControlRadius: boolean;
  37949. /**
  37950. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37951. */
  37952. axisPinchControlHeight: boolean;
  37953. /**
  37954. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37955. */
  37956. axisPinchControlRotation: boolean;
  37957. /**
  37958. * Log error messages if basic misconfiguration has occurred.
  37959. */
  37960. warningEnable: boolean;
  37961. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37962. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37963. private _warningCounter;
  37964. private _warning;
  37965. }
  37966. }
  37967. declare module BABYLON {
  37968. /**
  37969. * Default Inputs manager for the FollowCamera.
  37970. * It groups all the default supported inputs for ease of use.
  37971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37972. */
  37973. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37974. /**
  37975. * Instantiates a new FollowCameraInputsManager.
  37976. * @param camera Defines the camera the inputs belong to
  37977. */
  37978. constructor(camera: FollowCamera);
  37979. /**
  37980. * Add keyboard input support to the input manager.
  37981. * @returns the current input manager
  37982. */
  37983. addKeyboard(): FollowCameraInputsManager;
  37984. /**
  37985. * Add mouse wheel input support to the input manager.
  37986. * @returns the current input manager
  37987. */
  37988. addMouseWheel(): FollowCameraInputsManager;
  37989. /**
  37990. * Add pointers input support to the input manager.
  37991. * @returns the current input manager
  37992. */
  37993. addPointers(): FollowCameraInputsManager;
  37994. /**
  37995. * Add orientation input support to the input manager.
  37996. * @returns the current input manager
  37997. */
  37998. addVRDeviceOrientation(): FollowCameraInputsManager;
  37999. }
  38000. }
  38001. declare module BABYLON {
  38002. /**
  38003. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38004. * an arc rotate version arcFollowCamera are available.
  38005. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38006. */
  38007. export class FollowCamera extends TargetCamera {
  38008. /**
  38009. * Distance the follow camera should follow an object at
  38010. */
  38011. radius: number;
  38012. /**
  38013. * Minimum allowed distance of the camera to the axis of rotation
  38014. * (The camera can not get closer).
  38015. * This can help limiting how the Camera is able to move in the scene.
  38016. */
  38017. lowerRadiusLimit: Nullable<number>;
  38018. /**
  38019. * Maximum allowed distance of the camera to the axis of rotation
  38020. * (The camera can not get further).
  38021. * This can help limiting how the Camera is able to move in the scene.
  38022. */
  38023. upperRadiusLimit: Nullable<number>;
  38024. /**
  38025. * Define a rotation offset between the camera and the object it follows
  38026. */
  38027. rotationOffset: number;
  38028. /**
  38029. * Minimum allowed angle to camera position relative to target object.
  38030. * This can help limiting how the Camera is able to move in the scene.
  38031. */
  38032. lowerRotationOffsetLimit: Nullable<number>;
  38033. /**
  38034. * Maximum allowed angle to camera position relative to target object.
  38035. * This can help limiting how the Camera is able to move in the scene.
  38036. */
  38037. upperRotationOffsetLimit: Nullable<number>;
  38038. /**
  38039. * Define a height offset between the camera and the object it follows.
  38040. * It can help following an object from the top (like a car chaing a plane)
  38041. */
  38042. heightOffset: number;
  38043. /**
  38044. * Minimum allowed height of camera position relative to target object.
  38045. * This can help limiting how the Camera is able to move in the scene.
  38046. */
  38047. lowerHeightOffsetLimit: Nullable<number>;
  38048. /**
  38049. * Maximum allowed height of camera position relative to target object.
  38050. * This can help limiting how the Camera is able to move in the scene.
  38051. */
  38052. upperHeightOffsetLimit: Nullable<number>;
  38053. /**
  38054. * Define how fast the camera can accelerate to follow it s target.
  38055. */
  38056. cameraAcceleration: number;
  38057. /**
  38058. * Define the speed limit of the camera following an object.
  38059. */
  38060. maxCameraSpeed: number;
  38061. /**
  38062. * Define the target of the camera.
  38063. */
  38064. lockedTarget: Nullable<AbstractMesh>;
  38065. /**
  38066. * Defines the input associated with the camera.
  38067. */
  38068. inputs: FollowCameraInputsManager;
  38069. /**
  38070. * Instantiates the follow camera.
  38071. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38072. * @param name Define the name of the camera in the scene
  38073. * @param position Define the position of the camera
  38074. * @param scene Define the scene the camera belong to
  38075. * @param lockedTarget Define the target of the camera
  38076. */
  38077. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38078. private _follow;
  38079. /**
  38080. * Attached controls to the current camera.
  38081. * @param element Defines the element the controls should be listened from
  38082. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38083. */
  38084. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38085. /**
  38086. * Detach the current controls from the camera.
  38087. * The camera will stop reacting to inputs.
  38088. * @param element Defines the element to stop listening the inputs from
  38089. */
  38090. detachControl(element: HTMLElement): void;
  38091. /** @hidden */
  38092. _checkInputs(): void;
  38093. private _checkLimits;
  38094. /**
  38095. * Gets the camera class name.
  38096. * @returns the class name
  38097. */
  38098. getClassName(): string;
  38099. }
  38100. /**
  38101. * Arc Rotate version of the follow camera.
  38102. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38103. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38104. */
  38105. export class ArcFollowCamera extends TargetCamera {
  38106. /** The longitudinal angle of the camera */
  38107. alpha: number;
  38108. /** The latitudinal angle of the camera */
  38109. beta: number;
  38110. /** The radius of the camera from its target */
  38111. radius: number;
  38112. /** Define the camera target (the messh it should follow) */
  38113. target: Nullable<AbstractMesh>;
  38114. private _cartesianCoordinates;
  38115. /**
  38116. * Instantiates a new ArcFollowCamera
  38117. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38118. * @param name Define the name of the camera
  38119. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38120. * @param beta Define the rotation angle of the camera around the elevation axis
  38121. * @param radius Define the radius of the camera from its target point
  38122. * @param target Define the target of the camera
  38123. * @param scene Define the scene the camera belongs to
  38124. */
  38125. constructor(name: string,
  38126. /** The longitudinal angle of the camera */
  38127. alpha: number,
  38128. /** The latitudinal angle of the camera */
  38129. beta: number,
  38130. /** The radius of the camera from its target */
  38131. radius: number,
  38132. /** Define the camera target (the messh it should follow) */
  38133. target: Nullable<AbstractMesh>, scene: Scene);
  38134. private _follow;
  38135. /** @hidden */
  38136. _checkInputs(): void;
  38137. /**
  38138. * Returns the class name of the object.
  38139. * It is mostly used internally for serialization purposes.
  38140. */
  38141. getClassName(): string;
  38142. }
  38143. }
  38144. declare module BABYLON {
  38145. /**
  38146. * Manage the keyboard inputs to control the movement of a follow camera.
  38147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38148. */
  38149. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38150. /**
  38151. * Defines the camera the input is attached to.
  38152. */
  38153. camera: FollowCamera;
  38154. /**
  38155. * Defines the list of key codes associated with the up action (increase heightOffset)
  38156. */
  38157. keysHeightOffsetIncr: number[];
  38158. /**
  38159. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38160. */
  38161. keysHeightOffsetDecr: number[];
  38162. /**
  38163. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38164. */
  38165. keysHeightOffsetModifierAlt: boolean;
  38166. /**
  38167. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38168. */
  38169. keysHeightOffsetModifierCtrl: boolean;
  38170. /**
  38171. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38172. */
  38173. keysHeightOffsetModifierShift: boolean;
  38174. /**
  38175. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38176. */
  38177. keysRotationOffsetIncr: number[];
  38178. /**
  38179. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38180. */
  38181. keysRotationOffsetDecr: number[];
  38182. /**
  38183. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38184. */
  38185. keysRotationOffsetModifierAlt: boolean;
  38186. /**
  38187. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38188. */
  38189. keysRotationOffsetModifierCtrl: boolean;
  38190. /**
  38191. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38192. */
  38193. keysRotationOffsetModifierShift: boolean;
  38194. /**
  38195. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38196. */
  38197. keysRadiusIncr: number[];
  38198. /**
  38199. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38200. */
  38201. keysRadiusDecr: number[];
  38202. /**
  38203. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38204. */
  38205. keysRadiusModifierAlt: boolean;
  38206. /**
  38207. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38208. */
  38209. keysRadiusModifierCtrl: boolean;
  38210. /**
  38211. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38212. */
  38213. keysRadiusModifierShift: boolean;
  38214. /**
  38215. * Defines the rate of change of heightOffset.
  38216. */
  38217. heightSensibility: number;
  38218. /**
  38219. * Defines the rate of change of rotationOffset.
  38220. */
  38221. rotationSensibility: number;
  38222. /**
  38223. * Defines the rate of change of radius.
  38224. */
  38225. radiusSensibility: number;
  38226. private _keys;
  38227. private _ctrlPressed;
  38228. private _altPressed;
  38229. private _shiftPressed;
  38230. private _onCanvasBlurObserver;
  38231. private _onKeyboardObserver;
  38232. private _engine;
  38233. private _scene;
  38234. /**
  38235. * Attach the input controls to a specific dom element to get the input from.
  38236. * @param element Defines the element the controls should be listened from
  38237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38238. */
  38239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38240. /**
  38241. * Detach the current controls from the specified dom element.
  38242. * @param element Defines the element to stop listening the inputs from
  38243. */
  38244. detachControl(element: Nullable<HTMLElement>): void;
  38245. /**
  38246. * Update the current camera state depending on the inputs that have been used this frame.
  38247. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38248. */
  38249. checkInputs(): void;
  38250. /**
  38251. * Gets the class name of the current input.
  38252. * @returns the class name
  38253. */
  38254. getClassName(): string;
  38255. /**
  38256. * Get the friendly name associated with the input class.
  38257. * @returns the input friendly name
  38258. */
  38259. getSimpleName(): string;
  38260. /**
  38261. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38262. * allow modification of the heightOffset value.
  38263. */
  38264. private _modifierHeightOffset;
  38265. /**
  38266. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38267. * allow modification of the rotationOffset value.
  38268. */
  38269. private _modifierRotationOffset;
  38270. /**
  38271. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38272. * allow modification of the radius value.
  38273. */
  38274. private _modifierRadius;
  38275. }
  38276. }
  38277. declare module BABYLON {
  38278. interface FreeCameraInputsManager {
  38279. /**
  38280. * @hidden
  38281. */
  38282. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38283. /**
  38284. * Add orientation input support to the input manager.
  38285. * @returns the current input manager
  38286. */
  38287. addDeviceOrientation(): FreeCameraInputsManager;
  38288. }
  38289. /**
  38290. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38291. * Screen rotation is taken into account.
  38292. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38293. */
  38294. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38295. private _camera;
  38296. private _screenOrientationAngle;
  38297. private _constantTranform;
  38298. private _screenQuaternion;
  38299. private _alpha;
  38300. private _beta;
  38301. private _gamma;
  38302. /**
  38303. * Can be used to detect if a device orientation sensor is availible on a device
  38304. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38305. * @returns a promise that will resolve on orientation change
  38306. */
  38307. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38308. /**
  38309. * @hidden
  38310. */
  38311. _onDeviceOrientationChangedObservable: Observable<void>;
  38312. /**
  38313. * Instantiates a new input
  38314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38315. */
  38316. constructor();
  38317. /**
  38318. * Define the camera controlled by the input.
  38319. */
  38320. camera: FreeCamera;
  38321. /**
  38322. * Attach the input controls to a specific dom element to get the input from.
  38323. * @param element Defines the element the controls should be listened from
  38324. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38325. */
  38326. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38327. private _orientationChanged;
  38328. private _deviceOrientation;
  38329. /**
  38330. * Detach the current controls from the specified dom element.
  38331. * @param element Defines the element to stop listening the inputs from
  38332. */
  38333. detachControl(element: Nullable<HTMLElement>): void;
  38334. /**
  38335. * Update the current camera state depending on the inputs that have been used this frame.
  38336. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38337. */
  38338. checkInputs(): void;
  38339. /**
  38340. * Gets the class name of the current intput.
  38341. * @returns the class name
  38342. */
  38343. getClassName(): string;
  38344. /**
  38345. * Get the friendly name associated with the input class.
  38346. * @returns the input friendly name
  38347. */
  38348. getSimpleName(): string;
  38349. }
  38350. }
  38351. declare module BABYLON {
  38352. /**
  38353. * Manage the gamepad inputs to control a free camera.
  38354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38355. */
  38356. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38357. /**
  38358. * Define the camera the input is attached to.
  38359. */
  38360. camera: FreeCamera;
  38361. /**
  38362. * Define the Gamepad controlling the input
  38363. */
  38364. gamepad: Nullable<Gamepad>;
  38365. /**
  38366. * Defines the gamepad rotation sensiblity.
  38367. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38368. */
  38369. gamepadAngularSensibility: number;
  38370. /**
  38371. * Defines the gamepad move sensiblity.
  38372. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38373. */
  38374. gamepadMoveSensibility: number;
  38375. private _yAxisScale;
  38376. /**
  38377. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38378. */
  38379. invertYAxis: boolean;
  38380. private _onGamepadConnectedObserver;
  38381. private _onGamepadDisconnectedObserver;
  38382. private _cameraTransform;
  38383. private _deltaTransform;
  38384. private _vector3;
  38385. private _vector2;
  38386. /**
  38387. * Attach the input controls to a specific dom element to get the input from.
  38388. * @param element Defines the element the controls should be listened from
  38389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38390. */
  38391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38392. /**
  38393. * Detach the current controls from the specified dom element.
  38394. * @param element Defines the element to stop listening the inputs from
  38395. */
  38396. detachControl(element: Nullable<HTMLElement>): void;
  38397. /**
  38398. * Update the current camera state depending on the inputs that have been used this frame.
  38399. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38400. */
  38401. checkInputs(): void;
  38402. /**
  38403. * Gets the class name of the current intput.
  38404. * @returns the class name
  38405. */
  38406. getClassName(): string;
  38407. /**
  38408. * Get the friendly name associated with the input class.
  38409. * @returns the input friendly name
  38410. */
  38411. getSimpleName(): string;
  38412. }
  38413. }
  38414. declare module BABYLON {
  38415. /**
  38416. * Defines the potential axis of a Joystick
  38417. */
  38418. export enum JoystickAxis {
  38419. /** X axis */
  38420. X = 0,
  38421. /** Y axis */
  38422. Y = 1,
  38423. /** Z axis */
  38424. Z = 2
  38425. }
  38426. /**
  38427. * Class used to define virtual joystick (used in touch mode)
  38428. */
  38429. export class VirtualJoystick {
  38430. /**
  38431. * Gets or sets a boolean indicating that left and right values must be inverted
  38432. */
  38433. reverseLeftRight: boolean;
  38434. /**
  38435. * Gets or sets a boolean indicating that up and down values must be inverted
  38436. */
  38437. reverseUpDown: boolean;
  38438. /**
  38439. * Gets the offset value for the position (ie. the change of the position value)
  38440. */
  38441. deltaPosition: Vector3;
  38442. /**
  38443. * Gets a boolean indicating if the virtual joystick was pressed
  38444. */
  38445. pressed: boolean;
  38446. /**
  38447. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38448. */
  38449. static Canvas: Nullable<HTMLCanvasElement>;
  38450. private static _globalJoystickIndex;
  38451. private static vjCanvasContext;
  38452. private static vjCanvasWidth;
  38453. private static vjCanvasHeight;
  38454. private static halfWidth;
  38455. private _action;
  38456. private _axisTargetedByLeftAndRight;
  38457. private _axisTargetedByUpAndDown;
  38458. private _joystickSensibility;
  38459. private _inversedSensibility;
  38460. private _joystickPointerID;
  38461. private _joystickColor;
  38462. private _joystickPointerPos;
  38463. private _joystickPreviousPointerPos;
  38464. private _joystickPointerStartPos;
  38465. private _deltaJoystickVector;
  38466. private _leftJoystick;
  38467. private _touches;
  38468. private _onPointerDownHandlerRef;
  38469. private _onPointerMoveHandlerRef;
  38470. private _onPointerUpHandlerRef;
  38471. private _onResize;
  38472. /**
  38473. * Creates a new virtual joystick
  38474. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38475. */
  38476. constructor(leftJoystick?: boolean);
  38477. /**
  38478. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38479. * @param newJoystickSensibility defines the new sensibility
  38480. */
  38481. setJoystickSensibility(newJoystickSensibility: number): void;
  38482. private _onPointerDown;
  38483. private _onPointerMove;
  38484. private _onPointerUp;
  38485. /**
  38486. * Change the color of the virtual joystick
  38487. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38488. */
  38489. setJoystickColor(newColor: string): void;
  38490. /**
  38491. * Defines a callback to call when the joystick is touched
  38492. * @param action defines the callback
  38493. */
  38494. setActionOnTouch(action: () => any): void;
  38495. /**
  38496. * Defines which axis you'd like to control for left & right
  38497. * @param axis defines the axis to use
  38498. */
  38499. setAxisForLeftRight(axis: JoystickAxis): void;
  38500. /**
  38501. * Defines which axis you'd like to control for up & down
  38502. * @param axis defines the axis to use
  38503. */
  38504. setAxisForUpDown(axis: JoystickAxis): void;
  38505. private _drawVirtualJoystick;
  38506. /**
  38507. * Release internal HTML canvas
  38508. */
  38509. releaseCanvas(): void;
  38510. }
  38511. }
  38512. declare module BABYLON {
  38513. interface FreeCameraInputsManager {
  38514. /**
  38515. * Add virtual joystick input support to the input manager.
  38516. * @returns the current input manager
  38517. */
  38518. addVirtualJoystick(): FreeCameraInputsManager;
  38519. }
  38520. /**
  38521. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38523. */
  38524. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38525. /**
  38526. * Defines the camera the input is attached to.
  38527. */
  38528. camera: FreeCamera;
  38529. private _leftjoystick;
  38530. private _rightjoystick;
  38531. /**
  38532. * Gets the left stick of the virtual joystick.
  38533. * @returns The virtual Joystick
  38534. */
  38535. getLeftJoystick(): VirtualJoystick;
  38536. /**
  38537. * Gets the right stick of the virtual joystick.
  38538. * @returns The virtual Joystick
  38539. */
  38540. getRightJoystick(): VirtualJoystick;
  38541. /**
  38542. * Update the current camera state depending on the inputs that have been used this frame.
  38543. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38544. */
  38545. checkInputs(): void;
  38546. /**
  38547. * Attach the input controls to a specific dom element to get the input from.
  38548. * @param element Defines the element the controls should be listened from
  38549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38550. */
  38551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38552. /**
  38553. * Detach the current controls from the specified dom element.
  38554. * @param element Defines the element to stop listening the inputs from
  38555. */
  38556. detachControl(element: Nullable<HTMLElement>): void;
  38557. /**
  38558. * Gets the class name of the current intput.
  38559. * @returns the class name
  38560. */
  38561. getClassName(): string;
  38562. /**
  38563. * Get the friendly name associated with the input class.
  38564. * @returns the input friendly name
  38565. */
  38566. getSimpleName(): string;
  38567. }
  38568. }
  38569. declare module BABYLON {
  38570. /**
  38571. * This represents a FPS type of camera controlled by touch.
  38572. * This is like a universal camera minus the Gamepad controls.
  38573. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38574. */
  38575. export class TouchCamera extends FreeCamera {
  38576. /**
  38577. * Defines the touch sensibility for rotation.
  38578. * The higher the faster.
  38579. */
  38580. touchAngularSensibility: number;
  38581. /**
  38582. * Defines the touch sensibility for move.
  38583. * The higher the faster.
  38584. */
  38585. touchMoveSensibility: number;
  38586. /**
  38587. * Instantiates a new touch camera.
  38588. * This represents a FPS type of camera controlled by touch.
  38589. * This is like a universal camera minus the Gamepad controls.
  38590. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38591. * @param name Define the name of the camera in the scene
  38592. * @param position Define the start position of the camera in the scene
  38593. * @param scene Define the scene the camera belongs to
  38594. */
  38595. constructor(name: string, position: Vector3, scene: Scene);
  38596. /**
  38597. * Gets the current object class name.
  38598. * @return the class name
  38599. */
  38600. getClassName(): string;
  38601. /** @hidden */
  38602. _setupInputs(): void;
  38603. }
  38604. }
  38605. declare module BABYLON {
  38606. /**
  38607. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38608. * being tilted forward or back and left or right.
  38609. */
  38610. export class DeviceOrientationCamera extends FreeCamera {
  38611. private _initialQuaternion;
  38612. private _quaternionCache;
  38613. private _tmpDragQuaternion;
  38614. private _disablePointerInputWhenUsingDeviceOrientation;
  38615. /**
  38616. * Creates a new device orientation camera
  38617. * @param name The name of the camera
  38618. * @param position The start position camera
  38619. * @param scene The scene the camera belongs to
  38620. */
  38621. constructor(name: string, position: Vector3, scene: Scene);
  38622. /**
  38623. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38624. */
  38625. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38626. private _dragFactor;
  38627. /**
  38628. * Enabled turning on the y axis when the orientation sensor is active
  38629. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38630. */
  38631. enableHorizontalDragging(dragFactor?: number): void;
  38632. /**
  38633. * Gets the current instance class name ("DeviceOrientationCamera").
  38634. * This helps avoiding instanceof at run time.
  38635. * @returns the class name
  38636. */
  38637. getClassName(): string;
  38638. /**
  38639. * @hidden
  38640. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38641. */
  38642. _checkInputs(): void;
  38643. /**
  38644. * Reset the camera to its default orientation on the specified axis only.
  38645. * @param axis The axis to reset
  38646. */
  38647. resetToCurrentRotation(axis?: Axis): void;
  38648. }
  38649. }
  38650. declare module BABYLON {
  38651. /**
  38652. * Defines supported buttons for XBox360 compatible gamepads
  38653. */
  38654. export enum Xbox360Button {
  38655. /** A */
  38656. A = 0,
  38657. /** B */
  38658. B = 1,
  38659. /** X */
  38660. X = 2,
  38661. /** Y */
  38662. Y = 3,
  38663. /** Start */
  38664. Start = 4,
  38665. /** Back */
  38666. Back = 5,
  38667. /** Left button */
  38668. LB = 6,
  38669. /** Right button */
  38670. RB = 7,
  38671. /** Left stick */
  38672. LeftStick = 8,
  38673. /** Right stick */
  38674. RightStick = 9
  38675. }
  38676. /** Defines values for XBox360 DPad */
  38677. export enum Xbox360Dpad {
  38678. /** Up */
  38679. Up = 0,
  38680. /** Down */
  38681. Down = 1,
  38682. /** Left */
  38683. Left = 2,
  38684. /** Right */
  38685. Right = 3
  38686. }
  38687. /**
  38688. * Defines a XBox360 gamepad
  38689. */
  38690. export class Xbox360Pad extends Gamepad {
  38691. private _leftTrigger;
  38692. private _rightTrigger;
  38693. private _onlefttriggerchanged;
  38694. private _onrighttriggerchanged;
  38695. private _onbuttondown;
  38696. private _onbuttonup;
  38697. private _ondpaddown;
  38698. private _ondpadup;
  38699. /** Observable raised when a button is pressed */
  38700. onButtonDownObservable: Observable<Xbox360Button>;
  38701. /** Observable raised when a button is released */
  38702. onButtonUpObservable: Observable<Xbox360Button>;
  38703. /** Observable raised when a pad is pressed */
  38704. onPadDownObservable: Observable<Xbox360Dpad>;
  38705. /** Observable raised when a pad is released */
  38706. onPadUpObservable: Observable<Xbox360Dpad>;
  38707. private _buttonA;
  38708. private _buttonB;
  38709. private _buttonX;
  38710. private _buttonY;
  38711. private _buttonBack;
  38712. private _buttonStart;
  38713. private _buttonLB;
  38714. private _buttonRB;
  38715. private _buttonLeftStick;
  38716. private _buttonRightStick;
  38717. private _dPadUp;
  38718. private _dPadDown;
  38719. private _dPadLeft;
  38720. private _dPadRight;
  38721. private _isXboxOnePad;
  38722. /**
  38723. * Creates a new XBox360 gamepad object
  38724. * @param id defines the id of this gamepad
  38725. * @param index defines its index
  38726. * @param gamepad defines the internal HTML gamepad object
  38727. * @param xboxOne defines if it is a XBox One gamepad
  38728. */
  38729. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38730. /**
  38731. * Defines the callback to call when left trigger is pressed
  38732. * @param callback defines the callback to use
  38733. */
  38734. onlefttriggerchanged(callback: (value: number) => void): void;
  38735. /**
  38736. * Defines the callback to call when right trigger is pressed
  38737. * @param callback defines the callback to use
  38738. */
  38739. onrighttriggerchanged(callback: (value: number) => void): void;
  38740. /**
  38741. * Gets the left trigger value
  38742. */
  38743. /**
  38744. * Sets the left trigger value
  38745. */
  38746. leftTrigger: number;
  38747. /**
  38748. * Gets the right trigger value
  38749. */
  38750. /**
  38751. * Sets the right trigger value
  38752. */
  38753. rightTrigger: number;
  38754. /**
  38755. * Defines the callback to call when a button is pressed
  38756. * @param callback defines the callback to use
  38757. */
  38758. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38759. /**
  38760. * Defines the callback to call when a button is released
  38761. * @param callback defines the callback to use
  38762. */
  38763. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38764. /**
  38765. * Defines the callback to call when a pad is pressed
  38766. * @param callback defines the callback to use
  38767. */
  38768. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38769. /**
  38770. * Defines the callback to call when a pad is released
  38771. * @param callback defines the callback to use
  38772. */
  38773. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38774. private _setButtonValue;
  38775. private _setDPadValue;
  38776. /**
  38777. * Gets the value of the `A` button
  38778. */
  38779. /**
  38780. * Sets the value of the `A` button
  38781. */
  38782. buttonA: number;
  38783. /**
  38784. * Gets the value of the `B` button
  38785. */
  38786. /**
  38787. * Sets the value of the `B` button
  38788. */
  38789. buttonB: number;
  38790. /**
  38791. * Gets the value of the `X` button
  38792. */
  38793. /**
  38794. * Sets the value of the `X` button
  38795. */
  38796. buttonX: number;
  38797. /**
  38798. * Gets the value of the `Y` button
  38799. */
  38800. /**
  38801. * Sets the value of the `Y` button
  38802. */
  38803. buttonY: number;
  38804. /**
  38805. * Gets the value of the `Start` button
  38806. */
  38807. /**
  38808. * Sets the value of the `Start` button
  38809. */
  38810. buttonStart: number;
  38811. /**
  38812. * Gets the value of the `Back` button
  38813. */
  38814. /**
  38815. * Sets the value of the `Back` button
  38816. */
  38817. buttonBack: number;
  38818. /**
  38819. * Gets the value of the `Left` button
  38820. */
  38821. /**
  38822. * Sets the value of the `Left` button
  38823. */
  38824. buttonLB: number;
  38825. /**
  38826. * Gets the value of the `Right` button
  38827. */
  38828. /**
  38829. * Sets the value of the `Right` button
  38830. */
  38831. buttonRB: number;
  38832. /**
  38833. * Gets the value of the Left joystick
  38834. */
  38835. /**
  38836. * Sets the value of the Left joystick
  38837. */
  38838. buttonLeftStick: number;
  38839. /**
  38840. * Gets the value of the Right joystick
  38841. */
  38842. /**
  38843. * Sets the value of the Right joystick
  38844. */
  38845. buttonRightStick: number;
  38846. /**
  38847. * Gets the value of D-pad up
  38848. */
  38849. /**
  38850. * Sets the value of D-pad up
  38851. */
  38852. dPadUp: number;
  38853. /**
  38854. * Gets the value of D-pad down
  38855. */
  38856. /**
  38857. * Sets the value of D-pad down
  38858. */
  38859. dPadDown: number;
  38860. /**
  38861. * Gets the value of D-pad left
  38862. */
  38863. /**
  38864. * Sets the value of D-pad left
  38865. */
  38866. dPadLeft: number;
  38867. /**
  38868. * Gets the value of D-pad right
  38869. */
  38870. /**
  38871. * Sets the value of D-pad right
  38872. */
  38873. dPadRight: number;
  38874. /**
  38875. * Force the gamepad to synchronize with device values
  38876. */
  38877. update(): void;
  38878. /**
  38879. * Disposes the gamepad
  38880. */
  38881. dispose(): void;
  38882. }
  38883. }
  38884. declare module BABYLON {
  38885. /**
  38886. * Defines supported buttons for DualShock compatible gamepads
  38887. */
  38888. export enum DualShockButton {
  38889. /** Cross */
  38890. Cross = 0,
  38891. /** Circle */
  38892. Circle = 1,
  38893. /** Square */
  38894. Square = 2,
  38895. /** Triangle */
  38896. Triangle = 3,
  38897. /** Options */
  38898. Options = 4,
  38899. /** Share */
  38900. Share = 5,
  38901. /** L1 */
  38902. L1 = 6,
  38903. /** R1 */
  38904. R1 = 7,
  38905. /** Left stick */
  38906. LeftStick = 8,
  38907. /** Right stick */
  38908. RightStick = 9
  38909. }
  38910. /** Defines values for DualShock DPad */
  38911. export enum DualShockDpad {
  38912. /** Up */
  38913. Up = 0,
  38914. /** Down */
  38915. Down = 1,
  38916. /** Left */
  38917. Left = 2,
  38918. /** Right */
  38919. Right = 3
  38920. }
  38921. /**
  38922. * Defines a DualShock gamepad
  38923. */
  38924. export class DualShockPad extends Gamepad {
  38925. private _leftTrigger;
  38926. private _rightTrigger;
  38927. private _onlefttriggerchanged;
  38928. private _onrighttriggerchanged;
  38929. private _onbuttondown;
  38930. private _onbuttonup;
  38931. private _ondpaddown;
  38932. private _ondpadup;
  38933. /** Observable raised when a button is pressed */
  38934. onButtonDownObservable: Observable<DualShockButton>;
  38935. /** Observable raised when a button is released */
  38936. onButtonUpObservable: Observable<DualShockButton>;
  38937. /** Observable raised when a pad is pressed */
  38938. onPadDownObservable: Observable<DualShockDpad>;
  38939. /** Observable raised when a pad is released */
  38940. onPadUpObservable: Observable<DualShockDpad>;
  38941. private _buttonCross;
  38942. private _buttonCircle;
  38943. private _buttonSquare;
  38944. private _buttonTriangle;
  38945. private _buttonShare;
  38946. private _buttonOptions;
  38947. private _buttonL1;
  38948. private _buttonR1;
  38949. private _buttonLeftStick;
  38950. private _buttonRightStick;
  38951. private _dPadUp;
  38952. private _dPadDown;
  38953. private _dPadLeft;
  38954. private _dPadRight;
  38955. /**
  38956. * Creates a new DualShock gamepad object
  38957. * @param id defines the id of this gamepad
  38958. * @param index defines its index
  38959. * @param gamepad defines the internal HTML gamepad object
  38960. */
  38961. constructor(id: string, index: number, gamepad: any);
  38962. /**
  38963. * Defines the callback to call when left trigger is pressed
  38964. * @param callback defines the callback to use
  38965. */
  38966. onlefttriggerchanged(callback: (value: number) => void): void;
  38967. /**
  38968. * Defines the callback to call when right trigger is pressed
  38969. * @param callback defines the callback to use
  38970. */
  38971. onrighttriggerchanged(callback: (value: number) => void): void;
  38972. /**
  38973. * Gets the left trigger value
  38974. */
  38975. /**
  38976. * Sets the left trigger value
  38977. */
  38978. leftTrigger: number;
  38979. /**
  38980. * Gets the right trigger value
  38981. */
  38982. /**
  38983. * Sets the right trigger value
  38984. */
  38985. rightTrigger: number;
  38986. /**
  38987. * Defines the callback to call when a button is pressed
  38988. * @param callback defines the callback to use
  38989. */
  38990. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38991. /**
  38992. * Defines the callback to call when a button is released
  38993. * @param callback defines the callback to use
  38994. */
  38995. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38996. /**
  38997. * Defines the callback to call when a pad is pressed
  38998. * @param callback defines the callback to use
  38999. */
  39000. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39001. /**
  39002. * Defines the callback to call when a pad is released
  39003. * @param callback defines the callback to use
  39004. */
  39005. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39006. private _setButtonValue;
  39007. private _setDPadValue;
  39008. /**
  39009. * Gets the value of the `Cross` button
  39010. */
  39011. /**
  39012. * Sets the value of the `Cross` button
  39013. */
  39014. buttonCross: number;
  39015. /**
  39016. * Gets the value of the `Circle` button
  39017. */
  39018. /**
  39019. * Sets the value of the `Circle` button
  39020. */
  39021. buttonCircle: number;
  39022. /**
  39023. * Gets the value of the `Square` button
  39024. */
  39025. /**
  39026. * Sets the value of the `Square` button
  39027. */
  39028. buttonSquare: number;
  39029. /**
  39030. * Gets the value of the `Triangle` button
  39031. */
  39032. /**
  39033. * Sets the value of the `Triangle` button
  39034. */
  39035. buttonTriangle: number;
  39036. /**
  39037. * Gets the value of the `Options` button
  39038. */
  39039. /**
  39040. * Sets the value of the `Options` button
  39041. */
  39042. buttonOptions: number;
  39043. /**
  39044. * Gets the value of the `Share` button
  39045. */
  39046. /**
  39047. * Sets the value of the `Share` button
  39048. */
  39049. buttonShare: number;
  39050. /**
  39051. * Gets the value of the `L1` button
  39052. */
  39053. /**
  39054. * Sets the value of the `L1` button
  39055. */
  39056. buttonL1: number;
  39057. /**
  39058. * Gets the value of the `R1` button
  39059. */
  39060. /**
  39061. * Sets the value of the `R1` button
  39062. */
  39063. buttonR1: number;
  39064. /**
  39065. * Gets the value of the Left joystick
  39066. */
  39067. /**
  39068. * Sets the value of the Left joystick
  39069. */
  39070. buttonLeftStick: number;
  39071. /**
  39072. * Gets the value of the Right joystick
  39073. */
  39074. /**
  39075. * Sets the value of the Right joystick
  39076. */
  39077. buttonRightStick: number;
  39078. /**
  39079. * Gets the value of D-pad up
  39080. */
  39081. /**
  39082. * Sets the value of D-pad up
  39083. */
  39084. dPadUp: number;
  39085. /**
  39086. * Gets the value of D-pad down
  39087. */
  39088. /**
  39089. * Sets the value of D-pad down
  39090. */
  39091. dPadDown: number;
  39092. /**
  39093. * Gets the value of D-pad left
  39094. */
  39095. /**
  39096. * Sets the value of D-pad left
  39097. */
  39098. dPadLeft: number;
  39099. /**
  39100. * Gets the value of D-pad right
  39101. */
  39102. /**
  39103. * Sets the value of D-pad right
  39104. */
  39105. dPadRight: number;
  39106. /**
  39107. * Force the gamepad to synchronize with device values
  39108. */
  39109. update(): void;
  39110. /**
  39111. * Disposes the gamepad
  39112. */
  39113. dispose(): void;
  39114. }
  39115. }
  39116. declare module BABYLON {
  39117. /**
  39118. * Manager for handling gamepads
  39119. */
  39120. export class GamepadManager {
  39121. private _scene?;
  39122. private _babylonGamepads;
  39123. private _oneGamepadConnected;
  39124. /** @hidden */
  39125. _isMonitoring: boolean;
  39126. private _gamepadEventSupported;
  39127. private _gamepadSupport;
  39128. /**
  39129. * observable to be triggered when the gamepad controller has been connected
  39130. */
  39131. onGamepadConnectedObservable: Observable<Gamepad>;
  39132. /**
  39133. * observable to be triggered when the gamepad controller has been disconnected
  39134. */
  39135. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39136. private _onGamepadConnectedEvent;
  39137. private _onGamepadDisconnectedEvent;
  39138. /**
  39139. * Initializes the gamepad manager
  39140. * @param _scene BabylonJS scene
  39141. */
  39142. constructor(_scene?: Scene | undefined);
  39143. /**
  39144. * The gamepads in the game pad manager
  39145. */
  39146. readonly gamepads: Gamepad[];
  39147. /**
  39148. * Get the gamepad controllers based on type
  39149. * @param type The type of gamepad controller
  39150. * @returns Nullable gamepad
  39151. */
  39152. getGamepadByType(type?: number): Nullable<Gamepad>;
  39153. /**
  39154. * Disposes the gamepad manager
  39155. */
  39156. dispose(): void;
  39157. private _addNewGamepad;
  39158. private _startMonitoringGamepads;
  39159. private _stopMonitoringGamepads;
  39160. /** @hidden */
  39161. _checkGamepadsStatus(): void;
  39162. private _updateGamepadObjects;
  39163. }
  39164. }
  39165. declare module BABYLON {
  39166. interface Scene {
  39167. /** @hidden */
  39168. _gamepadManager: Nullable<GamepadManager>;
  39169. /**
  39170. * Gets the gamepad manager associated with the scene
  39171. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39172. */
  39173. gamepadManager: GamepadManager;
  39174. }
  39175. /**
  39176. * Interface representing a free camera inputs manager
  39177. */
  39178. interface FreeCameraInputsManager {
  39179. /**
  39180. * Adds gamepad input support to the FreeCameraInputsManager.
  39181. * @returns the FreeCameraInputsManager
  39182. */
  39183. addGamepad(): FreeCameraInputsManager;
  39184. }
  39185. /**
  39186. * Interface representing an arc rotate camera inputs manager
  39187. */
  39188. interface ArcRotateCameraInputsManager {
  39189. /**
  39190. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39191. * @returns the camera inputs manager
  39192. */
  39193. addGamepad(): ArcRotateCameraInputsManager;
  39194. }
  39195. /**
  39196. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39197. */
  39198. export class GamepadSystemSceneComponent implements ISceneComponent {
  39199. /**
  39200. * The component name helpfull to identify the component in the list of scene components.
  39201. */
  39202. readonly name: string;
  39203. /**
  39204. * The scene the component belongs to.
  39205. */
  39206. scene: Scene;
  39207. /**
  39208. * Creates a new instance of the component for the given scene
  39209. * @param scene Defines the scene to register the component in
  39210. */
  39211. constructor(scene: Scene);
  39212. /**
  39213. * Registers the component in a given scene
  39214. */
  39215. register(): void;
  39216. /**
  39217. * Rebuilds the elements related to this component in case of
  39218. * context lost for instance.
  39219. */
  39220. rebuild(): void;
  39221. /**
  39222. * Disposes the component and the associated ressources
  39223. */
  39224. dispose(): void;
  39225. private _beforeCameraUpdate;
  39226. }
  39227. }
  39228. declare module BABYLON {
  39229. /**
  39230. * 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,
  39231. * which still works and will still be found in many Playgrounds.
  39232. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39233. */
  39234. export class UniversalCamera extends TouchCamera {
  39235. /**
  39236. * Defines the gamepad rotation sensiblity.
  39237. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39238. */
  39239. gamepadAngularSensibility: number;
  39240. /**
  39241. * Defines the gamepad move sensiblity.
  39242. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39243. */
  39244. gamepadMoveSensibility: number;
  39245. /**
  39246. * 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,
  39247. * which still works and will still be found in many Playgrounds.
  39248. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39249. * @param name Define the name of the camera in the scene
  39250. * @param position Define the start position of the camera in the scene
  39251. * @param scene Define the scene the camera belongs to
  39252. */
  39253. constructor(name: string, position: Vector3, scene: Scene);
  39254. /**
  39255. * Gets the current object class name.
  39256. * @return the class name
  39257. */
  39258. getClassName(): string;
  39259. }
  39260. }
  39261. declare module BABYLON {
  39262. /**
  39263. * This represents a FPS type of camera. This is only here for back compat purpose.
  39264. * Please use the UniversalCamera instead as both are identical.
  39265. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39266. */
  39267. export class GamepadCamera extends UniversalCamera {
  39268. /**
  39269. * Instantiates a new Gamepad Camera
  39270. * This represents a FPS type of camera. This is only here for back compat purpose.
  39271. * Please use the UniversalCamera instead as both are identical.
  39272. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39273. * @param name Define the name of the camera in the scene
  39274. * @param position Define the start position of the camera in the scene
  39275. * @param scene Define the scene the camera belongs to
  39276. */
  39277. constructor(name: string, position: Vector3, scene: Scene);
  39278. /**
  39279. * Gets the current object class name.
  39280. * @return the class name
  39281. */
  39282. getClassName(): string;
  39283. }
  39284. }
  39285. declare module BABYLON {
  39286. /** @hidden */
  39287. export var passPixelShader: {
  39288. name: string;
  39289. shader: string;
  39290. };
  39291. }
  39292. declare module BABYLON {
  39293. /** @hidden */
  39294. export var passCubePixelShader: {
  39295. name: string;
  39296. shader: string;
  39297. };
  39298. }
  39299. declare module BABYLON {
  39300. /**
  39301. * PassPostProcess which produces an output the same as it's input
  39302. */
  39303. export class PassPostProcess extends PostProcess {
  39304. /**
  39305. * Creates the PassPostProcess
  39306. * @param name The name of the effect.
  39307. * @param options The required width/height ratio to downsize to before computing the render pass.
  39308. * @param camera The camera to apply the render pass to.
  39309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39310. * @param engine The engine which the post process will be applied. (default: current engine)
  39311. * @param reusable If the post process can be reused on the same frame. (default: false)
  39312. * @param textureType The type of texture to be used when performing the post processing.
  39313. * @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)
  39314. */
  39315. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39316. }
  39317. /**
  39318. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39319. */
  39320. export class PassCubePostProcess extends PostProcess {
  39321. private _face;
  39322. /**
  39323. * Gets or sets the cube face to display.
  39324. * * 0 is +X
  39325. * * 1 is -X
  39326. * * 2 is +Y
  39327. * * 3 is -Y
  39328. * * 4 is +Z
  39329. * * 5 is -Z
  39330. */
  39331. face: number;
  39332. /**
  39333. * Creates the PassCubePostProcess
  39334. * @param name The name of the effect.
  39335. * @param options The required width/height ratio to downsize to before computing the render pass.
  39336. * @param camera The camera to apply the render pass to.
  39337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39338. * @param engine The engine which the post process will be applied. (default: current engine)
  39339. * @param reusable If the post process can be reused on the same frame. (default: false)
  39340. * @param textureType The type of texture to be used when performing the post processing.
  39341. * @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)
  39342. */
  39343. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39344. }
  39345. }
  39346. declare module BABYLON {
  39347. /** @hidden */
  39348. export var anaglyphPixelShader: {
  39349. name: string;
  39350. shader: string;
  39351. };
  39352. }
  39353. declare module BABYLON {
  39354. /**
  39355. * Postprocess used to generate anaglyphic rendering
  39356. */
  39357. export class AnaglyphPostProcess extends PostProcess {
  39358. private _passedProcess;
  39359. /**
  39360. * Creates a new AnaglyphPostProcess
  39361. * @param name defines postprocess name
  39362. * @param options defines creation options or target ratio scale
  39363. * @param rigCameras defines cameras using this postprocess
  39364. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39365. * @param engine defines hosting engine
  39366. * @param reusable defines if the postprocess will be reused multiple times per frame
  39367. */
  39368. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39369. }
  39370. }
  39371. declare module BABYLON {
  39372. /**
  39373. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39374. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39375. */
  39376. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39377. /**
  39378. * Creates a new AnaglyphArcRotateCamera
  39379. * @param name defines camera name
  39380. * @param alpha defines alpha angle (in radians)
  39381. * @param beta defines beta angle (in radians)
  39382. * @param radius defines radius
  39383. * @param target defines camera target
  39384. * @param interaxialDistance defines distance between each color axis
  39385. * @param scene defines the hosting scene
  39386. */
  39387. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39388. /**
  39389. * Gets camera class name
  39390. * @returns AnaglyphArcRotateCamera
  39391. */
  39392. getClassName(): string;
  39393. }
  39394. }
  39395. declare module BABYLON {
  39396. /**
  39397. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39398. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39399. */
  39400. export class AnaglyphFreeCamera extends FreeCamera {
  39401. /**
  39402. * Creates a new AnaglyphFreeCamera
  39403. * @param name defines camera name
  39404. * @param position defines initial position
  39405. * @param interaxialDistance defines distance between each color axis
  39406. * @param scene defines the hosting scene
  39407. */
  39408. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39409. /**
  39410. * Gets camera class name
  39411. * @returns AnaglyphFreeCamera
  39412. */
  39413. getClassName(): string;
  39414. }
  39415. }
  39416. declare module BABYLON {
  39417. /**
  39418. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39419. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39420. */
  39421. export class AnaglyphGamepadCamera extends GamepadCamera {
  39422. /**
  39423. * Creates a new AnaglyphGamepadCamera
  39424. * @param name defines camera name
  39425. * @param position defines initial position
  39426. * @param interaxialDistance defines distance between each color axis
  39427. * @param scene defines the hosting scene
  39428. */
  39429. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39430. /**
  39431. * Gets camera class name
  39432. * @returns AnaglyphGamepadCamera
  39433. */
  39434. getClassName(): string;
  39435. }
  39436. }
  39437. declare module BABYLON {
  39438. /**
  39439. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39440. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39441. */
  39442. export class AnaglyphUniversalCamera extends UniversalCamera {
  39443. /**
  39444. * Creates a new AnaglyphUniversalCamera
  39445. * @param name defines camera name
  39446. * @param position defines initial position
  39447. * @param interaxialDistance defines distance between each color axis
  39448. * @param scene defines the hosting scene
  39449. */
  39450. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39451. /**
  39452. * Gets camera class name
  39453. * @returns AnaglyphUniversalCamera
  39454. */
  39455. getClassName(): string;
  39456. }
  39457. }
  39458. declare module BABYLON {
  39459. /** @hidden */
  39460. export var stereoscopicInterlacePixelShader: {
  39461. name: string;
  39462. shader: string;
  39463. };
  39464. }
  39465. declare module BABYLON {
  39466. /**
  39467. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39468. */
  39469. export class StereoscopicInterlacePostProcess extends PostProcess {
  39470. private _stepSize;
  39471. private _passedProcess;
  39472. /**
  39473. * Initializes a StereoscopicInterlacePostProcess
  39474. * @param name The name of the effect.
  39475. * @param rigCameras The rig cameras to be appled to the post process
  39476. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39478. * @param engine The engine which the post process will be applied. (default: current engine)
  39479. * @param reusable If the post process can be reused on the same frame. (default: false)
  39480. */
  39481. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39482. }
  39483. }
  39484. declare module BABYLON {
  39485. /**
  39486. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39487. * @see http://doc.babylonjs.com/features/cameras
  39488. */
  39489. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39490. /**
  39491. * Creates a new StereoscopicArcRotateCamera
  39492. * @param name defines camera name
  39493. * @param alpha defines alpha angle (in radians)
  39494. * @param beta defines beta angle (in radians)
  39495. * @param radius defines radius
  39496. * @param target defines camera target
  39497. * @param interaxialDistance defines distance between each color axis
  39498. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39499. * @param scene defines the hosting scene
  39500. */
  39501. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39502. /**
  39503. * Gets camera class name
  39504. * @returns StereoscopicArcRotateCamera
  39505. */
  39506. getClassName(): string;
  39507. }
  39508. }
  39509. declare module BABYLON {
  39510. /**
  39511. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39512. * @see http://doc.babylonjs.com/features/cameras
  39513. */
  39514. export class StereoscopicFreeCamera extends FreeCamera {
  39515. /**
  39516. * Creates a new StereoscopicFreeCamera
  39517. * @param name defines camera name
  39518. * @param position defines initial position
  39519. * @param interaxialDistance defines distance between each color axis
  39520. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39521. * @param scene defines the hosting scene
  39522. */
  39523. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39524. /**
  39525. * Gets camera class name
  39526. * @returns StereoscopicFreeCamera
  39527. */
  39528. getClassName(): string;
  39529. }
  39530. }
  39531. declare module BABYLON {
  39532. /**
  39533. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39534. * @see http://doc.babylonjs.com/features/cameras
  39535. */
  39536. export class StereoscopicGamepadCamera extends GamepadCamera {
  39537. /**
  39538. * Creates a new StereoscopicGamepadCamera
  39539. * @param name defines camera name
  39540. * @param position defines initial position
  39541. * @param interaxialDistance defines distance between each color axis
  39542. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39543. * @param scene defines the hosting scene
  39544. */
  39545. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39546. /**
  39547. * Gets camera class name
  39548. * @returns StereoscopicGamepadCamera
  39549. */
  39550. getClassName(): string;
  39551. }
  39552. }
  39553. declare module BABYLON {
  39554. /**
  39555. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39556. * @see http://doc.babylonjs.com/features/cameras
  39557. */
  39558. export class StereoscopicUniversalCamera extends UniversalCamera {
  39559. /**
  39560. * Creates a new StereoscopicUniversalCamera
  39561. * @param name defines camera name
  39562. * @param position defines initial position
  39563. * @param interaxialDistance defines distance between each color axis
  39564. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39565. * @param scene defines the hosting scene
  39566. */
  39567. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39568. /**
  39569. * Gets camera class name
  39570. * @returns StereoscopicUniversalCamera
  39571. */
  39572. getClassName(): string;
  39573. }
  39574. }
  39575. declare module BABYLON {
  39576. /**
  39577. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39578. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39579. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39580. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39581. */
  39582. export class VirtualJoysticksCamera extends FreeCamera {
  39583. /**
  39584. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39585. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39586. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39587. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39588. * @param name Define the name of the camera in the scene
  39589. * @param position Define the start position of the camera in the scene
  39590. * @param scene Define the scene the camera belongs to
  39591. */
  39592. constructor(name: string, position: Vector3, scene: Scene);
  39593. /**
  39594. * Gets the current object class name.
  39595. * @return the class name
  39596. */
  39597. getClassName(): string;
  39598. }
  39599. }
  39600. declare module BABYLON {
  39601. /**
  39602. * This represents all the required metrics to create a VR camera.
  39603. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39604. */
  39605. export class VRCameraMetrics {
  39606. /**
  39607. * Define the horizontal resolution off the screen.
  39608. */
  39609. hResolution: number;
  39610. /**
  39611. * Define the vertical resolution off the screen.
  39612. */
  39613. vResolution: number;
  39614. /**
  39615. * Define the horizontal screen size.
  39616. */
  39617. hScreenSize: number;
  39618. /**
  39619. * Define the vertical screen size.
  39620. */
  39621. vScreenSize: number;
  39622. /**
  39623. * Define the vertical screen center position.
  39624. */
  39625. vScreenCenter: number;
  39626. /**
  39627. * Define the distance of the eyes to the screen.
  39628. */
  39629. eyeToScreenDistance: number;
  39630. /**
  39631. * Define the distance between both lenses
  39632. */
  39633. lensSeparationDistance: number;
  39634. /**
  39635. * Define the distance between both viewer's eyes.
  39636. */
  39637. interpupillaryDistance: number;
  39638. /**
  39639. * Define the distortion factor of the VR postprocess.
  39640. * Please, touch with care.
  39641. */
  39642. distortionK: number[];
  39643. /**
  39644. * Define the chromatic aberration correction factors for the VR post process.
  39645. */
  39646. chromaAbCorrection: number[];
  39647. /**
  39648. * Define the scale factor of the post process.
  39649. * The smaller the better but the slower.
  39650. */
  39651. postProcessScaleFactor: number;
  39652. /**
  39653. * Define an offset for the lens center.
  39654. */
  39655. lensCenterOffset: number;
  39656. /**
  39657. * Define if the current vr camera should compensate the distortion of the lense or not.
  39658. */
  39659. compensateDistortion: boolean;
  39660. /**
  39661. * Defines if multiview should be enabled when rendering (Default: false)
  39662. */
  39663. multiviewEnabled: boolean;
  39664. /**
  39665. * Gets the rendering aspect ratio based on the provided resolutions.
  39666. */
  39667. readonly aspectRatio: number;
  39668. /**
  39669. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39670. */
  39671. readonly aspectRatioFov: number;
  39672. /**
  39673. * @hidden
  39674. */
  39675. readonly leftHMatrix: Matrix;
  39676. /**
  39677. * @hidden
  39678. */
  39679. readonly rightHMatrix: Matrix;
  39680. /**
  39681. * @hidden
  39682. */
  39683. readonly leftPreViewMatrix: Matrix;
  39684. /**
  39685. * @hidden
  39686. */
  39687. readonly rightPreViewMatrix: Matrix;
  39688. /**
  39689. * Get the default VRMetrics based on the most generic setup.
  39690. * @returns the default vr metrics
  39691. */
  39692. static GetDefault(): VRCameraMetrics;
  39693. }
  39694. }
  39695. declare module BABYLON {
  39696. /** @hidden */
  39697. export var vrDistortionCorrectionPixelShader: {
  39698. name: string;
  39699. shader: string;
  39700. };
  39701. }
  39702. declare module BABYLON {
  39703. /**
  39704. * VRDistortionCorrectionPostProcess used for mobile VR
  39705. */
  39706. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39707. private _isRightEye;
  39708. private _distortionFactors;
  39709. private _postProcessScaleFactor;
  39710. private _lensCenterOffset;
  39711. private _scaleIn;
  39712. private _scaleFactor;
  39713. private _lensCenter;
  39714. /**
  39715. * Initializes the VRDistortionCorrectionPostProcess
  39716. * @param name The name of the effect.
  39717. * @param camera The camera to apply the render pass to.
  39718. * @param isRightEye If this is for the right eye distortion
  39719. * @param vrMetrics All the required metrics for the VR camera
  39720. */
  39721. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39722. }
  39723. }
  39724. declare module BABYLON {
  39725. /**
  39726. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39727. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39728. */
  39729. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39730. /**
  39731. * Creates a new VRDeviceOrientationArcRotateCamera
  39732. * @param name defines camera name
  39733. * @param alpha defines the camera rotation along the logitudinal axis
  39734. * @param beta defines the camera rotation along the latitudinal axis
  39735. * @param radius defines the camera distance from its target
  39736. * @param target defines the camera target
  39737. * @param scene defines the scene the camera belongs to
  39738. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39739. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39740. */
  39741. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39742. /**
  39743. * Gets camera class name
  39744. * @returns VRDeviceOrientationArcRotateCamera
  39745. */
  39746. getClassName(): string;
  39747. }
  39748. }
  39749. declare module BABYLON {
  39750. /**
  39751. * Camera used to simulate VR rendering (based on FreeCamera)
  39752. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39753. */
  39754. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39755. /**
  39756. * Creates a new VRDeviceOrientationFreeCamera
  39757. * @param name defines camera name
  39758. * @param position defines the start position of the camera
  39759. * @param scene defines the scene the camera belongs to
  39760. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39761. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39762. */
  39763. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39764. /**
  39765. * Gets camera class name
  39766. * @returns VRDeviceOrientationFreeCamera
  39767. */
  39768. getClassName(): string;
  39769. }
  39770. }
  39771. declare module BABYLON {
  39772. /**
  39773. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39774. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39775. */
  39776. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39777. /**
  39778. * Creates a new VRDeviceOrientationGamepadCamera
  39779. * @param name defines camera name
  39780. * @param position defines the start position of the camera
  39781. * @param scene defines the scene the camera belongs to
  39782. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39783. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39784. */
  39785. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39786. /**
  39787. * Gets camera class name
  39788. * @returns VRDeviceOrientationGamepadCamera
  39789. */
  39790. getClassName(): string;
  39791. }
  39792. }
  39793. declare module BABYLON {
  39794. /**
  39795. * Base class of materials working in push mode in babylon JS
  39796. * @hidden
  39797. */
  39798. export class PushMaterial extends Material {
  39799. protected _activeEffect: Effect;
  39800. protected _normalMatrix: Matrix;
  39801. /**
  39802. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39803. * This means that the material can keep using a previous shader while a new one is being compiled.
  39804. * This is mostly used when shader parallel compilation is supported (true by default)
  39805. */
  39806. allowShaderHotSwapping: boolean;
  39807. constructor(name: string, scene: Scene);
  39808. getEffect(): Effect;
  39809. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39810. /**
  39811. * Binds the given world matrix to the active effect
  39812. *
  39813. * @param world the matrix to bind
  39814. */
  39815. bindOnlyWorldMatrix(world: Matrix): void;
  39816. /**
  39817. * Binds the given normal matrix to the active effect
  39818. *
  39819. * @param normalMatrix the matrix to bind
  39820. */
  39821. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39822. bind(world: Matrix, mesh?: Mesh): void;
  39823. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39824. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39825. }
  39826. }
  39827. declare module BABYLON {
  39828. /**
  39829. * This groups all the flags used to control the materials channel.
  39830. */
  39831. export class MaterialFlags {
  39832. private static _DiffuseTextureEnabled;
  39833. /**
  39834. * Are diffuse textures enabled in the application.
  39835. */
  39836. static DiffuseTextureEnabled: boolean;
  39837. private static _AmbientTextureEnabled;
  39838. /**
  39839. * Are ambient textures enabled in the application.
  39840. */
  39841. static AmbientTextureEnabled: boolean;
  39842. private static _OpacityTextureEnabled;
  39843. /**
  39844. * Are opacity textures enabled in the application.
  39845. */
  39846. static OpacityTextureEnabled: boolean;
  39847. private static _ReflectionTextureEnabled;
  39848. /**
  39849. * Are reflection textures enabled in the application.
  39850. */
  39851. static ReflectionTextureEnabled: boolean;
  39852. private static _EmissiveTextureEnabled;
  39853. /**
  39854. * Are emissive textures enabled in the application.
  39855. */
  39856. static EmissiveTextureEnabled: boolean;
  39857. private static _SpecularTextureEnabled;
  39858. /**
  39859. * Are specular textures enabled in the application.
  39860. */
  39861. static SpecularTextureEnabled: boolean;
  39862. private static _BumpTextureEnabled;
  39863. /**
  39864. * Are bump textures enabled in the application.
  39865. */
  39866. static BumpTextureEnabled: boolean;
  39867. private static _LightmapTextureEnabled;
  39868. /**
  39869. * Are lightmap textures enabled in the application.
  39870. */
  39871. static LightmapTextureEnabled: boolean;
  39872. private static _RefractionTextureEnabled;
  39873. /**
  39874. * Are refraction textures enabled in the application.
  39875. */
  39876. static RefractionTextureEnabled: boolean;
  39877. private static _ColorGradingTextureEnabled;
  39878. /**
  39879. * Are color grading textures enabled in the application.
  39880. */
  39881. static ColorGradingTextureEnabled: boolean;
  39882. private static _FresnelEnabled;
  39883. /**
  39884. * Are fresnels enabled in the application.
  39885. */
  39886. static FresnelEnabled: boolean;
  39887. private static _ClearCoatTextureEnabled;
  39888. /**
  39889. * Are clear coat textures enabled in the application.
  39890. */
  39891. static ClearCoatTextureEnabled: boolean;
  39892. private static _ClearCoatBumpTextureEnabled;
  39893. /**
  39894. * Are clear coat bump textures enabled in the application.
  39895. */
  39896. static ClearCoatBumpTextureEnabled: boolean;
  39897. private static _ClearCoatTintTextureEnabled;
  39898. /**
  39899. * Are clear coat tint textures enabled in the application.
  39900. */
  39901. static ClearCoatTintTextureEnabled: boolean;
  39902. private static _SheenTextureEnabled;
  39903. /**
  39904. * Are sheen textures enabled in the application.
  39905. */
  39906. static SheenTextureEnabled: boolean;
  39907. private static _AnisotropicTextureEnabled;
  39908. /**
  39909. * Are anisotropic textures enabled in the application.
  39910. */
  39911. static AnisotropicTextureEnabled: boolean;
  39912. private static _ThicknessTextureEnabled;
  39913. /**
  39914. * Are thickness textures enabled in the application.
  39915. */
  39916. static ThicknessTextureEnabled: boolean;
  39917. }
  39918. }
  39919. declare module BABYLON {
  39920. /** @hidden */
  39921. export var defaultFragmentDeclaration: {
  39922. name: string;
  39923. shader: string;
  39924. };
  39925. }
  39926. declare module BABYLON {
  39927. /** @hidden */
  39928. export var defaultUboDeclaration: {
  39929. name: string;
  39930. shader: string;
  39931. };
  39932. }
  39933. declare module BABYLON {
  39934. /** @hidden */
  39935. export var lightFragmentDeclaration: {
  39936. name: string;
  39937. shader: string;
  39938. };
  39939. }
  39940. declare module BABYLON {
  39941. /** @hidden */
  39942. export var lightUboDeclaration: {
  39943. name: string;
  39944. shader: string;
  39945. };
  39946. }
  39947. declare module BABYLON {
  39948. /** @hidden */
  39949. export var lightsFragmentFunctions: {
  39950. name: string;
  39951. shader: string;
  39952. };
  39953. }
  39954. declare module BABYLON {
  39955. /** @hidden */
  39956. export var shadowsFragmentFunctions: {
  39957. name: string;
  39958. shader: string;
  39959. };
  39960. }
  39961. declare module BABYLON {
  39962. /** @hidden */
  39963. export var fresnelFunction: {
  39964. name: string;
  39965. shader: string;
  39966. };
  39967. }
  39968. declare module BABYLON {
  39969. /** @hidden */
  39970. export var reflectionFunction: {
  39971. name: string;
  39972. shader: string;
  39973. };
  39974. }
  39975. declare module BABYLON {
  39976. /** @hidden */
  39977. export var bumpFragmentFunctions: {
  39978. name: string;
  39979. shader: string;
  39980. };
  39981. }
  39982. declare module BABYLON {
  39983. /** @hidden */
  39984. export var logDepthDeclaration: {
  39985. name: string;
  39986. shader: string;
  39987. };
  39988. }
  39989. declare module BABYLON {
  39990. /** @hidden */
  39991. export var bumpFragment: {
  39992. name: string;
  39993. shader: string;
  39994. };
  39995. }
  39996. declare module BABYLON {
  39997. /** @hidden */
  39998. export var depthPrePass: {
  39999. name: string;
  40000. shader: string;
  40001. };
  40002. }
  40003. declare module BABYLON {
  40004. /** @hidden */
  40005. export var lightFragment: {
  40006. name: string;
  40007. shader: string;
  40008. };
  40009. }
  40010. declare module BABYLON {
  40011. /** @hidden */
  40012. export var logDepthFragment: {
  40013. name: string;
  40014. shader: string;
  40015. };
  40016. }
  40017. declare module BABYLON {
  40018. /** @hidden */
  40019. export var defaultPixelShader: {
  40020. name: string;
  40021. shader: string;
  40022. };
  40023. }
  40024. declare module BABYLON {
  40025. /** @hidden */
  40026. export var defaultVertexDeclaration: {
  40027. name: string;
  40028. shader: string;
  40029. };
  40030. }
  40031. declare module BABYLON {
  40032. /** @hidden */
  40033. export var bumpVertexDeclaration: {
  40034. name: string;
  40035. shader: string;
  40036. };
  40037. }
  40038. declare module BABYLON {
  40039. /** @hidden */
  40040. export var bumpVertex: {
  40041. name: string;
  40042. shader: string;
  40043. };
  40044. }
  40045. declare module BABYLON {
  40046. /** @hidden */
  40047. export var fogVertex: {
  40048. name: string;
  40049. shader: string;
  40050. };
  40051. }
  40052. declare module BABYLON {
  40053. /** @hidden */
  40054. export var shadowsVertex: {
  40055. name: string;
  40056. shader: string;
  40057. };
  40058. }
  40059. declare module BABYLON {
  40060. /** @hidden */
  40061. export var pointCloudVertex: {
  40062. name: string;
  40063. shader: string;
  40064. };
  40065. }
  40066. declare module BABYLON {
  40067. /** @hidden */
  40068. export var logDepthVertex: {
  40069. name: string;
  40070. shader: string;
  40071. };
  40072. }
  40073. declare module BABYLON {
  40074. /** @hidden */
  40075. export var defaultVertexShader: {
  40076. name: string;
  40077. shader: string;
  40078. };
  40079. }
  40080. declare module BABYLON {
  40081. /** @hidden */
  40082. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40083. MAINUV1: boolean;
  40084. MAINUV2: boolean;
  40085. DIFFUSE: boolean;
  40086. DIFFUSEDIRECTUV: number;
  40087. AMBIENT: boolean;
  40088. AMBIENTDIRECTUV: number;
  40089. OPACITY: boolean;
  40090. OPACITYDIRECTUV: number;
  40091. OPACITYRGB: boolean;
  40092. REFLECTION: boolean;
  40093. EMISSIVE: boolean;
  40094. EMISSIVEDIRECTUV: number;
  40095. SPECULAR: boolean;
  40096. SPECULARDIRECTUV: number;
  40097. BUMP: boolean;
  40098. BUMPDIRECTUV: number;
  40099. PARALLAX: boolean;
  40100. PARALLAXOCCLUSION: boolean;
  40101. SPECULAROVERALPHA: boolean;
  40102. CLIPPLANE: boolean;
  40103. CLIPPLANE2: boolean;
  40104. CLIPPLANE3: boolean;
  40105. CLIPPLANE4: boolean;
  40106. ALPHATEST: boolean;
  40107. DEPTHPREPASS: boolean;
  40108. ALPHAFROMDIFFUSE: boolean;
  40109. POINTSIZE: boolean;
  40110. FOG: boolean;
  40111. SPECULARTERM: boolean;
  40112. DIFFUSEFRESNEL: boolean;
  40113. OPACITYFRESNEL: boolean;
  40114. REFLECTIONFRESNEL: boolean;
  40115. REFRACTIONFRESNEL: boolean;
  40116. EMISSIVEFRESNEL: boolean;
  40117. FRESNEL: boolean;
  40118. NORMAL: boolean;
  40119. UV1: boolean;
  40120. UV2: boolean;
  40121. VERTEXCOLOR: boolean;
  40122. VERTEXALPHA: boolean;
  40123. NUM_BONE_INFLUENCERS: number;
  40124. BonesPerMesh: number;
  40125. BONETEXTURE: boolean;
  40126. INSTANCES: boolean;
  40127. GLOSSINESS: boolean;
  40128. ROUGHNESS: boolean;
  40129. EMISSIVEASILLUMINATION: boolean;
  40130. LINKEMISSIVEWITHDIFFUSE: boolean;
  40131. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40132. LIGHTMAP: boolean;
  40133. LIGHTMAPDIRECTUV: number;
  40134. OBJECTSPACE_NORMALMAP: boolean;
  40135. USELIGHTMAPASSHADOWMAP: boolean;
  40136. REFLECTIONMAP_3D: boolean;
  40137. REFLECTIONMAP_SPHERICAL: boolean;
  40138. REFLECTIONMAP_PLANAR: boolean;
  40139. REFLECTIONMAP_CUBIC: boolean;
  40140. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40141. REFLECTIONMAP_PROJECTION: boolean;
  40142. REFLECTIONMAP_SKYBOX: boolean;
  40143. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40144. REFLECTIONMAP_EXPLICIT: boolean;
  40145. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40146. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40147. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40148. INVERTCUBICMAP: boolean;
  40149. LOGARITHMICDEPTH: boolean;
  40150. REFRACTION: boolean;
  40151. REFRACTIONMAP_3D: boolean;
  40152. REFLECTIONOVERALPHA: boolean;
  40153. TWOSIDEDLIGHTING: boolean;
  40154. SHADOWFLOAT: boolean;
  40155. MORPHTARGETS: boolean;
  40156. MORPHTARGETS_NORMAL: boolean;
  40157. MORPHTARGETS_TANGENT: boolean;
  40158. MORPHTARGETS_UV: boolean;
  40159. NUM_MORPH_INFLUENCERS: number;
  40160. NONUNIFORMSCALING: boolean;
  40161. PREMULTIPLYALPHA: boolean;
  40162. IMAGEPROCESSING: boolean;
  40163. VIGNETTE: boolean;
  40164. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40165. VIGNETTEBLENDMODEOPAQUE: boolean;
  40166. TONEMAPPING: boolean;
  40167. TONEMAPPING_ACES: boolean;
  40168. CONTRAST: boolean;
  40169. COLORCURVES: boolean;
  40170. COLORGRADING: boolean;
  40171. COLORGRADING3D: boolean;
  40172. SAMPLER3DGREENDEPTH: boolean;
  40173. SAMPLER3DBGRMAP: boolean;
  40174. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40175. MULTIVIEW: boolean;
  40176. /**
  40177. * If the reflection texture on this material is in linear color space
  40178. * @hidden
  40179. */
  40180. IS_REFLECTION_LINEAR: boolean;
  40181. /**
  40182. * If the refraction texture on this material is in linear color space
  40183. * @hidden
  40184. */
  40185. IS_REFRACTION_LINEAR: boolean;
  40186. EXPOSURE: boolean;
  40187. constructor();
  40188. setReflectionMode(modeToEnable: string): void;
  40189. }
  40190. /**
  40191. * This is the default material used in Babylon. It is the best trade off between quality
  40192. * and performances.
  40193. * @see http://doc.babylonjs.com/babylon101/materials
  40194. */
  40195. export class StandardMaterial extends PushMaterial {
  40196. private _diffuseTexture;
  40197. /**
  40198. * The basic texture of the material as viewed under a light.
  40199. */
  40200. diffuseTexture: Nullable<BaseTexture>;
  40201. private _ambientTexture;
  40202. /**
  40203. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40204. */
  40205. ambientTexture: Nullable<BaseTexture>;
  40206. private _opacityTexture;
  40207. /**
  40208. * Define the transparency of the material from a texture.
  40209. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40210. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40211. */
  40212. opacityTexture: Nullable<BaseTexture>;
  40213. private _reflectionTexture;
  40214. /**
  40215. * Define the texture used to display the reflection.
  40216. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40217. */
  40218. reflectionTexture: Nullable<BaseTexture>;
  40219. private _emissiveTexture;
  40220. /**
  40221. * Define texture of the material as if self lit.
  40222. * This will be mixed in the final result even in the absence of light.
  40223. */
  40224. emissiveTexture: Nullable<BaseTexture>;
  40225. private _specularTexture;
  40226. /**
  40227. * Define how the color and intensity of the highlight given by the light in the material.
  40228. */
  40229. specularTexture: Nullable<BaseTexture>;
  40230. private _bumpTexture;
  40231. /**
  40232. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40233. * 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.
  40234. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40235. */
  40236. bumpTexture: Nullable<BaseTexture>;
  40237. private _lightmapTexture;
  40238. /**
  40239. * Complex lighting can be computationally expensive to compute at runtime.
  40240. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40241. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40242. */
  40243. lightmapTexture: Nullable<BaseTexture>;
  40244. private _refractionTexture;
  40245. /**
  40246. * Define the texture used to display the refraction.
  40247. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40248. */
  40249. refractionTexture: Nullable<BaseTexture>;
  40250. /**
  40251. * The color of the material lit by the environmental background lighting.
  40252. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40253. */
  40254. ambientColor: Color3;
  40255. /**
  40256. * The basic color of the material as viewed under a light.
  40257. */
  40258. diffuseColor: Color3;
  40259. /**
  40260. * Define how the color and intensity of the highlight given by the light in the material.
  40261. */
  40262. specularColor: Color3;
  40263. /**
  40264. * Define the color of the material as if self lit.
  40265. * This will be mixed in the final result even in the absence of light.
  40266. */
  40267. emissiveColor: Color3;
  40268. /**
  40269. * Defines how sharp are the highlights in the material.
  40270. * The bigger the value the sharper giving a more glossy feeling to the result.
  40271. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40272. */
  40273. specularPower: number;
  40274. private _useAlphaFromDiffuseTexture;
  40275. /**
  40276. * Does the transparency come from the diffuse texture alpha channel.
  40277. */
  40278. useAlphaFromDiffuseTexture: boolean;
  40279. private _useEmissiveAsIllumination;
  40280. /**
  40281. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40282. */
  40283. useEmissiveAsIllumination: boolean;
  40284. private _linkEmissiveWithDiffuse;
  40285. /**
  40286. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40287. * the emissive level when the final color is close to one.
  40288. */
  40289. linkEmissiveWithDiffuse: boolean;
  40290. private _useSpecularOverAlpha;
  40291. /**
  40292. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40293. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40294. */
  40295. useSpecularOverAlpha: boolean;
  40296. private _useReflectionOverAlpha;
  40297. /**
  40298. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40299. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40300. */
  40301. useReflectionOverAlpha: boolean;
  40302. private _disableLighting;
  40303. /**
  40304. * Does lights from the scene impacts this material.
  40305. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40306. */
  40307. disableLighting: boolean;
  40308. private _useObjectSpaceNormalMap;
  40309. /**
  40310. * Allows using an object space normal map (instead of tangent space).
  40311. */
  40312. useObjectSpaceNormalMap: boolean;
  40313. private _useParallax;
  40314. /**
  40315. * Is parallax enabled or not.
  40316. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40317. */
  40318. useParallax: boolean;
  40319. private _useParallaxOcclusion;
  40320. /**
  40321. * Is parallax occlusion enabled or not.
  40322. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40323. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40324. */
  40325. useParallaxOcclusion: boolean;
  40326. /**
  40327. * 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.
  40328. */
  40329. parallaxScaleBias: number;
  40330. private _roughness;
  40331. /**
  40332. * Helps to define how blurry the reflections should appears in the material.
  40333. */
  40334. roughness: number;
  40335. /**
  40336. * In case of refraction, define the value of the index of refraction.
  40337. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40338. */
  40339. indexOfRefraction: number;
  40340. /**
  40341. * Invert the refraction texture alongside the y axis.
  40342. * It can be useful with procedural textures or probe for instance.
  40343. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40344. */
  40345. invertRefractionY: boolean;
  40346. /**
  40347. * Defines the alpha limits in alpha test mode.
  40348. */
  40349. alphaCutOff: number;
  40350. private _useLightmapAsShadowmap;
  40351. /**
  40352. * In case of light mapping, define whether the map contains light or shadow informations.
  40353. */
  40354. useLightmapAsShadowmap: boolean;
  40355. private _diffuseFresnelParameters;
  40356. /**
  40357. * Define the diffuse fresnel parameters of the material.
  40358. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40359. */
  40360. diffuseFresnelParameters: FresnelParameters;
  40361. private _opacityFresnelParameters;
  40362. /**
  40363. * Define the opacity fresnel parameters of the material.
  40364. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40365. */
  40366. opacityFresnelParameters: FresnelParameters;
  40367. private _reflectionFresnelParameters;
  40368. /**
  40369. * Define the reflection fresnel parameters of the material.
  40370. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40371. */
  40372. reflectionFresnelParameters: FresnelParameters;
  40373. private _refractionFresnelParameters;
  40374. /**
  40375. * Define the refraction fresnel parameters of the material.
  40376. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40377. */
  40378. refractionFresnelParameters: FresnelParameters;
  40379. private _emissiveFresnelParameters;
  40380. /**
  40381. * Define the emissive fresnel parameters of the material.
  40382. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40383. */
  40384. emissiveFresnelParameters: FresnelParameters;
  40385. private _useReflectionFresnelFromSpecular;
  40386. /**
  40387. * If true automatically deducts the fresnels values from the material specularity.
  40388. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40389. */
  40390. useReflectionFresnelFromSpecular: boolean;
  40391. private _useGlossinessFromSpecularMapAlpha;
  40392. /**
  40393. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40394. */
  40395. useGlossinessFromSpecularMapAlpha: boolean;
  40396. private _maxSimultaneousLights;
  40397. /**
  40398. * Defines the maximum number of lights that can be used in the material
  40399. */
  40400. maxSimultaneousLights: number;
  40401. private _invertNormalMapX;
  40402. /**
  40403. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40404. */
  40405. invertNormalMapX: boolean;
  40406. private _invertNormalMapY;
  40407. /**
  40408. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40409. */
  40410. invertNormalMapY: boolean;
  40411. private _twoSidedLighting;
  40412. /**
  40413. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40414. */
  40415. twoSidedLighting: boolean;
  40416. /**
  40417. * Default configuration related to image processing available in the standard Material.
  40418. */
  40419. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40420. /**
  40421. * Gets the image processing configuration used either in this material.
  40422. */
  40423. /**
  40424. * Sets the Default image processing configuration used either in the this material.
  40425. *
  40426. * If sets to null, the scene one is in use.
  40427. */
  40428. imageProcessingConfiguration: ImageProcessingConfiguration;
  40429. /**
  40430. * Keep track of the image processing observer to allow dispose and replace.
  40431. */
  40432. private _imageProcessingObserver;
  40433. /**
  40434. * Attaches a new image processing configuration to the Standard Material.
  40435. * @param configuration
  40436. */
  40437. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40438. /**
  40439. * Gets wether the color curves effect is enabled.
  40440. */
  40441. /**
  40442. * Sets wether the color curves effect is enabled.
  40443. */
  40444. cameraColorCurvesEnabled: boolean;
  40445. /**
  40446. * Gets wether the color grading effect is enabled.
  40447. */
  40448. /**
  40449. * Gets wether the color grading effect is enabled.
  40450. */
  40451. cameraColorGradingEnabled: boolean;
  40452. /**
  40453. * Gets wether tonemapping is enabled or not.
  40454. */
  40455. /**
  40456. * Sets wether tonemapping is enabled or not
  40457. */
  40458. cameraToneMappingEnabled: boolean;
  40459. /**
  40460. * The camera exposure used on this material.
  40461. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40462. * This corresponds to a photographic exposure.
  40463. */
  40464. /**
  40465. * The camera exposure used on this material.
  40466. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40467. * This corresponds to a photographic exposure.
  40468. */
  40469. cameraExposure: number;
  40470. /**
  40471. * Gets The camera contrast used on this material.
  40472. */
  40473. /**
  40474. * Sets The camera contrast used on this material.
  40475. */
  40476. cameraContrast: number;
  40477. /**
  40478. * Gets the Color Grading 2D Lookup Texture.
  40479. */
  40480. /**
  40481. * Sets the Color Grading 2D Lookup Texture.
  40482. */
  40483. cameraColorGradingTexture: Nullable<BaseTexture>;
  40484. /**
  40485. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40486. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40487. * 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;
  40488. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40489. */
  40490. /**
  40491. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40492. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40493. * 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;
  40494. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40495. */
  40496. cameraColorCurves: Nullable<ColorCurves>;
  40497. /**
  40498. * Custom callback helping to override the default shader used in the material.
  40499. */
  40500. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40501. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40502. protected _worldViewProjectionMatrix: Matrix;
  40503. protected _globalAmbientColor: Color3;
  40504. protected _useLogarithmicDepth: boolean;
  40505. protected _rebuildInParallel: boolean;
  40506. /**
  40507. * Instantiates a new standard material.
  40508. * This is the default material used in Babylon. It is the best trade off between quality
  40509. * and performances.
  40510. * @see http://doc.babylonjs.com/babylon101/materials
  40511. * @param name Define the name of the material in the scene
  40512. * @param scene Define the scene the material belong to
  40513. */
  40514. constructor(name: string, scene: Scene);
  40515. /**
  40516. * Gets a boolean indicating that current material needs to register RTT
  40517. */
  40518. readonly hasRenderTargetTextures: boolean;
  40519. /**
  40520. * Gets the current class name of the material e.g. "StandardMaterial"
  40521. * Mainly use in serialization.
  40522. * @returns the class name
  40523. */
  40524. getClassName(): string;
  40525. /**
  40526. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40527. * You can try switching to logarithmic depth.
  40528. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40529. */
  40530. useLogarithmicDepth: boolean;
  40531. /**
  40532. * Specifies if the material will require alpha blending
  40533. * @returns a boolean specifying if alpha blending is needed
  40534. */
  40535. needAlphaBlending(): boolean;
  40536. /**
  40537. * Specifies if this material should be rendered in alpha test mode
  40538. * @returns a boolean specifying if an alpha test is needed.
  40539. */
  40540. needAlphaTesting(): boolean;
  40541. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40542. /**
  40543. * Get the texture used for alpha test purpose.
  40544. * @returns the diffuse texture in case of the standard material.
  40545. */
  40546. getAlphaTestTexture(): Nullable<BaseTexture>;
  40547. /**
  40548. * Get if the submesh is ready to be used and all its information available.
  40549. * Child classes can use it to update shaders
  40550. * @param mesh defines the mesh to check
  40551. * @param subMesh defines which submesh to check
  40552. * @param useInstances specifies that instances should be used
  40553. * @returns a boolean indicating that the submesh is ready or not
  40554. */
  40555. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40556. /**
  40557. * Builds the material UBO layouts.
  40558. * Used internally during the effect preparation.
  40559. */
  40560. buildUniformLayout(): void;
  40561. /**
  40562. * Unbinds the material from the mesh
  40563. */
  40564. unbind(): void;
  40565. /**
  40566. * Binds the submesh to this material by preparing the effect and shader to draw
  40567. * @param world defines the world transformation matrix
  40568. * @param mesh defines the mesh containing the submesh
  40569. * @param subMesh defines the submesh to bind the material to
  40570. */
  40571. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40572. /**
  40573. * Get the list of animatables in the material.
  40574. * @returns the list of animatables object used in the material
  40575. */
  40576. getAnimatables(): IAnimatable[];
  40577. /**
  40578. * Gets the active textures from the material
  40579. * @returns an array of textures
  40580. */
  40581. getActiveTextures(): BaseTexture[];
  40582. /**
  40583. * Specifies if the material uses a texture
  40584. * @param texture defines the texture to check against the material
  40585. * @returns a boolean specifying if the material uses the texture
  40586. */
  40587. hasTexture(texture: BaseTexture): boolean;
  40588. /**
  40589. * Disposes the material
  40590. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40591. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40592. */
  40593. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40594. /**
  40595. * Makes a duplicate of the material, and gives it a new name
  40596. * @param name defines the new name for the duplicated material
  40597. * @returns the cloned material
  40598. */
  40599. clone(name: string): StandardMaterial;
  40600. /**
  40601. * Serializes this material in a JSON representation
  40602. * @returns the serialized material object
  40603. */
  40604. serialize(): any;
  40605. /**
  40606. * Creates a standard material from parsed material data
  40607. * @param source defines the JSON representation of the material
  40608. * @param scene defines the hosting scene
  40609. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40610. * @returns a new standard material
  40611. */
  40612. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40613. /**
  40614. * Are diffuse textures enabled in the application.
  40615. */
  40616. static DiffuseTextureEnabled: boolean;
  40617. /**
  40618. * Are ambient textures enabled in the application.
  40619. */
  40620. static AmbientTextureEnabled: boolean;
  40621. /**
  40622. * Are opacity textures enabled in the application.
  40623. */
  40624. static OpacityTextureEnabled: boolean;
  40625. /**
  40626. * Are reflection textures enabled in the application.
  40627. */
  40628. static ReflectionTextureEnabled: boolean;
  40629. /**
  40630. * Are emissive textures enabled in the application.
  40631. */
  40632. static EmissiveTextureEnabled: boolean;
  40633. /**
  40634. * Are specular textures enabled in the application.
  40635. */
  40636. static SpecularTextureEnabled: boolean;
  40637. /**
  40638. * Are bump textures enabled in the application.
  40639. */
  40640. static BumpTextureEnabled: boolean;
  40641. /**
  40642. * Are lightmap textures enabled in the application.
  40643. */
  40644. static LightmapTextureEnabled: boolean;
  40645. /**
  40646. * Are refraction textures enabled in the application.
  40647. */
  40648. static RefractionTextureEnabled: boolean;
  40649. /**
  40650. * Are color grading textures enabled in the application.
  40651. */
  40652. static ColorGradingTextureEnabled: boolean;
  40653. /**
  40654. * Are fresnels enabled in the application.
  40655. */
  40656. static FresnelEnabled: boolean;
  40657. }
  40658. }
  40659. declare module BABYLON {
  40660. /** @hidden */
  40661. export var imageProcessingPixelShader: {
  40662. name: string;
  40663. shader: string;
  40664. };
  40665. }
  40666. declare module BABYLON {
  40667. /**
  40668. * ImageProcessingPostProcess
  40669. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40670. */
  40671. export class ImageProcessingPostProcess extends PostProcess {
  40672. /**
  40673. * Default configuration related to image processing available in the PBR Material.
  40674. */
  40675. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40676. /**
  40677. * Gets the image processing configuration used either in this material.
  40678. */
  40679. /**
  40680. * Sets the Default image processing configuration used either in the this material.
  40681. *
  40682. * If sets to null, the scene one is in use.
  40683. */
  40684. imageProcessingConfiguration: ImageProcessingConfiguration;
  40685. /**
  40686. * Keep track of the image processing observer to allow dispose and replace.
  40687. */
  40688. private _imageProcessingObserver;
  40689. /**
  40690. * Attaches a new image processing configuration to the PBR Material.
  40691. * @param configuration
  40692. */
  40693. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40694. /**
  40695. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40696. */
  40697. /**
  40698. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40699. */
  40700. colorCurves: Nullable<ColorCurves>;
  40701. /**
  40702. * Gets wether the color curves effect is enabled.
  40703. */
  40704. /**
  40705. * Sets wether the color curves effect is enabled.
  40706. */
  40707. colorCurvesEnabled: boolean;
  40708. /**
  40709. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40710. */
  40711. /**
  40712. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40713. */
  40714. colorGradingTexture: Nullable<BaseTexture>;
  40715. /**
  40716. * Gets wether the color grading effect is enabled.
  40717. */
  40718. /**
  40719. * Gets wether the color grading effect is enabled.
  40720. */
  40721. colorGradingEnabled: boolean;
  40722. /**
  40723. * Gets exposure used in the effect.
  40724. */
  40725. /**
  40726. * Sets exposure used in the effect.
  40727. */
  40728. exposure: number;
  40729. /**
  40730. * Gets wether tonemapping is enabled or not.
  40731. */
  40732. /**
  40733. * Sets wether tonemapping is enabled or not
  40734. */
  40735. toneMappingEnabled: boolean;
  40736. /**
  40737. * Gets the type of tone mapping effect.
  40738. */
  40739. /**
  40740. * Sets the type of tone mapping effect.
  40741. */
  40742. toneMappingType: number;
  40743. /**
  40744. * Gets contrast used in the effect.
  40745. */
  40746. /**
  40747. * Sets contrast used in the effect.
  40748. */
  40749. contrast: number;
  40750. /**
  40751. * Gets Vignette stretch size.
  40752. */
  40753. /**
  40754. * Sets Vignette stretch size.
  40755. */
  40756. vignetteStretch: number;
  40757. /**
  40758. * Gets Vignette centre X Offset.
  40759. */
  40760. /**
  40761. * Sets Vignette centre X Offset.
  40762. */
  40763. vignetteCentreX: number;
  40764. /**
  40765. * Gets Vignette centre Y Offset.
  40766. */
  40767. /**
  40768. * Sets Vignette centre Y Offset.
  40769. */
  40770. vignetteCentreY: number;
  40771. /**
  40772. * Gets Vignette weight or intensity of the vignette effect.
  40773. */
  40774. /**
  40775. * Sets Vignette weight or intensity of the vignette effect.
  40776. */
  40777. vignetteWeight: number;
  40778. /**
  40779. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40780. * if vignetteEnabled is set to true.
  40781. */
  40782. /**
  40783. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40784. * if vignetteEnabled is set to true.
  40785. */
  40786. vignetteColor: Color4;
  40787. /**
  40788. * Gets Camera field of view used by the Vignette effect.
  40789. */
  40790. /**
  40791. * Sets Camera field of view used by the Vignette effect.
  40792. */
  40793. vignetteCameraFov: number;
  40794. /**
  40795. * Gets the vignette blend mode allowing different kind of effect.
  40796. */
  40797. /**
  40798. * Sets the vignette blend mode allowing different kind of effect.
  40799. */
  40800. vignetteBlendMode: number;
  40801. /**
  40802. * Gets wether the vignette effect is enabled.
  40803. */
  40804. /**
  40805. * Sets wether the vignette effect is enabled.
  40806. */
  40807. vignetteEnabled: boolean;
  40808. private _fromLinearSpace;
  40809. /**
  40810. * Gets wether the input of the processing is in Gamma or Linear Space.
  40811. */
  40812. /**
  40813. * Sets wether the input of the processing is in Gamma or Linear Space.
  40814. */
  40815. fromLinearSpace: boolean;
  40816. /**
  40817. * Defines cache preventing GC.
  40818. */
  40819. private _defines;
  40820. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40821. /**
  40822. * "ImageProcessingPostProcess"
  40823. * @returns "ImageProcessingPostProcess"
  40824. */
  40825. getClassName(): string;
  40826. protected _updateParameters(): void;
  40827. dispose(camera?: Camera): void;
  40828. }
  40829. }
  40830. declare module BABYLON {
  40831. /**
  40832. * Class containing static functions to help procedurally build meshes
  40833. */
  40834. export class GroundBuilder {
  40835. /**
  40836. * Creates a ground mesh
  40837. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40838. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40840. * @param name defines the name of the mesh
  40841. * @param options defines the options used to create the mesh
  40842. * @param scene defines the hosting scene
  40843. * @returns the ground mesh
  40844. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40845. */
  40846. static CreateGround(name: string, options: {
  40847. width?: number;
  40848. height?: number;
  40849. subdivisions?: number;
  40850. subdivisionsX?: number;
  40851. subdivisionsY?: number;
  40852. updatable?: boolean;
  40853. }, scene: any): Mesh;
  40854. /**
  40855. * Creates a tiled ground mesh
  40856. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40857. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40858. * * 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
  40859. * * 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
  40860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40861. * @param name defines the name of the mesh
  40862. * @param options defines the options used to create the mesh
  40863. * @param scene defines the hosting scene
  40864. * @returns the tiled ground mesh
  40865. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40866. */
  40867. static CreateTiledGround(name: string, options: {
  40868. xmin: number;
  40869. zmin: number;
  40870. xmax: number;
  40871. zmax: number;
  40872. subdivisions?: {
  40873. w: number;
  40874. h: number;
  40875. };
  40876. precision?: {
  40877. w: number;
  40878. h: number;
  40879. };
  40880. updatable?: boolean;
  40881. }, scene?: Nullable<Scene>): Mesh;
  40882. /**
  40883. * Creates a ground mesh from a height map
  40884. * * The parameter `url` sets the URL of the height map image resource.
  40885. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40886. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40887. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40888. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40889. * * 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.
  40890. * * 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).
  40891. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40893. * @param name defines the name of the mesh
  40894. * @param url defines the url to the height map
  40895. * @param options defines the options used to create the mesh
  40896. * @param scene defines the hosting scene
  40897. * @returns the ground mesh
  40898. * @see https://doc.babylonjs.com/babylon101/height_map
  40899. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40900. */
  40901. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40902. width?: number;
  40903. height?: number;
  40904. subdivisions?: number;
  40905. minHeight?: number;
  40906. maxHeight?: number;
  40907. colorFilter?: Color3;
  40908. alphaFilter?: number;
  40909. updatable?: boolean;
  40910. onReady?: (mesh: GroundMesh) => void;
  40911. }, scene?: Nullable<Scene>): GroundMesh;
  40912. }
  40913. }
  40914. declare module BABYLON {
  40915. /**
  40916. * Class containing static functions to help procedurally build meshes
  40917. */
  40918. export class TorusBuilder {
  40919. /**
  40920. * Creates a torus mesh
  40921. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40922. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40923. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40925. * * 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
  40926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40927. * @param name defines the name of the mesh
  40928. * @param options defines the options used to create the mesh
  40929. * @param scene defines the hosting scene
  40930. * @returns the torus mesh
  40931. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40932. */
  40933. static CreateTorus(name: string, options: {
  40934. diameter?: number;
  40935. thickness?: number;
  40936. tessellation?: number;
  40937. updatable?: boolean;
  40938. sideOrientation?: number;
  40939. frontUVs?: Vector4;
  40940. backUVs?: Vector4;
  40941. }, scene: any): Mesh;
  40942. }
  40943. }
  40944. declare module BABYLON {
  40945. /**
  40946. * Class containing static functions to help procedurally build meshes
  40947. */
  40948. export class CylinderBuilder {
  40949. /**
  40950. * Creates a cylinder or a cone mesh
  40951. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40952. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40953. * * 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.
  40954. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40955. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40956. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40957. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40958. * * 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).
  40959. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40960. * * 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).
  40961. * * 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
  40962. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40963. * * 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
  40964. * * 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.
  40965. * * If `enclose` is false, a ring surface is one element.
  40966. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40967. * * 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
  40968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40969. * * 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
  40970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40971. * @param name defines the name of the mesh
  40972. * @param options defines the options used to create the mesh
  40973. * @param scene defines the hosting scene
  40974. * @returns the cylinder mesh
  40975. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40976. */
  40977. static CreateCylinder(name: string, options: {
  40978. height?: number;
  40979. diameterTop?: number;
  40980. diameterBottom?: number;
  40981. diameter?: number;
  40982. tessellation?: number;
  40983. subdivisions?: number;
  40984. arc?: number;
  40985. faceColors?: Color4[];
  40986. faceUV?: Vector4[];
  40987. updatable?: boolean;
  40988. hasRings?: boolean;
  40989. enclose?: boolean;
  40990. cap?: number;
  40991. sideOrientation?: number;
  40992. frontUVs?: Vector4;
  40993. backUVs?: Vector4;
  40994. }, scene: any): Mesh;
  40995. }
  40996. }
  40997. declare module BABYLON {
  40998. /**
  40999. * Options to modify the vr teleportation behavior.
  41000. */
  41001. export interface VRTeleportationOptions {
  41002. /**
  41003. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41004. */
  41005. floorMeshName?: string;
  41006. /**
  41007. * A list of meshes to be used as the teleportation floor. (default: empty)
  41008. */
  41009. floorMeshes?: Mesh[];
  41010. }
  41011. /**
  41012. * Options to modify the vr experience helper's behavior.
  41013. */
  41014. export interface VRExperienceHelperOptions extends WebVROptions {
  41015. /**
  41016. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41017. */
  41018. createDeviceOrientationCamera?: boolean;
  41019. /**
  41020. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41021. */
  41022. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41023. /**
  41024. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41025. */
  41026. laserToggle?: boolean;
  41027. /**
  41028. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41029. */
  41030. floorMeshes?: Mesh[];
  41031. /**
  41032. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41033. */
  41034. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41035. }
  41036. /**
  41037. * Event containing information after VR has been entered
  41038. */
  41039. export class OnAfterEnteringVRObservableEvent {
  41040. /**
  41041. * If entering vr was successful
  41042. */
  41043. success: boolean;
  41044. }
  41045. /**
  41046. * Helps to quickly add VR support to an existing scene.
  41047. * See http://doc.babylonjs.com/how_to/webvr_helper
  41048. */
  41049. export class VRExperienceHelper {
  41050. /** Options to modify the vr experience helper's behavior. */
  41051. webVROptions: VRExperienceHelperOptions;
  41052. private _scene;
  41053. private _position;
  41054. private _btnVR;
  41055. private _btnVRDisplayed;
  41056. private _webVRsupported;
  41057. private _webVRready;
  41058. private _webVRrequesting;
  41059. private _webVRpresenting;
  41060. private _hasEnteredVR;
  41061. private _fullscreenVRpresenting;
  41062. private _canvas;
  41063. private _webVRCamera;
  41064. private _vrDeviceOrientationCamera;
  41065. private _deviceOrientationCamera;
  41066. private _existingCamera;
  41067. private _onKeyDown;
  41068. private _onVrDisplayPresentChange;
  41069. private _onVRDisplayChanged;
  41070. private _onVRRequestPresentStart;
  41071. private _onVRRequestPresentComplete;
  41072. /**
  41073. * 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)
  41074. */
  41075. enableGazeEvenWhenNoPointerLock: boolean;
  41076. /**
  41077. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41078. */
  41079. exitVROnDoubleTap: boolean;
  41080. /**
  41081. * Observable raised right before entering VR.
  41082. */
  41083. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41084. /**
  41085. * Observable raised when entering VR has completed.
  41086. */
  41087. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41088. /**
  41089. * Observable raised when exiting VR.
  41090. */
  41091. onExitingVRObservable: Observable<VRExperienceHelper>;
  41092. /**
  41093. * Observable raised when controller mesh is loaded.
  41094. */
  41095. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41096. /** Return this.onEnteringVRObservable
  41097. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41098. */
  41099. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41100. /** Return this.onExitingVRObservable
  41101. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41102. */
  41103. readonly onExitingVR: Observable<VRExperienceHelper>;
  41104. /** Return this.onControllerMeshLoadedObservable
  41105. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41106. */
  41107. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41108. private _rayLength;
  41109. private _useCustomVRButton;
  41110. private _teleportationRequested;
  41111. private _teleportActive;
  41112. private _floorMeshName;
  41113. private _floorMeshesCollection;
  41114. private _rotationAllowed;
  41115. private _teleportBackwardsVector;
  41116. private _teleportationTarget;
  41117. private _isDefaultTeleportationTarget;
  41118. private _postProcessMove;
  41119. private _teleportationFillColor;
  41120. private _teleportationBorderColor;
  41121. private _rotationAngle;
  41122. private _haloCenter;
  41123. private _cameraGazer;
  41124. private _padSensibilityUp;
  41125. private _padSensibilityDown;
  41126. private _leftController;
  41127. private _rightController;
  41128. /**
  41129. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41130. */
  41131. onNewMeshSelected: Observable<AbstractMesh>;
  41132. /**
  41133. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41134. * This observable will provide the mesh and the controller used to select the mesh
  41135. */
  41136. onMeshSelectedWithController: Observable<{
  41137. mesh: AbstractMesh;
  41138. controller: WebVRController;
  41139. }>;
  41140. /**
  41141. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41142. */
  41143. onNewMeshPicked: Observable<PickingInfo>;
  41144. private _circleEase;
  41145. /**
  41146. * Observable raised before camera teleportation
  41147. */
  41148. onBeforeCameraTeleport: Observable<Vector3>;
  41149. /**
  41150. * Observable raised after camera teleportation
  41151. */
  41152. onAfterCameraTeleport: Observable<Vector3>;
  41153. /**
  41154. * Observable raised when current selected mesh gets unselected
  41155. */
  41156. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41157. private _raySelectionPredicate;
  41158. /**
  41159. * To be optionaly changed by user to define custom ray selection
  41160. */
  41161. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41162. /**
  41163. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41164. */
  41165. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41166. /**
  41167. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41168. */
  41169. teleportationEnabled: boolean;
  41170. private _defaultHeight;
  41171. private _teleportationInitialized;
  41172. private _interactionsEnabled;
  41173. private _interactionsRequested;
  41174. private _displayGaze;
  41175. private _displayLaserPointer;
  41176. /**
  41177. * The mesh used to display where the user is going to teleport.
  41178. */
  41179. /**
  41180. * Sets the mesh to be used to display where the user is going to teleport.
  41181. */
  41182. teleportationTarget: Mesh;
  41183. /**
  41184. * 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
  41185. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41186. * See http://doc.babylonjs.com/resources/baking_transformations
  41187. */
  41188. gazeTrackerMesh: Mesh;
  41189. /**
  41190. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41191. */
  41192. updateGazeTrackerScale: boolean;
  41193. /**
  41194. * If the gaze trackers color should be updated when selecting meshes
  41195. */
  41196. updateGazeTrackerColor: boolean;
  41197. /**
  41198. * If the controller laser color should be updated when selecting meshes
  41199. */
  41200. updateControllerLaserColor: boolean;
  41201. /**
  41202. * The gaze tracking mesh corresponding to the left controller
  41203. */
  41204. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41205. /**
  41206. * The gaze tracking mesh corresponding to the right controller
  41207. */
  41208. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41209. /**
  41210. * If the ray of the gaze should be displayed.
  41211. */
  41212. /**
  41213. * Sets if the ray of the gaze should be displayed.
  41214. */
  41215. displayGaze: boolean;
  41216. /**
  41217. * If the ray of the LaserPointer should be displayed.
  41218. */
  41219. /**
  41220. * Sets if the ray of the LaserPointer should be displayed.
  41221. */
  41222. displayLaserPointer: boolean;
  41223. /**
  41224. * The deviceOrientationCamera used as the camera when not in VR.
  41225. */
  41226. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41227. /**
  41228. * Based on the current WebVR support, returns the current VR camera used.
  41229. */
  41230. readonly currentVRCamera: Nullable<Camera>;
  41231. /**
  41232. * The webVRCamera which is used when in VR.
  41233. */
  41234. readonly webVRCamera: WebVRFreeCamera;
  41235. /**
  41236. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41237. */
  41238. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41239. /**
  41240. * The html button that is used to trigger entering into VR.
  41241. */
  41242. readonly vrButton: Nullable<HTMLButtonElement>;
  41243. private readonly _teleportationRequestInitiated;
  41244. /**
  41245. * Defines wether or not Pointer lock should be requested when switching to
  41246. * full screen.
  41247. */
  41248. requestPointerLockOnFullScreen: boolean;
  41249. /**
  41250. * Instantiates a VRExperienceHelper.
  41251. * Helps to quickly add VR support to an existing scene.
  41252. * @param scene The scene the VRExperienceHelper belongs to.
  41253. * @param webVROptions Options to modify the vr experience helper's behavior.
  41254. */
  41255. constructor(scene: Scene,
  41256. /** Options to modify the vr experience helper's behavior. */
  41257. webVROptions?: VRExperienceHelperOptions);
  41258. private _onDefaultMeshLoaded;
  41259. private _onResize;
  41260. private _onFullscreenChange;
  41261. /**
  41262. * Gets a value indicating if we are currently in VR mode.
  41263. */
  41264. readonly isInVRMode: boolean;
  41265. private onVrDisplayPresentChange;
  41266. private onVRDisplayChanged;
  41267. private moveButtonToBottomRight;
  41268. private displayVRButton;
  41269. private updateButtonVisibility;
  41270. private _cachedAngularSensibility;
  41271. /**
  41272. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41273. * Otherwise, will use the fullscreen API.
  41274. */
  41275. enterVR(): void;
  41276. /**
  41277. * Attempt to exit VR, or fullscreen.
  41278. */
  41279. exitVR(): void;
  41280. /**
  41281. * The position of the vr experience helper.
  41282. */
  41283. /**
  41284. * Sets the position of the vr experience helper.
  41285. */
  41286. position: Vector3;
  41287. /**
  41288. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41289. */
  41290. enableInteractions(): void;
  41291. private readonly _noControllerIsActive;
  41292. private beforeRender;
  41293. private _isTeleportationFloor;
  41294. /**
  41295. * Adds a floor mesh to be used for teleportation.
  41296. * @param floorMesh the mesh to be used for teleportation.
  41297. */
  41298. addFloorMesh(floorMesh: Mesh): void;
  41299. /**
  41300. * Removes a floor mesh from being used for teleportation.
  41301. * @param floorMesh the mesh to be removed.
  41302. */
  41303. removeFloorMesh(floorMesh: Mesh): void;
  41304. /**
  41305. * Enables interactions and teleportation using the VR controllers and gaze.
  41306. * @param vrTeleportationOptions options to modify teleportation behavior.
  41307. */
  41308. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41309. private _onNewGamepadConnected;
  41310. private _tryEnableInteractionOnController;
  41311. private _onNewGamepadDisconnected;
  41312. private _enableInteractionOnController;
  41313. private _checkTeleportWithRay;
  41314. private _checkRotate;
  41315. private _checkTeleportBackwards;
  41316. private _enableTeleportationOnController;
  41317. private _createTeleportationCircles;
  41318. private _displayTeleportationTarget;
  41319. private _hideTeleportationTarget;
  41320. private _rotateCamera;
  41321. private _moveTeleportationSelectorTo;
  41322. private _workingVector;
  41323. private _workingQuaternion;
  41324. private _workingMatrix;
  41325. /**
  41326. * Teleports the users feet to the desired location
  41327. * @param location The location where the user's feet should be placed
  41328. */
  41329. teleportCamera(location: Vector3): void;
  41330. private _convertNormalToDirectionOfRay;
  41331. private _castRayAndSelectObject;
  41332. private _notifySelectedMeshUnselected;
  41333. /**
  41334. * Sets the color of the laser ray from the vr controllers.
  41335. * @param color new color for the ray.
  41336. */
  41337. changeLaserColor(color: Color3): void;
  41338. /**
  41339. * Sets the color of the ray from the vr headsets gaze.
  41340. * @param color new color for the ray.
  41341. */
  41342. changeGazeColor(color: Color3): void;
  41343. /**
  41344. * Exits VR and disposes of the vr experience helper
  41345. */
  41346. dispose(): void;
  41347. /**
  41348. * Gets the name of the VRExperienceHelper class
  41349. * @returns "VRExperienceHelper"
  41350. */
  41351. getClassName(): string;
  41352. }
  41353. }
  41354. declare module BABYLON {
  41355. /**
  41356. * Manages an XRSession to work with Babylon's engine
  41357. * @see https://doc.babylonjs.com/how_to/webxr
  41358. */
  41359. export class WebXRSessionManager implements IDisposable {
  41360. private scene;
  41361. /**
  41362. * Fires every time a new xrFrame arrives which can be used to update the camera
  41363. */
  41364. onXRFrameObservable: Observable<any>;
  41365. /**
  41366. * Fires when the xr session is ended either by the device or manually done
  41367. */
  41368. onXRSessionEnded: Observable<any>;
  41369. /**
  41370. * Underlying xr session
  41371. */
  41372. session: XRSession;
  41373. /**
  41374. * Type of reference space used when creating the session
  41375. */
  41376. referenceSpace: XRReferenceSpace;
  41377. /** @hidden */
  41378. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41379. /**
  41380. * Current XR frame
  41381. */
  41382. currentFrame: Nullable<XRFrame>;
  41383. private _xrNavigator;
  41384. private baseLayer;
  41385. /**
  41386. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41387. * @param scene The scene which the session should be created for
  41388. */
  41389. constructor(scene: Scene);
  41390. /**
  41391. * Initializes the manager
  41392. * After initialization enterXR can be called to start an XR session
  41393. * @returns Promise which resolves after it is initialized
  41394. */
  41395. initializeAsync(): Promise<void>;
  41396. /**
  41397. * Initializes an xr session
  41398. * @param xrSessionMode mode to initialize
  41399. * @returns a promise which will resolve once the session has been initialized
  41400. */
  41401. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41402. /**
  41403. * Sets the reference space on the xr session
  41404. * @param referenceSpace space to set
  41405. * @returns a promise that will resolve once the reference space has been set
  41406. */
  41407. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41408. /**
  41409. * Updates the render state of the session
  41410. * @param state state to set
  41411. * @returns a promise that resolves once the render state has been updated
  41412. */
  41413. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41414. /**
  41415. * Starts rendering to the xr layer
  41416. * @returns a promise that will resolve once rendering has started
  41417. */
  41418. startRenderingToXRAsync(): Promise<void>;
  41419. /**
  41420. * Stops the xrSession and restores the renderloop
  41421. * @returns Promise which resolves after it exits XR
  41422. */
  41423. exitXRAsync(): Promise<unknown>;
  41424. /**
  41425. * Checks if a session would be supported for the creation options specified
  41426. * @param sessionMode session mode to check if supported eg. immersive-vr
  41427. * @returns true if supported
  41428. */
  41429. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41430. /**
  41431. * @hidden
  41432. * Converts the render layer of xrSession to a render target
  41433. * @param session session to create render target for
  41434. * @param scene scene the new render target should be created for
  41435. */
  41436. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41437. /**
  41438. * Disposes of the session manager
  41439. */
  41440. dispose(): void;
  41441. }
  41442. }
  41443. declare module BABYLON {
  41444. /**
  41445. * WebXR Camera which holds the views for the xrSession
  41446. * @see https://doc.babylonjs.com/how_to/webxr
  41447. */
  41448. export class WebXRCamera extends FreeCamera {
  41449. private static _TmpMatrix;
  41450. /**
  41451. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41452. * @param name the name of the camera
  41453. * @param scene the scene to add the camera to
  41454. */
  41455. constructor(name: string, scene: Scene);
  41456. private _updateNumberOfRigCameras;
  41457. /** @hidden */
  41458. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41459. /**
  41460. * Updates the cameras position from the current pose information of the XR session
  41461. * @param xrSessionManager the session containing pose information
  41462. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41463. */
  41464. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41465. }
  41466. }
  41467. declare module BABYLON {
  41468. /**
  41469. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41470. */
  41471. export class WebXRManagedOutputCanvas implements IDisposable {
  41472. private helper;
  41473. private _canvas;
  41474. /**
  41475. * xrpresent context of the canvas which can be used to display/mirror xr content
  41476. */
  41477. canvasContext: WebGLRenderingContext;
  41478. /**
  41479. * xr layer for the canvas
  41480. */
  41481. xrLayer: Nullable<XRWebGLLayer>;
  41482. /**
  41483. * Initializes the xr layer for the session
  41484. * @param xrSession xr session
  41485. * @returns a promise that will resolve once the XR Layer has been created
  41486. */
  41487. initializeXRLayerAsync(xrSession: any): any;
  41488. /**
  41489. * Initializes the canvas to be added/removed upon entering/exiting xr
  41490. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41491. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41492. */
  41493. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41494. /**
  41495. * Disposes of the object
  41496. */
  41497. dispose(): void;
  41498. private _setManagedOutputCanvas;
  41499. private _addCanvas;
  41500. private _removeCanvas;
  41501. }
  41502. }
  41503. declare module BABYLON {
  41504. /**
  41505. * States of the webXR experience
  41506. */
  41507. export enum WebXRState {
  41508. /**
  41509. * Transitioning to being in XR mode
  41510. */
  41511. ENTERING_XR = 0,
  41512. /**
  41513. * Transitioning to non XR mode
  41514. */
  41515. EXITING_XR = 1,
  41516. /**
  41517. * In XR mode and presenting
  41518. */
  41519. IN_XR = 2,
  41520. /**
  41521. * Not entered XR mode
  41522. */
  41523. NOT_IN_XR = 3
  41524. }
  41525. /**
  41526. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41527. * @see https://doc.babylonjs.com/how_to/webxr
  41528. */
  41529. export class WebXRExperienceHelper implements IDisposable {
  41530. private scene;
  41531. /**
  41532. * 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
  41533. */
  41534. container: AbstractMesh;
  41535. /**
  41536. * Camera used to render xr content
  41537. */
  41538. camera: WebXRCamera;
  41539. /**
  41540. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41541. */
  41542. state: WebXRState;
  41543. private _setState;
  41544. private static _TmpVector;
  41545. /**
  41546. * Fires when the state of the experience helper has changed
  41547. */
  41548. onStateChangedObservable: Observable<WebXRState>;
  41549. /** Session manager used to keep track of xr session */
  41550. sessionManager: WebXRSessionManager;
  41551. private _nonVRCamera;
  41552. private _originalSceneAutoClear;
  41553. private _supported;
  41554. /**
  41555. * Creates the experience helper
  41556. * @param scene the scene to attach the experience helper to
  41557. * @returns a promise for the experience helper
  41558. */
  41559. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41560. /**
  41561. * Creates a WebXRExperienceHelper
  41562. * @param scene The scene the helper should be created in
  41563. */
  41564. private constructor();
  41565. /**
  41566. * Exits XR mode and returns the scene to its original state
  41567. * @returns promise that resolves after xr mode has exited
  41568. */
  41569. exitXRAsync(): Promise<unknown>;
  41570. /**
  41571. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41572. * @param sessionCreationOptions options for the XR session
  41573. * @param referenceSpaceType frame of reference of the XR session
  41574. * @param outputCanvas the output canvas that will be used to enter XR mode
  41575. * @returns promise that resolves after xr mode has entered
  41576. */
  41577. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41578. /**
  41579. * Updates the global position of the camera by moving the camera's container
  41580. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41581. * @param position The desired global position of the camera
  41582. */
  41583. setPositionOfCameraUsingContainer(position: Vector3): void;
  41584. /**
  41585. * Rotates the xr camera by rotating the camera's container around the camera's position
  41586. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41587. * @param rotation the desired quaternion rotation to apply to the camera
  41588. */
  41589. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41590. /**
  41591. * Disposes of the experience helper
  41592. */
  41593. dispose(): void;
  41594. }
  41595. }
  41596. declare module BABYLON {
  41597. /**
  41598. * Button which can be used to enter a different mode of XR
  41599. */
  41600. export class WebXREnterExitUIButton {
  41601. /** button element */
  41602. element: HTMLElement;
  41603. /** XR initialization options for the button */
  41604. sessionMode: XRSessionMode;
  41605. /** Reference space type */
  41606. referenceSpaceType: XRReferenceSpaceType;
  41607. /**
  41608. * Creates a WebXREnterExitUIButton
  41609. * @param element button element
  41610. * @param sessionMode XR initialization session mode
  41611. * @param referenceSpaceType the type of reference space to be used
  41612. */
  41613. constructor(
  41614. /** button element */
  41615. element: HTMLElement,
  41616. /** XR initialization options for the button */
  41617. sessionMode: XRSessionMode,
  41618. /** Reference space type */
  41619. referenceSpaceType: XRReferenceSpaceType);
  41620. /**
  41621. * Overwritable function which can be used to update the button's visuals when the state changes
  41622. * @param activeButton the current active button in the UI
  41623. */
  41624. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41625. }
  41626. /**
  41627. * Options to create the webXR UI
  41628. */
  41629. export class WebXREnterExitUIOptions {
  41630. /**
  41631. * Context to enter xr with
  41632. */
  41633. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41634. /**
  41635. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41636. */
  41637. customButtons?: Array<WebXREnterExitUIButton>;
  41638. }
  41639. /**
  41640. * UI to allow the user to enter/exit XR mode
  41641. */
  41642. export class WebXREnterExitUI implements IDisposable {
  41643. private scene;
  41644. private _overlay;
  41645. private _buttons;
  41646. private _activeButton;
  41647. /**
  41648. * Fired every time the active button is changed.
  41649. *
  41650. * When xr is entered via a button that launches xr that button will be the callback parameter
  41651. *
  41652. * When exiting xr the callback parameter will be null)
  41653. */
  41654. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41655. /**
  41656. * Creates UI to allow the user to enter/exit XR mode
  41657. * @param scene the scene to add the ui to
  41658. * @param helper the xr experience helper to enter/exit xr with
  41659. * @param options options to configure the UI
  41660. * @returns the created ui
  41661. */
  41662. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41663. private constructor();
  41664. private _updateButtons;
  41665. /**
  41666. * Disposes of the object
  41667. */
  41668. dispose(): void;
  41669. }
  41670. }
  41671. declare module BABYLON {
  41672. /**
  41673. * Represents an XR input
  41674. */
  41675. export class WebXRController {
  41676. private scene;
  41677. /** The underlying input source for the controller */
  41678. inputSource: XRInputSource;
  41679. private parentContainer;
  41680. /**
  41681. * 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
  41682. */
  41683. grip?: AbstractMesh;
  41684. /**
  41685. * Pointer which can be used to select objects or attach a visible laser to
  41686. */
  41687. pointer: AbstractMesh;
  41688. /**
  41689. * Event that fires when the controller is removed/disposed
  41690. */
  41691. onDisposeObservable: Observable<{}>;
  41692. private _tmpMatrix;
  41693. private _tmpQuaternion;
  41694. private _tmpVector;
  41695. /**
  41696. * Creates the controller
  41697. * @see https://doc.babylonjs.com/how_to/webxr
  41698. * @param scene the scene which the controller should be associated to
  41699. * @param inputSource the underlying input source for the controller
  41700. * @param parentContainer parent that the controller meshes should be children of
  41701. */
  41702. constructor(scene: Scene,
  41703. /** The underlying input source for the controller */
  41704. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41705. /**
  41706. * Updates the controller pose based on the given XRFrame
  41707. * @param xrFrame xr frame to update the pose with
  41708. * @param referenceSpace reference space to use
  41709. */
  41710. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41711. /**
  41712. * Gets a world space ray coming from the controller
  41713. * @param result the resulting ray
  41714. */
  41715. getWorldPointerRayToRef(result: Ray): void;
  41716. /**
  41717. * Disposes of the object
  41718. */
  41719. dispose(): void;
  41720. }
  41721. }
  41722. declare module BABYLON {
  41723. /**
  41724. * XR input used to track XR inputs such as controllers/rays
  41725. */
  41726. export class WebXRInput implements IDisposable {
  41727. /**
  41728. * Base experience the input listens to
  41729. */
  41730. baseExperience: WebXRExperienceHelper;
  41731. /**
  41732. * XR controllers being tracked
  41733. */
  41734. controllers: Array<WebXRController>;
  41735. private _frameObserver;
  41736. private _stateObserver;
  41737. /**
  41738. * Event when a controller has been connected/added
  41739. */
  41740. onControllerAddedObservable: Observable<WebXRController>;
  41741. /**
  41742. * Event when a controller has been removed/disconnected
  41743. */
  41744. onControllerRemovedObservable: Observable<WebXRController>;
  41745. /**
  41746. * Initializes the WebXRInput
  41747. * @param baseExperience experience helper which the input should be created for
  41748. */
  41749. constructor(
  41750. /**
  41751. * Base experience the input listens to
  41752. */
  41753. baseExperience: WebXRExperienceHelper);
  41754. private _onInputSourcesChange;
  41755. private _addAndRemoveControllers;
  41756. /**
  41757. * Disposes of the object
  41758. */
  41759. dispose(): void;
  41760. }
  41761. }
  41762. declare module BABYLON {
  41763. /**
  41764. * Enables teleportation
  41765. */
  41766. export class WebXRControllerTeleportation {
  41767. private _teleportationFillColor;
  41768. private _teleportationBorderColor;
  41769. private _tmpRay;
  41770. private _tmpVector;
  41771. /**
  41772. * Creates a WebXRControllerTeleportation
  41773. * @param input input manager to add teleportation to
  41774. * @param floorMeshes floormeshes which can be teleported to
  41775. */
  41776. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41777. }
  41778. }
  41779. declare module BABYLON {
  41780. /**
  41781. * Handles pointer input automatically for the pointer of XR controllers
  41782. */
  41783. export class WebXRControllerPointerSelection {
  41784. private static _idCounter;
  41785. private _tmpRay;
  41786. /**
  41787. * Creates a WebXRControllerPointerSelection
  41788. * @param input input manager to setup pointer selection
  41789. */
  41790. constructor(input: WebXRInput);
  41791. private _convertNormalToDirectionOfRay;
  41792. private _updatePointerDistance;
  41793. }
  41794. }
  41795. declare module BABYLON {
  41796. /**
  41797. * Class used to represent data loading progression
  41798. */
  41799. export class SceneLoaderProgressEvent {
  41800. /** defines if data length to load can be evaluated */
  41801. readonly lengthComputable: boolean;
  41802. /** defines the loaded data length */
  41803. readonly loaded: number;
  41804. /** defines the data length to load */
  41805. readonly total: number;
  41806. /**
  41807. * Create a new progress event
  41808. * @param lengthComputable defines if data length to load can be evaluated
  41809. * @param loaded defines the loaded data length
  41810. * @param total defines the data length to load
  41811. */
  41812. constructor(
  41813. /** defines if data length to load can be evaluated */
  41814. lengthComputable: boolean,
  41815. /** defines the loaded data length */
  41816. loaded: number,
  41817. /** defines the data length to load */
  41818. total: number);
  41819. /**
  41820. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41821. * @param event defines the source event
  41822. * @returns a new SceneLoaderProgressEvent
  41823. */
  41824. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41825. }
  41826. /**
  41827. * Interface used by SceneLoader plugins to define supported file extensions
  41828. */
  41829. export interface ISceneLoaderPluginExtensions {
  41830. /**
  41831. * Defines the list of supported extensions
  41832. */
  41833. [extension: string]: {
  41834. isBinary: boolean;
  41835. };
  41836. }
  41837. /**
  41838. * Interface used by SceneLoader plugin factory
  41839. */
  41840. export interface ISceneLoaderPluginFactory {
  41841. /**
  41842. * Defines the name of the factory
  41843. */
  41844. name: string;
  41845. /**
  41846. * Function called to create a new plugin
  41847. * @return the new plugin
  41848. */
  41849. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41850. /**
  41851. * Boolean indicating if the plugin can direct load specific data
  41852. */
  41853. canDirectLoad?: (data: string) => boolean;
  41854. }
  41855. /**
  41856. * Interface used to define a SceneLoader plugin
  41857. */
  41858. export interface ISceneLoaderPlugin {
  41859. /**
  41860. * The friendly name of this plugin.
  41861. */
  41862. name: string;
  41863. /**
  41864. * The file extensions supported by this plugin.
  41865. */
  41866. extensions: string | ISceneLoaderPluginExtensions;
  41867. /**
  41868. * Import meshes into a scene.
  41869. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41870. * @param scene The scene to import into
  41871. * @param data The data to import
  41872. * @param rootUrl The root url for scene and resources
  41873. * @param meshes The meshes array to import into
  41874. * @param particleSystems The particle systems array to import into
  41875. * @param skeletons The skeletons array to import into
  41876. * @param onError The callback when import fails
  41877. * @returns True if successful or false otherwise
  41878. */
  41879. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41880. /**
  41881. * Load into a scene.
  41882. * @param scene The scene to load into
  41883. * @param data The data to import
  41884. * @param rootUrl The root url for scene and resources
  41885. * @param onError The callback when import fails
  41886. * @returns true if successful or false otherwise
  41887. */
  41888. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41889. /**
  41890. * The callback that returns true if the data can be directly loaded.
  41891. */
  41892. canDirectLoad?: (data: string) => boolean;
  41893. /**
  41894. * The callback that allows custom handling of the root url based on the response url.
  41895. */
  41896. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41897. /**
  41898. * Load into an asset container.
  41899. * @param scene The scene to load into
  41900. * @param data The data to import
  41901. * @param rootUrl The root url for scene and resources
  41902. * @param onError The callback when import fails
  41903. * @returns The loaded asset container
  41904. */
  41905. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41906. }
  41907. /**
  41908. * Interface used to define an async SceneLoader plugin
  41909. */
  41910. export interface ISceneLoaderPluginAsync {
  41911. /**
  41912. * The friendly name of this plugin.
  41913. */
  41914. name: string;
  41915. /**
  41916. * The file extensions supported by this plugin.
  41917. */
  41918. extensions: string | ISceneLoaderPluginExtensions;
  41919. /**
  41920. * Import meshes into a scene.
  41921. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41922. * @param scene The scene to import into
  41923. * @param data The data to import
  41924. * @param rootUrl The root url for scene and resources
  41925. * @param onProgress The callback when the load progresses
  41926. * @param fileName Defines the name of the file to load
  41927. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41928. */
  41929. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41930. meshes: AbstractMesh[];
  41931. particleSystems: IParticleSystem[];
  41932. skeletons: Skeleton[];
  41933. animationGroups: AnimationGroup[];
  41934. }>;
  41935. /**
  41936. * Load into a scene.
  41937. * @param scene The scene to load into
  41938. * @param data The data to import
  41939. * @param rootUrl The root url for scene and resources
  41940. * @param onProgress The callback when the load progresses
  41941. * @param fileName Defines the name of the file to load
  41942. * @returns Nothing
  41943. */
  41944. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41945. /**
  41946. * The callback that returns true if the data can be directly loaded.
  41947. */
  41948. canDirectLoad?: (data: string) => boolean;
  41949. /**
  41950. * The callback that allows custom handling of the root url based on the response url.
  41951. */
  41952. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41953. /**
  41954. * Load into an asset container.
  41955. * @param scene The scene to load into
  41956. * @param data The data to import
  41957. * @param rootUrl The root url for scene and resources
  41958. * @param onProgress The callback when the load progresses
  41959. * @param fileName Defines the name of the file to load
  41960. * @returns The loaded asset container
  41961. */
  41962. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41963. }
  41964. /**
  41965. * Class used to load scene from various file formats using registered plugins
  41966. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41967. */
  41968. export class SceneLoader {
  41969. /**
  41970. * No logging while loading
  41971. */
  41972. static readonly NO_LOGGING: number;
  41973. /**
  41974. * Minimal logging while loading
  41975. */
  41976. static readonly MINIMAL_LOGGING: number;
  41977. /**
  41978. * Summary logging while loading
  41979. */
  41980. static readonly SUMMARY_LOGGING: number;
  41981. /**
  41982. * Detailled logging while loading
  41983. */
  41984. static readonly DETAILED_LOGGING: number;
  41985. /**
  41986. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41987. */
  41988. static ForceFullSceneLoadingForIncremental: boolean;
  41989. /**
  41990. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41991. */
  41992. static ShowLoadingScreen: boolean;
  41993. /**
  41994. * Defines the current logging level (while loading the scene)
  41995. * @ignorenaming
  41996. */
  41997. static loggingLevel: number;
  41998. /**
  41999. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42000. */
  42001. static CleanBoneMatrixWeights: boolean;
  42002. /**
  42003. * Event raised when a plugin is used to load a scene
  42004. */
  42005. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42006. private static _registeredPlugins;
  42007. private static _getDefaultPlugin;
  42008. private static _getPluginForExtension;
  42009. private static _getPluginForDirectLoad;
  42010. private static _getPluginForFilename;
  42011. private static _getDirectLoad;
  42012. private static _loadData;
  42013. private static _getFileInfo;
  42014. /**
  42015. * Gets a plugin that can load the given extension
  42016. * @param extension defines the extension to load
  42017. * @returns a plugin or null if none works
  42018. */
  42019. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42020. /**
  42021. * Gets a boolean indicating that the given extension can be loaded
  42022. * @param extension defines the extension to load
  42023. * @returns true if the extension is supported
  42024. */
  42025. static IsPluginForExtensionAvailable(extension: string): boolean;
  42026. /**
  42027. * Adds a new plugin to the list of registered plugins
  42028. * @param plugin defines the plugin to add
  42029. */
  42030. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42031. /**
  42032. * Import meshes into a scene
  42033. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42034. * @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)
  42035. * @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)
  42036. * @param scene the instance of BABYLON.Scene to append to
  42037. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42038. * @param onProgress a callback with a progress event for each file being loaded
  42039. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42040. * @param pluginExtension the extension used to determine the plugin
  42041. * @returns The loaded plugin
  42042. */
  42043. 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>;
  42044. /**
  42045. * Import meshes into a scene
  42046. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42047. * @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)
  42048. * @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)
  42049. * @param scene the instance of BABYLON.Scene to append to
  42050. * @param onProgress a callback with a progress event for each file being loaded
  42051. * @param pluginExtension the extension used to determine the plugin
  42052. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42053. */
  42054. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42055. meshes: AbstractMesh[];
  42056. particleSystems: IParticleSystem[];
  42057. skeletons: Skeleton[];
  42058. animationGroups: AnimationGroup[];
  42059. }>;
  42060. /**
  42061. * Load a scene
  42062. * @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)
  42063. * @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)
  42064. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42065. * @param onSuccess a callback with the scene when import succeeds
  42066. * @param onProgress a callback with a progress event for each file being loaded
  42067. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42068. * @param pluginExtension the extension used to determine the plugin
  42069. * @returns The loaded plugin
  42070. */
  42071. 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>;
  42072. /**
  42073. * Load a scene
  42074. * @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)
  42075. * @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)
  42076. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42077. * @param onProgress a callback with a progress event for each file being loaded
  42078. * @param pluginExtension the extension used to determine the plugin
  42079. * @returns The loaded scene
  42080. */
  42081. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42082. /**
  42083. * Append a scene
  42084. * @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)
  42085. * @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)
  42086. * @param scene is the instance of BABYLON.Scene to append to
  42087. * @param onSuccess a callback with the scene when import succeeds
  42088. * @param onProgress a callback with a progress event for each file being loaded
  42089. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42090. * @param pluginExtension the extension used to determine the plugin
  42091. * @returns The loaded plugin
  42092. */
  42093. 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>;
  42094. /**
  42095. * Append a scene
  42096. * @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)
  42097. * @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)
  42098. * @param scene is the instance of BABYLON.Scene to append to
  42099. * @param onProgress a callback with a progress event for each file being loaded
  42100. * @param pluginExtension the extension used to determine the plugin
  42101. * @returns The given scene
  42102. */
  42103. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42104. /**
  42105. * Load a scene into an asset container
  42106. * @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)
  42107. * @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)
  42108. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42109. * @param onSuccess a callback with the scene when import succeeds
  42110. * @param onProgress a callback with a progress event for each file being loaded
  42111. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42112. * @param pluginExtension the extension used to determine the plugin
  42113. * @returns The loaded plugin
  42114. */
  42115. 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>;
  42116. /**
  42117. * Load a scene into an asset container
  42118. * @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)
  42119. * @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)
  42120. * @param scene is the instance of Scene to append to
  42121. * @param onProgress a callback with a progress event for each file being loaded
  42122. * @param pluginExtension the extension used to determine the plugin
  42123. * @returns The loaded asset container
  42124. */
  42125. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42126. }
  42127. }
  42128. declare module BABYLON {
  42129. /**
  42130. * Generic Controller
  42131. */
  42132. export class GenericController extends WebVRController {
  42133. /**
  42134. * Base Url for the controller model.
  42135. */
  42136. static readonly MODEL_BASE_URL: string;
  42137. /**
  42138. * File name for the controller model.
  42139. */
  42140. static readonly MODEL_FILENAME: string;
  42141. /**
  42142. * Creates a new GenericController from a gamepad
  42143. * @param vrGamepad the gamepad that the controller should be created from
  42144. */
  42145. constructor(vrGamepad: any);
  42146. /**
  42147. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42148. * @param scene scene in which to add meshes
  42149. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42150. */
  42151. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42152. /**
  42153. * Called once for each button that changed state since the last frame
  42154. * @param buttonIdx Which button index changed
  42155. * @param state New state of the button
  42156. * @param changes Which properties on the state changed since last frame
  42157. */
  42158. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42159. }
  42160. }
  42161. declare module BABYLON {
  42162. /**
  42163. * Defines the WindowsMotionController object that the state of the windows motion controller
  42164. */
  42165. export class WindowsMotionController extends WebVRController {
  42166. /**
  42167. * The base url used to load the left and right controller models
  42168. */
  42169. static MODEL_BASE_URL: string;
  42170. /**
  42171. * The name of the left controller model file
  42172. */
  42173. static MODEL_LEFT_FILENAME: string;
  42174. /**
  42175. * The name of the right controller model file
  42176. */
  42177. static MODEL_RIGHT_FILENAME: string;
  42178. /**
  42179. * The controller name prefix for this controller type
  42180. */
  42181. static readonly GAMEPAD_ID_PREFIX: string;
  42182. /**
  42183. * The controller id pattern for this controller type
  42184. */
  42185. private static readonly GAMEPAD_ID_PATTERN;
  42186. private _loadedMeshInfo;
  42187. private readonly _mapping;
  42188. /**
  42189. * Fired when the trackpad on this controller is clicked
  42190. */
  42191. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42192. /**
  42193. * Fired when the trackpad on this controller is modified
  42194. */
  42195. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42196. /**
  42197. * The current x and y values of this controller's trackpad
  42198. */
  42199. trackpad: StickValues;
  42200. /**
  42201. * Creates a new WindowsMotionController from a gamepad
  42202. * @param vrGamepad the gamepad that the controller should be created from
  42203. */
  42204. constructor(vrGamepad: any);
  42205. /**
  42206. * Fired when the trigger on this controller is modified
  42207. */
  42208. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42209. /**
  42210. * Fired when the menu button on this controller is modified
  42211. */
  42212. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42213. /**
  42214. * Fired when the grip button on this controller is modified
  42215. */
  42216. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42217. /**
  42218. * Fired when the thumbstick button on this controller is modified
  42219. */
  42220. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42221. /**
  42222. * Fired when the touchpad button on this controller is modified
  42223. */
  42224. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42225. /**
  42226. * Fired when the touchpad values on this controller are modified
  42227. */
  42228. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42229. private _updateTrackpad;
  42230. /**
  42231. * Called once per frame by the engine.
  42232. */
  42233. update(): void;
  42234. /**
  42235. * Called once for each button that changed state since the last frame
  42236. * @param buttonIdx Which button index changed
  42237. * @param state New state of the button
  42238. * @param changes Which properties on the state changed since last frame
  42239. */
  42240. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42241. /**
  42242. * Moves the buttons on the controller mesh based on their current state
  42243. * @param buttonName the name of the button to move
  42244. * @param buttonValue the value of the button which determines the buttons new position
  42245. */
  42246. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42247. /**
  42248. * Moves the axis on the controller mesh based on its current state
  42249. * @param axis the index of the axis
  42250. * @param axisValue the value of the axis which determines the meshes new position
  42251. * @hidden
  42252. */
  42253. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42254. /**
  42255. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42256. * @param scene scene in which to add meshes
  42257. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42258. */
  42259. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42260. /**
  42261. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42262. * can be transformed by button presses and axes values, based on this._mapping.
  42263. *
  42264. * @param scene scene in which the meshes exist
  42265. * @param meshes list of meshes that make up the controller model to process
  42266. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42267. */
  42268. private processModel;
  42269. private createMeshInfo;
  42270. /**
  42271. * Gets the ray of the controller in the direction the controller is pointing
  42272. * @param length the length the resulting ray should be
  42273. * @returns a ray in the direction the controller is pointing
  42274. */
  42275. getForwardRay(length?: number): Ray;
  42276. /**
  42277. * Disposes of the controller
  42278. */
  42279. dispose(): void;
  42280. }
  42281. }
  42282. declare module BABYLON {
  42283. /**
  42284. * Oculus Touch Controller
  42285. */
  42286. export class OculusTouchController extends WebVRController {
  42287. /**
  42288. * Base Url for the controller model.
  42289. */
  42290. static MODEL_BASE_URL: string;
  42291. /**
  42292. * File name for the left controller model.
  42293. */
  42294. static MODEL_LEFT_FILENAME: string;
  42295. /**
  42296. * File name for the right controller model.
  42297. */
  42298. static MODEL_RIGHT_FILENAME: string;
  42299. /**
  42300. * Base Url for the Quest controller model.
  42301. */
  42302. static QUEST_MODEL_BASE_URL: string;
  42303. /**
  42304. * @hidden
  42305. * If the controllers are running on a device that needs the updated Quest controller models
  42306. */
  42307. static _IsQuest: boolean;
  42308. /**
  42309. * Fired when the secondary trigger on this controller is modified
  42310. */
  42311. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42312. /**
  42313. * Fired when the thumb rest on this controller is modified
  42314. */
  42315. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42316. /**
  42317. * Creates a new OculusTouchController from a gamepad
  42318. * @param vrGamepad the gamepad that the controller should be created from
  42319. */
  42320. constructor(vrGamepad: any);
  42321. /**
  42322. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42323. * @param scene scene in which to add meshes
  42324. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42325. */
  42326. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42327. /**
  42328. * Fired when the A button on this controller is modified
  42329. */
  42330. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42331. /**
  42332. * Fired when the B button on this controller is modified
  42333. */
  42334. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42335. /**
  42336. * Fired when the X button on this controller is modified
  42337. */
  42338. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42339. /**
  42340. * Fired when the Y button on this controller is modified
  42341. */
  42342. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42343. /**
  42344. * Called once for each button that changed state since the last frame
  42345. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42346. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42347. * 2) secondary trigger (same)
  42348. * 3) A (right) X (left), touch, pressed = value
  42349. * 4) B / Y
  42350. * 5) thumb rest
  42351. * @param buttonIdx Which button index changed
  42352. * @param state New state of the button
  42353. * @param changes Which properties on the state changed since last frame
  42354. */
  42355. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42356. }
  42357. }
  42358. declare module BABYLON {
  42359. /**
  42360. * Vive Controller
  42361. */
  42362. export class ViveController extends WebVRController {
  42363. /**
  42364. * Base Url for the controller model.
  42365. */
  42366. static MODEL_BASE_URL: string;
  42367. /**
  42368. * File name for the controller model.
  42369. */
  42370. static MODEL_FILENAME: string;
  42371. /**
  42372. * Creates a new ViveController from a gamepad
  42373. * @param vrGamepad the gamepad that the controller should be created from
  42374. */
  42375. constructor(vrGamepad: any);
  42376. /**
  42377. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42378. * @param scene scene in which to add meshes
  42379. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42380. */
  42381. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42382. /**
  42383. * Fired when the left button on this controller is modified
  42384. */
  42385. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42386. /**
  42387. * Fired when the right button on this controller is modified
  42388. */
  42389. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42390. /**
  42391. * Fired when the menu button on this controller is modified
  42392. */
  42393. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42394. /**
  42395. * Called once for each button that changed state since the last frame
  42396. * Vive mapping:
  42397. * 0: touchpad
  42398. * 1: trigger
  42399. * 2: left AND right buttons
  42400. * 3: menu button
  42401. * @param buttonIdx Which button index changed
  42402. * @param state New state of the button
  42403. * @param changes Which properties on the state changed since last frame
  42404. */
  42405. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42406. }
  42407. }
  42408. declare module BABYLON {
  42409. /**
  42410. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42411. */
  42412. export class WebXRControllerModelLoader {
  42413. /**
  42414. * Creates the WebXRControllerModelLoader
  42415. * @param input xr input that creates the controllers
  42416. */
  42417. constructor(input: WebXRInput);
  42418. }
  42419. }
  42420. declare module BABYLON {
  42421. /**
  42422. * Contains an array of blocks representing the octree
  42423. */
  42424. export interface IOctreeContainer<T> {
  42425. /**
  42426. * Blocks within the octree
  42427. */
  42428. blocks: Array<OctreeBlock<T>>;
  42429. }
  42430. /**
  42431. * Class used to store a cell in an octree
  42432. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42433. */
  42434. export class OctreeBlock<T> {
  42435. /**
  42436. * Gets the content of the current block
  42437. */
  42438. entries: T[];
  42439. /**
  42440. * Gets the list of block children
  42441. */
  42442. blocks: Array<OctreeBlock<T>>;
  42443. private _depth;
  42444. private _maxDepth;
  42445. private _capacity;
  42446. private _minPoint;
  42447. private _maxPoint;
  42448. private _boundingVectors;
  42449. private _creationFunc;
  42450. /**
  42451. * Creates a new block
  42452. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42453. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42454. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42455. * @param depth defines the current depth of this block in the octree
  42456. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42457. * @param creationFunc defines a callback to call when an element is added to the block
  42458. */
  42459. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42460. /**
  42461. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42462. */
  42463. readonly capacity: number;
  42464. /**
  42465. * Gets the minimum vector (in world space) of the block's bounding box
  42466. */
  42467. readonly minPoint: Vector3;
  42468. /**
  42469. * Gets the maximum vector (in world space) of the block's bounding box
  42470. */
  42471. readonly maxPoint: Vector3;
  42472. /**
  42473. * Add a new element to this block
  42474. * @param entry defines the element to add
  42475. */
  42476. addEntry(entry: T): void;
  42477. /**
  42478. * Remove an element from this block
  42479. * @param entry defines the element to remove
  42480. */
  42481. removeEntry(entry: T): void;
  42482. /**
  42483. * Add an array of elements to this block
  42484. * @param entries defines the array of elements to add
  42485. */
  42486. addEntries(entries: T[]): void;
  42487. /**
  42488. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42489. * @param frustumPlanes defines the frustum planes to test
  42490. * @param selection defines the array to store current content if selection is positive
  42491. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42492. */
  42493. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42494. /**
  42495. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42496. * @param sphereCenter defines the bounding sphere center
  42497. * @param sphereRadius defines the bounding sphere radius
  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. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42502. /**
  42503. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42504. * @param ray defines the ray to test with
  42505. * @param selection defines the array to store current content if selection is positive
  42506. */
  42507. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42508. /**
  42509. * Subdivide the content into child blocks (this block will then be empty)
  42510. */
  42511. createInnerBlocks(): void;
  42512. /**
  42513. * @hidden
  42514. */
  42515. 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;
  42516. }
  42517. }
  42518. declare module BABYLON {
  42519. /**
  42520. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42521. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42522. */
  42523. export class Octree<T> {
  42524. /** 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.) */
  42525. maxDepth: number;
  42526. /**
  42527. * Blocks within the octree containing objects
  42528. */
  42529. blocks: Array<OctreeBlock<T>>;
  42530. /**
  42531. * Content stored in the octree
  42532. */
  42533. dynamicContent: T[];
  42534. private _maxBlockCapacity;
  42535. private _selectionContent;
  42536. private _creationFunc;
  42537. /**
  42538. * Creates a octree
  42539. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42540. * @param creationFunc function to be used to instatiate the octree
  42541. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42542. * @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.)
  42543. */
  42544. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42545. /** 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.) */
  42546. maxDepth?: number);
  42547. /**
  42548. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42549. * @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);
  42550. * @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);
  42551. * @param entries meshes to be added to the octree blocks
  42552. */
  42553. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42554. /**
  42555. * Adds a mesh to the octree
  42556. * @param entry Mesh to add to the octree
  42557. */
  42558. addMesh(entry: T): void;
  42559. /**
  42560. * Remove an element from the octree
  42561. * @param entry defines the element to remove
  42562. */
  42563. removeMesh(entry: T): void;
  42564. /**
  42565. * Selects an array of meshes within the frustum
  42566. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42567. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42568. * @returns array of meshes within the frustum
  42569. */
  42570. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42571. /**
  42572. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42573. * @param sphereCenter defines the bounding sphere center
  42574. * @param sphereRadius defines the bounding sphere radius
  42575. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42576. * @returns an array of objects that intersect the sphere
  42577. */
  42578. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42579. /**
  42580. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42581. * @param ray defines the ray to test with
  42582. * @returns array of intersected objects
  42583. */
  42584. intersectsRay(ray: Ray): SmartArray<T>;
  42585. /**
  42586. * Adds a mesh into the octree block if it intersects the block
  42587. */
  42588. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42589. /**
  42590. * Adds a submesh into the octree block if it intersects the block
  42591. */
  42592. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42593. }
  42594. }
  42595. declare module BABYLON {
  42596. interface Scene {
  42597. /**
  42598. * @hidden
  42599. * Backing Filed
  42600. */
  42601. _selectionOctree: Octree<AbstractMesh>;
  42602. /**
  42603. * Gets the octree used to boost mesh selection (picking)
  42604. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42605. */
  42606. selectionOctree: Octree<AbstractMesh>;
  42607. /**
  42608. * Creates or updates the octree used to boost selection (picking)
  42609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42610. * @param maxCapacity defines the maximum capacity per leaf
  42611. * @param maxDepth defines the maximum depth of the octree
  42612. * @returns an octree of AbstractMesh
  42613. */
  42614. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42615. }
  42616. interface AbstractMesh {
  42617. /**
  42618. * @hidden
  42619. * Backing Field
  42620. */
  42621. _submeshesOctree: Octree<SubMesh>;
  42622. /**
  42623. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42624. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42625. * @param maxCapacity defines the maximum size of each block (64 by default)
  42626. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42627. * @returns the new octree
  42628. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42630. */
  42631. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42632. }
  42633. /**
  42634. * Defines the octree scene component responsible to manage any octrees
  42635. * in a given scene.
  42636. */
  42637. export class OctreeSceneComponent {
  42638. /**
  42639. * The component name help to identify the component in the list of scene components.
  42640. */
  42641. readonly name: string;
  42642. /**
  42643. * The scene the component belongs to.
  42644. */
  42645. scene: Scene;
  42646. /**
  42647. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42648. */
  42649. readonly checksIsEnabled: boolean;
  42650. /**
  42651. * Creates a new instance of the component for the given scene
  42652. * @param scene Defines the scene to register the component in
  42653. */
  42654. constructor(scene: Scene);
  42655. /**
  42656. * Registers the component in a given scene
  42657. */
  42658. register(): void;
  42659. /**
  42660. * Return the list of active meshes
  42661. * @returns the list of active meshes
  42662. */
  42663. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42664. /**
  42665. * Return the list of active sub meshes
  42666. * @param mesh The mesh to get the candidates sub meshes from
  42667. * @returns the list of active sub meshes
  42668. */
  42669. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42670. private _tempRay;
  42671. /**
  42672. * Return the list of sub meshes intersecting with a given local ray
  42673. * @param mesh defines the mesh to find the submesh for
  42674. * @param localRay defines the ray in local space
  42675. * @returns the list of intersecting sub meshes
  42676. */
  42677. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42678. /**
  42679. * Return the list of sub meshes colliding with a collider
  42680. * @param mesh defines the mesh to find the submesh for
  42681. * @param collider defines the collider to evaluate the collision against
  42682. * @returns the list of colliding sub meshes
  42683. */
  42684. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42685. /**
  42686. * Rebuilds the elements related to this component in case of
  42687. * context lost for instance.
  42688. */
  42689. rebuild(): void;
  42690. /**
  42691. * Disposes the component and the associated ressources.
  42692. */
  42693. dispose(): void;
  42694. }
  42695. }
  42696. declare module BABYLON {
  42697. /**
  42698. * Renders a layer on top of an existing scene
  42699. */
  42700. export class UtilityLayerRenderer implements IDisposable {
  42701. /** the original scene that will be rendered on top of */
  42702. originalScene: Scene;
  42703. private _pointerCaptures;
  42704. private _lastPointerEvents;
  42705. private static _DefaultUtilityLayer;
  42706. private static _DefaultKeepDepthUtilityLayer;
  42707. private _sharedGizmoLight;
  42708. private _renderCamera;
  42709. /**
  42710. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42711. * @returns the camera that is used when rendering the utility layer
  42712. */
  42713. getRenderCamera(): Nullable<Camera>;
  42714. /**
  42715. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42716. * @param cam the camera that should be used when rendering the utility layer
  42717. */
  42718. setRenderCamera(cam: Nullable<Camera>): void;
  42719. /**
  42720. * @hidden
  42721. * Light which used by gizmos to get light shading
  42722. */
  42723. _getSharedGizmoLight(): HemisphericLight;
  42724. /**
  42725. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42726. */
  42727. pickUtilitySceneFirst: boolean;
  42728. /**
  42729. * 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)
  42730. */
  42731. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42732. /**
  42733. * 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)
  42734. */
  42735. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42736. /**
  42737. * The scene that is rendered on top of the original scene
  42738. */
  42739. utilityLayerScene: Scene;
  42740. /**
  42741. * If the utility layer should automatically be rendered on top of existing scene
  42742. */
  42743. shouldRender: boolean;
  42744. /**
  42745. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42746. */
  42747. onlyCheckPointerDownEvents: boolean;
  42748. /**
  42749. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42750. */
  42751. processAllEvents: boolean;
  42752. /**
  42753. * Observable raised when the pointer move from the utility layer scene to the main scene
  42754. */
  42755. onPointerOutObservable: Observable<number>;
  42756. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42757. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42758. private _afterRenderObserver;
  42759. private _sceneDisposeObserver;
  42760. private _originalPointerObserver;
  42761. /**
  42762. * Instantiates a UtilityLayerRenderer
  42763. * @param originalScene the original scene that will be rendered on top of
  42764. * @param handleEvents boolean indicating if the utility layer should handle events
  42765. */
  42766. constructor(
  42767. /** the original scene that will be rendered on top of */
  42768. originalScene: Scene, handleEvents?: boolean);
  42769. private _notifyObservers;
  42770. /**
  42771. * Renders the utility layers scene on top of the original scene
  42772. */
  42773. render(): void;
  42774. /**
  42775. * Disposes of the renderer
  42776. */
  42777. dispose(): void;
  42778. private _updateCamera;
  42779. }
  42780. }
  42781. declare module BABYLON {
  42782. /**
  42783. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42784. */
  42785. export class Gizmo implements IDisposable {
  42786. /** The utility layer the gizmo will be added to */
  42787. gizmoLayer: UtilityLayerRenderer;
  42788. /**
  42789. * The root mesh of the gizmo
  42790. */
  42791. _rootMesh: Mesh;
  42792. private _attachedMesh;
  42793. /**
  42794. * Ratio for the scale of the gizmo (Default: 1)
  42795. */
  42796. scaleRatio: number;
  42797. /**
  42798. * If a custom mesh has been set (Default: false)
  42799. */
  42800. protected _customMeshSet: boolean;
  42801. /**
  42802. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42803. * * When set, interactions will be enabled
  42804. */
  42805. attachedMesh: Nullable<AbstractMesh>;
  42806. /**
  42807. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42808. * @param mesh The mesh to replace the default mesh of the gizmo
  42809. */
  42810. setCustomMesh(mesh: Mesh): void;
  42811. /**
  42812. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42813. */
  42814. updateGizmoRotationToMatchAttachedMesh: boolean;
  42815. /**
  42816. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42817. */
  42818. updateGizmoPositionToMatchAttachedMesh: boolean;
  42819. /**
  42820. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42821. */
  42822. updateScale: boolean;
  42823. protected _interactionsEnabled: boolean;
  42824. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42825. private _beforeRenderObserver;
  42826. private _tempVector;
  42827. /**
  42828. * Creates a gizmo
  42829. * @param gizmoLayer The utility layer the gizmo will be added to
  42830. */
  42831. constructor(
  42832. /** The utility layer the gizmo will be added to */
  42833. gizmoLayer?: UtilityLayerRenderer);
  42834. /**
  42835. * Updates the gizmo to match the attached mesh's position/rotation
  42836. */
  42837. protected _update(): void;
  42838. /**
  42839. * Disposes of the gizmo
  42840. */
  42841. dispose(): void;
  42842. }
  42843. }
  42844. declare module BABYLON {
  42845. /**
  42846. * Single plane drag gizmo
  42847. */
  42848. export class PlaneDragGizmo extends Gizmo {
  42849. /**
  42850. * Drag behavior responsible for the gizmos dragging interactions
  42851. */
  42852. dragBehavior: PointerDragBehavior;
  42853. private _pointerObserver;
  42854. /**
  42855. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42856. */
  42857. snapDistance: number;
  42858. /**
  42859. * Event that fires each time the gizmo snaps to a new location.
  42860. * * snapDistance is the the change in distance
  42861. */
  42862. onSnapObservable: Observable<{
  42863. snapDistance: number;
  42864. }>;
  42865. private _plane;
  42866. private _coloredMaterial;
  42867. private _hoverMaterial;
  42868. private _isEnabled;
  42869. private _parent;
  42870. /** @hidden */
  42871. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42872. /** @hidden */
  42873. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42874. /**
  42875. * Creates a PlaneDragGizmo
  42876. * @param gizmoLayer The utility layer the gizmo will be added to
  42877. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42878. * @param color The color of the gizmo
  42879. */
  42880. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42881. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42882. /**
  42883. * If the gizmo is enabled
  42884. */
  42885. isEnabled: boolean;
  42886. /**
  42887. * Disposes of the gizmo
  42888. */
  42889. dispose(): void;
  42890. }
  42891. }
  42892. declare module BABYLON {
  42893. /**
  42894. * Gizmo that enables dragging a mesh along 3 axis
  42895. */
  42896. export class PositionGizmo extends Gizmo {
  42897. /**
  42898. * Internal gizmo used for interactions on the x axis
  42899. */
  42900. xGizmo: AxisDragGizmo;
  42901. /**
  42902. * Internal gizmo used for interactions on the y axis
  42903. */
  42904. yGizmo: AxisDragGizmo;
  42905. /**
  42906. * Internal gizmo used for interactions on the z axis
  42907. */
  42908. zGizmo: AxisDragGizmo;
  42909. /**
  42910. * Internal gizmo used for interactions on the yz plane
  42911. */
  42912. xPlaneGizmo: PlaneDragGizmo;
  42913. /**
  42914. * Internal gizmo used for interactions on the xz plane
  42915. */
  42916. yPlaneGizmo: PlaneDragGizmo;
  42917. /**
  42918. * Internal gizmo used for interactions on the xy plane
  42919. */
  42920. zPlaneGizmo: PlaneDragGizmo;
  42921. /**
  42922. * private variables
  42923. */
  42924. private _meshAttached;
  42925. private _updateGizmoRotationToMatchAttachedMesh;
  42926. private _snapDistance;
  42927. private _scaleRatio;
  42928. /** Fires an event when any of it's sub gizmos are dragged */
  42929. onDragStartObservable: Observable<unknown>;
  42930. /** Fires an event when any of it's sub gizmos are released from dragging */
  42931. onDragEndObservable: Observable<unknown>;
  42932. /**
  42933. * If set to true, planar drag is enabled
  42934. */
  42935. private _planarGizmoEnabled;
  42936. attachedMesh: Nullable<AbstractMesh>;
  42937. /**
  42938. * Creates a PositionGizmo
  42939. * @param gizmoLayer The utility layer the gizmo will be added to
  42940. */
  42941. constructor(gizmoLayer?: UtilityLayerRenderer);
  42942. /**
  42943. * If the planar drag gizmo is enabled
  42944. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42945. */
  42946. planarGizmoEnabled: boolean;
  42947. updateGizmoRotationToMatchAttachedMesh: boolean;
  42948. /**
  42949. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42950. */
  42951. snapDistance: number;
  42952. /**
  42953. * Ratio for the scale of the gizmo (Default: 1)
  42954. */
  42955. scaleRatio: number;
  42956. /**
  42957. * Disposes of the gizmo
  42958. */
  42959. dispose(): void;
  42960. /**
  42961. * CustomMeshes are not supported by this gizmo
  42962. * @param mesh The mesh to replace the default mesh of the gizmo
  42963. */
  42964. setCustomMesh(mesh: Mesh): void;
  42965. }
  42966. }
  42967. declare module BABYLON {
  42968. /**
  42969. * Single axis drag gizmo
  42970. */
  42971. export class AxisDragGizmo extends Gizmo {
  42972. /**
  42973. * Drag behavior responsible for the gizmos dragging interactions
  42974. */
  42975. dragBehavior: PointerDragBehavior;
  42976. private _pointerObserver;
  42977. /**
  42978. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42979. */
  42980. snapDistance: number;
  42981. /**
  42982. * Event that fires each time the gizmo snaps to a new location.
  42983. * * snapDistance is the the change in distance
  42984. */
  42985. onSnapObservable: Observable<{
  42986. snapDistance: number;
  42987. }>;
  42988. private _isEnabled;
  42989. private _parent;
  42990. private _arrow;
  42991. private _coloredMaterial;
  42992. private _hoverMaterial;
  42993. /** @hidden */
  42994. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42995. /** @hidden */
  42996. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42997. /**
  42998. * Creates an AxisDragGizmo
  42999. * @param gizmoLayer The utility layer the gizmo will be added to
  43000. * @param dragAxis The axis which the gizmo will be able to drag on
  43001. * @param color The color of the gizmo
  43002. */
  43003. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43004. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43005. /**
  43006. * If the gizmo is enabled
  43007. */
  43008. isEnabled: boolean;
  43009. /**
  43010. * Disposes of the gizmo
  43011. */
  43012. dispose(): void;
  43013. }
  43014. }
  43015. declare module BABYLON.Debug {
  43016. /**
  43017. * The Axes viewer will show 3 axes in a specific point in space
  43018. */
  43019. export class AxesViewer {
  43020. private _xAxis;
  43021. private _yAxis;
  43022. private _zAxis;
  43023. private _scaleLinesFactor;
  43024. private _instanced;
  43025. /**
  43026. * Gets the hosting scene
  43027. */
  43028. scene: Scene;
  43029. /**
  43030. * Gets or sets a number used to scale line length
  43031. */
  43032. scaleLines: number;
  43033. /** Gets the node hierarchy used to render x-axis */
  43034. readonly xAxis: TransformNode;
  43035. /** Gets the node hierarchy used to render y-axis */
  43036. readonly yAxis: TransformNode;
  43037. /** Gets the node hierarchy used to render z-axis */
  43038. readonly zAxis: TransformNode;
  43039. /**
  43040. * Creates a new AxesViewer
  43041. * @param scene defines the hosting scene
  43042. * @param scaleLines defines a number used to scale line length (1 by default)
  43043. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43044. * @param xAxis defines the node hierarchy used to render the x-axis
  43045. * @param yAxis defines the node hierarchy used to render the y-axis
  43046. * @param zAxis defines the node hierarchy used to render the z-axis
  43047. */
  43048. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43049. /**
  43050. * Force the viewer to update
  43051. * @param position defines the position of the viewer
  43052. * @param xaxis defines the x axis of the viewer
  43053. * @param yaxis defines the y axis of the viewer
  43054. * @param zaxis defines the z axis of the viewer
  43055. */
  43056. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43057. /**
  43058. * Creates an instance of this axes viewer.
  43059. * @returns a new axes viewer with instanced meshes
  43060. */
  43061. createInstance(): AxesViewer;
  43062. /** Releases resources */
  43063. dispose(): void;
  43064. private static _SetRenderingGroupId;
  43065. }
  43066. }
  43067. declare module BABYLON.Debug {
  43068. /**
  43069. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43070. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43071. */
  43072. export class BoneAxesViewer extends AxesViewer {
  43073. /**
  43074. * Gets or sets the target mesh where to display the axes viewer
  43075. */
  43076. mesh: Nullable<Mesh>;
  43077. /**
  43078. * Gets or sets the target bone where to display the axes viewer
  43079. */
  43080. bone: Nullable<Bone>;
  43081. /** Gets current position */
  43082. pos: Vector3;
  43083. /** Gets direction of X axis */
  43084. xaxis: Vector3;
  43085. /** Gets direction of Y axis */
  43086. yaxis: Vector3;
  43087. /** Gets direction of Z axis */
  43088. zaxis: Vector3;
  43089. /**
  43090. * Creates a new BoneAxesViewer
  43091. * @param scene defines the hosting scene
  43092. * @param bone defines the target bone
  43093. * @param mesh defines the target mesh
  43094. * @param scaleLines defines a scaling factor for line length (1 by default)
  43095. */
  43096. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43097. /**
  43098. * Force the viewer to update
  43099. */
  43100. update(): void;
  43101. /** Releases resources */
  43102. dispose(): void;
  43103. }
  43104. }
  43105. declare module BABYLON {
  43106. /**
  43107. * Interface used to define scene explorer extensibility option
  43108. */
  43109. export interface IExplorerExtensibilityOption {
  43110. /**
  43111. * Define the option label
  43112. */
  43113. label: string;
  43114. /**
  43115. * Defines the action to execute on click
  43116. */
  43117. action: (entity: any) => void;
  43118. }
  43119. /**
  43120. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43121. */
  43122. export interface IExplorerExtensibilityGroup {
  43123. /**
  43124. * Defines a predicate to test if a given type mut be extended
  43125. */
  43126. predicate: (entity: any) => boolean;
  43127. /**
  43128. * Gets the list of options added to a type
  43129. */
  43130. entries: IExplorerExtensibilityOption[];
  43131. }
  43132. /**
  43133. * Interface used to define the options to use to create the Inspector
  43134. */
  43135. export interface IInspectorOptions {
  43136. /**
  43137. * Display in overlay mode (default: false)
  43138. */
  43139. overlay?: boolean;
  43140. /**
  43141. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43142. */
  43143. globalRoot?: HTMLElement;
  43144. /**
  43145. * Display the Scene explorer
  43146. */
  43147. showExplorer?: boolean;
  43148. /**
  43149. * Display the property inspector
  43150. */
  43151. showInspector?: boolean;
  43152. /**
  43153. * Display in embed mode (both panes on the right)
  43154. */
  43155. embedMode?: boolean;
  43156. /**
  43157. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43158. */
  43159. handleResize?: boolean;
  43160. /**
  43161. * Allow the panes to popup (default: true)
  43162. */
  43163. enablePopup?: boolean;
  43164. /**
  43165. * Allow the panes to be closed by users (default: true)
  43166. */
  43167. enableClose?: boolean;
  43168. /**
  43169. * Optional list of extensibility entries
  43170. */
  43171. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43172. /**
  43173. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43174. */
  43175. inspectorURL?: string;
  43176. }
  43177. interface Scene {
  43178. /**
  43179. * @hidden
  43180. * Backing field
  43181. */
  43182. _debugLayer: DebugLayer;
  43183. /**
  43184. * Gets the debug layer (aka Inspector) associated with the scene
  43185. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43186. */
  43187. debugLayer: DebugLayer;
  43188. }
  43189. /**
  43190. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43191. * what is happening in your scene
  43192. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43193. */
  43194. export class DebugLayer {
  43195. /**
  43196. * Define the url to get the inspector script from.
  43197. * By default it uses the babylonjs CDN.
  43198. * @ignoreNaming
  43199. */
  43200. static InspectorURL: string;
  43201. private _scene;
  43202. private BJSINSPECTOR;
  43203. private _onPropertyChangedObservable?;
  43204. /**
  43205. * Observable triggered when a property is changed through the inspector.
  43206. */
  43207. readonly onPropertyChangedObservable: any;
  43208. /**
  43209. * Instantiates a new debug layer.
  43210. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43211. * what is happening in your scene
  43212. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43213. * @param scene Defines the scene to inspect
  43214. */
  43215. constructor(scene: Scene);
  43216. /** Creates the inspector window. */
  43217. private _createInspector;
  43218. /**
  43219. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43220. * @param entity defines the entity to select
  43221. * @param lineContainerTitle defines the specific block to highlight
  43222. */
  43223. select(entity: any, lineContainerTitle?: string): void;
  43224. /** Get the inspector from bundle or global */
  43225. private _getGlobalInspector;
  43226. /**
  43227. * Get if the inspector is visible or not.
  43228. * @returns true if visible otherwise, false
  43229. */
  43230. isVisible(): boolean;
  43231. /**
  43232. * Hide the inspector and close its window.
  43233. */
  43234. hide(): void;
  43235. /**
  43236. * Launch the debugLayer.
  43237. * @param config Define the configuration of the inspector
  43238. * @return a promise fulfilled when the debug layer is visible
  43239. */
  43240. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43241. }
  43242. }
  43243. declare module BABYLON {
  43244. /**
  43245. * Class containing static functions to help procedurally build meshes
  43246. */
  43247. export class BoxBuilder {
  43248. /**
  43249. * Creates a box mesh
  43250. * * The parameter `size` sets the size (float) of each box side (default 1)
  43251. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43252. * * 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)
  43253. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43255. * * 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
  43256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43257. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43258. * @param name defines the name of the mesh
  43259. * @param options defines the options used to create the mesh
  43260. * @param scene defines the hosting scene
  43261. * @returns the box mesh
  43262. */
  43263. static CreateBox(name: string, options: {
  43264. size?: number;
  43265. width?: number;
  43266. height?: number;
  43267. depth?: number;
  43268. faceUV?: Vector4[];
  43269. faceColors?: Color4[];
  43270. sideOrientation?: number;
  43271. frontUVs?: Vector4;
  43272. backUVs?: Vector4;
  43273. wrap?: boolean;
  43274. topBaseAt?: number;
  43275. bottomBaseAt?: number;
  43276. updatable?: boolean;
  43277. }, scene?: Nullable<Scene>): Mesh;
  43278. }
  43279. }
  43280. declare module BABYLON {
  43281. /**
  43282. * Class containing static functions to help procedurally build meshes
  43283. */
  43284. export class SphereBuilder {
  43285. /**
  43286. * Creates a sphere mesh
  43287. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43288. * * 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`)
  43289. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43290. * * 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
  43291. * * 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)
  43292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43293. * * 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
  43294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43295. * @param name defines the name of the mesh
  43296. * @param options defines the options used to create the mesh
  43297. * @param scene defines the hosting scene
  43298. * @returns the sphere mesh
  43299. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43300. */
  43301. static CreateSphere(name: string, options: {
  43302. segments?: number;
  43303. diameter?: number;
  43304. diameterX?: number;
  43305. diameterY?: number;
  43306. diameterZ?: number;
  43307. arc?: number;
  43308. slice?: number;
  43309. sideOrientation?: number;
  43310. frontUVs?: Vector4;
  43311. backUVs?: Vector4;
  43312. updatable?: boolean;
  43313. }, scene?: Nullable<Scene>): Mesh;
  43314. }
  43315. }
  43316. declare module BABYLON.Debug {
  43317. /**
  43318. * Used to show the physics impostor around the specific mesh
  43319. */
  43320. export class PhysicsViewer {
  43321. /** @hidden */
  43322. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43323. /** @hidden */
  43324. protected _meshes: Array<Nullable<AbstractMesh>>;
  43325. /** @hidden */
  43326. protected _scene: Nullable<Scene>;
  43327. /** @hidden */
  43328. protected _numMeshes: number;
  43329. /** @hidden */
  43330. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43331. private _renderFunction;
  43332. private _utilityLayer;
  43333. private _debugBoxMesh;
  43334. private _debugSphereMesh;
  43335. private _debugCylinderMesh;
  43336. private _debugMaterial;
  43337. private _debugMeshMeshes;
  43338. /**
  43339. * Creates a new PhysicsViewer
  43340. * @param scene defines the hosting scene
  43341. */
  43342. constructor(scene: Scene);
  43343. /** @hidden */
  43344. protected _updateDebugMeshes(): void;
  43345. /**
  43346. * Renders a specified physic impostor
  43347. * @param impostor defines the impostor to render
  43348. * @param targetMesh defines the mesh represented by the impostor
  43349. * @returns the new debug mesh used to render the impostor
  43350. */
  43351. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43352. /**
  43353. * Hides a specified physic impostor
  43354. * @param impostor defines the impostor to hide
  43355. */
  43356. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43357. private _getDebugMaterial;
  43358. private _getDebugBoxMesh;
  43359. private _getDebugSphereMesh;
  43360. private _getDebugCylinderMesh;
  43361. private _getDebugMeshMesh;
  43362. private _getDebugMesh;
  43363. /** Releases all resources */
  43364. dispose(): void;
  43365. }
  43366. }
  43367. declare module BABYLON {
  43368. /**
  43369. * Class containing static functions to help procedurally build meshes
  43370. */
  43371. export class LinesBuilder {
  43372. /**
  43373. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43374. * * 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
  43375. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43376. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43377. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43378. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43379. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43380. * * 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
  43381. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43384. * @param name defines the name of the new line system
  43385. * @param options defines the options used to create the line system
  43386. * @param scene defines the hosting scene
  43387. * @returns a new line system mesh
  43388. */
  43389. static CreateLineSystem(name: string, options: {
  43390. lines: Vector3[][];
  43391. updatable?: boolean;
  43392. instance?: Nullable<LinesMesh>;
  43393. colors?: Nullable<Color4[][]>;
  43394. useVertexAlpha?: boolean;
  43395. }, scene: Nullable<Scene>): LinesMesh;
  43396. /**
  43397. * Creates a line mesh
  43398. * 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
  43399. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43400. * * The parameter `points` is an array successive Vector3
  43401. * * 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
  43402. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43403. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43404. * * When updating an instance, remember that only point positions can change, not the number of points
  43405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43407. * @param name defines the name of the new line system
  43408. * @param options defines the options used to create the line system
  43409. * @param scene defines the hosting scene
  43410. * @returns a new line mesh
  43411. */
  43412. static CreateLines(name: string, options: {
  43413. points: Vector3[];
  43414. updatable?: boolean;
  43415. instance?: Nullable<LinesMesh>;
  43416. colors?: Color4[];
  43417. useVertexAlpha?: boolean;
  43418. }, scene?: Nullable<Scene>): LinesMesh;
  43419. /**
  43420. * Creates a dashed line mesh
  43421. * * 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
  43422. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43423. * * The parameter `points` is an array successive Vector3
  43424. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43425. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43426. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43427. * * 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
  43428. * * When updating an instance, remember that only point positions can change, not the number of points
  43429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43430. * @param name defines the name of the mesh
  43431. * @param options defines the options used to create the mesh
  43432. * @param scene defines the hosting scene
  43433. * @returns the dashed line mesh
  43434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43435. */
  43436. static CreateDashedLines(name: string, options: {
  43437. points: Vector3[];
  43438. dashSize?: number;
  43439. gapSize?: number;
  43440. dashNb?: number;
  43441. updatable?: boolean;
  43442. instance?: LinesMesh;
  43443. }, scene?: Nullable<Scene>): LinesMesh;
  43444. }
  43445. }
  43446. declare module BABYLON {
  43447. /**
  43448. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43449. * in order to better appreciate the issue one might have.
  43450. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43451. */
  43452. export class RayHelper {
  43453. /**
  43454. * Defines the ray we are currently tryin to visualize.
  43455. */
  43456. ray: Nullable<Ray>;
  43457. private _renderPoints;
  43458. private _renderLine;
  43459. private _renderFunction;
  43460. private _scene;
  43461. private _updateToMeshFunction;
  43462. private _attachedToMesh;
  43463. private _meshSpaceDirection;
  43464. private _meshSpaceOrigin;
  43465. /**
  43466. * Helper function to create a colored helper in a scene in one line.
  43467. * @param ray Defines the ray we are currently tryin to visualize
  43468. * @param scene Defines the scene the ray is used in
  43469. * @param color Defines the color we want to see the ray in
  43470. * @returns The newly created ray helper.
  43471. */
  43472. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43473. /**
  43474. * Instantiate a new ray helper.
  43475. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43476. * in order to better appreciate the issue one might have.
  43477. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43478. * @param ray Defines the ray we are currently tryin to visualize
  43479. */
  43480. constructor(ray: Ray);
  43481. /**
  43482. * Shows the ray we are willing to debug.
  43483. * @param scene Defines the scene the ray needs to be rendered in
  43484. * @param color Defines the color the ray needs to be rendered in
  43485. */
  43486. show(scene: Scene, color?: Color3): void;
  43487. /**
  43488. * Hides the ray we are debugging.
  43489. */
  43490. hide(): void;
  43491. private _render;
  43492. /**
  43493. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43494. * @param mesh Defines the mesh we want the helper attached to
  43495. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43496. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43497. * @param length Defines the length of the ray
  43498. */
  43499. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43500. /**
  43501. * Detach the ray helper from the mesh it has previously been attached to.
  43502. */
  43503. detachFromMesh(): void;
  43504. private _updateToMesh;
  43505. /**
  43506. * Dispose the helper and release its associated resources.
  43507. */
  43508. dispose(): void;
  43509. }
  43510. }
  43511. declare module BABYLON.Debug {
  43512. /**
  43513. * Class used to render a debug view of a given skeleton
  43514. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43515. */
  43516. export class SkeletonViewer {
  43517. /** defines the skeleton to render */
  43518. skeleton: Skeleton;
  43519. /** defines the mesh attached to the skeleton */
  43520. mesh: AbstractMesh;
  43521. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43522. autoUpdateBonesMatrices: boolean;
  43523. /** defines the rendering group id to use with the viewer */
  43524. renderingGroupId: number;
  43525. /** Gets or sets the color used to render the skeleton */
  43526. color: Color3;
  43527. private _scene;
  43528. private _debugLines;
  43529. private _debugMesh;
  43530. private _isEnabled;
  43531. private _renderFunction;
  43532. private _utilityLayer;
  43533. /**
  43534. * Returns the mesh used to render the bones
  43535. */
  43536. readonly debugMesh: Nullable<LinesMesh>;
  43537. /**
  43538. * Creates a new SkeletonViewer
  43539. * @param skeleton defines the skeleton to render
  43540. * @param mesh defines the mesh attached to the skeleton
  43541. * @param scene defines the hosting scene
  43542. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43543. * @param renderingGroupId defines the rendering group id to use with the viewer
  43544. */
  43545. constructor(
  43546. /** defines the skeleton to render */
  43547. skeleton: Skeleton,
  43548. /** defines the mesh attached to the skeleton */
  43549. mesh: AbstractMesh, scene: Scene,
  43550. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43551. autoUpdateBonesMatrices?: boolean,
  43552. /** defines the rendering group id to use with the viewer */
  43553. renderingGroupId?: number);
  43554. /** Gets or sets a boolean indicating if the viewer is enabled */
  43555. isEnabled: boolean;
  43556. private _getBonePosition;
  43557. private _getLinesForBonesWithLength;
  43558. private _getLinesForBonesNoLength;
  43559. /** Update the viewer to sync with current skeleton state */
  43560. update(): void;
  43561. /** Release associated resources */
  43562. dispose(): void;
  43563. }
  43564. }
  43565. declare module BABYLON {
  43566. /**
  43567. * Options to create the null engine
  43568. */
  43569. export class NullEngineOptions {
  43570. /**
  43571. * Render width (Default: 512)
  43572. */
  43573. renderWidth: number;
  43574. /**
  43575. * Render height (Default: 256)
  43576. */
  43577. renderHeight: number;
  43578. /**
  43579. * Texture size (Default: 512)
  43580. */
  43581. textureSize: number;
  43582. /**
  43583. * If delta time between frames should be constant
  43584. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43585. */
  43586. deterministicLockstep: boolean;
  43587. /**
  43588. * Maximum about of steps between frames (Default: 4)
  43589. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43590. */
  43591. lockstepMaxSteps: number;
  43592. }
  43593. /**
  43594. * The null engine class provides support for headless version of babylon.js.
  43595. * This can be used in server side scenario or for testing purposes
  43596. */
  43597. export class NullEngine extends Engine {
  43598. private _options;
  43599. /**
  43600. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43601. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43602. * @returns true if engine is in deterministic lock step mode
  43603. */
  43604. isDeterministicLockStep(): boolean;
  43605. /**
  43606. * Gets the max steps when engine is running in deterministic lock step
  43607. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43608. * @returns the max steps
  43609. */
  43610. getLockstepMaxSteps(): number;
  43611. /**
  43612. * Gets the current hardware scaling level.
  43613. * By default the hardware scaling level is computed from the window device ratio.
  43614. * 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.
  43615. * @returns a number indicating the current hardware scaling level
  43616. */
  43617. getHardwareScalingLevel(): number;
  43618. constructor(options?: NullEngineOptions);
  43619. /**
  43620. * Creates a vertex buffer
  43621. * @param vertices the data for the vertex buffer
  43622. * @returns the new WebGL static buffer
  43623. */
  43624. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43625. /**
  43626. * Creates a new index buffer
  43627. * @param indices defines the content of the index buffer
  43628. * @param updatable defines if the index buffer must be updatable
  43629. * @returns a new webGL buffer
  43630. */
  43631. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43632. /**
  43633. * Clear the current render buffer or the current render target (if any is set up)
  43634. * @param color defines the color to use
  43635. * @param backBuffer defines if the back buffer must be cleared
  43636. * @param depth defines if the depth buffer must be cleared
  43637. * @param stencil defines if the stencil buffer must be cleared
  43638. */
  43639. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43640. /**
  43641. * Gets the current render width
  43642. * @param useScreen defines if screen size must be used (or the current render target if any)
  43643. * @returns a number defining the current render width
  43644. */
  43645. getRenderWidth(useScreen?: boolean): number;
  43646. /**
  43647. * Gets the current render height
  43648. * @param useScreen defines if screen size must be used (or the current render target if any)
  43649. * @returns a number defining the current render height
  43650. */
  43651. getRenderHeight(useScreen?: boolean): number;
  43652. /**
  43653. * Set the WebGL's viewport
  43654. * @param viewport defines the viewport element to be used
  43655. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43656. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43657. */
  43658. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43659. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43660. /**
  43661. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43662. * @param pipelineContext defines the pipeline context to use
  43663. * @param uniformsNames defines the list of uniform names
  43664. * @returns an array of webGL uniform locations
  43665. */
  43666. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43667. /**
  43668. * Gets the lsit of active attributes for a given webGL program
  43669. * @param pipelineContext defines the pipeline context to use
  43670. * @param attributesNames defines the list of attribute names to get
  43671. * @returns an array of indices indicating the offset of each attribute
  43672. */
  43673. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43674. /**
  43675. * Binds an effect to the webGL context
  43676. * @param effect defines the effect to bind
  43677. */
  43678. bindSamplers(effect: Effect): void;
  43679. /**
  43680. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43681. * @param effect defines the effect to activate
  43682. */
  43683. enableEffect(effect: Effect): void;
  43684. /**
  43685. * Set various states to the webGL context
  43686. * @param culling defines backface culling state
  43687. * @param zOffset defines the value to apply to zOffset (0 by default)
  43688. * @param force defines if states must be applied even if cache is up to date
  43689. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43690. */
  43691. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43692. /**
  43693. * Set the value of an uniform to an array of int32
  43694. * @param uniform defines the webGL uniform location where to store the value
  43695. * @param array defines the array of int32 to store
  43696. */
  43697. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43698. /**
  43699. * Set the value of an uniform to an array of int32 (stored as vec2)
  43700. * @param uniform defines the webGL uniform location where to store the value
  43701. * @param array defines the array of int32 to store
  43702. */
  43703. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43704. /**
  43705. * Set the value of an uniform to an array of int32 (stored as vec3)
  43706. * @param uniform defines the webGL uniform location where to store the value
  43707. * @param array defines the array of int32 to store
  43708. */
  43709. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43710. /**
  43711. * Set the value of an uniform to an array of int32 (stored as vec4)
  43712. * @param uniform defines the webGL uniform location where to store the value
  43713. * @param array defines the array of int32 to store
  43714. */
  43715. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43716. /**
  43717. * Set the value of an uniform to an array of float32
  43718. * @param uniform defines the webGL uniform location where to store the value
  43719. * @param array defines the array of float32 to store
  43720. */
  43721. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43722. /**
  43723. * Set the value of an uniform to an array of float32 (stored as vec2)
  43724. * @param uniform defines the webGL uniform location where to store the value
  43725. * @param array defines the array of float32 to store
  43726. */
  43727. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43728. /**
  43729. * Set the value of an uniform to an array of float32 (stored as vec3)
  43730. * @param uniform defines the webGL uniform location where to store the value
  43731. * @param array defines the array of float32 to store
  43732. */
  43733. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43734. /**
  43735. * Set the value of an uniform to an array of float32 (stored as vec4)
  43736. * @param uniform defines the webGL uniform location where to store the value
  43737. * @param array defines the array of float32 to store
  43738. */
  43739. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43740. /**
  43741. * Set the value of an uniform to an array of number
  43742. * @param uniform defines the webGL uniform location where to store the value
  43743. * @param array defines the array of number to store
  43744. */
  43745. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43746. /**
  43747. * Set the value of an uniform to an array of number (stored as vec2)
  43748. * @param uniform defines the webGL uniform location where to store the value
  43749. * @param array defines the array of number to store
  43750. */
  43751. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43752. /**
  43753. * Set the value of an uniform to an array of number (stored as vec3)
  43754. * @param uniform defines the webGL uniform location where to store the value
  43755. * @param array defines the array of number to store
  43756. */
  43757. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43758. /**
  43759. * Set the value of an uniform to an array of number (stored as vec4)
  43760. * @param uniform defines the webGL uniform location where to store the value
  43761. * @param array defines the array of number to store
  43762. */
  43763. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43764. /**
  43765. * Set the value of an uniform to an array of float32 (stored as matrices)
  43766. * @param uniform defines the webGL uniform location where to store the value
  43767. * @param matrices defines the array of float32 to store
  43768. */
  43769. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43770. /**
  43771. * Set the value of an uniform to a matrix (3x3)
  43772. * @param uniform defines the webGL uniform location where to store the value
  43773. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43774. */
  43775. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43776. /**
  43777. * Set the value of an uniform to a matrix (2x2)
  43778. * @param uniform defines the webGL uniform location where to store the value
  43779. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43780. */
  43781. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43782. /**
  43783. * Set the value of an uniform to a number (float)
  43784. * @param uniform defines the webGL uniform location where to store the value
  43785. * @param value defines the float number to store
  43786. */
  43787. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43788. /**
  43789. * Set the value of an uniform to a vec2
  43790. * @param uniform defines the webGL uniform location where to store the value
  43791. * @param x defines the 1st component of the value
  43792. * @param y defines the 2nd component of the value
  43793. */
  43794. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43795. /**
  43796. * Set the value of an uniform to a vec3
  43797. * @param uniform defines the webGL uniform location where to store the value
  43798. * @param x defines the 1st component of the value
  43799. * @param y defines the 2nd component of the value
  43800. * @param z defines the 3rd component of the value
  43801. */
  43802. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43803. /**
  43804. * Set the value of an uniform to a boolean
  43805. * @param uniform defines the webGL uniform location where to store the value
  43806. * @param bool defines the boolean to store
  43807. */
  43808. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43809. /**
  43810. * Set the value of an uniform to a vec4
  43811. * @param uniform defines the webGL uniform location where to store the value
  43812. * @param x defines the 1st component of the value
  43813. * @param y defines the 2nd component of the value
  43814. * @param z defines the 3rd component of the value
  43815. * @param w defines the 4th component of the value
  43816. */
  43817. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43818. /**
  43819. * Sets the current alpha mode
  43820. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43821. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43822. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43823. */
  43824. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43825. /**
  43826. * Bind webGl buffers directly to the webGL context
  43827. * @param vertexBuffers defines the vertex buffer to bind
  43828. * @param indexBuffer defines the index buffer to bind
  43829. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43830. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43831. * @param effect defines the effect associated with the vertex buffer
  43832. */
  43833. bindBuffers(vertexBuffers: {
  43834. [key: string]: VertexBuffer;
  43835. }, indexBuffer: DataBuffer, effect: Effect): void;
  43836. /**
  43837. * Force the entire cache to be cleared
  43838. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43839. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43840. */
  43841. wipeCaches(bruteForce?: boolean): void;
  43842. /**
  43843. * Send a draw order
  43844. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43845. * @param indexStart defines the starting index
  43846. * @param indexCount defines the number of index to draw
  43847. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43848. */
  43849. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43850. /**
  43851. * Draw a list of indexed primitives
  43852. * @param fillMode defines the primitive to use
  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. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43858. /**
  43859. * Draw a list of unindexed primitives
  43860. * @param fillMode defines the primitive to use
  43861. * @param verticesStart defines the index of first vertex to draw
  43862. * @param verticesCount defines the count of vertices to draw
  43863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43864. */
  43865. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43866. /** @hidden */
  43867. _createTexture(): WebGLTexture;
  43868. /** @hidden */
  43869. _releaseTexture(texture: InternalTexture): void;
  43870. /**
  43871. * Usually called from Texture.ts.
  43872. * Passed information to create a WebGLTexture
  43873. * @param urlArg defines a value which contains one of the following:
  43874. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43875. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43876. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43877. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43878. * @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)
  43879. * @param scene needed for loading to the correct scene
  43880. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43881. * @param onLoad optional callback to be called upon successful completion
  43882. * @param onError optional callback to be called upon failure
  43883. * @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
  43884. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43885. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43886. * @param forcedExtension defines the extension to use to pick the right loader
  43887. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43888. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43889. */
  43890. 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;
  43891. /**
  43892. * Creates a new render target texture
  43893. * @param size defines the size of the texture
  43894. * @param options defines the options used to create the texture
  43895. * @returns a new render target texture stored in an InternalTexture
  43896. */
  43897. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43898. /**
  43899. * Update the sampling mode of a given texture
  43900. * @param samplingMode defines the required sampling mode
  43901. * @param texture defines the texture to update
  43902. */
  43903. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43904. /**
  43905. * Binds the frame buffer to the specified texture.
  43906. * @param texture The texture to render to or null for the default canvas
  43907. * @param faceIndex The face of the texture to render to in case of cube texture
  43908. * @param requiredWidth The width of the target to render to
  43909. * @param requiredHeight The height of the target to render to
  43910. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43911. * @param depthStencilTexture The depth stencil texture to use to render
  43912. * @param lodLevel defines le lod level to bind to the frame buffer
  43913. */
  43914. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43915. /**
  43916. * Unbind the current render target texture from the webGL context
  43917. * @param texture defines the render target texture to unbind
  43918. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43919. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43920. */
  43921. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43922. /**
  43923. * Creates a dynamic vertex buffer
  43924. * @param vertices the data for the dynamic vertex buffer
  43925. * @returns the new WebGL dynamic buffer
  43926. */
  43927. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43928. /**
  43929. * Update the content of a dynamic texture
  43930. * @param texture defines the texture to update
  43931. * @param canvas defines the canvas containing the source
  43932. * @param invertY defines if data must be stored with Y axis inverted
  43933. * @param premulAlpha defines if alpha is stored as premultiplied
  43934. * @param format defines the format of the data
  43935. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43936. */
  43937. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43938. /**
  43939. * Gets a boolean indicating if all created effects are ready
  43940. * @returns true if all effects are ready
  43941. */
  43942. areAllEffectsReady(): boolean;
  43943. /**
  43944. * @hidden
  43945. * Get the current error code of the webGL context
  43946. * @returns the error code
  43947. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43948. */
  43949. getError(): number;
  43950. /** @hidden */
  43951. _getUnpackAlignement(): number;
  43952. /** @hidden */
  43953. _unpackFlipY(value: boolean): void;
  43954. /**
  43955. * Update a dynamic index buffer
  43956. * @param indexBuffer defines the target index buffer
  43957. * @param indices defines the data to update
  43958. * @param offset defines the offset in the target index buffer where update should start
  43959. */
  43960. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43961. /**
  43962. * Updates a dynamic vertex buffer.
  43963. * @param vertexBuffer the vertex buffer to update
  43964. * @param vertices the data used to update the vertex buffer
  43965. * @param byteOffset the byte offset of the data (optional)
  43966. * @param byteLength the byte length of the data (optional)
  43967. */
  43968. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43969. /** @hidden */
  43970. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43971. /** @hidden */
  43972. _bindTexture(channel: number, texture: InternalTexture): void;
  43973. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43974. /**
  43975. * 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
  43976. */
  43977. releaseEffects(): void;
  43978. displayLoadingUI(): void;
  43979. hideLoadingUI(): void;
  43980. /** @hidden */
  43981. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43982. /** @hidden */
  43983. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43984. /** @hidden */
  43985. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43986. /** @hidden */
  43987. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43988. }
  43989. }
  43990. declare module BABYLON {
  43991. /** @hidden */
  43992. export class _OcclusionDataStorage {
  43993. /** @hidden */
  43994. occlusionInternalRetryCounter: number;
  43995. /** @hidden */
  43996. isOcclusionQueryInProgress: boolean;
  43997. /** @hidden */
  43998. isOccluded: boolean;
  43999. /** @hidden */
  44000. occlusionRetryCount: number;
  44001. /** @hidden */
  44002. occlusionType: number;
  44003. /** @hidden */
  44004. occlusionQueryAlgorithmType: number;
  44005. }
  44006. interface Engine {
  44007. /**
  44008. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44009. * @return the new query
  44010. */
  44011. createQuery(): WebGLQuery;
  44012. /**
  44013. * Delete and release a webGL query
  44014. * @param query defines the query to delete
  44015. * @return the current engine
  44016. */
  44017. deleteQuery(query: WebGLQuery): Engine;
  44018. /**
  44019. * Check if a given query has resolved and got its value
  44020. * @param query defines the query to check
  44021. * @returns true if the query got its value
  44022. */
  44023. isQueryResultAvailable(query: WebGLQuery): boolean;
  44024. /**
  44025. * Gets the value of a given query
  44026. * @param query defines the query to check
  44027. * @returns the value of the query
  44028. */
  44029. getQueryResult(query: WebGLQuery): number;
  44030. /**
  44031. * Initiates an occlusion query
  44032. * @param algorithmType defines the algorithm to use
  44033. * @param query defines the query to use
  44034. * @returns the current engine
  44035. * @see http://doc.babylonjs.com/features/occlusionquery
  44036. */
  44037. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44038. /**
  44039. * Ends an occlusion query
  44040. * @see http://doc.babylonjs.com/features/occlusionquery
  44041. * @param algorithmType defines the algorithm to use
  44042. * @returns the current engine
  44043. */
  44044. endOcclusionQuery(algorithmType: number): Engine;
  44045. /**
  44046. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44047. * Please note that only one query can be issued at a time
  44048. * @returns a time token used to track the time span
  44049. */
  44050. startTimeQuery(): Nullable<_TimeToken>;
  44051. /**
  44052. * Ends a time query
  44053. * @param token defines the token used to measure the time span
  44054. * @returns the time spent (in ns)
  44055. */
  44056. endTimeQuery(token: _TimeToken): int;
  44057. /** @hidden */
  44058. _currentNonTimestampToken: Nullable<_TimeToken>;
  44059. /** @hidden */
  44060. _createTimeQuery(): WebGLQuery;
  44061. /** @hidden */
  44062. _deleteTimeQuery(query: WebGLQuery): void;
  44063. /** @hidden */
  44064. _getGlAlgorithmType(algorithmType: number): number;
  44065. /** @hidden */
  44066. _getTimeQueryResult(query: WebGLQuery): any;
  44067. /** @hidden */
  44068. _getTimeQueryAvailability(query: WebGLQuery): any;
  44069. }
  44070. interface AbstractMesh {
  44071. /**
  44072. * Backing filed
  44073. * @hidden
  44074. */
  44075. __occlusionDataStorage: _OcclusionDataStorage;
  44076. /**
  44077. * Access property
  44078. * @hidden
  44079. */
  44080. _occlusionDataStorage: _OcclusionDataStorage;
  44081. /**
  44082. * 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.
  44083. * The default value is -1 which means don't break the query and wait till the result
  44084. * @see http://doc.babylonjs.com/features/occlusionquery
  44085. */
  44086. occlusionRetryCount: number;
  44087. /**
  44088. * 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:
  44089. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44090. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44091. * * 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.
  44092. * @see http://doc.babylonjs.com/features/occlusionquery
  44093. */
  44094. occlusionType: number;
  44095. /**
  44096. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44097. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44098. * * 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.
  44099. * @see http://doc.babylonjs.com/features/occlusionquery
  44100. */
  44101. occlusionQueryAlgorithmType: number;
  44102. /**
  44103. * 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
  44104. * @see http://doc.babylonjs.com/features/occlusionquery
  44105. */
  44106. isOccluded: boolean;
  44107. /**
  44108. * Flag to check the progress status of the query
  44109. * @see http://doc.babylonjs.com/features/occlusionquery
  44110. */
  44111. isOcclusionQueryInProgress: boolean;
  44112. }
  44113. }
  44114. declare module BABYLON {
  44115. /** @hidden */
  44116. export var _forceTransformFeedbackToBundle: boolean;
  44117. interface Engine {
  44118. /**
  44119. * Creates a webGL transform feedback object
  44120. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44121. * @returns the webGL transform feedback object
  44122. */
  44123. createTransformFeedback(): WebGLTransformFeedback;
  44124. /**
  44125. * Delete a webGL transform feedback object
  44126. * @param value defines the webGL transform feedback object to delete
  44127. */
  44128. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44129. /**
  44130. * Bind a webGL transform feedback object to the webgl context
  44131. * @param value defines the webGL transform feedback object to bind
  44132. */
  44133. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44134. /**
  44135. * Begins a transform feedback operation
  44136. * @param usePoints defines if points or triangles must be used
  44137. */
  44138. beginTransformFeedback(usePoints: boolean): void;
  44139. /**
  44140. * Ends a transform feedback operation
  44141. */
  44142. endTransformFeedback(): void;
  44143. /**
  44144. * Specify the varyings to use with transform feedback
  44145. * @param program defines the associated webGL program
  44146. * @param value defines the list of strings representing the varying names
  44147. */
  44148. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44149. /**
  44150. * Bind a webGL buffer for a transform feedback operation
  44151. * @param value defines the webGL buffer to bind
  44152. */
  44153. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44154. }
  44155. }
  44156. declare module BABYLON {
  44157. /**
  44158. * Creation options of the multi render target texture.
  44159. */
  44160. export interface IMultiRenderTargetOptions {
  44161. /**
  44162. * Define if the texture needs to create mip maps after render.
  44163. */
  44164. generateMipMaps?: boolean;
  44165. /**
  44166. * Define the types of all the draw buffers we want to create
  44167. */
  44168. types?: number[];
  44169. /**
  44170. * Define the sampling modes of all the draw buffers we want to create
  44171. */
  44172. samplingModes?: number[];
  44173. /**
  44174. * Define if a depth buffer is required
  44175. */
  44176. generateDepthBuffer?: boolean;
  44177. /**
  44178. * Define if a stencil buffer is required
  44179. */
  44180. generateStencilBuffer?: boolean;
  44181. /**
  44182. * Define if a depth texture is required instead of a depth buffer
  44183. */
  44184. generateDepthTexture?: boolean;
  44185. /**
  44186. * Define the number of desired draw buffers
  44187. */
  44188. textureCount?: number;
  44189. /**
  44190. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44191. */
  44192. doNotChangeAspectRatio?: boolean;
  44193. /**
  44194. * Define the default type of the buffers we are creating
  44195. */
  44196. defaultType?: number;
  44197. }
  44198. /**
  44199. * A multi render target, like a render target provides the ability to render to a texture.
  44200. * Unlike the render target, it can render to several draw buffers in one draw.
  44201. * This is specially interesting in deferred rendering or for any effects requiring more than
  44202. * just one color from a single pass.
  44203. */
  44204. export class MultiRenderTarget extends RenderTargetTexture {
  44205. private _internalTextures;
  44206. private _textures;
  44207. private _multiRenderTargetOptions;
  44208. /**
  44209. * Get if draw buffers are currently supported by the used hardware and browser.
  44210. */
  44211. readonly isSupported: boolean;
  44212. /**
  44213. * Get the list of textures generated by the multi render target.
  44214. */
  44215. readonly textures: Texture[];
  44216. /**
  44217. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44218. */
  44219. readonly depthTexture: Texture;
  44220. /**
  44221. * Set the wrapping mode on U of all the textures we are rendering to.
  44222. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44223. */
  44224. wrapU: number;
  44225. /**
  44226. * Set the wrapping mode on V of all the textures we are rendering to.
  44227. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44228. */
  44229. wrapV: number;
  44230. /**
  44231. * Instantiate a new multi render target texture.
  44232. * A multi render target, like a render target provides the ability to render to a texture.
  44233. * Unlike the render target, it can render to several draw buffers in one draw.
  44234. * This is specially interesting in deferred rendering or for any effects requiring more than
  44235. * just one color from a single pass.
  44236. * @param name Define the name of the texture
  44237. * @param size Define the size of the buffers to render to
  44238. * @param count Define the number of target we are rendering into
  44239. * @param scene Define the scene the texture belongs to
  44240. * @param options Define the options used to create the multi render target
  44241. */
  44242. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44243. /** @hidden */
  44244. _rebuild(): void;
  44245. private _createInternalTextures;
  44246. private _createTextures;
  44247. /**
  44248. * Define the number of samples used if MSAA is enabled.
  44249. */
  44250. samples: number;
  44251. /**
  44252. * Resize all the textures in the multi render target.
  44253. * Be carrefull as it will recreate all the data in the new texture.
  44254. * @param size Define the new size
  44255. */
  44256. resize(size: any): void;
  44257. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44258. /**
  44259. * Dispose the render targets and their associated resources
  44260. */
  44261. dispose(): void;
  44262. /**
  44263. * Release all the underlying texture used as draw buffers.
  44264. */
  44265. releaseInternalTextures(): void;
  44266. }
  44267. }
  44268. declare module BABYLON {
  44269. interface ThinEngine {
  44270. /**
  44271. * Unbind a list of render target textures from the webGL context
  44272. * This is used only when drawBuffer extension or webGL2 are active
  44273. * @param textures defines the render target textures to unbind
  44274. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44275. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44276. */
  44277. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44278. /**
  44279. * Create a multi render target texture
  44280. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44281. * @param size defines the size of the texture
  44282. * @param options defines the creation options
  44283. * @returns the cube texture as an InternalTexture
  44284. */
  44285. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44286. /**
  44287. * Update the sample count for a given multiple render target texture
  44288. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44289. * @param textures defines the textures to update
  44290. * @param samples defines the sample count to set
  44291. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44292. */
  44293. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44294. }
  44295. }
  44296. declare module BABYLON {
  44297. /**
  44298. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  44299. */
  44300. export interface CubeMapInfo {
  44301. /**
  44302. * The pixel array for the front face.
  44303. * This is stored in format, left to right, up to down format.
  44304. */
  44305. front: Nullable<ArrayBufferView>;
  44306. /**
  44307. * The pixel array for the back face.
  44308. * This is stored in format, left to right, up to down format.
  44309. */
  44310. back: Nullable<ArrayBufferView>;
  44311. /**
  44312. * The pixel array for the left face.
  44313. * This is stored in format, left to right, up to down format.
  44314. */
  44315. left: Nullable<ArrayBufferView>;
  44316. /**
  44317. * The pixel array for the right face.
  44318. * This is stored in format, left to right, up to down format.
  44319. */
  44320. right: Nullable<ArrayBufferView>;
  44321. /**
  44322. * The pixel array for the up face.
  44323. * This is stored in format, left to right, up to down format.
  44324. */
  44325. up: Nullable<ArrayBufferView>;
  44326. /**
  44327. * The pixel array for the down face.
  44328. * This is stored in format, left to right, up to down format.
  44329. */
  44330. down: Nullable<ArrayBufferView>;
  44331. /**
  44332. * The size of the cubemap stored.
  44333. *
  44334. * Each faces will be size * size pixels.
  44335. */
  44336. size: number;
  44337. /**
  44338. * The format of the texture.
  44339. *
  44340. * RGBA, RGB.
  44341. */
  44342. format: number;
  44343. /**
  44344. * The type of the texture data.
  44345. *
  44346. * UNSIGNED_INT, FLOAT.
  44347. */
  44348. type: number;
  44349. /**
  44350. * Specifies whether the texture is in gamma space.
  44351. */
  44352. gammaSpace: boolean;
  44353. }
  44354. /**
  44355. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  44356. */
  44357. export class PanoramaToCubeMapTools {
  44358. private static FACE_FRONT;
  44359. private static FACE_BACK;
  44360. private static FACE_RIGHT;
  44361. private static FACE_LEFT;
  44362. private static FACE_DOWN;
  44363. private static FACE_UP;
  44364. /**
  44365. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  44366. *
  44367. * @param float32Array The source data.
  44368. * @param inputWidth The width of the input panorama.
  44369. * @param inputHeight The height of the input panorama.
  44370. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  44371. * @return The cubemap data
  44372. */
  44373. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  44374. private static CreateCubemapTexture;
  44375. private static CalcProjectionSpherical;
  44376. }
  44377. }
  44378. declare module BABYLON {
  44379. /**
  44380. * Helper class dealing with the extraction of spherical polynomial dataArray
  44381. * from a cube map.
  44382. */
  44383. export class CubeMapToSphericalPolynomialTools {
  44384. private static FileFaces;
  44385. /**
  44386. * Converts a texture to the according Spherical Polynomial data.
  44387. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44388. *
  44389. * @param texture The texture to extract the information from.
  44390. * @return The Spherical Polynomial data.
  44391. */
  44392. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  44393. /**
  44394. * Converts a cubemap 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 cubeInfo The Cube map to extract the information from.
  44398. * @return The Spherical Polynomial data.
  44399. */
  44400. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  44401. }
  44402. }
  44403. declare module BABYLON {
  44404. interface BaseTexture {
  44405. /**
  44406. * Get the polynomial representation of the texture data.
  44407. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  44408. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  44409. */
  44410. sphericalPolynomial: Nullable<SphericalPolynomial>;
  44411. }
  44412. }
  44413. declare module BABYLON {
  44414. /** @hidden */
  44415. export var rgbdEncodePixelShader: {
  44416. name: string;
  44417. shader: string;
  44418. };
  44419. }
  44420. declare module BABYLON {
  44421. /** @hidden */
  44422. export var rgbdDecodePixelShader: {
  44423. name: string;
  44424. shader: string;
  44425. };
  44426. }
  44427. declare module BABYLON {
  44428. /**
  44429. * Raw texture data and descriptor sufficient for WebGL texture upload
  44430. */
  44431. export interface EnvironmentTextureInfo {
  44432. /**
  44433. * Version of the environment map
  44434. */
  44435. version: number;
  44436. /**
  44437. * Width of image
  44438. */
  44439. width: number;
  44440. /**
  44441. * Irradiance information stored in the file.
  44442. */
  44443. irradiance: any;
  44444. /**
  44445. * Specular information stored in the file.
  44446. */
  44447. specular: any;
  44448. }
  44449. /**
  44450. * Defines One Image in the file. It requires only the position in the file
  44451. * as well as the length.
  44452. */
  44453. interface BufferImageData {
  44454. /**
  44455. * Length of the image data.
  44456. */
  44457. length: number;
  44458. /**
  44459. * Position of the data from the null terminator delimiting the end of the JSON.
  44460. */
  44461. position: number;
  44462. }
  44463. /**
  44464. * Defines the specular data enclosed in the file.
  44465. * This corresponds to the version 1 of the data.
  44466. */
  44467. export interface EnvironmentTextureSpecularInfoV1 {
  44468. /**
  44469. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44470. */
  44471. specularDataPosition?: number;
  44472. /**
  44473. * This contains all the images data needed to reconstruct the cubemap.
  44474. */
  44475. mipmaps: Array<BufferImageData>;
  44476. /**
  44477. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44478. */
  44479. lodGenerationScale: number;
  44480. }
  44481. /**
  44482. * Sets of helpers addressing the serialization and deserialization of environment texture
  44483. * stored in a BabylonJS env file.
  44484. * Those files are usually stored as .env files.
  44485. */
  44486. export class EnvironmentTextureTools {
  44487. /**
  44488. * Magic number identifying the env file.
  44489. */
  44490. private static _MagicBytes;
  44491. /**
  44492. * Gets the environment info from an env file.
  44493. * @param data The array buffer containing the .env bytes.
  44494. * @returns the environment file info (the json header) if successfully parsed.
  44495. */
  44496. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44497. /**
  44498. * Creates an environment texture from a loaded cube texture.
  44499. * @param texture defines the cube texture to convert in env file
  44500. * @return a promise containing the environment data if succesfull.
  44501. */
  44502. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44503. /**
  44504. * Creates a JSON representation of the spherical data.
  44505. * @param texture defines the texture containing the polynomials
  44506. * @return the JSON representation of the spherical info
  44507. */
  44508. private static _CreateEnvTextureIrradiance;
  44509. /**
  44510. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44511. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44512. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44513. * @return the views described by info providing access to the underlying buffer
  44514. */
  44515. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44516. /**
  44517. * Uploads the texture info contained in the env file to the GPU.
  44518. * @param texture defines the internal texture to upload to
  44519. * @param arrayBuffer defines the buffer cotaining the data to load
  44520. * @param info defines the texture info retrieved through the GetEnvInfo method
  44521. * @returns a promise
  44522. */
  44523. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44524. private static _OnImageReadyAsync;
  44525. /**
  44526. * Uploads the levels of image data to the GPU.
  44527. * @param texture defines the internal texture to upload to
  44528. * @param imageData defines the array buffer views of image data [mipmap][face]
  44529. * @returns a promise
  44530. */
  44531. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44532. /**
  44533. * Uploads spherical polynomials information to the texture.
  44534. * @param texture defines the texture we are trying to upload the information to
  44535. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44536. */
  44537. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44538. /** @hidden */
  44539. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44540. }
  44541. }
  44542. declare module BABYLON {
  44543. /**
  44544. * Contains position and normal vectors for a vertex
  44545. */
  44546. export class PositionNormalVertex {
  44547. /** the position of the vertex (defaut: 0,0,0) */
  44548. position: Vector3;
  44549. /** the normal of the vertex (defaut: 0,1,0) */
  44550. normal: Vector3;
  44551. /**
  44552. * Creates a PositionNormalVertex
  44553. * @param position the position of the vertex (defaut: 0,0,0)
  44554. * @param normal the normal of the vertex (defaut: 0,1,0)
  44555. */
  44556. constructor(
  44557. /** the position of the vertex (defaut: 0,0,0) */
  44558. position?: Vector3,
  44559. /** the normal of the vertex (defaut: 0,1,0) */
  44560. normal?: Vector3);
  44561. /**
  44562. * Clones the PositionNormalVertex
  44563. * @returns the cloned PositionNormalVertex
  44564. */
  44565. clone(): PositionNormalVertex;
  44566. }
  44567. /**
  44568. * Contains position, normal and uv vectors for a vertex
  44569. */
  44570. export class PositionNormalTextureVertex {
  44571. /** the position of the vertex (defaut: 0,0,0) */
  44572. position: Vector3;
  44573. /** the normal of the vertex (defaut: 0,1,0) */
  44574. normal: Vector3;
  44575. /** the uv of the vertex (default: 0,0) */
  44576. uv: Vector2;
  44577. /**
  44578. * Creates a PositionNormalTextureVertex
  44579. * @param position the position of the vertex (defaut: 0,0,0)
  44580. * @param normal the normal of the vertex (defaut: 0,1,0)
  44581. * @param uv the uv of the vertex (default: 0,0)
  44582. */
  44583. constructor(
  44584. /** the position of the vertex (defaut: 0,0,0) */
  44585. position?: Vector3,
  44586. /** the normal of the vertex (defaut: 0,1,0) */
  44587. normal?: Vector3,
  44588. /** the uv of the vertex (default: 0,0) */
  44589. uv?: Vector2);
  44590. /**
  44591. * Clones the PositionNormalTextureVertex
  44592. * @returns the cloned PositionNormalTextureVertex
  44593. */
  44594. clone(): PositionNormalTextureVertex;
  44595. }
  44596. }
  44597. declare module BABYLON {
  44598. /** @hidden */
  44599. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44600. private _genericAttributeLocation;
  44601. private _varyingLocationCount;
  44602. private _varyingLocationMap;
  44603. private _replacements;
  44604. private _textureCount;
  44605. private _uniforms;
  44606. lineProcessor(line: string): string;
  44607. attributeProcessor(attribute: string): string;
  44608. varyingProcessor(varying: string, isFragment: boolean): string;
  44609. uniformProcessor(uniform: string): string;
  44610. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44611. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44612. }
  44613. }
  44614. declare module BABYLON {
  44615. /**
  44616. * Container for accessors for natively-stored mesh data buffers.
  44617. */
  44618. class NativeDataBuffer extends DataBuffer {
  44619. /**
  44620. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44621. */
  44622. nativeIndexBuffer?: any;
  44623. /**
  44624. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44625. */
  44626. nativeVertexBuffer?: any;
  44627. }
  44628. /** @hidden */
  44629. export class NativeEngine extends Engine {
  44630. private readonly _native;
  44631. getHardwareScalingLevel(): number;
  44632. constructor();
  44633. /**
  44634. * Can be used to override the current requestAnimationFrame requester.
  44635. * @hidden
  44636. */
  44637. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44638. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44639. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44640. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44641. recordVertexArrayObject(vertexBuffers: {
  44642. [key: string]: VertexBuffer;
  44643. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44644. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44645. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44646. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44647. /**
  44648. * Draw a list of indexed primitives
  44649. * @param fillMode defines the primitive to use
  44650. * @param indexStart defines the starting index
  44651. * @param indexCount defines the number of index to draw
  44652. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44653. */
  44654. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44655. /**
  44656. * Draw a list of unindexed primitives
  44657. * @param fillMode defines the primitive to use
  44658. * @param verticesStart defines the index of first vertex to draw
  44659. * @param verticesCount defines the count of vertices to draw
  44660. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44661. */
  44662. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44663. createPipelineContext(): IPipelineContext;
  44664. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44665. /** @hidden */
  44666. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44667. /** @hidden */
  44668. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44669. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44670. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44671. protected _setProgram(program: WebGLProgram): void;
  44672. _releaseEffect(effect: Effect): void;
  44673. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44674. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44675. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44676. bindSamplers(effect: Effect): void;
  44677. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44678. getRenderWidth(useScreen?: boolean): number;
  44679. getRenderHeight(useScreen?: boolean): number;
  44680. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44681. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44682. /**
  44683. * Set the z offset to apply to current rendering
  44684. * @param value defines the offset to apply
  44685. */
  44686. setZOffset(value: number): void;
  44687. /**
  44688. * Gets the current value of the zOffset
  44689. * @returns the current zOffset state
  44690. */
  44691. getZOffset(): number;
  44692. /**
  44693. * Enable or disable depth buffering
  44694. * @param enable defines the state to set
  44695. */
  44696. setDepthBuffer(enable: boolean): void;
  44697. /**
  44698. * Gets a boolean indicating if depth writing is enabled
  44699. * @returns the current depth writing state
  44700. */
  44701. getDepthWrite(): boolean;
  44702. /**
  44703. * Enable or disable depth writing
  44704. * @param enable defines the state to set
  44705. */
  44706. setDepthWrite(enable: boolean): void;
  44707. /**
  44708. * Enable or disable color writing
  44709. * @param enable defines the state to set
  44710. */
  44711. setColorWrite(enable: boolean): void;
  44712. /**
  44713. * Gets a boolean indicating if color writing is enabled
  44714. * @returns the current color writing state
  44715. */
  44716. getColorWrite(): boolean;
  44717. /**
  44718. * Sets alpha constants used by some alpha blending modes
  44719. * @param r defines the red component
  44720. * @param g defines the green component
  44721. * @param b defines the blue component
  44722. * @param a defines the alpha component
  44723. */
  44724. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44725. /**
  44726. * Sets the current alpha mode
  44727. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44728. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44729. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44730. */
  44731. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44732. /**
  44733. * Gets the current alpha mode
  44734. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44735. * @returns the current alpha mode
  44736. */
  44737. getAlphaMode(): number;
  44738. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44739. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44740. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44741. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44742. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44743. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44744. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44745. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44746. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44747. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44748. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44749. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44750. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44751. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44752. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44753. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44754. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44755. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44756. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44757. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44758. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44759. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44760. wipeCaches(bruteForce?: boolean): void;
  44761. _createTexture(): WebGLTexture;
  44762. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44763. /**
  44764. * Usually called from BABYLON.Texture.ts.
  44765. * Passed information to create a WebGLTexture
  44766. * @param urlArg defines a value which contains one of the following:
  44767. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44768. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44769. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44770. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44771. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44772. * @param scene needed for loading to the correct scene
  44773. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44774. * @param onLoad optional callback to be called upon successful completion
  44775. * @param onError optional callback to be called upon failure
  44776. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44777. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44778. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44779. * @param forcedExtension defines the extension to use to pick the right loader
  44780. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44781. */
  44782. 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;
  44783. /**
  44784. * Creates a cube texture
  44785. * @param rootUrl defines the url where the files to load is located
  44786. * @param scene defines the current scene
  44787. * @param files defines the list of files to load (1 per face)
  44788. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44789. * @param onLoad defines an optional callback raised when the texture is loaded
  44790. * @param onError defines an optional callback raised if there is an issue to load the texture
  44791. * @param format defines the format of the data
  44792. * @param forcedExtension defines the extension to use to pick the right loader
  44793. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44794. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44795. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44796. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44797. * @returns the cube texture as an InternalTexture
  44798. */
  44799. 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;
  44800. private _getSamplingFilter;
  44801. private static _GetNativeTextureFormat;
  44802. createRenderTargetTexture(size: number | {
  44803. width: number;
  44804. height: number;
  44805. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44806. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44807. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44808. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44809. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44810. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44811. /**
  44812. * Updates a dynamic vertex buffer.
  44813. * @param vertexBuffer the vertex buffer to update
  44814. * @param data the data used to update the vertex buffer
  44815. * @param byteOffset the byte offset of the data (optional)
  44816. * @param byteLength the byte length of the data (optional)
  44817. */
  44818. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44819. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44820. private _updateAnisotropicLevel;
  44821. private _getAddressMode;
  44822. /** @hidden */
  44823. _bindTexture(channel: number, texture: InternalTexture): void;
  44824. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44825. releaseEffects(): void;
  44826. /** @hidden */
  44827. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44828. /** @hidden */
  44829. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44830. /** @hidden */
  44831. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44832. /** @hidden */
  44833. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44834. }
  44835. }
  44836. declare module BABYLON {
  44837. /**
  44838. * Gather the list of clipboard event types as constants.
  44839. */
  44840. export class ClipboardEventTypes {
  44841. /**
  44842. * The clipboard event is fired when a copy command is active (pressed).
  44843. */
  44844. static readonly COPY: number;
  44845. /**
  44846. * The clipboard event is fired when a cut command is active (pressed).
  44847. */
  44848. static readonly CUT: number;
  44849. /**
  44850. * The clipboard event is fired when a paste command is active (pressed).
  44851. */
  44852. static readonly PASTE: number;
  44853. }
  44854. /**
  44855. * This class is used to store clipboard related info for the onClipboardObservable event.
  44856. */
  44857. export class ClipboardInfo {
  44858. /**
  44859. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44860. */
  44861. type: number;
  44862. /**
  44863. * Defines the related dom event
  44864. */
  44865. event: ClipboardEvent;
  44866. /**
  44867. *Creates an instance of ClipboardInfo.
  44868. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44869. * @param event Defines the related dom event
  44870. */
  44871. constructor(
  44872. /**
  44873. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44874. */
  44875. type: number,
  44876. /**
  44877. * Defines the related dom event
  44878. */
  44879. event: ClipboardEvent);
  44880. /**
  44881. * Get the clipboard event's type from the keycode.
  44882. * @param keyCode Defines the keyCode for the current keyboard event.
  44883. * @return {number}
  44884. */
  44885. static GetTypeFromCharacter(keyCode: number): number;
  44886. }
  44887. }
  44888. declare module BABYLON {
  44889. /**
  44890. * Google Daydream controller
  44891. */
  44892. export class DaydreamController extends WebVRController {
  44893. /**
  44894. * Base Url for the controller model.
  44895. */
  44896. static MODEL_BASE_URL: string;
  44897. /**
  44898. * File name for the controller model.
  44899. */
  44900. static MODEL_FILENAME: string;
  44901. /**
  44902. * Gamepad Id prefix used to identify Daydream Controller.
  44903. */
  44904. static readonly GAMEPAD_ID_PREFIX: string;
  44905. /**
  44906. * Creates a new DaydreamController from a gamepad
  44907. * @param vrGamepad the gamepad that the controller should be created from
  44908. */
  44909. constructor(vrGamepad: any);
  44910. /**
  44911. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44912. * @param scene scene in which to add meshes
  44913. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44914. */
  44915. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44916. /**
  44917. * Called once for each button that changed state since the last frame
  44918. * @param buttonIdx Which button index changed
  44919. * @param state New state of the button
  44920. * @param changes Which properties on the state changed since last frame
  44921. */
  44922. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44923. }
  44924. }
  44925. declare module BABYLON {
  44926. /**
  44927. * Gear VR Controller
  44928. */
  44929. export class GearVRController extends WebVRController {
  44930. /**
  44931. * Base Url for the controller model.
  44932. */
  44933. static MODEL_BASE_URL: string;
  44934. /**
  44935. * File name for the controller model.
  44936. */
  44937. static MODEL_FILENAME: string;
  44938. /**
  44939. * Gamepad Id prefix used to identify this controller.
  44940. */
  44941. static readonly GAMEPAD_ID_PREFIX: string;
  44942. private readonly _buttonIndexToObservableNameMap;
  44943. /**
  44944. * Creates a new GearVRController from a gamepad
  44945. * @param vrGamepad the gamepad that the controller should be created from
  44946. */
  44947. constructor(vrGamepad: any);
  44948. /**
  44949. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44950. * @param scene scene in which to add meshes
  44951. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44952. */
  44953. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44954. /**
  44955. * Called once for each button that changed state since the last frame
  44956. * @param buttonIdx Which button index changed
  44957. * @param state New state of the button
  44958. * @param changes Which properties on the state changed since last frame
  44959. */
  44960. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44961. }
  44962. }
  44963. declare module BABYLON {
  44964. /**
  44965. * Class containing static functions to help procedurally build meshes
  44966. */
  44967. export class PolyhedronBuilder {
  44968. /**
  44969. * Creates a polyhedron mesh
  44970. * * 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
  44971. * * The parameter `size` (positive float, default 1) sets the polygon size
  44972. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44973. * * 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`
  44974. * * 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
  44975. * * 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)`)
  44976. * * 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
  44977. * * 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
  44978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44979. * * 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
  44980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44981. * @param name defines the name of the mesh
  44982. * @param options defines the options used to create the mesh
  44983. * @param scene defines the hosting scene
  44984. * @returns the polyhedron mesh
  44985. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44986. */
  44987. static CreatePolyhedron(name: string, options: {
  44988. type?: number;
  44989. size?: number;
  44990. sizeX?: number;
  44991. sizeY?: number;
  44992. sizeZ?: number;
  44993. custom?: any;
  44994. faceUV?: Vector4[];
  44995. faceColors?: Color4[];
  44996. flat?: boolean;
  44997. updatable?: boolean;
  44998. sideOrientation?: number;
  44999. frontUVs?: Vector4;
  45000. backUVs?: Vector4;
  45001. }, scene?: Nullable<Scene>): Mesh;
  45002. }
  45003. }
  45004. declare module BABYLON {
  45005. /**
  45006. * Gizmo that enables scaling a mesh along 3 axis
  45007. */
  45008. export class ScaleGizmo extends Gizmo {
  45009. /**
  45010. * Internal gizmo used for interactions on the x axis
  45011. */
  45012. xGizmo: AxisScaleGizmo;
  45013. /**
  45014. * Internal gizmo used for interactions on the y axis
  45015. */
  45016. yGizmo: AxisScaleGizmo;
  45017. /**
  45018. * Internal gizmo used for interactions on the z axis
  45019. */
  45020. zGizmo: AxisScaleGizmo;
  45021. /**
  45022. * Internal gizmo used to scale all axis equally
  45023. */
  45024. uniformScaleGizmo: AxisScaleGizmo;
  45025. private _meshAttached;
  45026. private _updateGizmoRotationToMatchAttachedMesh;
  45027. private _snapDistance;
  45028. private _scaleRatio;
  45029. private _uniformScalingMesh;
  45030. private _octahedron;
  45031. /** Fires an event when any of it's sub gizmos are dragged */
  45032. onDragStartObservable: Observable<unknown>;
  45033. /** Fires an event when any of it's sub gizmos are released from dragging */
  45034. onDragEndObservable: Observable<unknown>;
  45035. attachedMesh: Nullable<AbstractMesh>;
  45036. /**
  45037. * Creates a ScaleGizmo
  45038. * @param gizmoLayer The utility layer the gizmo will be added to
  45039. */
  45040. constructor(gizmoLayer?: UtilityLayerRenderer);
  45041. updateGizmoRotationToMatchAttachedMesh: boolean;
  45042. /**
  45043. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45044. */
  45045. snapDistance: number;
  45046. /**
  45047. * Ratio for the scale of the gizmo (Default: 1)
  45048. */
  45049. scaleRatio: number;
  45050. /**
  45051. * Disposes of the gizmo
  45052. */
  45053. dispose(): void;
  45054. }
  45055. }
  45056. declare module BABYLON {
  45057. /**
  45058. * Single axis scale gizmo
  45059. */
  45060. export class AxisScaleGizmo extends Gizmo {
  45061. /**
  45062. * Drag behavior responsible for the gizmos dragging interactions
  45063. */
  45064. dragBehavior: PointerDragBehavior;
  45065. private _pointerObserver;
  45066. /**
  45067. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45068. */
  45069. snapDistance: number;
  45070. /**
  45071. * Event that fires each time the gizmo snaps to a new location.
  45072. * * snapDistance is the the change in distance
  45073. */
  45074. onSnapObservable: Observable<{
  45075. snapDistance: number;
  45076. }>;
  45077. /**
  45078. * If the scaling operation should be done on all axis (default: false)
  45079. */
  45080. uniformScaling: boolean;
  45081. private _isEnabled;
  45082. private _parent;
  45083. private _arrow;
  45084. private _coloredMaterial;
  45085. private _hoverMaterial;
  45086. /**
  45087. * Creates an AxisScaleGizmo
  45088. * @param gizmoLayer The utility layer the gizmo will be added to
  45089. * @param dragAxis The axis which the gizmo will be able to scale on
  45090. * @param color The color of the gizmo
  45091. */
  45092. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45093. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45094. /**
  45095. * If the gizmo is enabled
  45096. */
  45097. isEnabled: boolean;
  45098. /**
  45099. * Disposes of the gizmo
  45100. */
  45101. dispose(): void;
  45102. /**
  45103. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45104. * @param mesh The mesh to replace the default mesh of the gizmo
  45105. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45106. */
  45107. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45108. }
  45109. }
  45110. declare module BABYLON {
  45111. /**
  45112. * Bounding box gizmo
  45113. */
  45114. export class BoundingBoxGizmo extends Gizmo {
  45115. private _lineBoundingBox;
  45116. private _rotateSpheresParent;
  45117. private _scaleBoxesParent;
  45118. private _boundingDimensions;
  45119. private _renderObserver;
  45120. private _pointerObserver;
  45121. private _scaleDragSpeed;
  45122. private _tmpQuaternion;
  45123. private _tmpVector;
  45124. private _tmpRotationMatrix;
  45125. /**
  45126. * 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)
  45127. */
  45128. ignoreChildren: boolean;
  45129. /**
  45130. * 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)
  45131. */
  45132. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45133. /**
  45134. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45135. */
  45136. rotationSphereSize: number;
  45137. /**
  45138. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45139. */
  45140. scaleBoxSize: number;
  45141. /**
  45142. * 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)
  45143. */
  45144. fixedDragMeshScreenSize: boolean;
  45145. /**
  45146. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45147. */
  45148. fixedDragMeshScreenSizeDistanceFactor: number;
  45149. /**
  45150. * Fired when a rotation sphere or scale box is dragged
  45151. */
  45152. onDragStartObservable: Observable<{}>;
  45153. /**
  45154. * Fired when a scale box is dragged
  45155. */
  45156. onScaleBoxDragObservable: Observable<{}>;
  45157. /**
  45158. * Fired when a scale box drag is ended
  45159. */
  45160. onScaleBoxDragEndObservable: Observable<{}>;
  45161. /**
  45162. * Fired when a rotation sphere is dragged
  45163. */
  45164. onRotationSphereDragObservable: Observable<{}>;
  45165. /**
  45166. * Fired when a rotation sphere drag is ended
  45167. */
  45168. onRotationSphereDragEndObservable: Observable<{}>;
  45169. /**
  45170. * 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)
  45171. */
  45172. scalePivot: Nullable<Vector3>;
  45173. /**
  45174. * Mesh used as a pivot to rotate the attached mesh
  45175. */
  45176. private _anchorMesh;
  45177. private _existingMeshScale;
  45178. private _dragMesh;
  45179. private pointerDragBehavior;
  45180. private coloredMaterial;
  45181. private hoverColoredMaterial;
  45182. /**
  45183. * Sets the color of the bounding box gizmo
  45184. * @param color the color to set
  45185. */
  45186. setColor(color: Color3): void;
  45187. /**
  45188. * Creates an BoundingBoxGizmo
  45189. * @param gizmoLayer The utility layer the gizmo will be added to
  45190. * @param color The color of the gizmo
  45191. */
  45192. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45193. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45194. private _selectNode;
  45195. /**
  45196. * Updates the bounding box information for the Gizmo
  45197. */
  45198. updateBoundingBox(): void;
  45199. private _updateRotationSpheres;
  45200. private _updateScaleBoxes;
  45201. /**
  45202. * Enables rotation on the specified axis and disables rotation on the others
  45203. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45204. */
  45205. setEnabledRotationAxis(axis: string): void;
  45206. /**
  45207. * Enables/disables scaling
  45208. * @param enable if scaling should be enabled
  45209. */
  45210. setEnabledScaling(enable: boolean): void;
  45211. private _updateDummy;
  45212. /**
  45213. * Enables a pointer drag behavior on the bounding box of the gizmo
  45214. */
  45215. enableDragBehavior(): void;
  45216. /**
  45217. * Disposes of the gizmo
  45218. */
  45219. dispose(): void;
  45220. /**
  45221. * 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)
  45222. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45223. * @returns the bounding box mesh with the passed in mesh as a child
  45224. */
  45225. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45226. /**
  45227. * CustomMeshes are not supported by this gizmo
  45228. * @param mesh The mesh to replace the default mesh of the gizmo
  45229. */
  45230. setCustomMesh(mesh: Mesh): void;
  45231. }
  45232. }
  45233. declare module BABYLON {
  45234. /**
  45235. * Single plane rotation gizmo
  45236. */
  45237. export class PlaneRotationGizmo extends Gizmo {
  45238. /**
  45239. * Drag behavior responsible for the gizmos dragging interactions
  45240. */
  45241. dragBehavior: PointerDragBehavior;
  45242. private _pointerObserver;
  45243. /**
  45244. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45245. */
  45246. snapDistance: number;
  45247. /**
  45248. * Event that fires each time the gizmo snaps to a new location.
  45249. * * snapDistance is the the change in distance
  45250. */
  45251. onSnapObservable: Observable<{
  45252. snapDistance: number;
  45253. }>;
  45254. private _isEnabled;
  45255. private _parent;
  45256. /**
  45257. * Creates a PlaneRotationGizmo
  45258. * @param gizmoLayer The utility layer the gizmo will be added to
  45259. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45260. * @param color The color of the gizmo
  45261. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45262. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45263. */
  45264. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45265. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45266. /**
  45267. * If the gizmo is enabled
  45268. */
  45269. isEnabled: boolean;
  45270. /**
  45271. * Disposes of the gizmo
  45272. */
  45273. dispose(): void;
  45274. }
  45275. }
  45276. declare module BABYLON {
  45277. /**
  45278. * Gizmo that enables rotating a mesh along 3 axis
  45279. */
  45280. export class RotationGizmo extends Gizmo {
  45281. /**
  45282. * Internal gizmo used for interactions on the x axis
  45283. */
  45284. xGizmo: PlaneRotationGizmo;
  45285. /**
  45286. * Internal gizmo used for interactions on the y axis
  45287. */
  45288. yGizmo: PlaneRotationGizmo;
  45289. /**
  45290. * Internal gizmo used for interactions on the z axis
  45291. */
  45292. zGizmo: PlaneRotationGizmo;
  45293. /** Fires an event when any of it's sub gizmos are dragged */
  45294. onDragStartObservable: Observable<unknown>;
  45295. /** Fires an event when any of it's sub gizmos are released from dragging */
  45296. onDragEndObservable: Observable<unknown>;
  45297. private _meshAttached;
  45298. attachedMesh: Nullable<AbstractMesh>;
  45299. /**
  45300. * Creates a RotationGizmo
  45301. * @param gizmoLayer The utility layer the gizmo will be added to
  45302. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45303. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45304. */
  45305. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45306. updateGizmoRotationToMatchAttachedMesh: boolean;
  45307. /**
  45308. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45309. */
  45310. snapDistance: number;
  45311. /**
  45312. * Ratio for the scale of the gizmo (Default: 1)
  45313. */
  45314. scaleRatio: number;
  45315. /**
  45316. * Disposes of the gizmo
  45317. */
  45318. dispose(): void;
  45319. /**
  45320. * CustomMeshes are not supported by this gizmo
  45321. * @param mesh The mesh to replace the default mesh of the gizmo
  45322. */
  45323. setCustomMesh(mesh: Mesh): void;
  45324. }
  45325. }
  45326. declare module BABYLON {
  45327. /**
  45328. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45329. */
  45330. export class GizmoManager implements IDisposable {
  45331. private scene;
  45332. /**
  45333. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45334. */
  45335. gizmos: {
  45336. positionGizmo: Nullable<PositionGizmo>;
  45337. rotationGizmo: Nullable<RotationGizmo>;
  45338. scaleGizmo: Nullable<ScaleGizmo>;
  45339. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45340. };
  45341. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45342. clearGizmoOnEmptyPointerEvent: boolean;
  45343. /** Fires an event when the manager is attached to a mesh */
  45344. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45345. private _gizmosEnabled;
  45346. private _pointerObserver;
  45347. private _attachedMesh;
  45348. private _boundingBoxColor;
  45349. private _defaultUtilityLayer;
  45350. private _defaultKeepDepthUtilityLayer;
  45351. /**
  45352. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45353. */
  45354. boundingBoxDragBehavior: SixDofDragBehavior;
  45355. /**
  45356. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45357. */
  45358. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45359. /**
  45360. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45361. */
  45362. usePointerToAttachGizmos: boolean;
  45363. /**
  45364. * Utility layer that the bounding box gizmo belongs to
  45365. */
  45366. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45367. /**
  45368. * Utility layer that all gizmos besides bounding box belong to
  45369. */
  45370. readonly utilityLayer: UtilityLayerRenderer;
  45371. /**
  45372. * Instatiates a gizmo manager
  45373. * @param scene the scene to overlay the gizmos on top of
  45374. */
  45375. constructor(scene: Scene);
  45376. /**
  45377. * Attaches a set of gizmos to the specified mesh
  45378. * @param mesh The mesh the gizmo's should be attached to
  45379. */
  45380. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45381. /**
  45382. * If the position gizmo is enabled
  45383. */
  45384. positionGizmoEnabled: boolean;
  45385. /**
  45386. * If the rotation gizmo is enabled
  45387. */
  45388. rotationGizmoEnabled: boolean;
  45389. /**
  45390. * If the scale gizmo is enabled
  45391. */
  45392. scaleGizmoEnabled: boolean;
  45393. /**
  45394. * If the boundingBox gizmo is enabled
  45395. */
  45396. boundingBoxGizmoEnabled: boolean;
  45397. /**
  45398. * Disposes of the gizmo manager
  45399. */
  45400. dispose(): void;
  45401. }
  45402. }
  45403. declare module BABYLON {
  45404. /**
  45405. * A directional light is defined by a direction (what a surprise!).
  45406. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45407. * 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.
  45408. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45409. */
  45410. export class DirectionalLight extends ShadowLight {
  45411. private _shadowFrustumSize;
  45412. /**
  45413. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45414. */
  45415. /**
  45416. * Specifies a fix frustum size for the shadow generation.
  45417. */
  45418. shadowFrustumSize: number;
  45419. private _shadowOrthoScale;
  45420. /**
  45421. * Gets the shadow projection scale against the optimal computed one.
  45422. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45423. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45424. */
  45425. /**
  45426. * Sets the shadow projection scale against the optimal computed one.
  45427. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45428. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45429. */
  45430. shadowOrthoScale: number;
  45431. /**
  45432. * Automatically compute the projection matrix to best fit (including all the casters)
  45433. * on each frame.
  45434. */
  45435. autoUpdateExtends: boolean;
  45436. private _orthoLeft;
  45437. private _orthoRight;
  45438. private _orthoTop;
  45439. private _orthoBottom;
  45440. /**
  45441. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45442. * The directional light is emitted from everywhere in the given direction.
  45443. * It can cast shadows.
  45444. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45445. * @param name The friendly name of the light
  45446. * @param direction The direction of the light
  45447. * @param scene The scene the light belongs to
  45448. */
  45449. constructor(name: string, direction: Vector3, scene: Scene);
  45450. /**
  45451. * Returns the string "DirectionalLight".
  45452. * @return The class name
  45453. */
  45454. getClassName(): string;
  45455. /**
  45456. * Returns the integer 1.
  45457. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45458. */
  45459. getTypeID(): number;
  45460. /**
  45461. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45462. * Returns the DirectionalLight Shadow projection matrix.
  45463. */
  45464. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45465. /**
  45466. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45467. * Returns the DirectionalLight Shadow projection matrix.
  45468. */
  45469. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45470. /**
  45471. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45472. * Returns the DirectionalLight Shadow projection matrix.
  45473. */
  45474. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45475. protected _buildUniformLayout(): void;
  45476. /**
  45477. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45478. * @param effect The effect to update
  45479. * @param lightIndex The index of the light in the effect to update
  45480. * @returns The directional light
  45481. */
  45482. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45483. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45484. /**
  45485. * Gets the minZ used for shadow according to both the scene and the light.
  45486. *
  45487. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45488. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45489. * @param activeCamera The camera we are returning the min for
  45490. * @returns the depth min z
  45491. */
  45492. getDepthMinZ(activeCamera: Camera): number;
  45493. /**
  45494. * Gets the maxZ used for shadow according to both the scene and the light.
  45495. *
  45496. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45497. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45498. * @param activeCamera The camera we are returning the max for
  45499. * @returns the depth max z
  45500. */
  45501. getDepthMaxZ(activeCamera: Camera): number;
  45502. /**
  45503. * Prepares the list of defines specific to the light type.
  45504. * @param defines the list of defines
  45505. * @param lightIndex defines the index of the light for the effect
  45506. */
  45507. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45508. }
  45509. }
  45510. declare module BABYLON {
  45511. /**
  45512. * Class containing static functions to help procedurally build meshes
  45513. */
  45514. export class HemisphereBuilder {
  45515. /**
  45516. * Creates a hemisphere mesh
  45517. * @param name defines the name of the mesh
  45518. * @param options defines the options used to create the mesh
  45519. * @param scene defines the hosting scene
  45520. * @returns the hemisphere mesh
  45521. */
  45522. static CreateHemisphere(name: string, options: {
  45523. segments?: number;
  45524. diameter?: number;
  45525. sideOrientation?: number;
  45526. }, scene: any): Mesh;
  45527. }
  45528. }
  45529. declare module BABYLON {
  45530. /**
  45531. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45532. * These values define a cone of light starting from the position, emitting toward the direction.
  45533. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45534. * and the exponent defines the speed of the decay of the light with distance (reach).
  45535. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45536. */
  45537. export class SpotLight extends ShadowLight {
  45538. private _angle;
  45539. private _innerAngle;
  45540. private _cosHalfAngle;
  45541. private _lightAngleScale;
  45542. private _lightAngleOffset;
  45543. /**
  45544. * Gets the cone angle of the spot light in Radians.
  45545. */
  45546. /**
  45547. * Sets the cone angle of the spot light in Radians.
  45548. */
  45549. angle: number;
  45550. /**
  45551. * Only used in gltf falloff mode, this defines the angle where
  45552. * the directional falloff will start before cutting at angle which could be seen
  45553. * as outer angle.
  45554. */
  45555. /**
  45556. * Only used in gltf falloff mode, this defines the angle where
  45557. * the directional falloff will start before cutting at angle which could be seen
  45558. * as outer angle.
  45559. */
  45560. innerAngle: number;
  45561. private _shadowAngleScale;
  45562. /**
  45563. * Allows scaling the angle of the light for shadow generation only.
  45564. */
  45565. /**
  45566. * Allows scaling the angle of the light for shadow generation only.
  45567. */
  45568. shadowAngleScale: number;
  45569. /**
  45570. * The light decay speed with the distance from the emission spot.
  45571. */
  45572. exponent: number;
  45573. private _projectionTextureMatrix;
  45574. /**
  45575. * Allows reading the projecton texture
  45576. */
  45577. readonly projectionTextureMatrix: Matrix;
  45578. protected _projectionTextureLightNear: number;
  45579. /**
  45580. * Gets the near clip of the Spotlight for texture projection.
  45581. */
  45582. /**
  45583. * Sets the near clip of the Spotlight for texture projection.
  45584. */
  45585. projectionTextureLightNear: number;
  45586. protected _projectionTextureLightFar: number;
  45587. /**
  45588. * Gets the far clip of the Spotlight for texture projection.
  45589. */
  45590. /**
  45591. * Sets the far clip of the Spotlight for texture projection.
  45592. */
  45593. projectionTextureLightFar: number;
  45594. protected _projectionTextureUpDirection: Vector3;
  45595. /**
  45596. * Gets the Up vector of the Spotlight for texture projection.
  45597. */
  45598. /**
  45599. * Sets the Up vector of the Spotlight for texture projection.
  45600. */
  45601. projectionTextureUpDirection: Vector3;
  45602. private _projectionTexture;
  45603. /**
  45604. * Gets the projection texture of the light.
  45605. */
  45606. /**
  45607. * Sets the projection texture of the light.
  45608. */
  45609. projectionTexture: Nullable<BaseTexture>;
  45610. private _projectionTextureViewLightDirty;
  45611. private _projectionTextureProjectionLightDirty;
  45612. private _projectionTextureDirty;
  45613. private _projectionTextureViewTargetVector;
  45614. private _projectionTextureViewLightMatrix;
  45615. private _projectionTextureProjectionLightMatrix;
  45616. private _projectionTextureScalingMatrix;
  45617. /**
  45618. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45619. * It can cast shadows.
  45620. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45621. * @param name The light friendly name
  45622. * @param position The position of the spot light in the scene
  45623. * @param direction The direction of the light in the scene
  45624. * @param angle The cone angle of the light in Radians
  45625. * @param exponent The light decay speed with the distance from the emission spot
  45626. * @param scene The scene the lights belongs to
  45627. */
  45628. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45629. /**
  45630. * Returns the string "SpotLight".
  45631. * @returns the class name
  45632. */
  45633. getClassName(): string;
  45634. /**
  45635. * Returns the integer 2.
  45636. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45637. */
  45638. getTypeID(): number;
  45639. /**
  45640. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45641. */
  45642. protected _setDirection(value: Vector3): void;
  45643. /**
  45644. * Overrides the position setter to recompute the projection texture view light Matrix.
  45645. */
  45646. protected _setPosition(value: Vector3): void;
  45647. /**
  45648. * 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.
  45649. * Returns the SpotLight.
  45650. */
  45651. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45652. protected _computeProjectionTextureViewLightMatrix(): void;
  45653. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45654. /**
  45655. * Main function for light texture projection matrix computing.
  45656. */
  45657. protected _computeProjectionTextureMatrix(): void;
  45658. protected _buildUniformLayout(): void;
  45659. private _computeAngleValues;
  45660. /**
  45661. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45662. * @param effect The effect to update
  45663. * @param lightIndex The index of the light in the effect to update
  45664. * @returns The spot light
  45665. */
  45666. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45667. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45668. /**
  45669. * Disposes the light and the associated resources.
  45670. */
  45671. dispose(): void;
  45672. /**
  45673. * Prepares the list of defines specific to the light type.
  45674. * @param defines the list of defines
  45675. * @param lightIndex defines the index of the light for the effect
  45676. */
  45677. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45678. }
  45679. }
  45680. declare module BABYLON {
  45681. /**
  45682. * Gizmo that enables viewing a light
  45683. */
  45684. export class LightGizmo extends Gizmo {
  45685. private _lightMesh;
  45686. private _material;
  45687. private cachedPosition;
  45688. private cachedForward;
  45689. /**
  45690. * Creates a LightGizmo
  45691. * @param gizmoLayer The utility layer the gizmo will be added to
  45692. */
  45693. constructor(gizmoLayer?: UtilityLayerRenderer);
  45694. private _light;
  45695. /**
  45696. * The light that the gizmo is attached to
  45697. */
  45698. light: Nullable<Light>;
  45699. /**
  45700. * Gets the material used to render the light gizmo
  45701. */
  45702. readonly material: StandardMaterial;
  45703. /**
  45704. * @hidden
  45705. * Updates the gizmo to match the attached mesh's position/rotation
  45706. */
  45707. protected _update(): void;
  45708. private static _Scale;
  45709. /**
  45710. * Creates the lines for a light mesh
  45711. */
  45712. private static _createLightLines;
  45713. /**
  45714. * Disposes of the light gizmo
  45715. */
  45716. dispose(): void;
  45717. private static _CreateHemisphericLightMesh;
  45718. private static _CreatePointLightMesh;
  45719. private static _CreateSpotLightMesh;
  45720. private static _CreateDirectionalLightMesh;
  45721. }
  45722. }
  45723. declare module BABYLON {
  45724. /** @hidden */
  45725. export var backgroundFragmentDeclaration: {
  45726. name: string;
  45727. shader: string;
  45728. };
  45729. }
  45730. declare module BABYLON {
  45731. /** @hidden */
  45732. export var backgroundUboDeclaration: {
  45733. name: string;
  45734. shader: string;
  45735. };
  45736. }
  45737. declare module BABYLON {
  45738. /** @hidden */
  45739. export var backgroundPixelShader: {
  45740. name: string;
  45741. shader: string;
  45742. };
  45743. }
  45744. declare module BABYLON {
  45745. /** @hidden */
  45746. export var backgroundVertexDeclaration: {
  45747. name: string;
  45748. shader: string;
  45749. };
  45750. }
  45751. declare module BABYLON {
  45752. /** @hidden */
  45753. export var backgroundVertexShader: {
  45754. name: string;
  45755. shader: string;
  45756. };
  45757. }
  45758. declare module BABYLON {
  45759. /**
  45760. * Background material used to create an efficient environement around your scene.
  45761. */
  45762. export class BackgroundMaterial extends PushMaterial {
  45763. /**
  45764. * Standard reflectance value at parallel view angle.
  45765. */
  45766. static StandardReflectance0: number;
  45767. /**
  45768. * Standard reflectance value at grazing angle.
  45769. */
  45770. static StandardReflectance90: number;
  45771. protected _primaryColor: Color3;
  45772. /**
  45773. * Key light Color (multiply against the environement texture)
  45774. */
  45775. primaryColor: Color3;
  45776. protected __perceptualColor: Nullable<Color3>;
  45777. /**
  45778. * Experimental Internal Use Only.
  45779. *
  45780. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45781. * This acts as a helper to set the primary color to a more "human friendly" value.
  45782. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45783. * output color as close as possible from the chosen value.
  45784. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45785. * part of lighting setup.)
  45786. */
  45787. _perceptualColor: Nullable<Color3>;
  45788. protected _primaryColorShadowLevel: float;
  45789. /**
  45790. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45791. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45792. */
  45793. primaryColorShadowLevel: float;
  45794. protected _primaryColorHighlightLevel: float;
  45795. /**
  45796. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45797. * The primary color is used at the level chosen to define what the white area would look.
  45798. */
  45799. primaryColorHighlightLevel: float;
  45800. protected _reflectionTexture: Nullable<BaseTexture>;
  45801. /**
  45802. * Reflection Texture used in the material.
  45803. * Should be author in a specific way for the best result (refer to the documentation).
  45804. */
  45805. reflectionTexture: Nullable<BaseTexture>;
  45806. protected _reflectionBlur: float;
  45807. /**
  45808. * Reflection Texture level of blur.
  45809. *
  45810. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45811. * texture twice.
  45812. */
  45813. reflectionBlur: float;
  45814. protected _diffuseTexture: Nullable<BaseTexture>;
  45815. /**
  45816. * Diffuse Texture used in the material.
  45817. * Should be author in a specific way for the best result (refer to the documentation).
  45818. */
  45819. diffuseTexture: Nullable<BaseTexture>;
  45820. protected _shadowLights: Nullable<IShadowLight[]>;
  45821. /**
  45822. * Specify the list of lights casting shadow on the material.
  45823. * All scene shadow lights will be included if null.
  45824. */
  45825. shadowLights: Nullable<IShadowLight[]>;
  45826. protected _shadowLevel: float;
  45827. /**
  45828. * Helps adjusting the shadow to a softer level if required.
  45829. * 0 means black shadows and 1 means no shadows.
  45830. */
  45831. shadowLevel: float;
  45832. protected _sceneCenter: Vector3;
  45833. /**
  45834. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45835. * It is usually zero but might be interesting to modify according to your setup.
  45836. */
  45837. sceneCenter: Vector3;
  45838. protected _opacityFresnel: boolean;
  45839. /**
  45840. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45841. * This helps ensuring a nice transition when the camera goes under the ground.
  45842. */
  45843. opacityFresnel: boolean;
  45844. protected _reflectionFresnel: boolean;
  45845. /**
  45846. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45847. * This helps adding a mirror texture on the ground.
  45848. */
  45849. reflectionFresnel: boolean;
  45850. protected _reflectionFalloffDistance: number;
  45851. /**
  45852. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45853. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45854. */
  45855. reflectionFalloffDistance: number;
  45856. protected _reflectionAmount: number;
  45857. /**
  45858. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45859. */
  45860. reflectionAmount: number;
  45861. protected _reflectionReflectance0: number;
  45862. /**
  45863. * This specifies the weight of the reflection at grazing angle.
  45864. */
  45865. reflectionReflectance0: number;
  45866. protected _reflectionReflectance90: number;
  45867. /**
  45868. * This specifies the weight of the reflection at a perpendicular point of view.
  45869. */
  45870. reflectionReflectance90: number;
  45871. /**
  45872. * Sets the reflection reflectance fresnel values according to the default standard
  45873. * empirically know to work well :-)
  45874. */
  45875. reflectionStandardFresnelWeight: number;
  45876. protected _useRGBColor: boolean;
  45877. /**
  45878. * Helps to directly use the maps channels instead of their level.
  45879. */
  45880. useRGBColor: boolean;
  45881. protected _enableNoise: boolean;
  45882. /**
  45883. * This helps reducing the banding effect that could occur on the background.
  45884. */
  45885. enableNoise: boolean;
  45886. /**
  45887. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45888. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45889. * Recommended to be keep at 1.0 except for special cases.
  45890. */
  45891. fovMultiplier: number;
  45892. private _fovMultiplier;
  45893. /**
  45894. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45895. */
  45896. useEquirectangularFOV: boolean;
  45897. private _maxSimultaneousLights;
  45898. /**
  45899. * Number of Simultaneous lights allowed on the material.
  45900. */
  45901. maxSimultaneousLights: int;
  45902. /**
  45903. * Default configuration related to image processing available in the Background Material.
  45904. */
  45905. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45906. /**
  45907. * Keep track of the image processing observer to allow dispose and replace.
  45908. */
  45909. private _imageProcessingObserver;
  45910. /**
  45911. * Attaches a new image processing configuration to the PBR Material.
  45912. * @param configuration (if null the scene configuration will be use)
  45913. */
  45914. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45915. /**
  45916. * Gets the image processing configuration used either in this material.
  45917. */
  45918. /**
  45919. * Sets the Default image processing configuration used either in the this material.
  45920. *
  45921. * If sets to null, the scene one is in use.
  45922. */
  45923. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45924. /**
  45925. * Gets wether the color curves effect is enabled.
  45926. */
  45927. /**
  45928. * Sets wether the color curves effect is enabled.
  45929. */
  45930. cameraColorCurvesEnabled: boolean;
  45931. /**
  45932. * Gets wether the color grading effect is enabled.
  45933. */
  45934. /**
  45935. * Gets wether the color grading effect is enabled.
  45936. */
  45937. cameraColorGradingEnabled: boolean;
  45938. /**
  45939. * Gets wether tonemapping is enabled or not.
  45940. */
  45941. /**
  45942. * Sets wether tonemapping is enabled or not
  45943. */
  45944. cameraToneMappingEnabled: boolean;
  45945. /**
  45946. * The camera exposure used on this material.
  45947. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45948. * This corresponds to a photographic exposure.
  45949. */
  45950. /**
  45951. * The camera exposure used on this material.
  45952. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45953. * This corresponds to a photographic exposure.
  45954. */
  45955. cameraExposure: float;
  45956. /**
  45957. * Gets The camera contrast used on this material.
  45958. */
  45959. /**
  45960. * Sets The camera contrast used on this material.
  45961. */
  45962. cameraContrast: float;
  45963. /**
  45964. * Gets the Color Grading 2D Lookup Texture.
  45965. */
  45966. /**
  45967. * Sets the Color Grading 2D Lookup Texture.
  45968. */
  45969. cameraColorGradingTexture: Nullable<BaseTexture>;
  45970. /**
  45971. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45972. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45973. * 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;
  45974. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45975. */
  45976. /**
  45977. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45978. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45979. * 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;
  45980. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45981. */
  45982. cameraColorCurves: Nullable<ColorCurves>;
  45983. /**
  45984. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45985. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45986. */
  45987. switchToBGR: boolean;
  45988. private _renderTargets;
  45989. private _reflectionControls;
  45990. private _white;
  45991. private _primaryShadowColor;
  45992. private _primaryHighlightColor;
  45993. /**
  45994. * Instantiates a Background Material in the given scene
  45995. * @param name The friendly name of the material
  45996. * @param scene The scene to add the material to
  45997. */
  45998. constructor(name: string, scene: Scene);
  45999. /**
  46000. * Gets a boolean indicating that current material needs to register RTT
  46001. */
  46002. readonly hasRenderTargetTextures: boolean;
  46003. /**
  46004. * The entire material has been created in order to prevent overdraw.
  46005. * @returns false
  46006. */
  46007. needAlphaTesting(): boolean;
  46008. /**
  46009. * The entire material has been created in order to prevent overdraw.
  46010. * @returns true if blending is enable
  46011. */
  46012. needAlphaBlending(): boolean;
  46013. /**
  46014. * Checks wether the material is ready to be rendered for a given mesh.
  46015. * @param mesh The mesh to render
  46016. * @param subMesh The submesh to check against
  46017. * @param useInstances Specify wether or not the material is used with instances
  46018. * @returns true if all the dependencies are ready (Textures, Effects...)
  46019. */
  46020. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46021. /**
  46022. * Compute the primary color according to the chosen perceptual color.
  46023. */
  46024. private _computePrimaryColorFromPerceptualColor;
  46025. /**
  46026. * Compute the highlights and shadow colors according to their chosen levels.
  46027. */
  46028. private _computePrimaryColors;
  46029. /**
  46030. * Build the uniform buffer used in the material.
  46031. */
  46032. buildUniformLayout(): void;
  46033. /**
  46034. * Unbind the material.
  46035. */
  46036. unbind(): void;
  46037. /**
  46038. * Bind only the world matrix to the material.
  46039. * @param world The world matrix to bind.
  46040. */
  46041. bindOnlyWorldMatrix(world: Matrix): void;
  46042. /**
  46043. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46044. * @param world The world matrix to bind.
  46045. * @param subMesh The submesh to bind for.
  46046. */
  46047. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46048. /**
  46049. * Checks to see if a texture is used in the material.
  46050. * @param texture - Base texture to use.
  46051. * @returns - Boolean specifying if a texture is used in the material.
  46052. */
  46053. hasTexture(texture: BaseTexture): boolean;
  46054. /**
  46055. * Dispose the material.
  46056. * @param forceDisposeEffect Force disposal of the associated effect.
  46057. * @param forceDisposeTextures Force disposal of the associated textures.
  46058. */
  46059. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46060. /**
  46061. * Clones the material.
  46062. * @param name The cloned name.
  46063. * @returns The cloned material.
  46064. */
  46065. clone(name: string): BackgroundMaterial;
  46066. /**
  46067. * Serializes the current material to its JSON representation.
  46068. * @returns The JSON representation.
  46069. */
  46070. serialize(): any;
  46071. /**
  46072. * Gets the class name of the material
  46073. * @returns "BackgroundMaterial"
  46074. */
  46075. getClassName(): string;
  46076. /**
  46077. * Parse a JSON input to create back a background material.
  46078. * @param source The JSON data to parse
  46079. * @param scene The scene to create the parsed material in
  46080. * @param rootUrl The root url of the assets the material depends upon
  46081. * @returns the instantiated BackgroundMaterial.
  46082. */
  46083. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46084. }
  46085. }
  46086. declare module BABYLON {
  46087. /**
  46088. * Represents the different options available during the creation of
  46089. * a Environment helper.
  46090. *
  46091. * This can control the default ground, skybox and image processing setup of your scene.
  46092. */
  46093. export interface IEnvironmentHelperOptions {
  46094. /**
  46095. * Specifies wether or not to create a ground.
  46096. * True by default.
  46097. */
  46098. createGround: boolean;
  46099. /**
  46100. * Specifies the ground size.
  46101. * 15 by default.
  46102. */
  46103. groundSize: number;
  46104. /**
  46105. * The texture used on the ground for the main color.
  46106. * Comes from the BabylonJS CDN by default.
  46107. *
  46108. * Remarks: Can be either a texture or a url.
  46109. */
  46110. groundTexture: string | BaseTexture;
  46111. /**
  46112. * The color mixed in the ground texture by default.
  46113. * BabylonJS clearColor by default.
  46114. */
  46115. groundColor: Color3;
  46116. /**
  46117. * Specifies the ground opacity.
  46118. * 1 by default.
  46119. */
  46120. groundOpacity: number;
  46121. /**
  46122. * Enables the ground to receive shadows.
  46123. * True by default.
  46124. */
  46125. enableGroundShadow: boolean;
  46126. /**
  46127. * Helps preventing the shadow to be fully black on the ground.
  46128. * 0.5 by default.
  46129. */
  46130. groundShadowLevel: number;
  46131. /**
  46132. * Creates a mirror texture attach to the ground.
  46133. * false by default.
  46134. */
  46135. enableGroundMirror: boolean;
  46136. /**
  46137. * Specifies the ground mirror size ratio.
  46138. * 0.3 by default as the default kernel is 64.
  46139. */
  46140. groundMirrorSizeRatio: number;
  46141. /**
  46142. * Specifies the ground mirror blur kernel size.
  46143. * 64 by default.
  46144. */
  46145. groundMirrorBlurKernel: number;
  46146. /**
  46147. * Specifies the ground mirror visibility amount.
  46148. * 1 by default
  46149. */
  46150. groundMirrorAmount: number;
  46151. /**
  46152. * Specifies the ground mirror reflectance weight.
  46153. * This uses the standard weight of the background material to setup the fresnel effect
  46154. * of the mirror.
  46155. * 1 by default.
  46156. */
  46157. groundMirrorFresnelWeight: number;
  46158. /**
  46159. * Specifies the ground mirror Falloff distance.
  46160. * This can helps reducing the size of the reflection.
  46161. * 0 by Default.
  46162. */
  46163. groundMirrorFallOffDistance: number;
  46164. /**
  46165. * Specifies the ground mirror texture type.
  46166. * Unsigned Int by Default.
  46167. */
  46168. groundMirrorTextureType: number;
  46169. /**
  46170. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46171. * the shown objects.
  46172. */
  46173. groundYBias: number;
  46174. /**
  46175. * Specifies wether or not to create a skybox.
  46176. * True by default.
  46177. */
  46178. createSkybox: boolean;
  46179. /**
  46180. * Specifies the skybox size.
  46181. * 20 by default.
  46182. */
  46183. skyboxSize: number;
  46184. /**
  46185. * The texture used on the skybox for the main color.
  46186. * Comes from the BabylonJS CDN by default.
  46187. *
  46188. * Remarks: Can be either a texture or a url.
  46189. */
  46190. skyboxTexture: string | BaseTexture;
  46191. /**
  46192. * The color mixed in the skybox texture by default.
  46193. * BabylonJS clearColor by default.
  46194. */
  46195. skyboxColor: Color3;
  46196. /**
  46197. * The background rotation around the Y axis of the scene.
  46198. * This helps aligning the key lights of your scene with the background.
  46199. * 0 by default.
  46200. */
  46201. backgroundYRotation: number;
  46202. /**
  46203. * Compute automatically the size of the elements to best fit with the scene.
  46204. */
  46205. sizeAuto: boolean;
  46206. /**
  46207. * Default position of the rootMesh if autoSize is not true.
  46208. */
  46209. rootPosition: Vector3;
  46210. /**
  46211. * Sets up the image processing in the scene.
  46212. * true by default.
  46213. */
  46214. setupImageProcessing: boolean;
  46215. /**
  46216. * The texture used as your environment texture in the scene.
  46217. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46218. *
  46219. * Remarks: Can be either a texture or a url.
  46220. */
  46221. environmentTexture: string | BaseTexture;
  46222. /**
  46223. * The value of the exposure to apply to the scene.
  46224. * 0.6 by default if setupImageProcessing is true.
  46225. */
  46226. cameraExposure: number;
  46227. /**
  46228. * The value of the contrast to apply to the scene.
  46229. * 1.6 by default if setupImageProcessing is true.
  46230. */
  46231. cameraContrast: number;
  46232. /**
  46233. * Specifies wether or not tonemapping should be enabled in the scene.
  46234. * true by default if setupImageProcessing is true.
  46235. */
  46236. toneMappingEnabled: boolean;
  46237. }
  46238. /**
  46239. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46240. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46241. * It also helps with the default setup of your imageProcessing configuration.
  46242. */
  46243. export class EnvironmentHelper {
  46244. /**
  46245. * Default ground texture URL.
  46246. */
  46247. private static _groundTextureCDNUrl;
  46248. /**
  46249. * Default skybox texture URL.
  46250. */
  46251. private static _skyboxTextureCDNUrl;
  46252. /**
  46253. * Default environment texture URL.
  46254. */
  46255. private static _environmentTextureCDNUrl;
  46256. /**
  46257. * Creates the default options for the helper.
  46258. */
  46259. private static _getDefaultOptions;
  46260. private _rootMesh;
  46261. /**
  46262. * Gets the root mesh created by the helper.
  46263. */
  46264. readonly rootMesh: Mesh;
  46265. private _skybox;
  46266. /**
  46267. * Gets the skybox created by the helper.
  46268. */
  46269. readonly skybox: Nullable<Mesh>;
  46270. private _skyboxTexture;
  46271. /**
  46272. * Gets the skybox texture created by the helper.
  46273. */
  46274. readonly skyboxTexture: Nullable<BaseTexture>;
  46275. private _skyboxMaterial;
  46276. /**
  46277. * Gets the skybox material created by the helper.
  46278. */
  46279. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46280. private _ground;
  46281. /**
  46282. * Gets the ground mesh created by the helper.
  46283. */
  46284. readonly ground: Nullable<Mesh>;
  46285. private _groundTexture;
  46286. /**
  46287. * Gets the ground texture created by the helper.
  46288. */
  46289. readonly groundTexture: Nullable<BaseTexture>;
  46290. private _groundMirror;
  46291. /**
  46292. * Gets the ground mirror created by the helper.
  46293. */
  46294. readonly groundMirror: Nullable<MirrorTexture>;
  46295. /**
  46296. * Gets the ground mirror render list to helps pushing the meshes
  46297. * you wish in the ground reflection.
  46298. */
  46299. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46300. private _groundMaterial;
  46301. /**
  46302. * Gets the ground material created by the helper.
  46303. */
  46304. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46305. /**
  46306. * Stores the creation options.
  46307. */
  46308. private readonly _scene;
  46309. private _options;
  46310. /**
  46311. * This observable will be notified with any error during the creation of the environment,
  46312. * mainly texture creation errors.
  46313. */
  46314. onErrorObservable: Observable<{
  46315. message?: string;
  46316. exception?: any;
  46317. }>;
  46318. /**
  46319. * constructor
  46320. * @param options Defines the options we want to customize the helper
  46321. * @param scene The scene to add the material to
  46322. */
  46323. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46324. /**
  46325. * Updates the background according to the new options
  46326. * @param options
  46327. */
  46328. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46329. /**
  46330. * Sets the primary color of all the available elements.
  46331. * @param color the main color to affect to the ground and the background
  46332. */
  46333. setMainColor(color: Color3): void;
  46334. /**
  46335. * Setup the image processing according to the specified options.
  46336. */
  46337. private _setupImageProcessing;
  46338. /**
  46339. * Setup the environment texture according to the specified options.
  46340. */
  46341. private _setupEnvironmentTexture;
  46342. /**
  46343. * Setup the background according to the specified options.
  46344. */
  46345. private _setupBackground;
  46346. /**
  46347. * Get the scene sizes according to the setup.
  46348. */
  46349. private _getSceneSize;
  46350. /**
  46351. * Setup the ground according to the specified options.
  46352. */
  46353. private _setupGround;
  46354. /**
  46355. * Setup the ground material according to the specified options.
  46356. */
  46357. private _setupGroundMaterial;
  46358. /**
  46359. * Setup the ground diffuse texture according to the specified options.
  46360. */
  46361. private _setupGroundDiffuseTexture;
  46362. /**
  46363. * Setup the ground mirror texture according to the specified options.
  46364. */
  46365. private _setupGroundMirrorTexture;
  46366. /**
  46367. * Setup the ground to receive the mirror texture.
  46368. */
  46369. private _setupMirrorInGroundMaterial;
  46370. /**
  46371. * Setup the skybox according to the specified options.
  46372. */
  46373. private _setupSkybox;
  46374. /**
  46375. * Setup the skybox material according to the specified options.
  46376. */
  46377. private _setupSkyboxMaterial;
  46378. /**
  46379. * Setup the skybox reflection texture according to the specified options.
  46380. */
  46381. private _setupSkyboxReflectionTexture;
  46382. private _errorHandler;
  46383. /**
  46384. * Dispose all the elements created by the Helper.
  46385. */
  46386. dispose(): void;
  46387. }
  46388. }
  46389. declare module BABYLON {
  46390. /**
  46391. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46392. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46393. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46394. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46395. */
  46396. export class PhotoDome extends TransformNode {
  46397. /**
  46398. * Define the image as a Monoscopic panoramic 360 image.
  46399. */
  46400. static readonly MODE_MONOSCOPIC: number;
  46401. /**
  46402. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46403. */
  46404. static readonly MODE_TOPBOTTOM: number;
  46405. /**
  46406. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46407. */
  46408. static readonly MODE_SIDEBYSIDE: number;
  46409. private _useDirectMapping;
  46410. /**
  46411. * The texture being displayed on the sphere
  46412. */
  46413. protected _photoTexture: Texture;
  46414. /**
  46415. * Gets or sets the texture being displayed on the sphere
  46416. */
  46417. photoTexture: Texture;
  46418. /**
  46419. * Observable raised when an error occured while loading the 360 image
  46420. */
  46421. onLoadErrorObservable: Observable<string>;
  46422. /**
  46423. * The skybox material
  46424. */
  46425. protected _material: BackgroundMaterial;
  46426. /**
  46427. * The surface used for the skybox
  46428. */
  46429. protected _mesh: Mesh;
  46430. /**
  46431. * Gets the mesh used for the skybox.
  46432. */
  46433. readonly mesh: Mesh;
  46434. /**
  46435. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46436. * Also see the options.resolution property.
  46437. */
  46438. fovMultiplier: number;
  46439. private _imageMode;
  46440. /**
  46441. * Gets or set the current video mode for the video. It can be:
  46442. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46443. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46444. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46445. */
  46446. imageMode: number;
  46447. /**
  46448. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46449. * @param name Element's name, child elements will append suffixes for their own names.
  46450. * @param urlsOfPhoto defines the url of the photo to display
  46451. * @param options defines an object containing optional or exposed sub element properties
  46452. * @param onError defines a callback called when an error occured while loading the texture
  46453. */
  46454. constructor(name: string, urlOfPhoto: string, options: {
  46455. resolution?: number;
  46456. size?: number;
  46457. useDirectMapping?: boolean;
  46458. faceForward?: boolean;
  46459. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46460. private _onBeforeCameraRenderObserver;
  46461. private _changeImageMode;
  46462. /**
  46463. * Releases resources associated with this node.
  46464. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46465. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46466. */
  46467. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46468. }
  46469. }
  46470. declare module BABYLON {
  46471. /**
  46472. * Class used to host RGBD texture specific utilities
  46473. */
  46474. export class RGBDTextureTools {
  46475. /**
  46476. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46477. * @param texture the texture to expand.
  46478. */
  46479. static ExpandRGBDTexture(texture: Texture): void;
  46480. }
  46481. }
  46482. declare module BABYLON {
  46483. /**
  46484. * Class used to host texture specific utilities
  46485. */
  46486. export class BRDFTextureTools {
  46487. /**
  46488. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46489. * @param scene defines the hosting scene
  46490. * @returns the environment BRDF texture
  46491. */
  46492. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46493. private static _environmentBRDFBase64Texture;
  46494. }
  46495. }
  46496. declare module BABYLON {
  46497. /**
  46498. * @hidden
  46499. */
  46500. export interface IMaterialClearCoatDefines {
  46501. CLEARCOAT: boolean;
  46502. CLEARCOAT_DEFAULTIOR: boolean;
  46503. CLEARCOAT_TEXTURE: boolean;
  46504. CLEARCOAT_TEXTUREDIRECTUV: number;
  46505. CLEARCOAT_BUMP: boolean;
  46506. CLEARCOAT_BUMPDIRECTUV: number;
  46507. CLEARCOAT_TINT: boolean;
  46508. CLEARCOAT_TINT_TEXTURE: boolean;
  46509. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46510. /** @hidden */
  46511. _areTexturesDirty: boolean;
  46512. }
  46513. /**
  46514. * Define the code related to the clear coat parameters of the pbr material.
  46515. */
  46516. export class PBRClearCoatConfiguration {
  46517. /**
  46518. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46519. * The default fits with a polyurethane material.
  46520. */
  46521. private static readonly _DefaultIndexOfRefraction;
  46522. private _isEnabled;
  46523. /**
  46524. * Defines if the clear coat is enabled in the material.
  46525. */
  46526. isEnabled: boolean;
  46527. /**
  46528. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46529. */
  46530. intensity: number;
  46531. /**
  46532. * Defines the clear coat layer roughness.
  46533. */
  46534. roughness: number;
  46535. private _indexOfRefraction;
  46536. /**
  46537. * Defines the index of refraction of the clear coat.
  46538. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46539. * The default fits with a polyurethane material.
  46540. * Changing the default value is more performance intensive.
  46541. */
  46542. indexOfRefraction: number;
  46543. private _texture;
  46544. /**
  46545. * Stores the clear coat values in a texture.
  46546. */
  46547. texture: Nullable<BaseTexture>;
  46548. private _bumpTexture;
  46549. /**
  46550. * Define the clear coat specific bump texture.
  46551. */
  46552. bumpTexture: Nullable<BaseTexture>;
  46553. private _isTintEnabled;
  46554. /**
  46555. * Defines if the clear coat tint is enabled in the material.
  46556. */
  46557. isTintEnabled: boolean;
  46558. /**
  46559. * Defines the clear coat tint of the material.
  46560. * This is only use if tint is enabled
  46561. */
  46562. tintColor: Color3;
  46563. /**
  46564. * Defines the distance at which the tint color should be found in the
  46565. * clear coat media.
  46566. * This is only use if tint is enabled
  46567. */
  46568. tintColorAtDistance: number;
  46569. /**
  46570. * Defines the clear coat layer thickness.
  46571. * This is only use if tint is enabled
  46572. */
  46573. tintThickness: number;
  46574. private _tintTexture;
  46575. /**
  46576. * Stores the clear tint values in a texture.
  46577. * rgb is tint
  46578. * a is a thickness factor
  46579. */
  46580. tintTexture: Nullable<BaseTexture>;
  46581. /** @hidden */
  46582. private _internalMarkAllSubMeshesAsTexturesDirty;
  46583. /** @hidden */
  46584. _markAllSubMeshesAsTexturesDirty(): void;
  46585. /**
  46586. * Instantiate a new istance of clear coat configuration.
  46587. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46588. */
  46589. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46590. /**
  46591. * Gets wehter the submesh is ready to be used or not.
  46592. * @param defines the list of "defines" to update.
  46593. * @param scene defines the scene the material belongs to.
  46594. * @param engine defines the engine the material belongs to.
  46595. * @param disableBumpMap defines wether the material disables bump or not.
  46596. * @returns - boolean indicating that the submesh is ready or not.
  46597. */
  46598. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46599. /**
  46600. * Checks to see if a texture is used in the material.
  46601. * @param defines the list of "defines" to update.
  46602. * @param scene defines the scene to the material belongs to.
  46603. */
  46604. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46605. /**
  46606. * Binds the material data.
  46607. * @param uniformBuffer defines the Uniform buffer to fill in.
  46608. * @param scene defines the scene the material belongs to.
  46609. * @param engine defines the engine the material belongs to.
  46610. * @param disableBumpMap defines wether the material disables bump or not.
  46611. * @param isFrozen defines wether the material is frozen or not.
  46612. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46613. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46614. */
  46615. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46616. /**
  46617. * Checks to see if a texture is used in the material.
  46618. * @param texture - Base texture to use.
  46619. * @returns - Boolean specifying if a texture is used in the material.
  46620. */
  46621. hasTexture(texture: BaseTexture): boolean;
  46622. /**
  46623. * Returns an array of the actively used textures.
  46624. * @param activeTextures Array of BaseTextures
  46625. */
  46626. getActiveTextures(activeTextures: BaseTexture[]): void;
  46627. /**
  46628. * Returns the animatable textures.
  46629. * @param animatables Array of animatable textures.
  46630. */
  46631. getAnimatables(animatables: IAnimatable[]): void;
  46632. /**
  46633. * Disposes the resources of the material.
  46634. * @param forceDisposeTextures - Forces the disposal of all textures.
  46635. */
  46636. dispose(forceDisposeTextures?: boolean): void;
  46637. /**
  46638. * Get the current class name of the texture useful for serialization or dynamic coding.
  46639. * @returns "PBRClearCoatConfiguration"
  46640. */
  46641. getClassName(): string;
  46642. /**
  46643. * Add fallbacks to the effect fallbacks list.
  46644. * @param defines defines the Base texture to use.
  46645. * @param fallbacks defines the current fallback list.
  46646. * @param currentRank defines the current fallback rank.
  46647. * @returns the new fallback rank.
  46648. */
  46649. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46650. /**
  46651. * Add the required uniforms to the current list.
  46652. * @param uniforms defines the current uniform list.
  46653. */
  46654. static AddUniforms(uniforms: string[]): void;
  46655. /**
  46656. * Add the required samplers to the current list.
  46657. * @param samplers defines the current sampler list.
  46658. */
  46659. static AddSamplers(samplers: string[]): void;
  46660. /**
  46661. * Add the required uniforms to the current buffer.
  46662. * @param uniformBuffer defines the current uniform buffer.
  46663. */
  46664. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46665. /**
  46666. * Makes a duplicate of the current configuration into another one.
  46667. * @param clearCoatConfiguration define the config where to copy the info
  46668. */
  46669. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46670. /**
  46671. * Serializes this clear coat configuration.
  46672. * @returns - An object with the serialized config.
  46673. */
  46674. serialize(): any;
  46675. /**
  46676. * Parses a anisotropy Configuration from a serialized object.
  46677. * @param source - Serialized object.
  46678. * @param scene Defines the scene we are parsing for
  46679. * @param rootUrl Defines the rootUrl to load from
  46680. */
  46681. parse(source: any, scene: Scene, rootUrl: string): void;
  46682. }
  46683. }
  46684. declare module BABYLON {
  46685. /**
  46686. * @hidden
  46687. */
  46688. export interface IMaterialAnisotropicDefines {
  46689. ANISOTROPIC: boolean;
  46690. ANISOTROPIC_TEXTURE: boolean;
  46691. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46692. MAINUV1: boolean;
  46693. _areTexturesDirty: boolean;
  46694. _needUVs: boolean;
  46695. }
  46696. /**
  46697. * Define the code related to the anisotropic parameters of the pbr material.
  46698. */
  46699. export class PBRAnisotropicConfiguration {
  46700. private _isEnabled;
  46701. /**
  46702. * Defines if the anisotropy is enabled in the material.
  46703. */
  46704. isEnabled: boolean;
  46705. /**
  46706. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46707. */
  46708. intensity: number;
  46709. /**
  46710. * Defines if the effect is along the tangents, bitangents or in between.
  46711. * By default, the effect is "strectching" the highlights along the tangents.
  46712. */
  46713. direction: Vector2;
  46714. private _texture;
  46715. /**
  46716. * Stores the anisotropy values in a texture.
  46717. * rg is direction (like normal from -1 to 1)
  46718. * b is a intensity
  46719. */
  46720. texture: Nullable<BaseTexture>;
  46721. /** @hidden */
  46722. private _internalMarkAllSubMeshesAsTexturesDirty;
  46723. /** @hidden */
  46724. _markAllSubMeshesAsTexturesDirty(): void;
  46725. /**
  46726. * Instantiate a new istance of anisotropy configuration.
  46727. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46728. */
  46729. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46730. /**
  46731. * Specifies that the submesh is ready to be used.
  46732. * @param defines the list of "defines" to update.
  46733. * @param scene defines the scene the material belongs to.
  46734. * @returns - boolean indicating that the submesh is ready or not.
  46735. */
  46736. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46737. /**
  46738. * Checks to see if a texture is used in the material.
  46739. * @param defines the list of "defines" to update.
  46740. * @param mesh the mesh we are preparing the defines for.
  46741. * @param scene defines the scene the material belongs to.
  46742. */
  46743. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46744. /**
  46745. * Binds the material data.
  46746. * @param uniformBuffer defines the Uniform buffer to fill in.
  46747. * @param scene defines the scene the material belongs to.
  46748. * @param isFrozen defines wether the material is frozen or not.
  46749. */
  46750. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46751. /**
  46752. * Checks to see if a texture is used in the material.
  46753. * @param texture - Base texture to use.
  46754. * @returns - Boolean specifying if a texture is used in the material.
  46755. */
  46756. hasTexture(texture: BaseTexture): boolean;
  46757. /**
  46758. * Returns an array of the actively used textures.
  46759. * @param activeTextures Array of BaseTextures
  46760. */
  46761. getActiveTextures(activeTextures: BaseTexture[]): void;
  46762. /**
  46763. * Returns the animatable textures.
  46764. * @param animatables Array of animatable textures.
  46765. */
  46766. getAnimatables(animatables: IAnimatable[]): void;
  46767. /**
  46768. * Disposes the resources of the material.
  46769. * @param forceDisposeTextures - Forces the disposal of all textures.
  46770. */
  46771. dispose(forceDisposeTextures?: boolean): void;
  46772. /**
  46773. * Get the current class name of the texture useful for serialization or dynamic coding.
  46774. * @returns "PBRAnisotropicConfiguration"
  46775. */
  46776. getClassName(): string;
  46777. /**
  46778. * Add fallbacks to the effect fallbacks list.
  46779. * @param defines defines the Base texture to use.
  46780. * @param fallbacks defines the current fallback list.
  46781. * @param currentRank defines the current fallback rank.
  46782. * @returns the new fallback rank.
  46783. */
  46784. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46785. /**
  46786. * Add the required uniforms to the current list.
  46787. * @param uniforms defines the current uniform list.
  46788. */
  46789. static AddUniforms(uniforms: string[]): void;
  46790. /**
  46791. * Add the required uniforms to the current buffer.
  46792. * @param uniformBuffer defines the current uniform buffer.
  46793. */
  46794. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46795. /**
  46796. * Add the required samplers to the current list.
  46797. * @param samplers defines the current sampler list.
  46798. */
  46799. static AddSamplers(samplers: string[]): void;
  46800. /**
  46801. * Makes a duplicate of the current configuration into another one.
  46802. * @param anisotropicConfiguration define the config where to copy the info
  46803. */
  46804. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46805. /**
  46806. * Serializes this anisotropy configuration.
  46807. * @returns - An object with the serialized config.
  46808. */
  46809. serialize(): any;
  46810. /**
  46811. * Parses a anisotropy Configuration from a serialized object.
  46812. * @param source - Serialized object.
  46813. * @param scene Defines the scene we are parsing for
  46814. * @param rootUrl Defines the rootUrl to load from
  46815. */
  46816. parse(source: any, scene: Scene, rootUrl: string): void;
  46817. }
  46818. }
  46819. declare module BABYLON {
  46820. /**
  46821. * @hidden
  46822. */
  46823. export interface IMaterialBRDFDefines {
  46824. BRDF_V_HEIGHT_CORRELATED: boolean;
  46825. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46826. SPHERICAL_HARMONICS: boolean;
  46827. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46828. /** @hidden */
  46829. _areMiscDirty: boolean;
  46830. }
  46831. /**
  46832. * Define the code related to the BRDF parameters of the pbr material.
  46833. */
  46834. export class PBRBRDFConfiguration {
  46835. /**
  46836. * Default value used for the energy conservation.
  46837. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46838. */
  46839. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46840. /**
  46841. * Default value used for the Smith Visibility Height Correlated mode.
  46842. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46843. */
  46844. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46845. /**
  46846. * Default value used for the IBL diffuse part.
  46847. * This can help switching back to the polynomials mode globally which is a tiny bit
  46848. * less GPU intensive at the drawback of a lower quality.
  46849. */
  46850. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46851. /**
  46852. * Default value used for activating energy conservation for the specular workflow.
  46853. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46854. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46855. */
  46856. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46857. private _useEnergyConservation;
  46858. /**
  46859. * Defines if the material uses energy conservation.
  46860. */
  46861. useEnergyConservation: boolean;
  46862. private _useSmithVisibilityHeightCorrelated;
  46863. /**
  46864. * LEGACY Mode set to false
  46865. * Defines if the material uses height smith correlated visibility term.
  46866. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46867. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46868. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46869. * Not relying on height correlated will also disable energy conservation.
  46870. */
  46871. useSmithVisibilityHeightCorrelated: boolean;
  46872. private _useSphericalHarmonics;
  46873. /**
  46874. * LEGACY Mode set to false
  46875. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46876. * diffuse part of the IBL.
  46877. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46878. * to the ground truth.
  46879. */
  46880. useSphericalHarmonics: boolean;
  46881. private _useSpecularGlossinessInputEnergyConservation;
  46882. /**
  46883. * Defines if the material uses energy conservation, when the specular workflow is active.
  46884. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46885. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46886. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46887. */
  46888. useSpecularGlossinessInputEnergyConservation: boolean;
  46889. /** @hidden */
  46890. private _internalMarkAllSubMeshesAsMiscDirty;
  46891. /** @hidden */
  46892. _markAllSubMeshesAsMiscDirty(): void;
  46893. /**
  46894. * Instantiate a new istance of clear coat configuration.
  46895. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46896. */
  46897. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46898. /**
  46899. * Checks to see if a texture is used in the material.
  46900. * @param defines the list of "defines" to update.
  46901. */
  46902. prepareDefines(defines: IMaterialBRDFDefines): void;
  46903. /**
  46904. * Get the current class name of the texture useful for serialization or dynamic coding.
  46905. * @returns "PBRClearCoatConfiguration"
  46906. */
  46907. getClassName(): string;
  46908. /**
  46909. * Makes a duplicate of the current configuration into another one.
  46910. * @param brdfConfiguration define the config where to copy the info
  46911. */
  46912. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46913. /**
  46914. * Serializes this BRDF configuration.
  46915. * @returns - An object with the serialized config.
  46916. */
  46917. serialize(): any;
  46918. /**
  46919. * Parses a anisotropy Configuration from a serialized object.
  46920. * @param source - Serialized object.
  46921. * @param scene Defines the scene we are parsing for
  46922. * @param rootUrl Defines the rootUrl to load from
  46923. */
  46924. parse(source: any, scene: Scene, rootUrl: string): void;
  46925. }
  46926. }
  46927. declare module BABYLON {
  46928. /**
  46929. * @hidden
  46930. */
  46931. export interface IMaterialSheenDefines {
  46932. SHEEN: boolean;
  46933. SHEEN_TEXTURE: boolean;
  46934. SHEEN_TEXTUREDIRECTUV: number;
  46935. SHEEN_LINKWITHALBEDO: boolean;
  46936. /** @hidden */
  46937. _areTexturesDirty: boolean;
  46938. }
  46939. /**
  46940. * Define the code related to the Sheen parameters of the pbr material.
  46941. */
  46942. export class PBRSheenConfiguration {
  46943. private _isEnabled;
  46944. /**
  46945. * Defines if the material uses sheen.
  46946. */
  46947. isEnabled: boolean;
  46948. private _linkSheenWithAlbedo;
  46949. /**
  46950. * Defines if the sheen is linked to the sheen color.
  46951. */
  46952. linkSheenWithAlbedo: boolean;
  46953. /**
  46954. * Defines the sheen intensity.
  46955. */
  46956. intensity: number;
  46957. /**
  46958. * Defines the sheen color.
  46959. */
  46960. color: Color3;
  46961. private _texture;
  46962. /**
  46963. * Stores the sheen tint values in a texture.
  46964. * rgb is tint
  46965. * a is a intensity
  46966. */
  46967. texture: Nullable<BaseTexture>;
  46968. /** @hidden */
  46969. private _internalMarkAllSubMeshesAsTexturesDirty;
  46970. /** @hidden */
  46971. _markAllSubMeshesAsTexturesDirty(): void;
  46972. /**
  46973. * Instantiate a new istance of clear coat configuration.
  46974. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46975. */
  46976. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46977. /**
  46978. * Specifies that the submesh is ready to be used.
  46979. * @param defines the list of "defines" to update.
  46980. * @param scene defines the scene the material belongs to.
  46981. * @returns - boolean indicating that the submesh is ready or not.
  46982. */
  46983. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46984. /**
  46985. * Checks to see if a texture is used in the material.
  46986. * @param defines the list of "defines" to update.
  46987. * @param scene defines the scene the material belongs to.
  46988. */
  46989. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46990. /**
  46991. * Binds the material data.
  46992. * @param uniformBuffer defines the Uniform buffer to fill in.
  46993. * @param scene defines the scene the material belongs to.
  46994. * @param isFrozen defines wether the material is frozen or not.
  46995. */
  46996. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46997. /**
  46998. * Checks to see if a texture is used in the material.
  46999. * @param texture - Base texture to use.
  47000. * @returns - Boolean specifying if a texture is used in the material.
  47001. */
  47002. hasTexture(texture: BaseTexture): boolean;
  47003. /**
  47004. * Returns an array of the actively used textures.
  47005. * @param activeTextures Array of BaseTextures
  47006. */
  47007. getActiveTextures(activeTextures: BaseTexture[]): void;
  47008. /**
  47009. * Returns the animatable textures.
  47010. * @param animatables Array of animatable textures.
  47011. */
  47012. getAnimatables(animatables: IAnimatable[]): void;
  47013. /**
  47014. * Disposes the resources of the material.
  47015. * @param forceDisposeTextures - Forces the disposal of all textures.
  47016. */
  47017. dispose(forceDisposeTextures?: boolean): void;
  47018. /**
  47019. * Get the current class name of the texture useful for serialization or dynamic coding.
  47020. * @returns "PBRSheenConfiguration"
  47021. */
  47022. getClassName(): string;
  47023. /**
  47024. * Add fallbacks to the effect fallbacks list.
  47025. * @param defines defines the Base texture to use.
  47026. * @param fallbacks defines the current fallback list.
  47027. * @param currentRank defines the current fallback rank.
  47028. * @returns the new fallback rank.
  47029. */
  47030. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47031. /**
  47032. * Add the required uniforms to the current list.
  47033. * @param uniforms defines the current uniform list.
  47034. */
  47035. static AddUniforms(uniforms: string[]): void;
  47036. /**
  47037. * Add the required uniforms to the current buffer.
  47038. * @param uniformBuffer defines the current uniform buffer.
  47039. */
  47040. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47041. /**
  47042. * Add the required samplers to the current list.
  47043. * @param samplers defines the current sampler list.
  47044. */
  47045. static AddSamplers(samplers: string[]): void;
  47046. /**
  47047. * Makes a duplicate of the current configuration into another one.
  47048. * @param sheenConfiguration define the config where to copy the info
  47049. */
  47050. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47051. /**
  47052. * Serializes this BRDF configuration.
  47053. * @returns - An object with the serialized config.
  47054. */
  47055. serialize(): any;
  47056. /**
  47057. * Parses a anisotropy Configuration from a serialized object.
  47058. * @param source - Serialized object.
  47059. * @param scene Defines the scene we are parsing for
  47060. * @param rootUrl Defines the rootUrl to load from
  47061. */
  47062. parse(source: any, scene: Scene, rootUrl: string): void;
  47063. }
  47064. }
  47065. declare module BABYLON {
  47066. /**
  47067. * @hidden
  47068. */
  47069. export interface IMaterialSubSurfaceDefines {
  47070. SUBSURFACE: boolean;
  47071. SS_REFRACTION: boolean;
  47072. SS_TRANSLUCENCY: boolean;
  47073. SS_SCATERRING: boolean;
  47074. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47075. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47076. SS_REFRACTIONMAP_3D: boolean;
  47077. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47078. SS_LODINREFRACTIONALPHA: boolean;
  47079. SS_GAMMAREFRACTION: boolean;
  47080. SS_RGBDREFRACTION: boolean;
  47081. SS_LINEARSPECULARREFRACTION: boolean;
  47082. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47083. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47084. /** @hidden */
  47085. _areTexturesDirty: boolean;
  47086. }
  47087. /**
  47088. * Define the code related to the sub surface parameters of the pbr material.
  47089. */
  47090. export class PBRSubSurfaceConfiguration {
  47091. private _isRefractionEnabled;
  47092. /**
  47093. * Defines if the refraction is enabled in the material.
  47094. */
  47095. isRefractionEnabled: boolean;
  47096. private _isTranslucencyEnabled;
  47097. /**
  47098. * Defines if the translucency is enabled in the material.
  47099. */
  47100. isTranslucencyEnabled: boolean;
  47101. private _isScatteringEnabled;
  47102. /**
  47103. * Defines the refraction intensity of the material.
  47104. * The refraction when enabled replaces the Diffuse part of the material.
  47105. * The intensity helps transitionning between diffuse and refraction.
  47106. */
  47107. refractionIntensity: number;
  47108. /**
  47109. * Defines the translucency intensity of the material.
  47110. * When translucency has been enabled, this defines how much of the "translucency"
  47111. * is addded to the diffuse part of the material.
  47112. */
  47113. translucencyIntensity: number;
  47114. /**
  47115. * Defines the scattering intensity of the material.
  47116. * When scattering has been enabled, this defines how much of the "scattered light"
  47117. * is addded to the diffuse part of the material.
  47118. */
  47119. scatteringIntensity: number;
  47120. private _thicknessTexture;
  47121. /**
  47122. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47123. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47124. * 0 would mean minimumThickness
  47125. * 1 would mean maximumThickness
  47126. * The other channels might be use as a mask to vary the different effects intensity.
  47127. */
  47128. thicknessTexture: Nullable<BaseTexture>;
  47129. private _refractionTexture;
  47130. /**
  47131. * Defines the texture to use for refraction.
  47132. */
  47133. refractionTexture: Nullable<BaseTexture>;
  47134. private _indexOfRefraction;
  47135. /**
  47136. * Defines the index of refraction used in the material.
  47137. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47138. */
  47139. indexOfRefraction: number;
  47140. private _invertRefractionY;
  47141. /**
  47142. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47143. */
  47144. invertRefractionY: boolean;
  47145. private _linkRefractionWithTransparency;
  47146. /**
  47147. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47148. * Materials half opaque for instance using refraction could benefit from this control.
  47149. */
  47150. linkRefractionWithTransparency: boolean;
  47151. /**
  47152. * Defines the minimum thickness stored in the thickness map.
  47153. * If no thickness map is defined, this value will be used to simulate thickness.
  47154. */
  47155. minimumThickness: number;
  47156. /**
  47157. * Defines the maximum thickness stored in the thickness map.
  47158. */
  47159. maximumThickness: number;
  47160. /**
  47161. * Defines the volume tint of the material.
  47162. * This is used for both translucency and scattering.
  47163. */
  47164. tintColor: Color3;
  47165. /**
  47166. * Defines the distance at which the tint color should be found in the media.
  47167. * This is used for refraction only.
  47168. */
  47169. tintColorAtDistance: number;
  47170. /**
  47171. * Defines how far each channel transmit through the media.
  47172. * It is defined as a color to simplify it selection.
  47173. */
  47174. diffusionDistance: Color3;
  47175. private _useMaskFromThicknessTexture;
  47176. /**
  47177. * Stores the intensity of the different subsurface effects in the thickness texture.
  47178. * * the green channel is the translucency intensity.
  47179. * * the blue channel is the scattering intensity.
  47180. * * the alpha channel is the refraction intensity.
  47181. */
  47182. useMaskFromThicknessTexture: boolean;
  47183. /** @hidden */
  47184. private _internalMarkAllSubMeshesAsTexturesDirty;
  47185. /** @hidden */
  47186. _markAllSubMeshesAsTexturesDirty(): void;
  47187. /**
  47188. * Instantiate a new istance of sub surface configuration.
  47189. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47190. */
  47191. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47192. /**
  47193. * Gets wehter the submesh is ready to be used or not.
  47194. * @param defines the list of "defines" to update.
  47195. * @param scene defines the scene the material belongs to.
  47196. * @returns - boolean indicating that the submesh is ready or not.
  47197. */
  47198. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47199. /**
  47200. * Checks to see if a texture is used in the material.
  47201. * @param defines the list of "defines" to update.
  47202. * @param scene defines the scene to the material belongs to.
  47203. */
  47204. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47205. /**
  47206. * Binds the material data.
  47207. * @param uniformBuffer defines the Uniform buffer to fill in.
  47208. * @param scene defines the scene the material belongs to.
  47209. * @param engine defines the engine the material belongs to.
  47210. * @param isFrozen defines wether the material is frozen or not.
  47211. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47212. */
  47213. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47214. /**
  47215. * Unbinds the material from the mesh.
  47216. * @param activeEffect defines the effect that should be unbound from.
  47217. * @returns true if unbound, otherwise false
  47218. */
  47219. unbind(activeEffect: Effect): boolean;
  47220. /**
  47221. * Returns the texture used for refraction or null if none is used.
  47222. * @param scene defines the scene the material belongs to.
  47223. * @returns - Refraction texture if present. If no refraction texture and refraction
  47224. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47225. */
  47226. private _getRefractionTexture;
  47227. /**
  47228. * Returns true if alpha blending should be disabled.
  47229. */
  47230. readonly disableAlphaBlending: boolean;
  47231. /**
  47232. * Fills the list of render target textures.
  47233. * @param renderTargets the list of render targets to update
  47234. */
  47235. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47236. /**
  47237. * Checks to see if a texture is used in the material.
  47238. * @param texture - Base texture to use.
  47239. * @returns - Boolean specifying if a texture is used in the material.
  47240. */
  47241. hasTexture(texture: BaseTexture): boolean;
  47242. /**
  47243. * Gets a boolean indicating that current material needs to register RTT
  47244. * @returns true if this uses a render target otherwise false.
  47245. */
  47246. hasRenderTargetTextures(): boolean;
  47247. /**
  47248. * Returns an array of the actively used textures.
  47249. * @param activeTextures Array of BaseTextures
  47250. */
  47251. getActiveTextures(activeTextures: BaseTexture[]): void;
  47252. /**
  47253. * Returns the animatable textures.
  47254. * @param animatables Array of animatable textures.
  47255. */
  47256. getAnimatables(animatables: IAnimatable[]): void;
  47257. /**
  47258. * Disposes the resources of the material.
  47259. * @param forceDisposeTextures - Forces the disposal of all textures.
  47260. */
  47261. dispose(forceDisposeTextures?: boolean): void;
  47262. /**
  47263. * Get the current class name of the texture useful for serialization or dynamic coding.
  47264. * @returns "PBRSubSurfaceConfiguration"
  47265. */
  47266. getClassName(): string;
  47267. /**
  47268. * Add fallbacks to the effect fallbacks list.
  47269. * @param defines defines the Base texture to use.
  47270. * @param fallbacks defines the current fallback list.
  47271. * @param currentRank defines the current fallback rank.
  47272. * @returns the new fallback rank.
  47273. */
  47274. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47275. /**
  47276. * Add the required uniforms to the current list.
  47277. * @param uniforms defines the current uniform list.
  47278. */
  47279. static AddUniforms(uniforms: string[]): void;
  47280. /**
  47281. * Add the required samplers to the current list.
  47282. * @param samplers defines the current sampler list.
  47283. */
  47284. static AddSamplers(samplers: string[]): void;
  47285. /**
  47286. * Add the required uniforms to the current buffer.
  47287. * @param uniformBuffer defines the current uniform buffer.
  47288. */
  47289. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47290. /**
  47291. * Makes a duplicate of the current configuration into another one.
  47292. * @param configuration define the config where to copy the info
  47293. */
  47294. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47295. /**
  47296. * Serializes this Sub Surface configuration.
  47297. * @returns - An object with the serialized config.
  47298. */
  47299. serialize(): any;
  47300. /**
  47301. * Parses a anisotropy Configuration from a serialized object.
  47302. * @param source - Serialized object.
  47303. * @param scene Defines the scene we are parsing for
  47304. * @param rootUrl Defines the rootUrl to load from
  47305. */
  47306. parse(source: any, scene: Scene, rootUrl: string): void;
  47307. }
  47308. }
  47309. declare module BABYLON {
  47310. /** @hidden */
  47311. export var pbrFragmentDeclaration: {
  47312. name: string;
  47313. shader: string;
  47314. };
  47315. }
  47316. declare module BABYLON {
  47317. /** @hidden */
  47318. export var pbrUboDeclaration: {
  47319. name: string;
  47320. shader: string;
  47321. };
  47322. }
  47323. declare module BABYLON {
  47324. /** @hidden */
  47325. export var pbrFragmentExtraDeclaration: {
  47326. name: string;
  47327. shader: string;
  47328. };
  47329. }
  47330. declare module BABYLON {
  47331. /** @hidden */
  47332. export var pbrFragmentSamplersDeclaration: {
  47333. name: string;
  47334. shader: string;
  47335. };
  47336. }
  47337. declare module BABYLON {
  47338. /** @hidden */
  47339. export var pbrHelperFunctions: {
  47340. name: string;
  47341. shader: string;
  47342. };
  47343. }
  47344. declare module BABYLON {
  47345. /** @hidden */
  47346. export var harmonicsFunctions: {
  47347. name: string;
  47348. shader: string;
  47349. };
  47350. }
  47351. declare module BABYLON {
  47352. /** @hidden */
  47353. export var pbrDirectLightingSetupFunctions: {
  47354. name: string;
  47355. shader: string;
  47356. };
  47357. }
  47358. declare module BABYLON {
  47359. /** @hidden */
  47360. export var pbrDirectLightingFalloffFunctions: {
  47361. name: string;
  47362. shader: string;
  47363. };
  47364. }
  47365. declare module BABYLON {
  47366. /** @hidden */
  47367. export var pbrBRDFFunctions: {
  47368. name: string;
  47369. shader: string;
  47370. };
  47371. }
  47372. declare module BABYLON {
  47373. /** @hidden */
  47374. export var pbrDirectLightingFunctions: {
  47375. name: string;
  47376. shader: string;
  47377. };
  47378. }
  47379. declare module BABYLON {
  47380. /** @hidden */
  47381. export var pbrIBLFunctions: {
  47382. name: string;
  47383. shader: string;
  47384. };
  47385. }
  47386. declare module BABYLON {
  47387. /** @hidden */
  47388. export var pbrDebug: {
  47389. name: string;
  47390. shader: string;
  47391. };
  47392. }
  47393. declare module BABYLON {
  47394. /** @hidden */
  47395. export var pbrPixelShader: {
  47396. name: string;
  47397. shader: string;
  47398. };
  47399. }
  47400. declare module BABYLON {
  47401. /** @hidden */
  47402. export var pbrVertexDeclaration: {
  47403. name: string;
  47404. shader: string;
  47405. };
  47406. }
  47407. declare module BABYLON {
  47408. /** @hidden */
  47409. export var pbrVertexShader: {
  47410. name: string;
  47411. shader: string;
  47412. };
  47413. }
  47414. declare module BABYLON {
  47415. /**
  47416. * Manages the defines for the PBR Material.
  47417. * @hidden
  47418. */
  47419. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47420. PBR: boolean;
  47421. MAINUV1: boolean;
  47422. MAINUV2: boolean;
  47423. UV1: boolean;
  47424. UV2: boolean;
  47425. ALBEDO: boolean;
  47426. ALBEDODIRECTUV: number;
  47427. VERTEXCOLOR: boolean;
  47428. AMBIENT: boolean;
  47429. AMBIENTDIRECTUV: number;
  47430. AMBIENTINGRAYSCALE: boolean;
  47431. OPACITY: boolean;
  47432. VERTEXALPHA: boolean;
  47433. OPACITYDIRECTUV: number;
  47434. OPACITYRGB: boolean;
  47435. ALPHATEST: boolean;
  47436. DEPTHPREPASS: boolean;
  47437. ALPHABLEND: boolean;
  47438. ALPHAFROMALBEDO: boolean;
  47439. ALPHATESTVALUE: string;
  47440. SPECULAROVERALPHA: boolean;
  47441. RADIANCEOVERALPHA: boolean;
  47442. ALPHAFRESNEL: boolean;
  47443. LINEARALPHAFRESNEL: boolean;
  47444. PREMULTIPLYALPHA: boolean;
  47445. EMISSIVE: boolean;
  47446. EMISSIVEDIRECTUV: number;
  47447. REFLECTIVITY: boolean;
  47448. REFLECTIVITYDIRECTUV: number;
  47449. SPECULARTERM: boolean;
  47450. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47451. MICROSURFACEAUTOMATIC: boolean;
  47452. LODBASEDMICROSFURACE: boolean;
  47453. MICROSURFACEMAP: boolean;
  47454. MICROSURFACEMAPDIRECTUV: number;
  47455. METALLICWORKFLOW: boolean;
  47456. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47457. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47458. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47459. AOSTOREINMETALMAPRED: boolean;
  47460. ENVIRONMENTBRDF: boolean;
  47461. ENVIRONMENTBRDF_RGBD: boolean;
  47462. NORMAL: boolean;
  47463. TANGENT: boolean;
  47464. BUMP: boolean;
  47465. BUMPDIRECTUV: number;
  47466. OBJECTSPACE_NORMALMAP: boolean;
  47467. PARALLAX: boolean;
  47468. PARALLAXOCCLUSION: boolean;
  47469. NORMALXYSCALE: boolean;
  47470. LIGHTMAP: boolean;
  47471. LIGHTMAPDIRECTUV: number;
  47472. USELIGHTMAPASSHADOWMAP: boolean;
  47473. GAMMALIGHTMAP: boolean;
  47474. RGBDLIGHTMAP: boolean;
  47475. REFLECTION: boolean;
  47476. REFLECTIONMAP_3D: boolean;
  47477. REFLECTIONMAP_SPHERICAL: boolean;
  47478. REFLECTIONMAP_PLANAR: boolean;
  47479. REFLECTIONMAP_CUBIC: boolean;
  47480. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47481. REFLECTIONMAP_PROJECTION: boolean;
  47482. REFLECTIONMAP_SKYBOX: boolean;
  47483. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47484. REFLECTIONMAP_EXPLICIT: boolean;
  47485. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47486. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47487. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47488. INVERTCUBICMAP: boolean;
  47489. USESPHERICALFROMREFLECTIONMAP: boolean;
  47490. USEIRRADIANCEMAP: boolean;
  47491. SPHERICAL_HARMONICS: boolean;
  47492. USESPHERICALINVERTEX: boolean;
  47493. REFLECTIONMAP_OPPOSITEZ: boolean;
  47494. LODINREFLECTIONALPHA: boolean;
  47495. GAMMAREFLECTION: boolean;
  47496. RGBDREFLECTION: boolean;
  47497. LINEARSPECULARREFLECTION: boolean;
  47498. RADIANCEOCCLUSION: boolean;
  47499. HORIZONOCCLUSION: boolean;
  47500. INSTANCES: boolean;
  47501. NUM_BONE_INFLUENCERS: number;
  47502. BonesPerMesh: number;
  47503. BONETEXTURE: boolean;
  47504. NONUNIFORMSCALING: boolean;
  47505. MORPHTARGETS: boolean;
  47506. MORPHTARGETS_NORMAL: boolean;
  47507. MORPHTARGETS_TANGENT: boolean;
  47508. MORPHTARGETS_UV: boolean;
  47509. NUM_MORPH_INFLUENCERS: number;
  47510. IMAGEPROCESSING: boolean;
  47511. VIGNETTE: boolean;
  47512. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47513. VIGNETTEBLENDMODEOPAQUE: boolean;
  47514. TONEMAPPING: boolean;
  47515. TONEMAPPING_ACES: boolean;
  47516. CONTRAST: boolean;
  47517. COLORCURVES: boolean;
  47518. COLORGRADING: boolean;
  47519. COLORGRADING3D: boolean;
  47520. SAMPLER3DGREENDEPTH: boolean;
  47521. SAMPLER3DBGRMAP: boolean;
  47522. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47523. EXPOSURE: boolean;
  47524. MULTIVIEW: boolean;
  47525. USEPHYSICALLIGHTFALLOFF: boolean;
  47526. USEGLTFLIGHTFALLOFF: boolean;
  47527. TWOSIDEDLIGHTING: boolean;
  47528. SHADOWFLOAT: boolean;
  47529. CLIPPLANE: boolean;
  47530. CLIPPLANE2: boolean;
  47531. CLIPPLANE3: boolean;
  47532. CLIPPLANE4: boolean;
  47533. POINTSIZE: boolean;
  47534. FOG: boolean;
  47535. LOGARITHMICDEPTH: boolean;
  47536. FORCENORMALFORWARD: boolean;
  47537. SPECULARAA: boolean;
  47538. CLEARCOAT: boolean;
  47539. CLEARCOAT_DEFAULTIOR: boolean;
  47540. CLEARCOAT_TEXTURE: boolean;
  47541. CLEARCOAT_TEXTUREDIRECTUV: number;
  47542. CLEARCOAT_BUMP: boolean;
  47543. CLEARCOAT_BUMPDIRECTUV: number;
  47544. CLEARCOAT_TINT: boolean;
  47545. CLEARCOAT_TINT_TEXTURE: boolean;
  47546. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47547. ANISOTROPIC: boolean;
  47548. ANISOTROPIC_TEXTURE: boolean;
  47549. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47550. BRDF_V_HEIGHT_CORRELATED: boolean;
  47551. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47552. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47553. SHEEN: boolean;
  47554. SHEEN_TEXTURE: boolean;
  47555. SHEEN_TEXTUREDIRECTUV: number;
  47556. SHEEN_LINKWITHALBEDO: boolean;
  47557. SUBSURFACE: boolean;
  47558. SS_REFRACTION: boolean;
  47559. SS_TRANSLUCENCY: boolean;
  47560. SS_SCATERRING: boolean;
  47561. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47562. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47563. SS_REFRACTIONMAP_3D: boolean;
  47564. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47565. SS_LODINREFRACTIONALPHA: boolean;
  47566. SS_GAMMAREFRACTION: boolean;
  47567. SS_RGBDREFRACTION: boolean;
  47568. SS_LINEARSPECULARREFRACTION: boolean;
  47569. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47570. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47571. UNLIT: boolean;
  47572. DEBUGMODE: number;
  47573. /**
  47574. * Initializes the PBR Material defines.
  47575. */
  47576. constructor();
  47577. /**
  47578. * Resets the PBR Material defines.
  47579. */
  47580. reset(): void;
  47581. }
  47582. /**
  47583. * The Physically based material base class of BJS.
  47584. *
  47585. * This offers the main features of a standard PBR material.
  47586. * For more information, please refer to the documentation :
  47587. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47588. */
  47589. export abstract class PBRBaseMaterial extends PushMaterial {
  47590. /**
  47591. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47592. */
  47593. static readonly PBRMATERIAL_OPAQUE: number;
  47594. /**
  47595. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47596. */
  47597. static readonly PBRMATERIAL_ALPHATEST: number;
  47598. /**
  47599. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47600. */
  47601. static readonly PBRMATERIAL_ALPHABLEND: number;
  47602. /**
  47603. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47604. * They are also discarded below the alpha cutoff threshold to improve performances.
  47605. */
  47606. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47607. /**
  47608. * Defines the default value of how much AO map is occluding the analytical lights
  47609. * (point spot...).
  47610. */
  47611. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47612. /**
  47613. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47614. */
  47615. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47616. /**
  47617. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47618. * to enhance interoperability with other engines.
  47619. */
  47620. static readonly LIGHTFALLOFF_GLTF: number;
  47621. /**
  47622. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47623. * to enhance interoperability with other materials.
  47624. */
  47625. static readonly LIGHTFALLOFF_STANDARD: number;
  47626. /**
  47627. * Intensity of the direct lights e.g. the four lights available in your scene.
  47628. * This impacts both the direct diffuse and specular highlights.
  47629. */
  47630. protected _directIntensity: number;
  47631. /**
  47632. * Intensity of the emissive part of the material.
  47633. * This helps controlling the emissive effect without modifying the emissive color.
  47634. */
  47635. protected _emissiveIntensity: number;
  47636. /**
  47637. * Intensity of the environment e.g. how much the environment will light the object
  47638. * either through harmonics for rough material or through the refelction for shiny ones.
  47639. */
  47640. protected _environmentIntensity: number;
  47641. /**
  47642. * This is a special control allowing the reduction of the specular highlights coming from the
  47643. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47644. */
  47645. protected _specularIntensity: number;
  47646. /**
  47647. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47648. */
  47649. private _lightingInfos;
  47650. /**
  47651. * Debug Control allowing disabling the bump map on this material.
  47652. */
  47653. protected _disableBumpMap: boolean;
  47654. /**
  47655. * AKA Diffuse Texture in standard nomenclature.
  47656. */
  47657. protected _albedoTexture: Nullable<BaseTexture>;
  47658. /**
  47659. * AKA Occlusion Texture in other nomenclature.
  47660. */
  47661. protected _ambientTexture: Nullable<BaseTexture>;
  47662. /**
  47663. * AKA Occlusion Texture Intensity in other nomenclature.
  47664. */
  47665. protected _ambientTextureStrength: number;
  47666. /**
  47667. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47668. * 1 means it completely occludes it
  47669. * 0 mean it has no impact
  47670. */
  47671. protected _ambientTextureImpactOnAnalyticalLights: number;
  47672. /**
  47673. * Stores the alpha values in a texture.
  47674. */
  47675. protected _opacityTexture: Nullable<BaseTexture>;
  47676. /**
  47677. * Stores the reflection values in a texture.
  47678. */
  47679. protected _reflectionTexture: Nullable<BaseTexture>;
  47680. /**
  47681. * Stores the emissive values in a texture.
  47682. */
  47683. protected _emissiveTexture: Nullable<BaseTexture>;
  47684. /**
  47685. * AKA Specular texture in other nomenclature.
  47686. */
  47687. protected _reflectivityTexture: Nullable<BaseTexture>;
  47688. /**
  47689. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47690. */
  47691. protected _metallicTexture: Nullable<BaseTexture>;
  47692. /**
  47693. * Specifies the metallic scalar of the metallic/roughness workflow.
  47694. * Can also be used to scale the metalness values of the metallic texture.
  47695. */
  47696. protected _metallic: Nullable<number>;
  47697. /**
  47698. * Specifies the roughness scalar of the metallic/roughness workflow.
  47699. * Can also be used to scale the roughness values of the metallic texture.
  47700. */
  47701. protected _roughness: Nullable<number>;
  47702. /**
  47703. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47704. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47705. */
  47706. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47707. /**
  47708. * Stores surface normal data used to displace a mesh in a texture.
  47709. */
  47710. protected _bumpTexture: Nullable<BaseTexture>;
  47711. /**
  47712. * Stores the pre-calculated light information of a mesh in a texture.
  47713. */
  47714. protected _lightmapTexture: Nullable<BaseTexture>;
  47715. /**
  47716. * The color of a material in ambient lighting.
  47717. */
  47718. protected _ambientColor: Color3;
  47719. /**
  47720. * AKA Diffuse Color in other nomenclature.
  47721. */
  47722. protected _albedoColor: Color3;
  47723. /**
  47724. * AKA Specular Color in other nomenclature.
  47725. */
  47726. protected _reflectivityColor: Color3;
  47727. /**
  47728. * The color applied when light is reflected from a material.
  47729. */
  47730. protected _reflectionColor: Color3;
  47731. /**
  47732. * The color applied when light is emitted from a material.
  47733. */
  47734. protected _emissiveColor: Color3;
  47735. /**
  47736. * AKA Glossiness in other nomenclature.
  47737. */
  47738. protected _microSurface: number;
  47739. /**
  47740. * Specifies that the material will use the light map as a show map.
  47741. */
  47742. protected _useLightmapAsShadowmap: boolean;
  47743. /**
  47744. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47745. * makes the reflect vector face the model (under horizon).
  47746. */
  47747. protected _useHorizonOcclusion: boolean;
  47748. /**
  47749. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47750. * too much the area relying on ambient texture to define their ambient occlusion.
  47751. */
  47752. protected _useRadianceOcclusion: boolean;
  47753. /**
  47754. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47755. */
  47756. protected _useAlphaFromAlbedoTexture: boolean;
  47757. /**
  47758. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47759. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47760. */
  47761. protected _useSpecularOverAlpha: boolean;
  47762. /**
  47763. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47764. */
  47765. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47766. /**
  47767. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47768. */
  47769. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47770. /**
  47771. * Specifies if the metallic texture contains the roughness information in its green channel.
  47772. */
  47773. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47774. /**
  47775. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47776. */
  47777. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47778. /**
  47779. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47780. */
  47781. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47782. /**
  47783. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47784. */
  47785. protected _useAmbientInGrayScale: boolean;
  47786. /**
  47787. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47788. * The material will try to infer what glossiness each pixel should be.
  47789. */
  47790. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47791. /**
  47792. * Defines the falloff type used in this material.
  47793. * It by default is Physical.
  47794. */
  47795. protected _lightFalloff: number;
  47796. /**
  47797. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47798. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47799. */
  47800. protected _useRadianceOverAlpha: boolean;
  47801. /**
  47802. * Allows using an object space normal map (instead of tangent space).
  47803. */
  47804. protected _useObjectSpaceNormalMap: boolean;
  47805. /**
  47806. * Allows using the bump map in parallax mode.
  47807. */
  47808. protected _useParallax: boolean;
  47809. /**
  47810. * Allows using the bump map in parallax occlusion mode.
  47811. */
  47812. protected _useParallaxOcclusion: boolean;
  47813. /**
  47814. * Controls the scale bias of the parallax mode.
  47815. */
  47816. protected _parallaxScaleBias: number;
  47817. /**
  47818. * If sets to true, disables all the lights affecting the material.
  47819. */
  47820. protected _disableLighting: boolean;
  47821. /**
  47822. * Number of Simultaneous lights allowed on the material.
  47823. */
  47824. protected _maxSimultaneousLights: number;
  47825. /**
  47826. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47827. */
  47828. protected _invertNormalMapX: boolean;
  47829. /**
  47830. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47831. */
  47832. protected _invertNormalMapY: boolean;
  47833. /**
  47834. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47835. */
  47836. protected _twoSidedLighting: boolean;
  47837. /**
  47838. * Defines the alpha limits in alpha test mode.
  47839. */
  47840. protected _alphaCutOff: number;
  47841. /**
  47842. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47843. */
  47844. protected _forceAlphaTest: boolean;
  47845. /**
  47846. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47847. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47848. */
  47849. protected _useAlphaFresnel: boolean;
  47850. /**
  47851. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47852. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47853. */
  47854. protected _useLinearAlphaFresnel: boolean;
  47855. /**
  47856. * The transparency mode of the material.
  47857. */
  47858. protected _transparencyMode: Nullable<number>;
  47859. /**
  47860. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47861. * from cos thetav and roughness:
  47862. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47863. */
  47864. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47865. /**
  47866. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47867. */
  47868. protected _forceIrradianceInFragment: boolean;
  47869. /**
  47870. * Force normal to face away from face.
  47871. */
  47872. protected _forceNormalForward: boolean;
  47873. /**
  47874. * Enables specular anti aliasing in the PBR shader.
  47875. * It will both interacts on the Geometry for analytical and IBL lighting.
  47876. * It also prefilter the roughness map based on the bump values.
  47877. */
  47878. protected _enableSpecularAntiAliasing: boolean;
  47879. /**
  47880. * Default configuration related to image processing available in the PBR Material.
  47881. */
  47882. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47883. /**
  47884. * Keep track of the image processing observer to allow dispose and replace.
  47885. */
  47886. private _imageProcessingObserver;
  47887. /**
  47888. * Attaches a new image processing configuration to the PBR Material.
  47889. * @param configuration
  47890. */
  47891. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47892. /**
  47893. * Stores the available render targets.
  47894. */
  47895. private _renderTargets;
  47896. /**
  47897. * Sets the global ambient color for the material used in lighting calculations.
  47898. */
  47899. private _globalAmbientColor;
  47900. /**
  47901. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47902. */
  47903. private _useLogarithmicDepth;
  47904. /**
  47905. * If set to true, no lighting calculations will be applied.
  47906. */
  47907. private _unlit;
  47908. private _debugMode;
  47909. /**
  47910. * @hidden
  47911. * This is reserved for the inspector.
  47912. * Defines the material debug mode.
  47913. * It helps seeing only some components of the material while troubleshooting.
  47914. */
  47915. debugMode: number;
  47916. /**
  47917. * @hidden
  47918. * This is reserved for the inspector.
  47919. * Specify from where on screen the debug mode should start.
  47920. * The value goes from -1 (full screen) to 1 (not visible)
  47921. * It helps with side by side comparison against the final render
  47922. * This defaults to -1
  47923. */
  47924. private debugLimit;
  47925. /**
  47926. * @hidden
  47927. * This is reserved for the inspector.
  47928. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47929. * You can use the factor to better multiply the final value.
  47930. */
  47931. private debugFactor;
  47932. /**
  47933. * Defines the clear coat layer parameters for the material.
  47934. */
  47935. readonly clearCoat: PBRClearCoatConfiguration;
  47936. /**
  47937. * Defines the anisotropic parameters for the material.
  47938. */
  47939. readonly anisotropy: PBRAnisotropicConfiguration;
  47940. /**
  47941. * Defines the BRDF parameters for the material.
  47942. */
  47943. readonly brdf: PBRBRDFConfiguration;
  47944. /**
  47945. * Defines the Sheen parameters for the material.
  47946. */
  47947. readonly sheen: PBRSheenConfiguration;
  47948. /**
  47949. * Defines the SubSurface parameters for the material.
  47950. */
  47951. readonly subSurface: PBRSubSurfaceConfiguration;
  47952. /**
  47953. * Custom callback helping to override the default shader used in the material.
  47954. */
  47955. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47956. protected _rebuildInParallel: boolean;
  47957. /**
  47958. * Instantiates a new PBRMaterial instance.
  47959. *
  47960. * @param name The material name
  47961. * @param scene The scene the material will be use in.
  47962. */
  47963. constructor(name: string, scene: Scene);
  47964. /**
  47965. * Gets a boolean indicating that current material needs to register RTT
  47966. */
  47967. readonly hasRenderTargetTextures: boolean;
  47968. /**
  47969. * Gets the name of the material class.
  47970. */
  47971. getClassName(): string;
  47972. /**
  47973. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47974. */
  47975. /**
  47976. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47977. */
  47978. useLogarithmicDepth: boolean;
  47979. /**
  47980. * Gets the current transparency mode.
  47981. */
  47982. /**
  47983. * Sets the transparency mode of the material.
  47984. *
  47985. * | Value | Type | Description |
  47986. * | ----- | ----------------------------------- | ----------- |
  47987. * | 0 | OPAQUE | |
  47988. * | 1 | ALPHATEST | |
  47989. * | 2 | ALPHABLEND | |
  47990. * | 3 | ALPHATESTANDBLEND | |
  47991. *
  47992. */
  47993. transparencyMode: Nullable<number>;
  47994. /**
  47995. * Returns true if alpha blending should be disabled.
  47996. */
  47997. private readonly _disableAlphaBlending;
  47998. /**
  47999. * Specifies whether or not this material should be rendered in alpha blend mode.
  48000. */
  48001. needAlphaBlending(): boolean;
  48002. /**
  48003. * Specifies if the mesh will require alpha blending.
  48004. * @param mesh - BJS mesh.
  48005. */
  48006. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48007. /**
  48008. * Specifies whether or not this material should be rendered in alpha test mode.
  48009. */
  48010. needAlphaTesting(): boolean;
  48011. /**
  48012. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48013. */
  48014. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48015. /**
  48016. * Gets the texture used for the alpha test.
  48017. */
  48018. getAlphaTestTexture(): Nullable<BaseTexture>;
  48019. /**
  48020. * Specifies that the submesh is ready to be used.
  48021. * @param mesh - BJS mesh.
  48022. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48023. * @param useInstances - Specifies that instances should be used.
  48024. * @returns - boolean indicating that the submesh is ready or not.
  48025. */
  48026. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48027. /**
  48028. * Specifies if the material uses metallic roughness workflow.
  48029. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48030. */
  48031. isMetallicWorkflow(): boolean;
  48032. private _prepareEffect;
  48033. private _prepareDefines;
  48034. /**
  48035. * Force shader compilation
  48036. */
  48037. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48038. clipPlane: boolean;
  48039. }>): void;
  48040. /**
  48041. * Initializes the uniform buffer layout for the shader.
  48042. */
  48043. buildUniformLayout(): void;
  48044. /**
  48045. * Unbinds the material from the mesh
  48046. */
  48047. unbind(): void;
  48048. /**
  48049. * Binds the submesh data.
  48050. * @param world - The world matrix.
  48051. * @param mesh - The BJS mesh.
  48052. * @param subMesh - A submesh of the BJS mesh.
  48053. */
  48054. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48055. /**
  48056. * Returns the animatable textures.
  48057. * @returns - Array of animatable textures.
  48058. */
  48059. getAnimatables(): IAnimatable[];
  48060. /**
  48061. * Returns the texture used for reflections.
  48062. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48063. */
  48064. private _getReflectionTexture;
  48065. /**
  48066. * Returns an array of the actively used textures.
  48067. * @returns - Array of BaseTextures
  48068. */
  48069. getActiveTextures(): BaseTexture[];
  48070. /**
  48071. * Checks to see if a texture is used in the material.
  48072. * @param texture - Base texture to use.
  48073. * @returns - Boolean specifying if a texture is used in the material.
  48074. */
  48075. hasTexture(texture: BaseTexture): boolean;
  48076. /**
  48077. * Disposes the resources of the material.
  48078. * @param forceDisposeEffect - Forces the disposal of effects.
  48079. * @param forceDisposeTextures - Forces the disposal of all textures.
  48080. */
  48081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48082. }
  48083. }
  48084. declare module BABYLON {
  48085. /**
  48086. * The Physically based material of BJS.
  48087. *
  48088. * This offers the main features of a standard PBR material.
  48089. * For more information, please refer to the documentation :
  48090. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48091. */
  48092. export class PBRMaterial extends PBRBaseMaterial {
  48093. /**
  48094. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48095. */
  48096. static readonly PBRMATERIAL_OPAQUE: number;
  48097. /**
  48098. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48099. */
  48100. static readonly PBRMATERIAL_ALPHATEST: number;
  48101. /**
  48102. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48103. */
  48104. static readonly PBRMATERIAL_ALPHABLEND: number;
  48105. /**
  48106. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48107. * They are also discarded below the alpha cutoff threshold to improve performances.
  48108. */
  48109. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48110. /**
  48111. * Defines the default value of how much AO map is occluding the analytical lights
  48112. * (point spot...).
  48113. */
  48114. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48115. /**
  48116. * Intensity of the direct lights e.g. the four lights available in your scene.
  48117. * This impacts both the direct diffuse and specular highlights.
  48118. */
  48119. directIntensity: number;
  48120. /**
  48121. * Intensity of the emissive part of the material.
  48122. * This helps controlling the emissive effect without modifying the emissive color.
  48123. */
  48124. emissiveIntensity: number;
  48125. /**
  48126. * Intensity of the environment e.g. how much the environment will light the object
  48127. * either through harmonics for rough material or through the refelction for shiny ones.
  48128. */
  48129. environmentIntensity: number;
  48130. /**
  48131. * This is a special control allowing the reduction of the specular highlights coming from the
  48132. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48133. */
  48134. specularIntensity: number;
  48135. /**
  48136. * Debug Control allowing disabling the bump map on this material.
  48137. */
  48138. disableBumpMap: boolean;
  48139. /**
  48140. * AKA Diffuse Texture in standard nomenclature.
  48141. */
  48142. albedoTexture: BaseTexture;
  48143. /**
  48144. * AKA Occlusion Texture in other nomenclature.
  48145. */
  48146. ambientTexture: BaseTexture;
  48147. /**
  48148. * AKA Occlusion Texture Intensity in other nomenclature.
  48149. */
  48150. ambientTextureStrength: number;
  48151. /**
  48152. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48153. * 1 means it completely occludes it
  48154. * 0 mean it has no impact
  48155. */
  48156. ambientTextureImpactOnAnalyticalLights: number;
  48157. /**
  48158. * Stores the alpha values in a texture.
  48159. */
  48160. opacityTexture: BaseTexture;
  48161. /**
  48162. * Stores the reflection values in a texture.
  48163. */
  48164. reflectionTexture: Nullable<BaseTexture>;
  48165. /**
  48166. * Stores the emissive values in a texture.
  48167. */
  48168. emissiveTexture: BaseTexture;
  48169. /**
  48170. * AKA Specular texture in other nomenclature.
  48171. */
  48172. reflectivityTexture: BaseTexture;
  48173. /**
  48174. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48175. */
  48176. metallicTexture: BaseTexture;
  48177. /**
  48178. * Specifies the metallic scalar of the metallic/roughness workflow.
  48179. * Can also be used to scale the metalness values of the metallic texture.
  48180. */
  48181. metallic: Nullable<number>;
  48182. /**
  48183. * Specifies the roughness scalar of the metallic/roughness workflow.
  48184. * Can also be used to scale the roughness values of the metallic texture.
  48185. */
  48186. roughness: Nullable<number>;
  48187. /**
  48188. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48189. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48190. */
  48191. microSurfaceTexture: BaseTexture;
  48192. /**
  48193. * Stores surface normal data used to displace a mesh in a texture.
  48194. */
  48195. bumpTexture: BaseTexture;
  48196. /**
  48197. * Stores the pre-calculated light information of a mesh in a texture.
  48198. */
  48199. lightmapTexture: BaseTexture;
  48200. /**
  48201. * Stores the refracted light information in a texture.
  48202. */
  48203. refractionTexture: Nullable<BaseTexture>;
  48204. /**
  48205. * The color of a material in ambient lighting.
  48206. */
  48207. ambientColor: Color3;
  48208. /**
  48209. * AKA Diffuse Color in other nomenclature.
  48210. */
  48211. albedoColor: Color3;
  48212. /**
  48213. * AKA Specular Color in other nomenclature.
  48214. */
  48215. reflectivityColor: Color3;
  48216. /**
  48217. * The color reflected from the material.
  48218. */
  48219. reflectionColor: Color3;
  48220. /**
  48221. * The color emitted from the material.
  48222. */
  48223. emissiveColor: Color3;
  48224. /**
  48225. * AKA Glossiness in other nomenclature.
  48226. */
  48227. microSurface: number;
  48228. /**
  48229. * source material index of refraction (IOR)' / 'destination material IOR.
  48230. */
  48231. indexOfRefraction: number;
  48232. /**
  48233. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48234. */
  48235. invertRefractionY: boolean;
  48236. /**
  48237. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48238. * Materials half opaque for instance using refraction could benefit from this control.
  48239. */
  48240. linkRefractionWithTransparency: boolean;
  48241. /**
  48242. * If true, the light map contains occlusion information instead of lighting info.
  48243. */
  48244. useLightmapAsShadowmap: boolean;
  48245. /**
  48246. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48247. */
  48248. useAlphaFromAlbedoTexture: boolean;
  48249. /**
  48250. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48251. */
  48252. forceAlphaTest: boolean;
  48253. /**
  48254. * Defines the alpha limits in alpha test mode.
  48255. */
  48256. alphaCutOff: number;
  48257. /**
  48258. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48259. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48260. */
  48261. useSpecularOverAlpha: boolean;
  48262. /**
  48263. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48264. */
  48265. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48266. /**
  48267. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48268. */
  48269. useRoughnessFromMetallicTextureAlpha: boolean;
  48270. /**
  48271. * Specifies if the metallic texture contains the roughness information in its green channel.
  48272. */
  48273. useRoughnessFromMetallicTextureGreen: boolean;
  48274. /**
  48275. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48276. */
  48277. useMetallnessFromMetallicTextureBlue: boolean;
  48278. /**
  48279. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48280. */
  48281. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48282. /**
  48283. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48284. */
  48285. useAmbientInGrayScale: boolean;
  48286. /**
  48287. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48288. * The material will try to infer what glossiness each pixel should be.
  48289. */
  48290. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48291. /**
  48292. * BJS is using an harcoded light falloff based on a manually sets up range.
  48293. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48294. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48295. */
  48296. /**
  48297. * BJS is using an harcoded light falloff based on a manually sets up range.
  48298. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48299. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48300. */
  48301. usePhysicalLightFalloff: boolean;
  48302. /**
  48303. * In order to support the falloff compatibility with gltf, a special mode has been added
  48304. * to reproduce the gltf light falloff.
  48305. */
  48306. /**
  48307. * In order to support the falloff compatibility with gltf, a special mode has been added
  48308. * to reproduce the gltf light falloff.
  48309. */
  48310. useGLTFLightFalloff: boolean;
  48311. /**
  48312. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48313. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48314. */
  48315. useRadianceOverAlpha: boolean;
  48316. /**
  48317. * Allows using an object space normal map (instead of tangent space).
  48318. */
  48319. useObjectSpaceNormalMap: boolean;
  48320. /**
  48321. * Allows using the bump map in parallax mode.
  48322. */
  48323. useParallax: boolean;
  48324. /**
  48325. * Allows using the bump map in parallax occlusion mode.
  48326. */
  48327. useParallaxOcclusion: boolean;
  48328. /**
  48329. * Controls the scale bias of the parallax mode.
  48330. */
  48331. parallaxScaleBias: number;
  48332. /**
  48333. * If sets to true, disables all the lights affecting the material.
  48334. */
  48335. disableLighting: boolean;
  48336. /**
  48337. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48338. */
  48339. forceIrradianceInFragment: boolean;
  48340. /**
  48341. * Number of Simultaneous lights allowed on the material.
  48342. */
  48343. maxSimultaneousLights: number;
  48344. /**
  48345. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48346. */
  48347. invertNormalMapX: boolean;
  48348. /**
  48349. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48350. */
  48351. invertNormalMapY: boolean;
  48352. /**
  48353. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48354. */
  48355. twoSidedLighting: boolean;
  48356. /**
  48357. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48358. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48359. */
  48360. useAlphaFresnel: boolean;
  48361. /**
  48362. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48363. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48364. */
  48365. useLinearAlphaFresnel: boolean;
  48366. /**
  48367. * Let user defines the brdf lookup texture used for IBL.
  48368. * A default 8bit version is embedded but you could point at :
  48369. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48370. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48371. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48372. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48373. */
  48374. environmentBRDFTexture: Nullable<BaseTexture>;
  48375. /**
  48376. * Force normal to face away from face.
  48377. */
  48378. forceNormalForward: boolean;
  48379. /**
  48380. * Enables specular anti aliasing in the PBR shader.
  48381. * It will both interacts on the Geometry for analytical and IBL lighting.
  48382. * It also prefilter the roughness map based on the bump values.
  48383. */
  48384. enableSpecularAntiAliasing: boolean;
  48385. /**
  48386. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48387. * makes the reflect vector face the model (under horizon).
  48388. */
  48389. useHorizonOcclusion: boolean;
  48390. /**
  48391. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48392. * too much the area relying on ambient texture to define their ambient occlusion.
  48393. */
  48394. useRadianceOcclusion: boolean;
  48395. /**
  48396. * If set to true, no lighting calculations will be applied.
  48397. */
  48398. unlit: boolean;
  48399. /**
  48400. * Gets the image processing configuration used either in this material.
  48401. */
  48402. /**
  48403. * Sets the Default image processing configuration used either in the this material.
  48404. *
  48405. * If sets to null, the scene one is in use.
  48406. */
  48407. imageProcessingConfiguration: ImageProcessingConfiguration;
  48408. /**
  48409. * Gets wether the color curves effect is enabled.
  48410. */
  48411. /**
  48412. * Sets wether the color curves effect is enabled.
  48413. */
  48414. cameraColorCurvesEnabled: boolean;
  48415. /**
  48416. * Gets wether the color grading effect is enabled.
  48417. */
  48418. /**
  48419. * Gets wether the color grading effect is enabled.
  48420. */
  48421. cameraColorGradingEnabled: boolean;
  48422. /**
  48423. * Gets wether tonemapping is enabled or not.
  48424. */
  48425. /**
  48426. * Sets wether tonemapping is enabled or not
  48427. */
  48428. cameraToneMappingEnabled: boolean;
  48429. /**
  48430. * The camera exposure used on this material.
  48431. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48432. * This corresponds to a photographic exposure.
  48433. */
  48434. /**
  48435. * The camera exposure used on this material.
  48436. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48437. * This corresponds to a photographic exposure.
  48438. */
  48439. cameraExposure: number;
  48440. /**
  48441. * Gets The camera contrast used on this material.
  48442. */
  48443. /**
  48444. * Sets The camera contrast used on this material.
  48445. */
  48446. cameraContrast: number;
  48447. /**
  48448. * Gets the Color Grading 2D Lookup Texture.
  48449. */
  48450. /**
  48451. * Sets the Color Grading 2D Lookup Texture.
  48452. */
  48453. cameraColorGradingTexture: Nullable<BaseTexture>;
  48454. /**
  48455. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48456. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48457. * 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;
  48458. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48459. */
  48460. /**
  48461. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48462. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48463. * 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;
  48464. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48465. */
  48466. cameraColorCurves: Nullable<ColorCurves>;
  48467. /**
  48468. * Instantiates a new PBRMaterial instance.
  48469. *
  48470. * @param name The material name
  48471. * @param scene The scene the material will be use in.
  48472. */
  48473. constructor(name: string, scene: Scene);
  48474. /**
  48475. * Returns the name of this material class.
  48476. */
  48477. getClassName(): string;
  48478. /**
  48479. * Makes a duplicate of the current material.
  48480. * @param name - name to use for the new material.
  48481. */
  48482. clone(name: string): PBRMaterial;
  48483. /**
  48484. * Serializes this PBR Material.
  48485. * @returns - An object with the serialized material.
  48486. */
  48487. serialize(): any;
  48488. /**
  48489. * Parses a PBR Material from a serialized object.
  48490. * @param source - Serialized object.
  48491. * @param scene - BJS scene instance.
  48492. * @param rootUrl - url for the scene object
  48493. * @returns - PBRMaterial
  48494. */
  48495. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48496. }
  48497. }
  48498. declare module BABYLON {
  48499. /**
  48500. * Direct draw surface info
  48501. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48502. */
  48503. export interface DDSInfo {
  48504. /**
  48505. * Width of the texture
  48506. */
  48507. width: number;
  48508. /**
  48509. * Width of the texture
  48510. */
  48511. height: number;
  48512. /**
  48513. * Number of Mipmaps for the texture
  48514. * @see https://en.wikipedia.org/wiki/Mipmap
  48515. */
  48516. mipmapCount: number;
  48517. /**
  48518. * If the textures format is a known fourCC format
  48519. * @see https://www.fourcc.org/
  48520. */
  48521. isFourCC: boolean;
  48522. /**
  48523. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48524. */
  48525. isRGB: boolean;
  48526. /**
  48527. * If the texture is a lumincance format
  48528. */
  48529. isLuminance: boolean;
  48530. /**
  48531. * If this is a cube texture
  48532. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48533. */
  48534. isCube: boolean;
  48535. /**
  48536. * If the texture is a compressed format eg. FOURCC_DXT1
  48537. */
  48538. isCompressed: boolean;
  48539. /**
  48540. * The dxgiFormat of the texture
  48541. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48542. */
  48543. dxgiFormat: number;
  48544. /**
  48545. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48546. */
  48547. textureType: number;
  48548. /**
  48549. * Sphericle polynomial created for the dds texture
  48550. */
  48551. sphericalPolynomial?: SphericalPolynomial;
  48552. }
  48553. /**
  48554. * Class used to provide DDS decompression tools
  48555. */
  48556. export class DDSTools {
  48557. /**
  48558. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48559. */
  48560. static StoreLODInAlphaChannel: boolean;
  48561. /**
  48562. * Gets DDS information from an array buffer
  48563. * @param arrayBuffer defines the array buffer to read data from
  48564. * @returns the DDS information
  48565. */
  48566. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48567. private static _FloatView;
  48568. private static _Int32View;
  48569. private static _ToHalfFloat;
  48570. private static _FromHalfFloat;
  48571. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48572. private static _GetHalfFloatRGBAArrayBuffer;
  48573. private static _GetFloatRGBAArrayBuffer;
  48574. private static _GetFloatAsUIntRGBAArrayBuffer;
  48575. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48576. private static _GetRGBAArrayBuffer;
  48577. private static _ExtractLongWordOrder;
  48578. private static _GetRGBArrayBuffer;
  48579. private static _GetLuminanceArrayBuffer;
  48580. /**
  48581. * Uploads DDS Levels to a Babylon Texture
  48582. * @hidden
  48583. */
  48584. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48585. }
  48586. interface ThinEngine {
  48587. /**
  48588. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48589. * @param rootUrl defines the url where the file to load is located
  48590. * @param scene defines the current scene
  48591. * @param lodScale defines scale to apply to the mip map selection
  48592. * @param lodOffset defines offset to apply to the mip map selection
  48593. * @param onLoad defines an optional callback raised when the texture is loaded
  48594. * @param onError defines an optional callback raised if there is an issue to load the texture
  48595. * @param format defines the format of the data
  48596. * @param forcedExtension defines the extension to use to pick the right loader
  48597. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48598. * @returns the cube texture as an InternalTexture
  48599. */
  48600. 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;
  48601. }
  48602. }
  48603. declare module BABYLON {
  48604. /**
  48605. * Implementation of the DDS Texture Loader.
  48606. * @hidden
  48607. */
  48608. export class _DDSTextureLoader implements IInternalTextureLoader {
  48609. /**
  48610. * Defines wether the loader supports cascade loading the different faces.
  48611. */
  48612. readonly supportCascades: boolean;
  48613. /**
  48614. * This returns if the loader support the current file information.
  48615. * @param extension defines the file extension of the file being loaded
  48616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48617. * @param fallback defines the fallback internal texture if any
  48618. * @param isBase64 defines whether the texture is encoded as a base64
  48619. * @param isBuffer defines whether the texture data are stored as a buffer
  48620. * @returns true if the loader can load the specified file
  48621. */
  48622. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48623. /**
  48624. * Transform the url before loading if required.
  48625. * @param rootUrl the url of the texture
  48626. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48627. * @returns the transformed texture
  48628. */
  48629. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48630. /**
  48631. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48632. * @param rootUrl the url of the texture
  48633. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48634. * @returns the fallback texture
  48635. */
  48636. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48637. /**
  48638. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48639. * @param data contains the texture data
  48640. * @param texture defines the BabylonJS internal texture
  48641. * @param createPolynomials will be true if polynomials have been requested
  48642. * @param onLoad defines the callback to trigger once the texture is ready
  48643. * @param onError defines the callback to trigger in case of error
  48644. */
  48645. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48646. /**
  48647. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48648. * @param data contains the texture data
  48649. * @param texture defines the BabylonJS internal texture
  48650. * @param callback defines the method to call once ready to upload
  48651. */
  48652. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48653. }
  48654. }
  48655. declare module BABYLON {
  48656. /**
  48657. * Implementation of the ENV Texture Loader.
  48658. * @hidden
  48659. */
  48660. export class _ENVTextureLoader implements IInternalTextureLoader {
  48661. /**
  48662. * Defines wether the loader supports cascade loading the different faces.
  48663. */
  48664. readonly supportCascades: boolean;
  48665. /**
  48666. * This returns if the loader support the current file information.
  48667. * @param extension defines the file extension of the file being loaded
  48668. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48669. * @param fallback defines the fallback internal texture if any
  48670. * @param isBase64 defines whether the texture is encoded as a base64
  48671. * @param isBuffer defines whether the texture data are stored as a buffer
  48672. * @returns true if the loader can load the specified file
  48673. */
  48674. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48675. /**
  48676. * Transform the url before loading if required.
  48677. * @param rootUrl the url of the texture
  48678. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48679. * @returns the transformed texture
  48680. */
  48681. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48682. /**
  48683. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48684. * @param rootUrl the url of the texture
  48685. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48686. * @returns the fallback texture
  48687. */
  48688. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48689. /**
  48690. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48691. * @param data contains the texture data
  48692. * @param texture defines the BabylonJS internal texture
  48693. * @param createPolynomials will be true if polynomials have been requested
  48694. * @param onLoad defines the callback to trigger once the texture is ready
  48695. * @param onError defines the callback to trigger in case of error
  48696. */
  48697. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48698. /**
  48699. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48700. * @param data contains the texture data
  48701. * @param texture defines the BabylonJS internal texture
  48702. * @param callback defines the method to call once ready to upload
  48703. */
  48704. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48705. }
  48706. }
  48707. declare module BABYLON {
  48708. /**
  48709. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48710. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48711. */
  48712. export class KhronosTextureContainer {
  48713. /** contents of the KTX container file */
  48714. arrayBuffer: any;
  48715. private static HEADER_LEN;
  48716. private static COMPRESSED_2D;
  48717. private static COMPRESSED_3D;
  48718. private static TEX_2D;
  48719. private static TEX_3D;
  48720. /**
  48721. * Gets the openGL type
  48722. */
  48723. glType: number;
  48724. /**
  48725. * Gets the openGL type size
  48726. */
  48727. glTypeSize: number;
  48728. /**
  48729. * Gets the openGL format
  48730. */
  48731. glFormat: number;
  48732. /**
  48733. * Gets the openGL internal format
  48734. */
  48735. glInternalFormat: number;
  48736. /**
  48737. * Gets the base internal format
  48738. */
  48739. glBaseInternalFormat: number;
  48740. /**
  48741. * Gets image width in pixel
  48742. */
  48743. pixelWidth: number;
  48744. /**
  48745. * Gets image height in pixel
  48746. */
  48747. pixelHeight: number;
  48748. /**
  48749. * Gets image depth in pixels
  48750. */
  48751. pixelDepth: number;
  48752. /**
  48753. * Gets the number of array elements
  48754. */
  48755. numberOfArrayElements: number;
  48756. /**
  48757. * Gets the number of faces
  48758. */
  48759. numberOfFaces: number;
  48760. /**
  48761. * Gets the number of mipmap levels
  48762. */
  48763. numberOfMipmapLevels: number;
  48764. /**
  48765. * Gets the bytes of key value data
  48766. */
  48767. bytesOfKeyValueData: number;
  48768. /**
  48769. * Gets the load type
  48770. */
  48771. loadType: number;
  48772. /**
  48773. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48774. */
  48775. isInvalid: boolean;
  48776. /**
  48777. * Creates a new KhronosTextureContainer
  48778. * @param arrayBuffer contents of the KTX container file
  48779. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48780. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48781. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48782. */
  48783. constructor(
  48784. /** contents of the KTX container file */
  48785. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48786. /**
  48787. * Uploads KTX content to a Babylon Texture.
  48788. * It is assumed that the texture has already been created & is currently bound
  48789. * @hidden
  48790. */
  48791. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48792. private _upload2DCompressedLevels;
  48793. }
  48794. }
  48795. declare module BABYLON {
  48796. /**
  48797. * Implementation of the KTX Texture Loader.
  48798. * @hidden
  48799. */
  48800. export class _KTXTextureLoader implements IInternalTextureLoader {
  48801. /**
  48802. * Defines wether the loader supports cascade loading the different faces.
  48803. */
  48804. readonly supportCascades: boolean;
  48805. /**
  48806. * This returns if the loader support the current file information.
  48807. * @param extension defines the file extension of the file being loaded
  48808. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48809. * @param fallback defines the fallback internal texture if any
  48810. * @param isBase64 defines whether the texture is encoded as a base64
  48811. * @param isBuffer defines whether the texture data are stored as a buffer
  48812. * @returns true if the loader can load the specified file
  48813. */
  48814. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48815. /**
  48816. * Transform the url before loading if required.
  48817. * @param rootUrl the url of the texture
  48818. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48819. * @returns the transformed texture
  48820. */
  48821. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48822. /**
  48823. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48824. * @param rootUrl the url of the texture
  48825. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48826. * @returns the fallback texture
  48827. */
  48828. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48829. /**
  48830. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48831. * @param data contains the texture data
  48832. * @param texture defines the BabylonJS internal texture
  48833. * @param createPolynomials will be true if polynomials have been requested
  48834. * @param onLoad defines the callback to trigger once the texture is ready
  48835. * @param onError defines the callback to trigger in case of error
  48836. */
  48837. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48838. /**
  48839. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48840. * @param data contains the texture data
  48841. * @param texture defines the BabylonJS internal texture
  48842. * @param callback defines the method to call once ready to upload
  48843. */
  48844. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48845. }
  48846. }
  48847. declare module BABYLON {
  48848. /**
  48849. * Options for the default xr helper
  48850. */
  48851. export class WebXRDefaultExperienceOptions {
  48852. /**
  48853. * Floor meshes that should be used for teleporting
  48854. */
  48855. floorMeshes: Array<AbstractMesh>;
  48856. }
  48857. /**
  48858. * Default experience which provides a similar setup to the previous webVRExperience
  48859. */
  48860. export class WebXRDefaultExperience {
  48861. /**
  48862. * Base experience
  48863. */
  48864. baseExperience: WebXRExperienceHelper;
  48865. /**
  48866. * Input experience extension
  48867. */
  48868. input: WebXRInput;
  48869. /**
  48870. * Loads the controller models
  48871. */
  48872. controllerModelLoader: WebXRControllerModelLoader;
  48873. /**
  48874. * Enables laser pointer and selection
  48875. */
  48876. pointerSelection: WebXRControllerPointerSelection;
  48877. /**
  48878. * Enables teleportation
  48879. */
  48880. teleportation: WebXRControllerTeleportation;
  48881. /**
  48882. * Enables ui for enetering/exiting xr
  48883. */
  48884. enterExitUI: WebXREnterExitUI;
  48885. /**
  48886. * Default output canvas xr should render to
  48887. */
  48888. outputCanvas: WebXRManagedOutputCanvas;
  48889. /**
  48890. * Creates the default xr experience
  48891. * @param scene scene
  48892. * @param options options for basic configuration
  48893. * @returns resulting WebXRDefaultExperience
  48894. */
  48895. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48896. private constructor();
  48897. /**
  48898. * DIsposes of the experience helper
  48899. */
  48900. dispose(): void;
  48901. }
  48902. }
  48903. declare module BABYLON {
  48904. /** @hidden */
  48905. export var _forceSceneHelpersToBundle: boolean;
  48906. interface Scene {
  48907. /**
  48908. * Creates a default light for the scene.
  48909. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48910. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48911. */
  48912. createDefaultLight(replace?: boolean): void;
  48913. /**
  48914. * Creates a default camera for the scene.
  48915. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48916. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48917. * @param replace has default false, when true replaces the active camera in the scene
  48918. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48919. */
  48920. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48921. /**
  48922. * Creates a default camera and a default light.
  48923. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48924. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48925. * @param replace has the default false, when true replaces the active camera/light in the scene
  48926. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48927. */
  48928. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48929. /**
  48930. * Creates a new sky box
  48931. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48932. * @param environmentTexture defines the texture to use as environment texture
  48933. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48934. * @param scale defines the overall scale of the skybox
  48935. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48936. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48937. * @returns a new mesh holding the sky box
  48938. */
  48939. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48940. /**
  48941. * Creates a new environment
  48942. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48943. * @param options defines the options you can use to configure the environment
  48944. * @returns the new EnvironmentHelper
  48945. */
  48946. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48947. /**
  48948. * Creates a new VREXperienceHelper
  48949. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48950. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48951. * @returns a new VREXperienceHelper
  48952. */
  48953. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48954. /**
  48955. * Creates a new WebXRDefaultExperience
  48956. * @see http://doc.babylonjs.com/how_to/webxr
  48957. * @param options experience options
  48958. * @returns a promise for a new WebXRDefaultExperience
  48959. */
  48960. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48961. }
  48962. }
  48963. declare module BABYLON {
  48964. /**
  48965. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48966. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48967. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48968. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48969. */
  48970. export class VideoDome extends TransformNode {
  48971. /**
  48972. * Define the video source as a Monoscopic panoramic 360 video.
  48973. */
  48974. static readonly MODE_MONOSCOPIC: number;
  48975. /**
  48976. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48977. */
  48978. static readonly MODE_TOPBOTTOM: number;
  48979. /**
  48980. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48981. */
  48982. static readonly MODE_SIDEBYSIDE: number;
  48983. private _halfDome;
  48984. private _useDirectMapping;
  48985. /**
  48986. * The video texture being displayed on the sphere
  48987. */
  48988. protected _videoTexture: VideoTexture;
  48989. /**
  48990. * Gets the video texture being displayed on the sphere
  48991. */
  48992. readonly videoTexture: VideoTexture;
  48993. /**
  48994. * The skybox material
  48995. */
  48996. protected _material: BackgroundMaterial;
  48997. /**
  48998. * The surface used for the skybox
  48999. */
  49000. protected _mesh: Mesh;
  49001. /**
  49002. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  49003. */
  49004. private _halfDomeMask;
  49005. /**
  49006. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49007. * Also see the options.resolution property.
  49008. */
  49009. fovMultiplier: number;
  49010. private _videoMode;
  49011. /**
  49012. * Gets or set the current video mode for the video. It can be:
  49013. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49014. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49015. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49016. */
  49017. videoMode: number;
  49018. /**
  49019. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  49020. *
  49021. */
  49022. /**
  49023. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  49024. */
  49025. halfDome: boolean;
  49026. /**
  49027. * Oberserver used in Stereoscopic VR Mode.
  49028. */
  49029. private _onBeforeCameraRenderObserver;
  49030. /**
  49031. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49032. * @param name Element's name, child elements will append suffixes for their own names.
  49033. * @param urlsOrVideo defines the url(s) or the video element to use
  49034. * @param options An object containing optional or exposed sub element properties
  49035. */
  49036. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49037. resolution?: number;
  49038. clickToPlay?: boolean;
  49039. autoPlay?: boolean;
  49040. loop?: boolean;
  49041. size?: number;
  49042. poster?: string;
  49043. faceForward?: boolean;
  49044. useDirectMapping?: boolean;
  49045. halfDomeMode?: boolean;
  49046. }, scene: Scene);
  49047. private _changeVideoMode;
  49048. /**
  49049. * Releases resources associated with this node.
  49050. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49051. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49052. */
  49053. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49054. }
  49055. }
  49056. declare module BABYLON {
  49057. /**
  49058. * This class can be used to get instrumentation data from a Babylon engine
  49059. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49060. */
  49061. export class EngineInstrumentation implements IDisposable {
  49062. /**
  49063. * Define the instrumented engine.
  49064. */
  49065. engine: Engine;
  49066. private _captureGPUFrameTime;
  49067. private _gpuFrameTimeToken;
  49068. private _gpuFrameTime;
  49069. private _captureShaderCompilationTime;
  49070. private _shaderCompilationTime;
  49071. private _onBeginFrameObserver;
  49072. private _onEndFrameObserver;
  49073. private _onBeforeShaderCompilationObserver;
  49074. private _onAfterShaderCompilationObserver;
  49075. /**
  49076. * Gets the perf counter used for GPU frame time
  49077. */
  49078. readonly gpuFrameTimeCounter: PerfCounter;
  49079. /**
  49080. * Gets the GPU frame time capture status
  49081. */
  49082. /**
  49083. * Enable or disable the GPU frame time capture
  49084. */
  49085. captureGPUFrameTime: boolean;
  49086. /**
  49087. * Gets the perf counter used for shader compilation time
  49088. */
  49089. readonly shaderCompilationTimeCounter: PerfCounter;
  49090. /**
  49091. * Gets the shader compilation time capture status
  49092. */
  49093. /**
  49094. * Enable or disable the shader compilation time capture
  49095. */
  49096. captureShaderCompilationTime: boolean;
  49097. /**
  49098. * Instantiates a new engine instrumentation.
  49099. * This class can be used to get instrumentation data from a Babylon engine
  49100. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49101. * @param engine Defines the engine to instrument
  49102. */
  49103. constructor(
  49104. /**
  49105. * Define the instrumented engine.
  49106. */
  49107. engine: Engine);
  49108. /**
  49109. * Dispose and release associated resources.
  49110. */
  49111. dispose(): void;
  49112. }
  49113. }
  49114. declare module BABYLON {
  49115. /**
  49116. * This class can be used to get instrumentation data from a Babylon engine
  49117. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49118. */
  49119. export class SceneInstrumentation implements IDisposable {
  49120. /**
  49121. * Defines the scene to instrument
  49122. */
  49123. scene: Scene;
  49124. private _captureActiveMeshesEvaluationTime;
  49125. private _activeMeshesEvaluationTime;
  49126. private _captureRenderTargetsRenderTime;
  49127. private _renderTargetsRenderTime;
  49128. private _captureFrameTime;
  49129. private _frameTime;
  49130. private _captureRenderTime;
  49131. private _renderTime;
  49132. private _captureInterFrameTime;
  49133. private _interFrameTime;
  49134. private _captureParticlesRenderTime;
  49135. private _particlesRenderTime;
  49136. private _captureSpritesRenderTime;
  49137. private _spritesRenderTime;
  49138. private _capturePhysicsTime;
  49139. private _physicsTime;
  49140. private _captureAnimationsTime;
  49141. private _animationsTime;
  49142. private _captureCameraRenderTime;
  49143. private _cameraRenderTime;
  49144. private _onBeforeActiveMeshesEvaluationObserver;
  49145. private _onAfterActiveMeshesEvaluationObserver;
  49146. private _onBeforeRenderTargetsRenderObserver;
  49147. private _onAfterRenderTargetsRenderObserver;
  49148. private _onAfterRenderObserver;
  49149. private _onBeforeDrawPhaseObserver;
  49150. private _onAfterDrawPhaseObserver;
  49151. private _onBeforeAnimationsObserver;
  49152. private _onBeforeParticlesRenderingObserver;
  49153. private _onAfterParticlesRenderingObserver;
  49154. private _onBeforeSpritesRenderingObserver;
  49155. private _onAfterSpritesRenderingObserver;
  49156. private _onBeforePhysicsObserver;
  49157. private _onAfterPhysicsObserver;
  49158. private _onAfterAnimationsObserver;
  49159. private _onBeforeCameraRenderObserver;
  49160. private _onAfterCameraRenderObserver;
  49161. /**
  49162. * Gets the perf counter used for active meshes evaluation time
  49163. */
  49164. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49165. /**
  49166. * Gets the active meshes evaluation time capture status
  49167. */
  49168. /**
  49169. * Enable or disable the active meshes evaluation time capture
  49170. */
  49171. captureActiveMeshesEvaluationTime: boolean;
  49172. /**
  49173. * Gets the perf counter used for render targets render time
  49174. */
  49175. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49176. /**
  49177. * Gets the render targets render time capture status
  49178. */
  49179. /**
  49180. * Enable or disable the render targets render time capture
  49181. */
  49182. captureRenderTargetsRenderTime: boolean;
  49183. /**
  49184. * Gets the perf counter used for particles render time
  49185. */
  49186. readonly particlesRenderTimeCounter: PerfCounter;
  49187. /**
  49188. * Gets the particles render time capture status
  49189. */
  49190. /**
  49191. * Enable or disable the particles render time capture
  49192. */
  49193. captureParticlesRenderTime: boolean;
  49194. /**
  49195. * Gets the perf counter used for sprites render time
  49196. */
  49197. readonly spritesRenderTimeCounter: PerfCounter;
  49198. /**
  49199. * Gets the sprites render time capture status
  49200. */
  49201. /**
  49202. * Enable or disable the sprites render time capture
  49203. */
  49204. captureSpritesRenderTime: boolean;
  49205. /**
  49206. * Gets the perf counter used for physics time
  49207. */
  49208. readonly physicsTimeCounter: PerfCounter;
  49209. /**
  49210. * Gets the physics time capture status
  49211. */
  49212. /**
  49213. * Enable or disable the physics time capture
  49214. */
  49215. capturePhysicsTime: boolean;
  49216. /**
  49217. * Gets the perf counter used for animations time
  49218. */
  49219. readonly animationsTimeCounter: PerfCounter;
  49220. /**
  49221. * Gets the animations time capture status
  49222. */
  49223. /**
  49224. * Enable or disable the animations time capture
  49225. */
  49226. captureAnimationsTime: boolean;
  49227. /**
  49228. * Gets the perf counter used for frame time capture
  49229. */
  49230. readonly frameTimeCounter: PerfCounter;
  49231. /**
  49232. * Gets the frame time capture status
  49233. */
  49234. /**
  49235. * Enable or disable the frame time capture
  49236. */
  49237. captureFrameTime: boolean;
  49238. /**
  49239. * Gets the perf counter used for inter-frames time capture
  49240. */
  49241. readonly interFrameTimeCounter: PerfCounter;
  49242. /**
  49243. * Gets the inter-frames time capture status
  49244. */
  49245. /**
  49246. * Enable or disable the inter-frames time capture
  49247. */
  49248. captureInterFrameTime: boolean;
  49249. /**
  49250. * Gets the perf counter used for render time capture
  49251. */
  49252. readonly renderTimeCounter: PerfCounter;
  49253. /**
  49254. * Gets the render time capture status
  49255. */
  49256. /**
  49257. * Enable or disable the render time capture
  49258. */
  49259. captureRenderTime: boolean;
  49260. /**
  49261. * Gets the perf counter used for camera render time capture
  49262. */
  49263. readonly cameraRenderTimeCounter: PerfCounter;
  49264. /**
  49265. * Gets the camera render time capture status
  49266. */
  49267. /**
  49268. * Enable or disable the camera render time capture
  49269. */
  49270. captureCameraRenderTime: boolean;
  49271. /**
  49272. * Gets the perf counter used for draw calls
  49273. */
  49274. readonly drawCallsCounter: PerfCounter;
  49275. /**
  49276. * Instantiates a new scene instrumentation.
  49277. * This class can be used to get instrumentation data from a Babylon engine
  49278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49279. * @param scene Defines the scene to instrument
  49280. */
  49281. constructor(
  49282. /**
  49283. * Defines the scene to instrument
  49284. */
  49285. scene: Scene);
  49286. /**
  49287. * Dispose and release associated resources.
  49288. */
  49289. dispose(): void;
  49290. }
  49291. }
  49292. declare module BABYLON {
  49293. /** @hidden */
  49294. export var glowMapGenerationPixelShader: {
  49295. name: string;
  49296. shader: string;
  49297. };
  49298. }
  49299. declare module BABYLON {
  49300. /** @hidden */
  49301. export var glowMapGenerationVertexShader: {
  49302. name: string;
  49303. shader: string;
  49304. };
  49305. }
  49306. declare module BABYLON {
  49307. /**
  49308. * Effect layer options. This helps customizing the behaviour
  49309. * of the effect layer.
  49310. */
  49311. export interface IEffectLayerOptions {
  49312. /**
  49313. * Multiplication factor apply to the canvas size to compute the render target size
  49314. * used to generated the objects (the smaller the faster).
  49315. */
  49316. mainTextureRatio: number;
  49317. /**
  49318. * Enforces a fixed size texture to ensure effect stability across devices.
  49319. */
  49320. mainTextureFixedSize?: number;
  49321. /**
  49322. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49323. */
  49324. alphaBlendingMode: number;
  49325. /**
  49326. * The camera attached to the layer.
  49327. */
  49328. camera: Nullable<Camera>;
  49329. /**
  49330. * The rendering group to draw the layer in.
  49331. */
  49332. renderingGroupId: number;
  49333. }
  49334. /**
  49335. * The effect layer Helps adding post process effect blended with the main pass.
  49336. *
  49337. * This can be for instance use to generate glow or higlight effects on the scene.
  49338. *
  49339. * The effect layer class can not be used directly and is intented to inherited from to be
  49340. * customized per effects.
  49341. */
  49342. export abstract class EffectLayer {
  49343. private _vertexBuffers;
  49344. private _indexBuffer;
  49345. private _cachedDefines;
  49346. private _effectLayerMapGenerationEffect;
  49347. private _effectLayerOptions;
  49348. private _mergeEffect;
  49349. protected _scene: Scene;
  49350. protected _engine: Engine;
  49351. protected _maxSize: number;
  49352. protected _mainTextureDesiredSize: ISize;
  49353. protected _mainTexture: RenderTargetTexture;
  49354. protected _shouldRender: boolean;
  49355. protected _postProcesses: PostProcess[];
  49356. protected _textures: BaseTexture[];
  49357. protected _emissiveTextureAndColor: {
  49358. texture: Nullable<BaseTexture>;
  49359. color: Color4;
  49360. };
  49361. /**
  49362. * The name of the layer
  49363. */
  49364. name: string;
  49365. /**
  49366. * The clear color of the texture used to generate the glow map.
  49367. */
  49368. neutralColor: Color4;
  49369. /**
  49370. * Specifies wether the highlight layer is enabled or not.
  49371. */
  49372. isEnabled: boolean;
  49373. /**
  49374. * Gets the camera attached to the layer.
  49375. */
  49376. readonly camera: Nullable<Camera>;
  49377. /**
  49378. * Gets the rendering group id the layer should render in.
  49379. */
  49380. renderingGroupId: number;
  49381. /**
  49382. * An event triggered when the effect layer has been disposed.
  49383. */
  49384. onDisposeObservable: Observable<EffectLayer>;
  49385. /**
  49386. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49387. */
  49388. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49389. /**
  49390. * An event triggered when the generated texture is being merged in the scene.
  49391. */
  49392. onBeforeComposeObservable: Observable<EffectLayer>;
  49393. /**
  49394. * An event triggered when the generated texture has been merged in the scene.
  49395. */
  49396. onAfterComposeObservable: Observable<EffectLayer>;
  49397. /**
  49398. * An event triggered when the efffect layer changes its size.
  49399. */
  49400. onSizeChangedObservable: Observable<EffectLayer>;
  49401. /** @hidden */
  49402. static _SceneComponentInitialization: (scene: Scene) => void;
  49403. /**
  49404. * Instantiates a new effect Layer and references it in the scene.
  49405. * @param name The name of the layer
  49406. * @param scene The scene to use the layer in
  49407. */
  49408. constructor(
  49409. /** The Friendly of the effect in the scene */
  49410. name: string, scene: Scene);
  49411. /**
  49412. * Get the effect name of the layer.
  49413. * @return The effect name
  49414. */
  49415. abstract getEffectName(): string;
  49416. /**
  49417. * Checks for the readiness of the element composing the layer.
  49418. * @param subMesh the mesh to check for
  49419. * @param useInstances specify wether or not to use instances to render the mesh
  49420. * @return true if ready otherwise, false
  49421. */
  49422. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49423. /**
  49424. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49425. * @returns true if the effect requires stencil during the main canvas render pass.
  49426. */
  49427. abstract needStencil(): boolean;
  49428. /**
  49429. * Create the merge effect. This is the shader use to blit the information back
  49430. * to the main canvas at the end of the scene rendering.
  49431. * @returns The effect containing the shader used to merge the effect on the main canvas
  49432. */
  49433. protected abstract _createMergeEffect(): Effect;
  49434. /**
  49435. * Creates the render target textures and post processes used in the effect layer.
  49436. */
  49437. protected abstract _createTextureAndPostProcesses(): void;
  49438. /**
  49439. * Implementation specific of rendering the generating effect on the main canvas.
  49440. * @param effect The effect used to render through
  49441. */
  49442. protected abstract _internalRender(effect: Effect): void;
  49443. /**
  49444. * Sets the required values for both the emissive texture and and the main color.
  49445. */
  49446. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49447. /**
  49448. * Free any resources and references associated to a mesh.
  49449. * Internal use
  49450. * @param mesh The mesh to free.
  49451. */
  49452. abstract _disposeMesh(mesh: Mesh): void;
  49453. /**
  49454. * Serializes this layer (Glow or Highlight for example)
  49455. * @returns a serialized layer object
  49456. */
  49457. abstract serialize?(): any;
  49458. /**
  49459. * Initializes the effect layer with the required options.
  49460. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49461. */
  49462. protected _init(options: Partial<IEffectLayerOptions>): void;
  49463. /**
  49464. * Generates the index buffer of the full screen quad blending to the main canvas.
  49465. */
  49466. private _generateIndexBuffer;
  49467. /**
  49468. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49469. */
  49470. private _generateVertexBuffer;
  49471. /**
  49472. * Sets the main texture desired size which is the closest power of two
  49473. * of the engine canvas size.
  49474. */
  49475. private _setMainTextureSize;
  49476. /**
  49477. * Creates the main texture for the effect layer.
  49478. */
  49479. protected _createMainTexture(): void;
  49480. /**
  49481. * Adds specific effects defines.
  49482. * @param defines The defines to add specifics to.
  49483. */
  49484. protected _addCustomEffectDefines(defines: string[]): void;
  49485. /**
  49486. * Checks for the readiness of the element composing the layer.
  49487. * @param subMesh the mesh to check for
  49488. * @param useInstances specify wether or not to use instances to render the mesh
  49489. * @param emissiveTexture the associated emissive texture used to generate the glow
  49490. * @return true if ready otherwise, false
  49491. */
  49492. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49493. /**
  49494. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49495. */
  49496. render(): void;
  49497. /**
  49498. * Determine if a given mesh will be used in the current effect.
  49499. * @param mesh mesh to test
  49500. * @returns true if the mesh will be used
  49501. */
  49502. hasMesh(mesh: AbstractMesh): boolean;
  49503. /**
  49504. * Returns true if the layer contains information to display, otherwise false.
  49505. * @returns true if the glow layer should be rendered
  49506. */
  49507. shouldRender(): boolean;
  49508. /**
  49509. * Returns true if the mesh should render, otherwise false.
  49510. * @param mesh The mesh to render
  49511. * @returns true if it should render otherwise false
  49512. */
  49513. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49514. /**
  49515. * Returns true if the mesh can be rendered, otherwise false.
  49516. * @param mesh The mesh to render
  49517. * @param material The material used on the mesh
  49518. * @returns true if it can be rendered otherwise false
  49519. */
  49520. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49521. /**
  49522. * Returns true if the mesh should render, otherwise false.
  49523. * @param mesh The mesh to render
  49524. * @returns true if it should render otherwise false
  49525. */
  49526. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49527. /**
  49528. * Renders the submesh passed in parameter to the generation map.
  49529. */
  49530. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49531. /**
  49532. * Rebuild the required buffers.
  49533. * @hidden Internal use only.
  49534. */
  49535. _rebuild(): void;
  49536. /**
  49537. * Dispose only the render target textures and post process.
  49538. */
  49539. private _disposeTextureAndPostProcesses;
  49540. /**
  49541. * Dispose the highlight layer and free resources.
  49542. */
  49543. dispose(): void;
  49544. /**
  49545. * Gets the class name of the effect layer
  49546. * @returns the string with the class name of the effect layer
  49547. */
  49548. getClassName(): string;
  49549. /**
  49550. * Creates an effect layer from parsed effect layer data
  49551. * @param parsedEffectLayer defines effect layer data
  49552. * @param scene defines the current scene
  49553. * @param rootUrl defines the root URL containing the effect layer information
  49554. * @returns a parsed effect Layer
  49555. */
  49556. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49557. }
  49558. }
  49559. declare module BABYLON {
  49560. interface AbstractScene {
  49561. /**
  49562. * The list of effect layers (highlights/glow) added to the scene
  49563. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49564. * @see http://doc.babylonjs.com/how_to/glow_layer
  49565. */
  49566. effectLayers: Array<EffectLayer>;
  49567. /**
  49568. * Removes the given effect layer from this scene.
  49569. * @param toRemove defines the effect layer to remove
  49570. * @returns the index of the removed effect layer
  49571. */
  49572. removeEffectLayer(toRemove: EffectLayer): number;
  49573. /**
  49574. * Adds the given effect layer to this scene
  49575. * @param newEffectLayer defines the effect layer to add
  49576. */
  49577. addEffectLayer(newEffectLayer: EffectLayer): void;
  49578. }
  49579. /**
  49580. * Defines the layer scene component responsible to manage any effect layers
  49581. * in a given scene.
  49582. */
  49583. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49584. /**
  49585. * The component name helpfull to identify the component in the list of scene components.
  49586. */
  49587. readonly name: string;
  49588. /**
  49589. * The scene the component belongs to.
  49590. */
  49591. scene: Scene;
  49592. private _engine;
  49593. private _renderEffects;
  49594. private _needStencil;
  49595. private _previousStencilState;
  49596. /**
  49597. * Creates a new instance of the component for the given scene
  49598. * @param scene Defines the scene to register the component in
  49599. */
  49600. constructor(scene: Scene);
  49601. /**
  49602. * Registers the component in a given scene
  49603. */
  49604. register(): void;
  49605. /**
  49606. * Rebuilds the elements related to this component in case of
  49607. * context lost for instance.
  49608. */
  49609. rebuild(): void;
  49610. /**
  49611. * Serializes the component data to the specified json object
  49612. * @param serializationObject The object to serialize to
  49613. */
  49614. serialize(serializationObject: any): void;
  49615. /**
  49616. * Adds all the elements from the container to the scene
  49617. * @param container the container holding the elements
  49618. */
  49619. addFromContainer(container: AbstractScene): void;
  49620. /**
  49621. * Removes all the elements in the container from the scene
  49622. * @param container contains the elements to remove
  49623. * @param dispose if the removed element should be disposed (default: false)
  49624. */
  49625. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49626. /**
  49627. * Disposes the component and the associated ressources.
  49628. */
  49629. dispose(): void;
  49630. private _isReadyForMesh;
  49631. private _renderMainTexture;
  49632. private _setStencil;
  49633. private _setStencilBack;
  49634. private _draw;
  49635. private _drawCamera;
  49636. private _drawRenderingGroup;
  49637. }
  49638. }
  49639. declare module BABYLON {
  49640. /** @hidden */
  49641. export var glowMapMergePixelShader: {
  49642. name: string;
  49643. shader: string;
  49644. };
  49645. }
  49646. declare module BABYLON {
  49647. /** @hidden */
  49648. export var glowMapMergeVertexShader: {
  49649. name: string;
  49650. shader: string;
  49651. };
  49652. }
  49653. declare module BABYLON {
  49654. interface AbstractScene {
  49655. /**
  49656. * Return a the first highlight layer of the scene with a given name.
  49657. * @param name The name of the highlight layer to look for.
  49658. * @return The highlight layer if found otherwise null.
  49659. */
  49660. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49661. }
  49662. /**
  49663. * Glow layer options. This helps customizing the behaviour
  49664. * of the glow layer.
  49665. */
  49666. export interface IGlowLayerOptions {
  49667. /**
  49668. * Multiplication factor apply to the canvas size to compute the render target size
  49669. * used to generated the glowing objects (the smaller the faster).
  49670. */
  49671. mainTextureRatio: number;
  49672. /**
  49673. * Enforces a fixed size texture to ensure resize independant blur.
  49674. */
  49675. mainTextureFixedSize?: number;
  49676. /**
  49677. * How big is the kernel of the blur texture.
  49678. */
  49679. blurKernelSize: number;
  49680. /**
  49681. * The camera attached to the layer.
  49682. */
  49683. camera: Nullable<Camera>;
  49684. /**
  49685. * Enable MSAA by chosing the number of samples.
  49686. */
  49687. mainTextureSamples?: number;
  49688. /**
  49689. * The rendering group to draw the layer in.
  49690. */
  49691. renderingGroupId: number;
  49692. }
  49693. /**
  49694. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49695. *
  49696. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49697. * glowy meshes to your scene.
  49698. *
  49699. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49700. */
  49701. export class GlowLayer extends EffectLayer {
  49702. /**
  49703. * Effect Name of the layer.
  49704. */
  49705. static readonly EffectName: string;
  49706. /**
  49707. * The default blur kernel size used for the glow.
  49708. */
  49709. static DefaultBlurKernelSize: number;
  49710. /**
  49711. * The default texture size ratio used for the glow.
  49712. */
  49713. static DefaultTextureRatio: number;
  49714. /**
  49715. * Sets the kernel size of the blur.
  49716. */
  49717. /**
  49718. * Gets the kernel size of the blur.
  49719. */
  49720. blurKernelSize: number;
  49721. /**
  49722. * Sets the glow intensity.
  49723. */
  49724. /**
  49725. * Gets the glow intensity.
  49726. */
  49727. intensity: number;
  49728. private _options;
  49729. private _intensity;
  49730. private _horizontalBlurPostprocess1;
  49731. private _verticalBlurPostprocess1;
  49732. private _horizontalBlurPostprocess2;
  49733. private _verticalBlurPostprocess2;
  49734. private _blurTexture1;
  49735. private _blurTexture2;
  49736. private _postProcesses1;
  49737. private _postProcesses2;
  49738. private _includedOnlyMeshes;
  49739. private _excludedMeshes;
  49740. /**
  49741. * Callback used to let the user override the color selection on a per mesh basis
  49742. */
  49743. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49744. /**
  49745. * Callback used to let the user override the texture selection on a per mesh basis
  49746. */
  49747. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49748. /**
  49749. * Instantiates a new glow Layer and references it to the scene.
  49750. * @param name The name of the layer
  49751. * @param scene The scene to use the layer in
  49752. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49753. */
  49754. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49755. /**
  49756. * Get the effect name of the layer.
  49757. * @return The effect name
  49758. */
  49759. getEffectName(): string;
  49760. /**
  49761. * Create the merge effect. This is the shader use to blit the information back
  49762. * to the main canvas at the end of the scene rendering.
  49763. */
  49764. protected _createMergeEffect(): Effect;
  49765. /**
  49766. * Creates the render target textures and post processes used in the glow layer.
  49767. */
  49768. protected _createTextureAndPostProcesses(): void;
  49769. /**
  49770. * Checks for the readiness of the element composing the layer.
  49771. * @param subMesh the mesh to check for
  49772. * @param useInstances specify wether or not to use instances to render the mesh
  49773. * @param emissiveTexture the associated emissive texture used to generate the glow
  49774. * @return true if ready otherwise, false
  49775. */
  49776. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49777. /**
  49778. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49779. */
  49780. needStencil(): boolean;
  49781. /**
  49782. * Returns true if the mesh can be rendered, otherwise false.
  49783. * @param mesh The mesh to render
  49784. * @param material The material used on the mesh
  49785. * @returns true if it can be rendered otherwise false
  49786. */
  49787. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49788. /**
  49789. * Implementation specific of rendering the generating effect on the main canvas.
  49790. * @param effect The effect used to render through
  49791. */
  49792. protected _internalRender(effect: Effect): void;
  49793. /**
  49794. * Sets the required values for both the emissive texture and and the main color.
  49795. */
  49796. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49797. /**
  49798. * Returns true if the mesh should render, otherwise false.
  49799. * @param mesh The mesh to render
  49800. * @returns true if it should render otherwise false
  49801. */
  49802. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49803. /**
  49804. * Adds specific effects defines.
  49805. * @param defines The defines to add specifics to.
  49806. */
  49807. protected _addCustomEffectDefines(defines: string[]): void;
  49808. /**
  49809. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49810. * @param mesh The mesh to exclude from the glow layer
  49811. */
  49812. addExcludedMesh(mesh: Mesh): void;
  49813. /**
  49814. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49815. * @param mesh The mesh to remove
  49816. */
  49817. removeExcludedMesh(mesh: Mesh): void;
  49818. /**
  49819. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49820. * @param mesh The mesh to include in the glow layer
  49821. */
  49822. addIncludedOnlyMesh(mesh: Mesh): void;
  49823. /**
  49824. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49825. * @param mesh The mesh to remove
  49826. */
  49827. removeIncludedOnlyMesh(mesh: Mesh): void;
  49828. /**
  49829. * Determine if a given mesh will be used in the glow layer
  49830. * @param mesh The mesh to test
  49831. * @returns true if the mesh will be highlighted by the current glow layer
  49832. */
  49833. hasMesh(mesh: AbstractMesh): boolean;
  49834. /**
  49835. * Free any resources and references associated to a mesh.
  49836. * Internal use
  49837. * @param mesh The mesh to free.
  49838. * @hidden
  49839. */
  49840. _disposeMesh(mesh: Mesh): void;
  49841. /**
  49842. * Gets the class name of the effect layer
  49843. * @returns the string with the class name of the effect layer
  49844. */
  49845. getClassName(): string;
  49846. /**
  49847. * Serializes this glow layer
  49848. * @returns a serialized glow layer object
  49849. */
  49850. serialize(): any;
  49851. /**
  49852. * Creates a Glow Layer from parsed glow layer data
  49853. * @param parsedGlowLayer defines glow layer data
  49854. * @param scene defines the current scene
  49855. * @param rootUrl defines the root URL containing the glow layer information
  49856. * @returns a parsed Glow Layer
  49857. */
  49858. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49859. }
  49860. }
  49861. declare module BABYLON {
  49862. /** @hidden */
  49863. export var glowBlurPostProcessPixelShader: {
  49864. name: string;
  49865. shader: string;
  49866. };
  49867. }
  49868. declare module BABYLON {
  49869. interface AbstractScene {
  49870. /**
  49871. * Return a the first highlight layer of the scene with a given name.
  49872. * @param name The name of the highlight layer to look for.
  49873. * @return The highlight layer if found otherwise null.
  49874. */
  49875. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49876. }
  49877. /**
  49878. * Highlight layer options. This helps customizing the behaviour
  49879. * of the highlight layer.
  49880. */
  49881. export interface IHighlightLayerOptions {
  49882. /**
  49883. * Multiplication factor apply to the canvas size to compute the render target size
  49884. * used to generated the glowing objects (the smaller the faster).
  49885. */
  49886. mainTextureRatio: number;
  49887. /**
  49888. * Enforces a fixed size texture to ensure resize independant blur.
  49889. */
  49890. mainTextureFixedSize?: number;
  49891. /**
  49892. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49893. * of the picture to blur (the smaller the faster).
  49894. */
  49895. blurTextureSizeRatio: number;
  49896. /**
  49897. * How big in texel of the blur texture is the vertical blur.
  49898. */
  49899. blurVerticalSize: number;
  49900. /**
  49901. * How big in texel of the blur texture is the horizontal blur.
  49902. */
  49903. blurHorizontalSize: number;
  49904. /**
  49905. * Alpha blending mode used to apply the blur. Default is combine.
  49906. */
  49907. alphaBlendingMode: number;
  49908. /**
  49909. * The camera attached to the layer.
  49910. */
  49911. camera: Nullable<Camera>;
  49912. /**
  49913. * Should we display highlight as a solid stroke?
  49914. */
  49915. isStroke?: boolean;
  49916. /**
  49917. * The rendering group to draw the layer in.
  49918. */
  49919. renderingGroupId: number;
  49920. }
  49921. /**
  49922. * The highlight layer Helps adding a glow effect around a mesh.
  49923. *
  49924. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49925. * glowy meshes to your scene.
  49926. *
  49927. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49928. */
  49929. export class HighlightLayer extends EffectLayer {
  49930. name: string;
  49931. /**
  49932. * Effect Name of the highlight layer.
  49933. */
  49934. static readonly EffectName: string;
  49935. /**
  49936. * The neutral color used during the preparation of the glow effect.
  49937. * This is black by default as the blend operation is a blend operation.
  49938. */
  49939. static NeutralColor: Color4;
  49940. /**
  49941. * Stencil value used for glowing meshes.
  49942. */
  49943. static GlowingMeshStencilReference: number;
  49944. /**
  49945. * Stencil value used for the other meshes in the scene.
  49946. */
  49947. static NormalMeshStencilReference: number;
  49948. /**
  49949. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49950. */
  49951. innerGlow: boolean;
  49952. /**
  49953. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49954. */
  49955. outerGlow: boolean;
  49956. /**
  49957. * Specifies the horizontal size of the blur.
  49958. */
  49959. /**
  49960. * Gets the horizontal size of the blur.
  49961. */
  49962. blurHorizontalSize: number;
  49963. /**
  49964. * Specifies the vertical size of the blur.
  49965. */
  49966. /**
  49967. * Gets the vertical size of the blur.
  49968. */
  49969. blurVerticalSize: number;
  49970. /**
  49971. * An event triggered when the highlight layer is being blurred.
  49972. */
  49973. onBeforeBlurObservable: Observable<HighlightLayer>;
  49974. /**
  49975. * An event triggered when the highlight layer has been blurred.
  49976. */
  49977. onAfterBlurObservable: Observable<HighlightLayer>;
  49978. private _instanceGlowingMeshStencilReference;
  49979. private _options;
  49980. private _downSamplePostprocess;
  49981. private _horizontalBlurPostprocess;
  49982. private _verticalBlurPostprocess;
  49983. private _blurTexture;
  49984. private _meshes;
  49985. private _excludedMeshes;
  49986. /**
  49987. * Instantiates a new highlight Layer and references it to the scene..
  49988. * @param name The name of the layer
  49989. * @param scene The scene to use the layer in
  49990. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49991. */
  49992. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49993. /**
  49994. * Get the effect name of the layer.
  49995. * @return The effect name
  49996. */
  49997. getEffectName(): string;
  49998. /**
  49999. * Create the merge effect. This is the shader use to blit the information back
  50000. * to the main canvas at the end of the scene rendering.
  50001. */
  50002. protected _createMergeEffect(): Effect;
  50003. /**
  50004. * Creates the render target textures and post processes used in the highlight layer.
  50005. */
  50006. protected _createTextureAndPostProcesses(): void;
  50007. /**
  50008. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50009. */
  50010. needStencil(): boolean;
  50011. /**
  50012. * Checks for the readiness of the element composing the layer.
  50013. * @param subMesh the mesh to check for
  50014. * @param useInstances specify wether or not to use instances to render the mesh
  50015. * @param emissiveTexture the associated emissive texture used to generate the glow
  50016. * @return true if ready otherwise, false
  50017. */
  50018. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50019. /**
  50020. * Implementation specific of rendering the generating effect on the main canvas.
  50021. * @param effect The effect used to render through
  50022. */
  50023. protected _internalRender(effect: Effect): void;
  50024. /**
  50025. * Returns true if the layer contains information to display, otherwise false.
  50026. */
  50027. shouldRender(): boolean;
  50028. /**
  50029. * Returns true if the mesh should render, otherwise false.
  50030. * @param mesh The mesh to render
  50031. * @returns true if it should render otherwise false
  50032. */
  50033. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50034. /**
  50035. * Sets the required values for both the emissive texture and and the main color.
  50036. */
  50037. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50038. /**
  50039. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50040. * @param mesh The mesh to exclude from the highlight layer
  50041. */
  50042. addExcludedMesh(mesh: Mesh): void;
  50043. /**
  50044. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50045. * @param mesh The mesh to highlight
  50046. */
  50047. removeExcludedMesh(mesh: Mesh): void;
  50048. /**
  50049. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50050. * @param mesh mesh to test
  50051. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50052. */
  50053. hasMesh(mesh: AbstractMesh): boolean;
  50054. /**
  50055. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50056. * @param mesh The mesh to highlight
  50057. * @param color The color of the highlight
  50058. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50059. */
  50060. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50061. /**
  50062. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50063. * @param mesh The mesh to highlight
  50064. */
  50065. removeMesh(mesh: Mesh): void;
  50066. /**
  50067. * Force the stencil to the normal expected value for none glowing parts
  50068. */
  50069. private _defaultStencilReference;
  50070. /**
  50071. * Free any resources and references associated to a mesh.
  50072. * Internal use
  50073. * @param mesh The mesh to free.
  50074. * @hidden
  50075. */
  50076. _disposeMesh(mesh: Mesh): void;
  50077. /**
  50078. * Dispose the highlight layer and free resources.
  50079. */
  50080. dispose(): void;
  50081. /**
  50082. * Gets the class name of the effect layer
  50083. * @returns the string with the class name of the effect layer
  50084. */
  50085. getClassName(): string;
  50086. /**
  50087. * Serializes this Highlight layer
  50088. * @returns a serialized Highlight layer object
  50089. */
  50090. serialize(): any;
  50091. /**
  50092. * Creates a Highlight layer from parsed Highlight layer data
  50093. * @param parsedHightlightLayer defines the Highlight layer data
  50094. * @param scene defines the current scene
  50095. * @param rootUrl defines the root URL containing the Highlight layer information
  50096. * @returns a parsed Highlight layer
  50097. */
  50098. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50099. }
  50100. }
  50101. declare module BABYLON {
  50102. interface AbstractScene {
  50103. /**
  50104. * The list of layers (background and foreground) of the scene
  50105. */
  50106. layers: Array<Layer>;
  50107. }
  50108. /**
  50109. * Defines the layer scene component responsible to manage any layers
  50110. * in a given scene.
  50111. */
  50112. export class LayerSceneComponent implements ISceneComponent {
  50113. /**
  50114. * The component name helpfull to identify the component in the list of scene components.
  50115. */
  50116. readonly name: string;
  50117. /**
  50118. * The scene the component belongs to.
  50119. */
  50120. scene: Scene;
  50121. private _engine;
  50122. /**
  50123. * Creates a new instance of the component for the given scene
  50124. * @param scene Defines the scene to register the component in
  50125. */
  50126. constructor(scene: Scene);
  50127. /**
  50128. * Registers the component in a given scene
  50129. */
  50130. register(): void;
  50131. /**
  50132. * Rebuilds the elements related to this component in case of
  50133. * context lost for instance.
  50134. */
  50135. rebuild(): void;
  50136. /**
  50137. * Disposes the component and the associated ressources.
  50138. */
  50139. dispose(): void;
  50140. private _draw;
  50141. private _drawCameraPredicate;
  50142. private _drawCameraBackground;
  50143. private _drawCameraForeground;
  50144. private _drawRenderTargetPredicate;
  50145. private _drawRenderTargetBackground;
  50146. private _drawRenderTargetForeground;
  50147. /**
  50148. * Adds all the elements from the container to the scene
  50149. * @param container the container holding the elements
  50150. */
  50151. addFromContainer(container: AbstractScene): void;
  50152. /**
  50153. * Removes all the elements in the container from the scene
  50154. * @param container contains the elements to remove
  50155. * @param dispose if the removed element should be disposed (default: false)
  50156. */
  50157. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50158. }
  50159. }
  50160. declare module BABYLON {
  50161. /** @hidden */
  50162. export var layerPixelShader: {
  50163. name: string;
  50164. shader: string;
  50165. };
  50166. }
  50167. declare module BABYLON {
  50168. /** @hidden */
  50169. export var layerVertexShader: {
  50170. name: string;
  50171. shader: string;
  50172. };
  50173. }
  50174. declare module BABYLON {
  50175. /**
  50176. * This represents a full screen 2d layer.
  50177. * This can be useful to display a picture in the background of your scene for instance.
  50178. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50179. */
  50180. export class Layer {
  50181. /**
  50182. * Define the name of the layer.
  50183. */
  50184. name: string;
  50185. /**
  50186. * Define the texture the layer should display.
  50187. */
  50188. texture: Nullable<Texture>;
  50189. /**
  50190. * Is the layer in background or foreground.
  50191. */
  50192. isBackground: boolean;
  50193. /**
  50194. * Define the color of the layer (instead of texture).
  50195. */
  50196. color: Color4;
  50197. /**
  50198. * Define the scale of the layer in order to zoom in out of the texture.
  50199. */
  50200. scale: Vector2;
  50201. /**
  50202. * Define an offset for the layer in order to shift the texture.
  50203. */
  50204. offset: Vector2;
  50205. /**
  50206. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50207. */
  50208. alphaBlendingMode: number;
  50209. /**
  50210. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50211. * Alpha test will not mix with the background color in case of transparency.
  50212. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50213. */
  50214. alphaTest: boolean;
  50215. /**
  50216. * Define a mask to restrict the layer to only some of the scene cameras.
  50217. */
  50218. layerMask: number;
  50219. /**
  50220. * Define the list of render target the layer is visible into.
  50221. */
  50222. renderTargetTextures: RenderTargetTexture[];
  50223. /**
  50224. * Define if the layer is only used in renderTarget or if it also
  50225. * renders in the main frame buffer of the canvas.
  50226. */
  50227. renderOnlyInRenderTargetTextures: boolean;
  50228. private _scene;
  50229. private _vertexBuffers;
  50230. private _indexBuffer;
  50231. private _effect;
  50232. private _alphaTestEffect;
  50233. /**
  50234. * An event triggered when the layer is disposed.
  50235. */
  50236. onDisposeObservable: Observable<Layer>;
  50237. private _onDisposeObserver;
  50238. /**
  50239. * Back compatibility with callback before the onDisposeObservable existed.
  50240. * The set callback will be triggered when the layer has been disposed.
  50241. */
  50242. onDispose: () => void;
  50243. /**
  50244. * An event triggered before rendering the scene
  50245. */
  50246. onBeforeRenderObservable: Observable<Layer>;
  50247. private _onBeforeRenderObserver;
  50248. /**
  50249. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50250. * The set callback will be triggered just before rendering the layer.
  50251. */
  50252. onBeforeRender: () => void;
  50253. /**
  50254. * An event triggered after rendering the scene
  50255. */
  50256. onAfterRenderObservable: Observable<Layer>;
  50257. private _onAfterRenderObserver;
  50258. /**
  50259. * Back compatibility with callback before the onAfterRenderObservable existed.
  50260. * The set callback will be triggered just after rendering the layer.
  50261. */
  50262. onAfterRender: () => void;
  50263. /**
  50264. * Instantiates a new layer.
  50265. * This represents a full screen 2d layer.
  50266. * This can be useful to display a picture in the background of your scene for instance.
  50267. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50268. * @param name Define the name of the layer in the scene
  50269. * @param imgUrl Define the url of the texture to display in the layer
  50270. * @param scene Define the scene the layer belongs to
  50271. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50272. * @param color Defines a color for the layer
  50273. */
  50274. constructor(
  50275. /**
  50276. * Define the name of the layer.
  50277. */
  50278. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50279. private _createIndexBuffer;
  50280. /** @hidden */
  50281. _rebuild(): void;
  50282. /**
  50283. * Renders the layer in the scene.
  50284. */
  50285. render(): void;
  50286. /**
  50287. * Disposes and releases the associated ressources.
  50288. */
  50289. dispose(): void;
  50290. }
  50291. }
  50292. declare module BABYLON {
  50293. /** @hidden */
  50294. export var lensFlarePixelShader: {
  50295. name: string;
  50296. shader: string;
  50297. };
  50298. }
  50299. declare module BABYLON {
  50300. /** @hidden */
  50301. export var lensFlareVertexShader: {
  50302. name: string;
  50303. shader: string;
  50304. };
  50305. }
  50306. declare module BABYLON {
  50307. /**
  50308. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50309. * It is usually composed of several `lensFlare`.
  50310. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50311. */
  50312. export class LensFlareSystem {
  50313. /**
  50314. * Define the name of the lens flare system
  50315. */
  50316. name: string;
  50317. /**
  50318. * List of lens flares used in this system.
  50319. */
  50320. lensFlares: LensFlare[];
  50321. /**
  50322. * Define a limit from the border the lens flare can be visible.
  50323. */
  50324. borderLimit: number;
  50325. /**
  50326. * Define a viewport border we do not want to see the lens flare in.
  50327. */
  50328. viewportBorder: number;
  50329. /**
  50330. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50331. */
  50332. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50333. /**
  50334. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50335. */
  50336. layerMask: number;
  50337. /**
  50338. * Define the id of the lens flare system in the scene.
  50339. * (equal to name by default)
  50340. */
  50341. id: string;
  50342. private _scene;
  50343. private _emitter;
  50344. private _vertexBuffers;
  50345. private _indexBuffer;
  50346. private _effect;
  50347. private _positionX;
  50348. private _positionY;
  50349. private _isEnabled;
  50350. /** @hidden */
  50351. static _SceneComponentInitialization: (scene: Scene) => void;
  50352. /**
  50353. * Instantiates a lens flare system.
  50354. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50355. * It is usually composed of several `lensFlare`.
  50356. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50357. * @param name Define the name of the lens flare system in the scene
  50358. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50359. * @param scene Define the scene the lens flare system belongs to
  50360. */
  50361. constructor(
  50362. /**
  50363. * Define the name of the lens flare system
  50364. */
  50365. name: string, emitter: any, scene: Scene);
  50366. /**
  50367. * Define if the lens flare system is enabled.
  50368. */
  50369. isEnabled: boolean;
  50370. /**
  50371. * Get the scene the effects belongs to.
  50372. * @returns the scene holding the lens flare system
  50373. */
  50374. getScene(): Scene;
  50375. /**
  50376. * Get the emitter of the lens flare system.
  50377. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50378. * @returns the emitter of the lens flare system
  50379. */
  50380. getEmitter(): any;
  50381. /**
  50382. * Set the emitter of the lens flare system.
  50383. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50384. * @param newEmitter Define the new emitter of the system
  50385. */
  50386. setEmitter(newEmitter: any): void;
  50387. /**
  50388. * Get the lens flare system emitter position.
  50389. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50390. * @returns the position
  50391. */
  50392. getEmitterPosition(): Vector3;
  50393. /**
  50394. * @hidden
  50395. */
  50396. computeEffectivePosition(globalViewport: Viewport): boolean;
  50397. /** @hidden */
  50398. _isVisible(): boolean;
  50399. /**
  50400. * @hidden
  50401. */
  50402. render(): boolean;
  50403. /**
  50404. * Dispose and release the lens flare with its associated resources.
  50405. */
  50406. dispose(): void;
  50407. /**
  50408. * Parse a lens flare system from a JSON repressentation
  50409. * @param parsedLensFlareSystem Define the JSON to parse
  50410. * @param scene Define the scene the parsed system should be instantiated in
  50411. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50412. * @returns the parsed system
  50413. */
  50414. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50415. /**
  50416. * Serialize the current Lens Flare System into a JSON representation.
  50417. * @returns the serialized JSON
  50418. */
  50419. serialize(): any;
  50420. }
  50421. }
  50422. declare module BABYLON {
  50423. /**
  50424. * This represents one of the lens effect in a `lensFlareSystem`.
  50425. * It controls one of the indiviual texture used in the effect.
  50426. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50427. */
  50428. export class LensFlare {
  50429. /**
  50430. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50431. */
  50432. size: number;
  50433. /**
  50434. * 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.
  50435. */
  50436. position: number;
  50437. /**
  50438. * Define the lens color.
  50439. */
  50440. color: Color3;
  50441. /**
  50442. * Define the lens texture.
  50443. */
  50444. texture: Nullable<Texture>;
  50445. /**
  50446. * Define the alpha mode to render this particular lens.
  50447. */
  50448. alphaMode: number;
  50449. private _system;
  50450. /**
  50451. * Creates a new Lens Flare.
  50452. * This represents one of the lens effect in a `lensFlareSystem`.
  50453. * It controls one of the indiviual texture used in the effect.
  50454. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50455. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50456. * @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.
  50457. * @param color Define the lens color
  50458. * @param imgUrl Define the lens texture url
  50459. * @param system Define the `lensFlareSystem` this flare is part of
  50460. * @returns The newly created Lens Flare
  50461. */
  50462. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50463. /**
  50464. * Instantiates a new Lens Flare.
  50465. * This represents one of the lens effect in a `lensFlareSystem`.
  50466. * It controls one of the indiviual texture used in the effect.
  50467. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50468. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50469. * @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.
  50470. * @param color Define the lens color
  50471. * @param imgUrl Define the lens texture url
  50472. * @param system Define the `lensFlareSystem` this flare is part of
  50473. */
  50474. constructor(
  50475. /**
  50476. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50477. */
  50478. size: number,
  50479. /**
  50480. * 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.
  50481. */
  50482. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50483. /**
  50484. * Dispose and release the lens flare with its associated resources.
  50485. */
  50486. dispose(): void;
  50487. }
  50488. }
  50489. declare module BABYLON {
  50490. interface AbstractScene {
  50491. /**
  50492. * The list of lens flare system added to the scene
  50493. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50494. */
  50495. lensFlareSystems: Array<LensFlareSystem>;
  50496. /**
  50497. * Removes the given lens flare system from this scene.
  50498. * @param toRemove The lens flare system to remove
  50499. * @returns The index of the removed lens flare system
  50500. */
  50501. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50502. /**
  50503. * Adds the given lens flare system to this scene
  50504. * @param newLensFlareSystem The lens flare system to add
  50505. */
  50506. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50507. /**
  50508. * Gets a lens flare system using its name
  50509. * @param name defines the name to look for
  50510. * @returns the lens flare system or null if not found
  50511. */
  50512. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50513. /**
  50514. * Gets a lens flare system using its id
  50515. * @param id defines the id to look for
  50516. * @returns the lens flare system or null if not found
  50517. */
  50518. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50519. }
  50520. /**
  50521. * Defines the lens flare scene component responsible to manage any lens flares
  50522. * in a given scene.
  50523. */
  50524. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50525. /**
  50526. * The component name helpfull to identify the component in the list of scene components.
  50527. */
  50528. readonly name: string;
  50529. /**
  50530. * The scene the component belongs to.
  50531. */
  50532. scene: Scene;
  50533. /**
  50534. * Creates a new instance of the component for the given scene
  50535. * @param scene Defines the scene to register the component in
  50536. */
  50537. constructor(scene: Scene);
  50538. /**
  50539. * Registers the component in a given scene
  50540. */
  50541. register(): void;
  50542. /**
  50543. * Rebuilds the elements related to this component in case of
  50544. * context lost for instance.
  50545. */
  50546. rebuild(): void;
  50547. /**
  50548. * Adds all the elements from the container to the scene
  50549. * @param container the container holding the elements
  50550. */
  50551. addFromContainer(container: AbstractScene): void;
  50552. /**
  50553. * Removes all the elements in the container from the scene
  50554. * @param container contains the elements to remove
  50555. * @param dispose if the removed element should be disposed (default: false)
  50556. */
  50557. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50558. /**
  50559. * Serializes the component data to the specified json object
  50560. * @param serializationObject The object to serialize to
  50561. */
  50562. serialize(serializationObject: any): void;
  50563. /**
  50564. * Disposes the component and the associated ressources.
  50565. */
  50566. dispose(): void;
  50567. private _draw;
  50568. }
  50569. }
  50570. declare module BABYLON {
  50571. /**
  50572. * Defines the shadow generator component responsible to manage any shadow generators
  50573. * in a given scene.
  50574. */
  50575. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50576. /**
  50577. * The component name helpfull to identify the component in the list of scene components.
  50578. */
  50579. readonly name: string;
  50580. /**
  50581. * The scene the component belongs to.
  50582. */
  50583. scene: Scene;
  50584. /**
  50585. * Creates a new instance of the component for the given scene
  50586. * @param scene Defines the scene to register the component in
  50587. */
  50588. constructor(scene: Scene);
  50589. /**
  50590. * Registers the component in a given scene
  50591. */
  50592. register(): void;
  50593. /**
  50594. * Rebuilds the elements related to this component in case of
  50595. * context lost for instance.
  50596. */
  50597. rebuild(): void;
  50598. /**
  50599. * Serializes the component data to the specified json object
  50600. * @param serializationObject The object to serialize to
  50601. */
  50602. serialize(serializationObject: any): void;
  50603. /**
  50604. * Adds all the elements from the container to the scene
  50605. * @param container the container holding the elements
  50606. */
  50607. addFromContainer(container: AbstractScene): void;
  50608. /**
  50609. * Removes all the elements in the container from the scene
  50610. * @param container contains the elements to remove
  50611. * @param dispose if the removed element should be disposed (default: false)
  50612. */
  50613. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50614. /**
  50615. * Rebuilds the elements related to this component in case of
  50616. * context lost for instance.
  50617. */
  50618. dispose(): void;
  50619. private _gatherRenderTargets;
  50620. }
  50621. }
  50622. declare module BABYLON {
  50623. /**
  50624. * A point light is a light defined by an unique point in world space.
  50625. * The light is emitted in every direction from this point.
  50626. * A good example of a point light is a standard light bulb.
  50627. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50628. */
  50629. export class PointLight extends ShadowLight {
  50630. private _shadowAngle;
  50631. /**
  50632. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50633. * This specifies what angle the shadow will use to be created.
  50634. *
  50635. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50636. */
  50637. /**
  50638. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50639. * This specifies what angle the shadow will use to be created.
  50640. *
  50641. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50642. */
  50643. shadowAngle: number;
  50644. /**
  50645. * Gets the direction if it has been set.
  50646. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50647. */
  50648. /**
  50649. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50650. */
  50651. direction: Vector3;
  50652. /**
  50653. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50654. * A PointLight emits the light in every direction.
  50655. * It can cast shadows.
  50656. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50657. * ```javascript
  50658. * var pointLight = new PointLight("pl", camera.position, scene);
  50659. * ```
  50660. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50661. * @param name The light friendly name
  50662. * @param position The position of the point light in the scene
  50663. * @param scene The scene the lights belongs to
  50664. */
  50665. constructor(name: string, position: Vector3, scene: Scene);
  50666. /**
  50667. * Returns the string "PointLight"
  50668. * @returns the class name
  50669. */
  50670. getClassName(): string;
  50671. /**
  50672. * Returns the integer 0.
  50673. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50674. */
  50675. getTypeID(): number;
  50676. /**
  50677. * Specifies wether or not the shadowmap should be a cube texture.
  50678. * @returns true if the shadowmap needs to be a cube texture.
  50679. */
  50680. needCube(): boolean;
  50681. /**
  50682. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50683. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50684. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50685. */
  50686. getShadowDirection(faceIndex?: number): Vector3;
  50687. /**
  50688. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50689. * - fov = PI / 2
  50690. * - aspect ratio : 1.0
  50691. * - z-near and far equal to the active camera minZ and maxZ.
  50692. * Returns the PointLight.
  50693. */
  50694. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50695. protected _buildUniformLayout(): void;
  50696. /**
  50697. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50698. * @param effect The effect to update
  50699. * @param lightIndex The index of the light in the effect to update
  50700. * @returns The point light
  50701. */
  50702. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50703. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50704. /**
  50705. * Prepares the list of defines specific to the light type.
  50706. * @param defines the list of defines
  50707. * @param lightIndex defines the index of the light for the effect
  50708. */
  50709. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50710. }
  50711. }
  50712. declare module BABYLON {
  50713. /**
  50714. * Header information of HDR texture files.
  50715. */
  50716. export interface HDRInfo {
  50717. /**
  50718. * The height of the texture in pixels.
  50719. */
  50720. height: number;
  50721. /**
  50722. * The width of the texture in pixels.
  50723. */
  50724. width: number;
  50725. /**
  50726. * The index of the beginning of the data in the binary file.
  50727. */
  50728. dataPosition: number;
  50729. }
  50730. /**
  50731. * This groups tools to convert HDR texture to native colors array.
  50732. */
  50733. export class HDRTools {
  50734. private static Ldexp;
  50735. private static Rgbe2float;
  50736. private static readStringLine;
  50737. /**
  50738. * Reads header information from an RGBE texture stored in a native array.
  50739. * More information on this format are available here:
  50740. * https://en.wikipedia.org/wiki/RGBE_image_format
  50741. *
  50742. * @param uint8array The binary file stored in native array.
  50743. * @return The header information.
  50744. */
  50745. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50746. /**
  50747. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50748. * This RGBE texture needs to store the information as a panorama.
  50749. *
  50750. * More information on this format are available here:
  50751. * https://en.wikipedia.org/wiki/RGBE_image_format
  50752. *
  50753. * @param buffer The binary file stored in an array buffer.
  50754. * @param size The expected size of the extracted cubemap.
  50755. * @return The Cube Map information.
  50756. */
  50757. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50758. /**
  50759. * Returns the pixels data extracted from an RGBE texture.
  50760. * This pixels will be stored left to right up to down in the R G B order in one array.
  50761. *
  50762. * More information on this format are available here:
  50763. * https://en.wikipedia.org/wiki/RGBE_image_format
  50764. *
  50765. * @param uint8array The binary file stored in an array buffer.
  50766. * @param hdrInfo The header information of the file.
  50767. * @return The pixels data in RGB right to left up to down order.
  50768. */
  50769. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50770. private static RGBE_ReadPixels_RLE;
  50771. }
  50772. }
  50773. declare module BABYLON {
  50774. /**
  50775. * This represents a texture coming from an HDR input.
  50776. *
  50777. * The only supported format is currently panorama picture stored in RGBE format.
  50778. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50779. */
  50780. export class HDRCubeTexture extends BaseTexture {
  50781. private static _facesMapping;
  50782. private _generateHarmonics;
  50783. private _noMipmap;
  50784. private _textureMatrix;
  50785. private _size;
  50786. private _onLoad;
  50787. private _onError;
  50788. /**
  50789. * The texture URL.
  50790. */
  50791. url: string;
  50792. /**
  50793. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50794. */
  50795. coordinatesMode: number;
  50796. protected _isBlocking: boolean;
  50797. /**
  50798. * Sets wether or not the texture is blocking during loading.
  50799. */
  50800. /**
  50801. * Gets wether or not the texture is blocking during loading.
  50802. */
  50803. isBlocking: boolean;
  50804. protected _rotationY: number;
  50805. /**
  50806. * Sets texture matrix rotation angle around Y axis in radians.
  50807. */
  50808. /**
  50809. * Gets texture matrix rotation angle around Y axis radians.
  50810. */
  50811. rotationY: number;
  50812. /**
  50813. * Gets or sets the center of the bounding box associated with the cube texture
  50814. * It must define where the camera used to render the texture was set
  50815. */
  50816. boundingBoxPosition: Vector3;
  50817. private _boundingBoxSize;
  50818. /**
  50819. * Gets or sets the size of the bounding box associated with the cube texture
  50820. * When defined, the cubemap will switch to local mode
  50821. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50822. * @example https://www.babylonjs-playground.com/#RNASML
  50823. */
  50824. boundingBoxSize: Vector3;
  50825. /**
  50826. * Instantiates an HDRTexture from the following parameters.
  50827. *
  50828. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50829. * @param scene The scene the texture will be used in
  50830. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50831. * @param noMipmap Forces to not generate the mipmap if true
  50832. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50833. * @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)
  50834. * @param reserved Reserved flag for internal use.
  50835. */
  50836. 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>);
  50837. /**
  50838. * Get the current class name of the texture useful for serialization or dynamic coding.
  50839. * @returns "HDRCubeTexture"
  50840. */
  50841. getClassName(): string;
  50842. /**
  50843. * Occurs when the file is raw .hdr file.
  50844. */
  50845. private loadTexture;
  50846. clone(): HDRCubeTexture;
  50847. delayLoad(): void;
  50848. /**
  50849. * Get the texture reflection matrix used to rotate/transform the reflection.
  50850. * @returns the reflection matrix
  50851. */
  50852. getReflectionTextureMatrix(): Matrix;
  50853. /**
  50854. * Set the texture reflection matrix used to rotate/transform the reflection.
  50855. * @param value Define the reflection matrix to set
  50856. */
  50857. setReflectionTextureMatrix(value: Matrix): void;
  50858. /**
  50859. * Parses a JSON representation of an HDR Texture in order to create the texture
  50860. * @param parsedTexture Define the JSON representation
  50861. * @param scene Define the scene the texture should be created in
  50862. * @param rootUrl Define the root url in case we need to load relative dependencies
  50863. * @returns the newly created texture after parsing
  50864. */
  50865. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50866. serialize(): any;
  50867. }
  50868. }
  50869. declare module BABYLON {
  50870. /**
  50871. * Class used to control physics engine
  50872. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50873. */
  50874. export class PhysicsEngine implements IPhysicsEngine {
  50875. private _physicsPlugin;
  50876. /**
  50877. * Global value used to control the smallest number supported by the simulation
  50878. */
  50879. static Epsilon: number;
  50880. private _impostors;
  50881. private _joints;
  50882. /**
  50883. * Gets the gravity vector used by the simulation
  50884. */
  50885. gravity: Vector3;
  50886. /**
  50887. * Factory used to create the default physics plugin.
  50888. * @returns The default physics plugin
  50889. */
  50890. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50891. /**
  50892. * Creates a new Physics Engine
  50893. * @param gravity defines the gravity vector used by the simulation
  50894. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50895. */
  50896. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50897. /**
  50898. * Sets the gravity vector used by the simulation
  50899. * @param gravity defines the gravity vector to use
  50900. */
  50901. setGravity(gravity: Vector3): void;
  50902. /**
  50903. * Set the time step of the physics engine.
  50904. * Default is 1/60.
  50905. * To slow it down, enter 1/600 for example.
  50906. * To speed it up, 1/30
  50907. * @param newTimeStep defines the new timestep to apply to this world.
  50908. */
  50909. setTimeStep(newTimeStep?: number): void;
  50910. /**
  50911. * Get the time step of the physics engine.
  50912. * @returns the current time step
  50913. */
  50914. getTimeStep(): number;
  50915. /**
  50916. * Release all resources
  50917. */
  50918. dispose(): void;
  50919. /**
  50920. * Gets the name of the current physics plugin
  50921. * @returns the name of the plugin
  50922. */
  50923. getPhysicsPluginName(): string;
  50924. /**
  50925. * Adding a new impostor for the impostor tracking.
  50926. * This will be done by the impostor itself.
  50927. * @param impostor the impostor to add
  50928. */
  50929. addImpostor(impostor: PhysicsImpostor): void;
  50930. /**
  50931. * Remove an impostor from the engine.
  50932. * This impostor and its mesh will not longer be updated by the physics engine.
  50933. * @param impostor the impostor to remove
  50934. */
  50935. removeImpostor(impostor: PhysicsImpostor): void;
  50936. /**
  50937. * Add a joint to the physics engine
  50938. * @param mainImpostor defines the main impostor to which the joint is added.
  50939. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50940. * @param joint defines the joint that will connect both impostors.
  50941. */
  50942. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50943. /**
  50944. * Removes a joint from the simulation
  50945. * @param mainImpostor defines the impostor used with the joint
  50946. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50947. * @param joint defines the joint to remove
  50948. */
  50949. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50950. /**
  50951. * Called by the scene. No need to call it.
  50952. * @param delta defines the timespam between frames
  50953. */
  50954. _step(delta: number): void;
  50955. /**
  50956. * Gets the current plugin used to run the simulation
  50957. * @returns current plugin
  50958. */
  50959. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50960. /**
  50961. * Gets the list of physic impostors
  50962. * @returns an array of PhysicsImpostor
  50963. */
  50964. getImpostors(): Array<PhysicsImpostor>;
  50965. /**
  50966. * Gets the impostor for a physics enabled object
  50967. * @param object defines the object impersonated by the impostor
  50968. * @returns the PhysicsImpostor or null if not found
  50969. */
  50970. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50971. /**
  50972. * Gets the impostor for a physics body object
  50973. * @param body defines physics body used by the impostor
  50974. * @returns the PhysicsImpostor or null if not found
  50975. */
  50976. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50977. /**
  50978. * Does a raycast in the physics world
  50979. * @param from when should the ray start?
  50980. * @param to when should the ray end?
  50981. * @returns PhysicsRaycastResult
  50982. */
  50983. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50984. }
  50985. }
  50986. declare module BABYLON {
  50987. /** @hidden */
  50988. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50989. private _useDeltaForWorldStep;
  50990. world: any;
  50991. name: string;
  50992. private _physicsMaterials;
  50993. private _fixedTimeStep;
  50994. private _cannonRaycastResult;
  50995. private _raycastResult;
  50996. private _physicsBodysToRemoveAfterStep;
  50997. BJSCANNON: any;
  50998. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50999. setGravity(gravity: Vector3): void;
  51000. setTimeStep(timeStep: number): void;
  51001. getTimeStep(): number;
  51002. executeStep(delta: number): void;
  51003. private _removeMarkedPhysicsBodiesFromWorld;
  51004. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51005. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51006. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51007. private _processChildMeshes;
  51008. removePhysicsBody(impostor: PhysicsImpostor): void;
  51009. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51010. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51011. private _addMaterial;
  51012. private _checkWithEpsilon;
  51013. private _createShape;
  51014. private _createHeightmap;
  51015. private _minus90X;
  51016. private _plus90X;
  51017. private _tmpPosition;
  51018. private _tmpDeltaPosition;
  51019. private _tmpUnityRotation;
  51020. private _updatePhysicsBodyTransformation;
  51021. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51022. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51023. isSupported(): boolean;
  51024. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51025. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51026. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51027. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51028. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51029. getBodyMass(impostor: PhysicsImpostor): number;
  51030. getBodyFriction(impostor: PhysicsImpostor): number;
  51031. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51032. getBodyRestitution(impostor: PhysicsImpostor): number;
  51033. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51034. sleepBody(impostor: PhysicsImpostor): void;
  51035. wakeUpBody(impostor: PhysicsImpostor): void;
  51036. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51037. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51038. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51039. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51040. getRadius(impostor: PhysicsImpostor): number;
  51041. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51042. dispose(): void;
  51043. private _extendNamespace;
  51044. /**
  51045. * Does a raycast in the physics world
  51046. * @param from when should the ray start?
  51047. * @param to when should the ray end?
  51048. * @returns PhysicsRaycastResult
  51049. */
  51050. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51051. }
  51052. }
  51053. declare module BABYLON {
  51054. /** @hidden */
  51055. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51056. world: any;
  51057. name: string;
  51058. BJSOIMO: any;
  51059. private _raycastResult;
  51060. constructor(iterations?: number, oimoInjection?: any);
  51061. setGravity(gravity: Vector3): void;
  51062. setTimeStep(timeStep: number): void;
  51063. getTimeStep(): number;
  51064. private _tmpImpostorsArray;
  51065. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51066. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51067. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51068. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51069. private _tmpPositionVector;
  51070. removePhysicsBody(impostor: PhysicsImpostor): void;
  51071. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51072. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51073. isSupported(): boolean;
  51074. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51075. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51076. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51077. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51078. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51079. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51080. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51081. getBodyMass(impostor: PhysicsImpostor): number;
  51082. getBodyFriction(impostor: PhysicsImpostor): number;
  51083. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51084. getBodyRestitution(impostor: PhysicsImpostor): number;
  51085. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51086. sleepBody(impostor: PhysicsImpostor): void;
  51087. wakeUpBody(impostor: PhysicsImpostor): void;
  51088. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51089. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51090. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51091. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51092. getRadius(impostor: PhysicsImpostor): number;
  51093. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51094. dispose(): void;
  51095. /**
  51096. * Does a raycast in the physics world
  51097. * @param from when should the ray start?
  51098. * @param to when should the ray end?
  51099. * @returns PhysicsRaycastResult
  51100. */
  51101. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51102. }
  51103. }
  51104. declare module BABYLON {
  51105. /**
  51106. * Class containing static functions to help procedurally build meshes
  51107. */
  51108. export class RibbonBuilder {
  51109. /**
  51110. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51111. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51112. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51113. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51114. * * 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
  51115. * * 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
  51116. * * 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
  51117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51118. * * 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
  51119. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51120. * * 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
  51121. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51122. * * 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
  51123. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51125. * @param name defines the name of the mesh
  51126. * @param options defines the options used to create the mesh
  51127. * @param scene defines the hosting scene
  51128. * @returns the ribbon mesh
  51129. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51130. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51131. */
  51132. static CreateRibbon(name: string, options: {
  51133. pathArray: Vector3[][];
  51134. closeArray?: boolean;
  51135. closePath?: boolean;
  51136. offset?: number;
  51137. updatable?: boolean;
  51138. sideOrientation?: number;
  51139. frontUVs?: Vector4;
  51140. backUVs?: Vector4;
  51141. instance?: Mesh;
  51142. invertUV?: boolean;
  51143. uvs?: Vector2[];
  51144. colors?: Color4[];
  51145. }, scene?: Nullable<Scene>): Mesh;
  51146. }
  51147. }
  51148. declare module BABYLON {
  51149. /**
  51150. * Class containing static functions to help procedurally build meshes
  51151. */
  51152. export class ShapeBuilder {
  51153. /**
  51154. * 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.
  51155. * * 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.
  51156. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51157. * * 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.
  51158. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51159. * * 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
  51160. * * 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
  51161. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51163. * * 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
  51164. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51166. * @param name defines the name of the mesh
  51167. * @param options defines the options used to create the mesh
  51168. * @param scene defines the hosting scene
  51169. * @returns the extruded shape mesh
  51170. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51171. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51172. */
  51173. static ExtrudeShape(name: string, options: {
  51174. shape: Vector3[];
  51175. path: Vector3[];
  51176. scale?: number;
  51177. rotation?: number;
  51178. cap?: number;
  51179. updatable?: boolean;
  51180. sideOrientation?: number;
  51181. frontUVs?: Vector4;
  51182. backUVs?: Vector4;
  51183. instance?: Mesh;
  51184. invertUV?: boolean;
  51185. }, scene?: Nullable<Scene>): Mesh;
  51186. /**
  51187. * Creates an custom extruded shape mesh.
  51188. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51189. * * 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.
  51190. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51191. * * 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
  51192. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51193. * * 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
  51194. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51195. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51196. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51197. * * 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
  51198. * * 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
  51199. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51201. * * 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
  51202. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51204. * @param name defines the name of the mesh
  51205. * @param options defines the options used to create the mesh
  51206. * @param scene defines the hosting scene
  51207. * @returns the custom extruded shape mesh
  51208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51209. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51211. */
  51212. static ExtrudeShapeCustom(name: string, options: {
  51213. shape: Vector3[];
  51214. path: Vector3[];
  51215. scaleFunction?: any;
  51216. rotationFunction?: any;
  51217. ribbonCloseArray?: boolean;
  51218. ribbonClosePath?: boolean;
  51219. cap?: number;
  51220. updatable?: boolean;
  51221. sideOrientation?: number;
  51222. frontUVs?: Vector4;
  51223. backUVs?: Vector4;
  51224. instance?: Mesh;
  51225. invertUV?: boolean;
  51226. }, scene?: Nullable<Scene>): Mesh;
  51227. private static _ExtrudeShapeGeneric;
  51228. }
  51229. }
  51230. declare module BABYLON {
  51231. /**
  51232. * AmmoJS Physics plugin
  51233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51234. * @see https://github.com/kripken/ammo.js/
  51235. */
  51236. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51237. private _useDeltaForWorldStep;
  51238. /**
  51239. * Reference to the Ammo library
  51240. */
  51241. bjsAMMO: any;
  51242. /**
  51243. * Created ammoJS world which physics bodies are added to
  51244. */
  51245. world: any;
  51246. /**
  51247. * Name of the plugin
  51248. */
  51249. name: string;
  51250. private _timeStep;
  51251. private _fixedTimeStep;
  51252. private _maxSteps;
  51253. private _tmpQuaternion;
  51254. private _tmpAmmoTransform;
  51255. private _tmpAmmoQuaternion;
  51256. private _tmpAmmoConcreteContactResultCallback;
  51257. private _collisionConfiguration;
  51258. private _dispatcher;
  51259. private _overlappingPairCache;
  51260. private _solver;
  51261. private _softBodySolver;
  51262. private _tmpAmmoVectorA;
  51263. private _tmpAmmoVectorB;
  51264. private _tmpAmmoVectorC;
  51265. private _tmpAmmoVectorD;
  51266. private _tmpContactCallbackResult;
  51267. private _tmpAmmoVectorRCA;
  51268. private _tmpAmmoVectorRCB;
  51269. private _raycastResult;
  51270. private static readonly DISABLE_COLLISION_FLAG;
  51271. private static readonly KINEMATIC_FLAG;
  51272. private static readonly DISABLE_DEACTIVATION_FLAG;
  51273. /**
  51274. * Initializes the ammoJS plugin
  51275. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51276. * @param ammoInjection can be used to inject your own ammo reference
  51277. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51278. */
  51279. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51280. /**
  51281. * Sets the gravity of the physics world (m/(s^2))
  51282. * @param gravity Gravity to set
  51283. */
  51284. setGravity(gravity: Vector3): void;
  51285. /**
  51286. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51287. * @param timeStep timestep to use in seconds
  51288. */
  51289. setTimeStep(timeStep: number): void;
  51290. /**
  51291. * 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)
  51292. * @param fixedTimeStep fixedTimeStep to use in seconds
  51293. */
  51294. setFixedTimeStep(fixedTimeStep: number): void;
  51295. /**
  51296. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51297. * @param maxSteps the maximum number of steps by the physics engine per frame
  51298. */
  51299. setMaxSteps(maxSteps: number): void;
  51300. /**
  51301. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51302. * @returns the current timestep in seconds
  51303. */
  51304. getTimeStep(): number;
  51305. private _isImpostorInContact;
  51306. private _isImpostorPairInContact;
  51307. private _stepSimulation;
  51308. /**
  51309. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51310. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51311. * After the step the babylon meshes are set to the position of the physics imposters
  51312. * @param delta amount of time to step forward
  51313. * @param impostors array of imposters to update before/after the step
  51314. */
  51315. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51316. /**
  51317. * Update babylon mesh to match physics world object
  51318. * @param impostor imposter to match
  51319. */
  51320. private _afterSoftStep;
  51321. /**
  51322. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51323. * @param impostor imposter to match
  51324. */
  51325. private _ropeStep;
  51326. /**
  51327. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51328. * @param impostor imposter to match
  51329. */
  51330. private _softbodyOrClothStep;
  51331. private _tmpVector;
  51332. private _tmpMatrix;
  51333. /**
  51334. * Applies an impulse on the imposter
  51335. * @param impostor imposter to apply impulse to
  51336. * @param force amount of force to be applied to the imposter
  51337. * @param contactPoint the location to apply the impulse on the imposter
  51338. */
  51339. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51340. /**
  51341. * Applies a force on the imposter
  51342. * @param impostor imposter to apply force
  51343. * @param force amount of force to be applied to the imposter
  51344. * @param contactPoint the location to apply the force on the imposter
  51345. */
  51346. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51347. /**
  51348. * Creates a physics body using the plugin
  51349. * @param impostor the imposter to create the physics body on
  51350. */
  51351. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51352. /**
  51353. * Removes the physics body from the imposter and disposes of the body's memory
  51354. * @param impostor imposter to remove the physics body from
  51355. */
  51356. removePhysicsBody(impostor: PhysicsImpostor): void;
  51357. /**
  51358. * Generates a joint
  51359. * @param impostorJoint the imposter joint to create the joint with
  51360. */
  51361. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51362. /**
  51363. * Removes a joint
  51364. * @param impostorJoint the imposter joint to remove the joint from
  51365. */
  51366. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51367. private _addMeshVerts;
  51368. /**
  51369. * Initialise the soft body vertices to match its object's (mesh) vertices
  51370. * Softbody vertices (nodes) are in world space and to match this
  51371. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51372. * @param impostor to create the softbody for
  51373. */
  51374. private _softVertexData;
  51375. /**
  51376. * Create an impostor's soft body
  51377. * @param impostor to create the softbody for
  51378. */
  51379. private _createSoftbody;
  51380. /**
  51381. * Create cloth for an impostor
  51382. * @param impostor to create the softbody for
  51383. */
  51384. private _createCloth;
  51385. /**
  51386. * Create rope for an impostor
  51387. * @param impostor to create the softbody for
  51388. */
  51389. private _createRope;
  51390. private _addHullVerts;
  51391. private _createShape;
  51392. /**
  51393. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51394. * @param impostor imposter containing the physics body and babylon object
  51395. */
  51396. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51397. /**
  51398. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51399. * @param impostor imposter containing the physics body and babylon object
  51400. * @param newPosition new position
  51401. * @param newRotation new rotation
  51402. */
  51403. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51404. /**
  51405. * If this plugin is supported
  51406. * @returns true if its supported
  51407. */
  51408. isSupported(): boolean;
  51409. /**
  51410. * Sets the linear velocity of the physics body
  51411. * @param impostor imposter to set the velocity on
  51412. * @param velocity velocity to set
  51413. */
  51414. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51415. /**
  51416. * Sets the angular velocity of the physics body
  51417. * @param impostor imposter to set the velocity on
  51418. * @param velocity velocity to set
  51419. */
  51420. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51421. /**
  51422. * gets the linear velocity
  51423. * @param impostor imposter to get linear velocity from
  51424. * @returns linear velocity
  51425. */
  51426. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51427. /**
  51428. * gets the angular velocity
  51429. * @param impostor imposter to get angular velocity from
  51430. * @returns angular velocity
  51431. */
  51432. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51433. /**
  51434. * Sets the mass of physics body
  51435. * @param impostor imposter to set the mass on
  51436. * @param mass mass to set
  51437. */
  51438. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51439. /**
  51440. * Gets the mass of the physics body
  51441. * @param impostor imposter to get the mass from
  51442. * @returns mass
  51443. */
  51444. getBodyMass(impostor: PhysicsImpostor): number;
  51445. /**
  51446. * Gets friction of the impostor
  51447. * @param impostor impostor to get friction from
  51448. * @returns friction value
  51449. */
  51450. getBodyFriction(impostor: PhysicsImpostor): number;
  51451. /**
  51452. * Sets friction of the impostor
  51453. * @param impostor impostor to set friction on
  51454. * @param friction friction value
  51455. */
  51456. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51457. /**
  51458. * Gets restitution of the impostor
  51459. * @param impostor impostor to get restitution from
  51460. * @returns restitution value
  51461. */
  51462. getBodyRestitution(impostor: PhysicsImpostor): number;
  51463. /**
  51464. * Sets resitution of the impostor
  51465. * @param impostor impostor to set resitution on
  51466. * @param restitution resitution value
  51467. */
  51468. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51469. /**
  51470. * Gets pressure inside the impostor
  51471. * @param impostor impostor to get pressure from
  51472. * @returns pressure value
  51473. */
  51474. getBodyPressure(impostor: PhysicsImpostor): number;
  51475. /**
  51476. * Sets pressure inside a soft body impostor
  51477. * Cloth and rope must remain 0 pressure
  51478. * @param impostor impostor to set pressure on
  51479. * @param pressure pressure value
  51480. */
  51481. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51482. /**
  51483. * Gets stiffness of the impostor
  51484. * @param impostor impostor to get stiffness from
  51485. * @returns pressure value
  51486. */
  51487. getBodyStiffness(impostor: PhysicsImpostor): number;
  51488. /**
  51489. * Sets stiffness of the impostor
  51490. * @param impostor impostor to set stiffness on
  51491. * @param stiffness stiffness value from 0 to 1
  51492. */
  51493. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51494. /**
  51495. * Gets velocityIterations of the impostor
  51496. * @param impostor impostor to get velocity iterations from
  51497. * @returns velocityIterations value
  51498. */
  51499. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51500. /**
  51501. * Sets velocityIterations of the impostor
  51502. * @param impostor impostor to set velocity iterations on
  51503. * @param velocityIterations velocityIterations value
  51504. */
  51505. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51506. /**
  51507. * Gets positionIterations of the impostor
  51508. * @param impostor impostor to get position iterations from
  51509. * @returns positionIterations value
  51510. */
  51511. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51512. /**
  51513. * Sets positionIterations of the impostor
  51514. * @param impostor impostor to set position on
  51515. * @param positionIterations positionIterations value
  51516. */
  51517. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51518. /**
  51519. * Append an anchor to a cloth object
  51520. * @param impostor is the cloth impostor to add anchor to
  51521. * @param otherImpostor is the rigid impostor to anchor to
  51522. * @param width ratio across width from 0 to 1
  51523. * @param height ratio up height from 0 to 1
  51524. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51525. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51526. */
  51527. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51528. /**
  51529. * Append an hook to a rope object
  51530. * @param impostor is the rope impostor to add hook to
  51531. * @param otherImpostor is the rigid impostor to hook to
  51532. * @param length ratio along the rope from 0 to 1
  51533. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51534. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51535. */
  51536. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51537. /**
  51538. * Sleeps the physics body and stops it from being active
  51539. * @param impostor impostor to sleep
  51540. */
  51541. sleepBody(impostor: PhysicsImpostor): void;
  51542. /**
  51543. * Activates the physics body
  51544. * @param impostor impostor to activate
  51545. */
  51546. wakeUpBody(impostor: PhysicsImpostor): void;
  51547. /**
  51548. * Updates the distance parameters of the joint
  51549. * @param joint joint to update
  51550. * @param maxDistance maximum distance of the joint
  51551. * @param minDistance minimum distance of the joint
  51552. */
  51553. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51554. /**
  51555. * Sets a motor on the joint
  51556. * @param joint joint to set motor on
  51557. * @param speed speed of the motor
  51558. * @param maxForce maximum force of the motor
  51559. * @param motorIndex index of the motor
  51560. */
  51561. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51562. /**
  51563. * Sets the motors limit
  51564. * @param joint joint to set limit on
  51565. * @param upperLimit upper limit
  51566. * @param lowerLimit lower limit
  51567. */
  51568. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51569. /**
  51570. * Syncs the position and rotation of a mesh with the impostor
  51571. * @param mesh mesh to sync
  51572. * @param impostor impostor to update the mesh with
  51573. */
  51574. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51575. /**
  51576. * Gets the radius of the impostor
  51577. * @param impostor impostor to get radius from
  51578. * @returns the radius
  51579. */
  51580. getRadius(impostor: PhysicsImpostor): number;
  51581. /**
  51582. * Gets the box size of the impostor
  51583. * @param impostor impostor to get box size from
  51584. * @param result the resulting box size
  51585. */
  51586. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51587. /**
  51588. * Disposes of the impostor
  51589. */
  51590. dispose(): void;
  51591. /**
  51592. * Does a raycast in the physics world
  51593. * @param from when should the ray start?
  51594. * @param to when should the ray end?
  51595. * @returns PhysicsRaycastResult
  51596. */
  51597. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51598. }
  51599. }
  51600. declare module BABYLON {
  51601. interface AbstractScene {
  51602. /**
  51603. * The list of reflection probes added to the scene
  51604. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51605. */
  51606. reflectionProbes: Array<ReflectionProbe>;
  51607. /**
  51608. * Removes the given reflection probe from this scene.
  51609. * @param toRemove The reflection probe to remove
  51610. * @returns The index of the removed reflection probe
  51611. */
  51612. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51613. /**
  51614. * Adds the given reflection probe to this scene.
  51615. * @param newReflectionProbe The reflection probe to add
  51616. */
  51617. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51618. }
  51619. /**
  51620. * Class used to generate realtime reflection / refraction cube textures
  51621. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51622. */
  51623. export class ReflectionProbe {
  51624. /** defines the name of the probe */
  51625. name: string;
  51626. private _scene;
  51627. private _renderTargetTexture;
  51628. private _projectionMatrix;
  51629. private _viewMatrix;
  51630. private _target;
  51631. private _add;
  51632. private _attachedMesh;
  51633. private _invertYAxis;
  51634. /** Gets or sets probe position (center of the cube map) */
  51635. position: Vector3;
  51636. /**
  51637. * Creates a new reflection probe
  51638. * @param name defines the name of the probe
  51639. * @param size defines the texture resolution (for each face)
  51640. * @param scene defines the hosting scene
  51641. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51642. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51643. */
  51644. constructor(
  51645. /** defines the name of the probe */
  51646. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51647. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51648. samples: number;
  51649. /** Gets or sets the refresh rate to use (on every frame by default) */
  51650. refreshRate: number;
  51651. /**
  51652. * Gets the hosting scene
  51653. * @returns a Scene
  51654. */
  51655. getScene(): Scene;
  51656. /** Gets the internal CubeTexture used to render to */
  51657. readonly cubeTexture: RenderTargetTexture;
  51658. /** Gets the list of meshes to render */
  51659. readonly renderList: Nullable<AbstractMesh[]>;
  51660. /**
  51661. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51662. * @param mesh defines the mesh to attach to
  51663. */
  51664. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51665. /**
  51666. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51667. * @param renderingGroupId The rendering group id corresponding to its index
  51668. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51669. */
  51670. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51671. /**
  51672. * Clean all associated resources
  51673. */
  51674. dispose(): void;
  51675. /**
  51676. * Converts the reflection probe information to a readable string for debug purpose.
  51677. * @param fullDetails Supports for multiple levels of logging within scene loading
  51678. * @returns the human readable reflection probe info
  51679. */
  51680. toString(fullDetails?: boolean): string;
  51681. /**
  51682. * Get the class name of the relfection probe.
  51683. * @returns "ReflectionProbe"
  51684. */
  51685. getClassName(): string;
  51686. /**
  51687. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51688. * @returns The JSON representation of the texture
  51689. */
  51690. serialize(): any;
  51691. /**
  51692. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51693. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51694. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51695. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51696. * @returns The parsed reflection probe if successful
  51697. */
  51698. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51699. }
  51700. }
  51701. declare module BABYLON {
  51702. /** @hidden */
  51703. export var _BabylonLoaderRegistered: boolean;
  51704. }
  51705. declare module BABYLON {
  51706. /**
  51707. * The Physically based simple base material of BJS.
  51708. *
  51709. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51710. * It is used as the base class for both the specGloss and metalRough conventions.
  51711. */
  51712. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51713. /**
  51714. * Number of Simultaneous lights allowed on the material.
  51715. */
  51716. maxSimultaneousLights: number;
  51717. /**
  51718. * If sets to true, disables all the lights affecting the material.
  51719. */
  51720. disableLighting: boolean;
  51721. /**
  51722. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51723. */
  51724. environmentTexture: BaseTexture;
  51725. /**
  51726. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51727. */
  51728. invertNormalMapX: boolean;
  51729. /**
  51730. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51731. */
  51732. invertNormalMapY: boolean;
  51733. /**
  51734. * Normal map used in the model.
  51735. */
  51736. normalTexture: BaseTexture;
  51737. /**
  51738. * Emissivie color used to self-illuminate the model.
  51739. */
  51740. emissiveColor: Color3;
  51741. /**
  51742. * Emissivie texture used to self-illuminate the model.
  51743. */
  51744. emissiveTexture: BaseTexture;
  51745. /**
  51746. * Occlusion Channel Strenght.
  51747. */
  51748. occlusionStrength: number;
  51749. /**
  51750. * Occlusion Texture of the material (adding extra occlusion effects).
  51751. */
  51752. occlusionTexture: BaseTexture;
  51753. /**
  51754. * Defines the alpha limits in alpha test mode.
  51755. */
  51756. alphaCutOff: number;
  51757. /**
  51758. * Gets the current double sided mode.
  51759. */
  51760. /**
  51761. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51762. */
  51763. doubleSided: boolean;
  51764. /**
  51765. * Stores the pre-calculated light information of a mesh in a texture.
  51766. */
  51767. lightmapTexture: BaseTexture;
  51768. /**
  51769. * If true, the light map contains occlusion information instead of lighting info.
  51770. */
  51771. useLightmapAsShadowmap: boolean;
  51772. /**
  51773. * Instantiates a new PBRMaterial instance.
  51774. *
  51775. * @param name The material name
  51776. * @param scene The scene the material will be use in.
  51777. */
  51778. constructor(name: string, scene: Scene);
  51779. getClassName(): string;
  51780. }
  51781. }
  51782. declare module BABYLON {
  51783. /**
  51784. * The PBR material of BJS following the metal roughness convention.
  51785. *
  51786. * This fits to the PBR convention in the GLTF definition:
  51787. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51788. */
  51789. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51790. /**
  51791. * The base color has two different interpretations depending on the value of metalness.
  51792. * When the material is a metal, the base color is the specific measured reflectance value
  51793. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51794. * of the material.
  51795. */
  51796. baseColor: Color3;
  51797. /**
  51798. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51799. * well as opacity information in the alpha channel.
  51800. */
  51801. baseTexture: BaseTexture;
  51802. /**
  51803. * Specifies the metallic scalar value of the material.
  51804. * Can also be used to scale the metalness values of the metallic texture.
  51805. */
  51806. metallic: number;
  51807. /**
  51808. * Specifies the roughness scalar value of the material.
  51809. * Can also be used to scale the roughness values of the metallic texture.
  51810. */
  51811. roughness: number;
  51812. /**
  51813. * Texture containing both the metallic value in the B channel and the
  51814. * roughness value in the G channel to keep better precision.
  51815. */
  51816. metallicRoughnessTexture: BaseTexture;
  51817. /**
  51818. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51819. *
  51820. * @param name The material name
  51821. * @param scene The scene the material will be use in.
  51822. */
  51823. constructor(name: string, scene: Scene);
  51824. /**
  51825. * Return the currrent class name of the material.
  51826. */
  51827. getClassName(): string;
  51828. /**
  51829. * Makes a duplicate of the current material.
  51830. * @param name - name to use for the new material.
  51831. */
  51832. clone(name: string): PBRMetallicRoughnessMaterial;
  51833. /**
  51834. * Serialize the material to a parsable JSON object.
  51835. */
  51836. serialize(): any;
  51837. /**
  51838. * Parses a JSON object correponding to the serialize function.
  51839. */
  51840. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51841. }
  51842. }
  51843. declare module BABYLON {
  51844. /**
  51845. * The PBR material of BJS following the specular glossiness convention.
  51846. *
  51847. * This fits to the PBR convention in the GLTF definition:
  51848. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51849. */
  51850. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51851. /**
  51852. * Specifies the diffuse color of the material.
  51853. */
  51854. diffuseColor: Color3;
  51855. /**
  51856. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51857. * channel.
  51858. */
  51859. diffuseTexture: BaseTexture;
  51860. /**
  51861. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51862. */
  51863. specularColor: Color3;
  51864. /**
  51865. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51866. */
  51867. glossiness: number;
  51868. /**
  51869. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51870. */
  51871. specularGlossinessTexture: BaseTexture;
  51872. /**
  51873. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51874. *
  51875. * @param name The material name
  51876. * @param scene The scene the material will be use in.
  51877. */
  51878. constructor(name: string, scene: Scene);
  51879. /**
  51880. * Return the currrent class name of the material.
  51881. */
  51882. getClassName(): string;
  51883. /**
  51884. * Makes a duplicate of the current material.
  51885. * @param name - name to use for the new material.
  51886. */
  51887. clone(name: string): PBRSpecularGlossinessMaterial;
  51888. /**
  51889. * Serialize the material to a parsable JSON object.
  51890. */
  51891. serialize(): any;
  51892. /**
  51893. * Parses a JSON object correponding to the serialize function.
  51894. */
  51895. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51896. }
  51897. }
  51898. declare module BABYLON {
  51899. /**
  51900. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51901. * It can help converting any input color in a desired output one. This can then be used to create effects
  51902. * from sepia, black and white to sixties or futuristic rendering...
  51903. *
  51904. * The only supported format is currently 3dl.
  51905. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51906. */
  51907. export class ColorGradingTexture extends BaseTexture {
  51908. /**
  51909. * The current texture matrix. (will always be identity in color grading texture)
  51910. */
  51911. private _textureMatrix;
  51912. /**
  51913. * The texture URL.
  51914. */
  51915. url: string;
  51916. /**
  51917. * Empty line regex stored for GC.
  51918. */
  51919. private static _noneEmptyLineRegex;
  51920. private _engine;
  51921. /**
  51922. * Instantiates a ColorGradingTexture from the following parameters.
  51923. *
  51924. * @param url The location of the color gradind data (currently only supporting 3dl)
  51925. * @param scene The scene the texture will be used in
  51926. */
  51927. constructor(url: string, scene: Scene);
  51928. /**
  51929. * Returns the texture matrix used in most of the material.
  51930. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51931. */
  51932. getTextureMatrix(): Matrix;
  51933. /**
  51934. * Occurs when the file being loaded is a .3dl LUT file.
  51935. */
  51936. private load3dlTexture;
  51937. /**
  51938. * Starts the loading process of the texture.
  51939. */
  51940. private loadTexture;
  51941. /**
  51942. * Clones the color gradind texture.
  51943. */
  51944. clone(): ColorGradingTexture;
  51945. /**
  51946. * Called during delayed load for textures.
  51947. */
  51948. delayLoad(): void;
  51949. /**
  51950. * Parses a color grading texture serialized by Babylon.
  51951. * @param parsedTexture The texture information being parsedTexture
  51952. * @param scene The scene to load the texture in
  51953. * @param rootUrl The root url of the data assets to load
  51954. * @return A color gradind texture
  51955. */
  51956. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51957. /**
  51958. * Serializes the LUT texture to json format.
  51959. */
  51960. serialize(): any;
  51961. }
  51962. }
  51963. declare module BABYLON {
  51964. /**
  51965. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51966. */
  51967. export class EquiRectangularCubeTexture extends BaseTexture {
  51968. /** The six faces of the cube. */
  51969. private static _FacesMapping;
  51970. private _noMipmap;
  51971. private _onLoad;
  51972. private _onError;
  51973. /** The size of the cubemap. */
  51974. private _size;
  51975. /** The buffer of the image. */
  51976. private _buffer;
  51977. /** The width of the input image. */
  51978. private _width;
  51979. /** The height of the input image. */
  51980. private _height;
  51981. /** The URL to the image. */
  51982. url: string;
  51983. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51984. coordinatesMode: number;
  51985. /**
  51986. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51987. * @param url The location of the image
  51988. * @param scene The scene the texture will be used in
  51989. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51990. * @param noMipmap Forces to not generate the mipmap if true
  51991. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51992. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51993. * @param onLoad — defines a callback called when texture is loaded
  51994. * @param onError — defines a callback called if there is an error
  51995. */
  51996. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51997. /**
  51998. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51999. */
  52000. private loadImage;
  52001. /**
  52002. * Convert the image buffer into a cubemap and create a CubeTexture.
  52003. */
  52004. private loadTexture;
  52005. /**
  52006. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52007. * @param buffer The ArrayBuffer that should be converted.
  52008. * @returns The buffer as Float32Array.
  52009. */
  52010. private getFloat32ArrayFromArrayBuffer;
  52011. /**
  52012. * Get the current class name of the texture useful for serialization or dynamic coding.
  52013. * @returns "EquiRectangularCubeTexture"
  52014. */
  52015. getClassName(): string;
  52016. /**
  52017. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52018. * @returns A clone of the current EquiRectangularCubeTexture.
  52019. */
  52020. clone(): EquiRectangularCubeTexture;
  52021. }
  52022. }
  52023. declare module BABYLON {
  52024. /**
  52025. * Based on jsTGALoader - Javascript loader for TGA file
  52026. * By Vincent Thibault
  52027. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52028. */
  52029. export class TGATools {
  52030. private static _TYPE_INDEXED;
  52031. private static _TYPE_RGB;
  52032. private static _TYPE_GREY;
  52033. private static _TYPE_RLE_INDEXED;
  52034. private static _TYPE_RLE_RGB;
  52035. private static _TYPE_RLE_GREY;
  52036. private static _ORIGIN_MASK;
  52037. private static _ORIGIN_SHIFT;
  52038. private static _ORIGIN_BL;
  52039. private static _ORIGIN_BR;
  52040. private static _ORIGIN_UL;
  52041. private static _ORIGIN_UR;
  52042. /**
  52043. * Gets the header of a TGA file
  52044. * @param data defines the TGA data
  52045. * @returns the header
  52046. */
  52047. static GetTGAHeader(data: Uint8Array): any;
  52048. /**
  52049. * Uploads TGA content to a Babylon Texture
  52050. * @hidden
  52051. */
  52052. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52053. /** @hidden */
  52054. 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;
  52055. /** @hidden */
  52056. 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;
  52057. /** @hidden */
  52058. 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;
  52059. /** @hidden */
  52060. 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;
  52061. /** @hidden */
  52062. 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;
  52063. /** @hidden */
  52064. 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;
  52065. }
  52066. }
  52067. declare module BABYLON {
  52068. /**
  52069. * Implementation of the TGA Texture Loader.
  52070. * @hidden
  52071. */
  52072. export class _TGATextureLoader implements IInternalTextureLoader {
  52073. /**
  52074. * Defines wether the loader supports cascade loading the different faces.
  52075. */
  52076. readonly supportCascades: boolean;
  52077. /**
  52078. * This returns if the loader support the current file information.
  52079. * @param extension defines the file extension of the file being loaded
  52080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52081. * @param fallback defines the fallback internal texture if any
  52082. * @param isBase64 defines whether the texture is encoded as a base64
  52083. * @param isBuffer defines whether the texture data are stored as a buffer
  52084. * @returns true if the loader can load the specified file
  52085. */
  52086. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52087. /**
  52088. * Transform the url before loading if required.
  52089. * @param rootUrl the url of the texture
  52090. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52091. * @returns the transformed texture
  52092. */
  52093. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52094. /**
  52095. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52096. * @param rootUrl the url of the texture
  52097. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52098. * @returns the fallback texture
  52099. */
  52100. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52101. /**
  52102. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52103. * @param data contains the texture data
  52104. * @param texture defines the BabylonJS internal texture
  52105. * @param createPolynomials will be true if polynomials have been requested
  52106. * @param onLoad defines the callback to trigger once the texture is ready
  52107. * @param onError defines the callback to trigger in case of error
  52108. */
  52109. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52110. /**
  52111. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52112. * @param data contains the texture data
  52113. * @param texture defines the BabylonJS internal texture
  52114. * @param callback defines the method to call once ready to upload
  52115. */
  52116. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52117. }
  52118. }
  52119. declare module BABYLON {
  52120. /**
  52121. * Info about the .basis files
  52122. */
  52123. class BasisFileInfo {
  52124. /**
  52125. * If the file has alpha
  52126. */
  52127. hasAlpha: boolean;
  52128. /**
  52129. * Info about each image of the basis file
  52130. */
  52131. images: Array<{
  52132. levels: Array<{
  52133. width: number;
  52134. height: number;
  52135. transcodedPixels: ArrayBufferView;
  52136. }>;
  52137. }>;
  52138. }
  52139. /**
  52140. * Result of transcoding a basis file
  52141. */
  52142. class TranscodeResult {
  52143. /**
  52144. * Info about the .basis file
  52145. */
  52146. fileInfo: BasisFileInfo;
  52147. /**
  52148. * Format to use when loading the file
  52149. */
  52150. format: number;
  52151. }
  52152. /**
  52153. * Configuration options for the Basis transcoder
  52154. */
  52155. export class BasisTranscodeConfiguration {
  52156. /**
  52157. * Supported compression formats used to determine the supported output format of the transcoder
  52158. */
  52159. supportedCompressionFormats?: {
  52160. /**
  52161. * etc1 compression format
  52162. */
  52163. etc1?: boolean;
  52164. /**
  52165. * s3tc compression format
  52166. */
  52167. s3tc?: boolean;
  52168. /**
  52169. * pvrtc compression format
  52170. */
  52171. pvrtc?: boolean;
  52172. /**
  52173. * etc2 compression format
  52174. */
  52175. etc2?: boolean;
  52176. };
  52177. /**
  52178. * If mipmap levels should be loaded for transcoded images (Default: true)
  52179. */
  52180. loadMipmapLevels?: boolean;
  52181. /**
  52182. * Index of a single image to load (Default: all images)
  52183. */
  52184. loadSingleImage?: number;
  52185. }
  52186. /**
  52187. * Used to load .Basis files
  52188. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52189. */
  52190. export class BasisTools {
  52191. private static _IgnoreSupportedFormats;
  52192. /**
  52193. * URL to use when loading the basis transcoder
  52194. */
  52195. static JSModuleURL: string;
  52196. /**
  52197. * URL to use when loading the wasm module for the transcoder
  52198. */
  52199. static WasmModuleURL: string;
  52200. /**
  52201. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52202. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52203. * @returns internal format corresponding to the Basis format
  52204. */
  52205. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52206. private static _WorkerPromise;
  52207. private static _Worker;
  52208. private static _actionId;
  52209. private static _CreateWorkerAsync;
  52210. /**
  52211. * Transcodes a loaded image file to compressed pixel data
  52212. * @param imageData image data to transcode
  52213. * @param config configuration options for the transcoding
  52214. * @returns a promise resulting in the transcoded image
  52215. */
  52216. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52217. /**
  52218. * Loads a texture from the transcode result
  52219. * @param texture texture load to
  52220. * @param transcodeResult the result of transcoding the basis file to load from
  52221. */
  52222. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52223. }
  52224. }
  52225. declare module BABYLON {
  52226. /**
  52227. * Loader for .basis file format
  52228. */
  52229. export class _BasisTextureLoader implements IInternalTextureLoader {
  52230. /**
  52231. * Defines whether the loader supports cascade loading the different faces.
  52232. */
  52233. readonly supportCascades: boolean;
  52234. /**
  52235. * This returns if the loader support the current file information.
  52236. * @param extension defines the file extension of the file being loaded
  52237. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52238. * @param fallback defines the fallback internal texture if any
  52239. * @param isBase64 defines whether the texture is encoded as a base64
  52240. * @param isBuffer defines whether the texture data are stored as a buffer
  52241. * @returns true if the loader can load the specified file
  52242. */
  52243. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52244. /**
  52245. * Transform the url before loading if required.
  52246. * @param rootUrl the url of the texture
  52247. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52248. * @returns the transformed texture
  52249. */
  52250. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52251. /**
  52252. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52253. * @param rootUrl the url of the texture
  52254. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52255. * @returns the fallback texture
  52256. */
  52257. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52258. /**
  52259. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52260. * @param data contains the texture data
  52261. * @param texture defines the BabylonJS internal texture
  52262. * @param createPolynomials will be true if polynomials have been requested
  52263. * @param onLoad defines the callback to trigger once the texture is ready
  52264. * @param onError defines the callback to trigger in case of error
  52265. */
  52266. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52267. /**
  52268. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52269. * @param data contains the texture data
  52270. * @param texture defines the BabylonJS internal texture
  52271. * @param callback defines the method to call once ready to upload
  52272. */
  52273. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52274. }
  52275. }
  52276. declare module BABYLON {
  52277. /**
  52278. * 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.
  52279. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52280. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52281. */
  52282. export class CustomProceduralTexture extends ProceduralTexture {
  52283. private _animate;
  52284. private _time;
  52285. private _config;
  52286. private _texturePath;
  52287. /**
  52288. * Instantiates a new Custom Procedural Texture.
  52289. * 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.
  52290. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52291. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52292. * @param name Define the name of the texture
  52293. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52294. * @param size Define the size of the texture to create
  52295. * @param scene Define the scene the texture belongs to
  52296. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52297. * @param generateMipMaps Define if the texture should creates mip maps or not
  52298. */
  52299. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52300. private _loadJson;
  52301. /**
  52302. * Is the texture ready to be used ? (rendered at least once)
  52303. * @returns true if ready, otherwise, false.
  52304. */
  52305. isReady(): boolean;
  52306. /**
  52307. * Render the texture to its associated render target.
  52308. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52309. */
  52310. render(useCameraPostProcess?: boolean): void;
  52311. /**
  52312. * Update the list of dependant textures samplers in the shader.
  52313. */
  52314. updateTextures(): void;
  52315. /**
  52316. * Update the uniform values of the procedural texture in the shader.
  52317. */
  52318. updateShaderUniforms(): void;
  52319. /**
  52320. * Define if the texture animates or not.
  52321. */
  52322. animate: boolean;
  52323. }
  52324. }
  52325. declare module BABYLON {
  52326. /** @hidden */
  52327. export var noisePixelShader: {
  52328. name: string;
  52329. shader: string;
  52330. };
  52331. }
  52332. declare module BABYLON {
  52333. /**
  52334. * Class used to generate noise procedural textures
  52335. */
  52336. export class NoiseProceduralTexture extends ProceduralTexture {
  52337. private _time;
  52338. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52339. brightness: number;
  52340. /** Defines the number of octaves to process */
  52341. octaves: number;
  52342. /** Defines the level of persistence (0.8 by default) */
  52343. persistence: number;
  52344. /** Gets or sets animation speed factor (default is 1) */
  52345. animationSpeedFactor: number;
  52346. /**
  52347. * Creates a new NoiseProceduralTexture
  52348. * @param name defines the name fo the texture
  52349. * @param size defines the size of the texture (default is 256)
  52350. * @param scene defines the hosting scene
  52351. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52352. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52353. */
  52354. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52355. private _updateShaderUniforms;
  52356. protected _getDefines(): string;
  52357. /** Generate the current state of the procedural texture */
  52358. render(useCameraPostProcess?: boolean): void;
  52359. /**
  52360. * Serializes this noise procedural texture
  52361. * @returns a serialized noise procedural texture object
  52362. */
  52363. serialize(): any;
  52364. /**
  52365. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52366. * @param parsedTexture defines parsed texture data
  52367. * @param scene defines the current scene
  52368. * @param rootUrl defines the root URL containing noise procedural texture information
  52369. * @returns a parsed NoiseProceduralTexture
  52370. */
  52371. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52372. }
  52373. }
  52374. declare module BABYLON {
  52375. /**
  52376. * Raw cube texture where the raw buffers are passed in
  52377. */
  52378. export class RawCubeTexture extends CubeTexture {
  52379. /**
  52380. * Creates a cube texture where the raw buffers are passed in.
  52381. * @param scene defines the scene the texture is attached to
  52382. * @param data defines the array of data to use to create each face
  52383. * @param size defines the size of the textures
  52384. * @param format defines the format of the data
  52385. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52386. * @param generateMipMaps defines if the engine should generate the mip levels
  52387. * @param invertY defines if data must be stored with Y axis inverted
  52388. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52389. * @param compression defines the compression used (null by default)
  52390. */
  52391. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52392. /**
  52393. * Updates the raw cube texture.
  52394. * @param data defines the data to store
  52395. * @param format defines the data format
  52396. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52397. * @param invertY defines if data must be stored with Y axis inverted
  52398. * @param compression defines the compression used (null by default)
  52399. * @param level defines which level of the texture to update
  52400. */
  52401. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52402. /**
  52403. * Updates a raw cube texture with RGBD encoded data.
  52404. * @param data defines the array of data [mipmap][face] to use to create each face
  52405. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52406. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52407. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52408. * @returns a promsie that resolves when the operation is complete
  52409. */
  52410. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52411. /**
  52412. * Clones the raw cube texture.
  52413. * @return a new cube texture
  52414. */
  52415. clone(): CubeTexture;
  52416. /** @hidden */
  52417. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52418. }
  52419. }
  52420. declare module BABYLON {
  52421. /**
  52422. * Class used to store 3D textures containing user data
  52423. */
  52424. export class RawTexture3D extends Texture {
  52425. /** Gets or sets the texture format to use */
  52426. format: number;
  52427. private _engine;
  52428. /**
  52429. * Create a new RawTexture3D
  52430. * @param data defines the data of the texture
  52431. * @param width defines the width of the texture
  52432. * @param height defines the height of the texture
  52433. * @param depth defines the depth of the texture
  52434. * @param format defines the texture format to use
  52435. * @param scene defines the hosting scene
  52436. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52437. * @param invertY defines if texture must be stored with Y axis inverted
  52438. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52439. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52440. */
  52441. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52442. /** Gets or sets the texture format to use */
  52443. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52444. /**
  52445. * Update the texture with new data
  52446. * @param data defines the data to store in the texture
  52447. */
  52448. update(data: ArrayBufferView): void;
  52449. }
  52450. }
  52451. declare module BABYLON {
  52452. /**
  52453. * Creates a refraction texture used by refraction channel of the standard material.
  52454. * It is like a mirror but to see through a material.
  52455. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52456. */
  52457. export class RefractionTexture extends RenderTargetTexture {
  52458. /**
  52459. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52460. * 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.
  52461. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52462. */
  52463. refractionPlane: Plane;
  52464. /**
  52465. * Define how deep under the surface we should see.
  52466. */
  52467. depth: number;
  52468. /**
  52469. * Creates a refraction texture used by refraction channel of the standard material.
  52470. * It is like a mirror but to see through a material.
  52471. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52472. * @param name Define the texture name
  52473. * @param size Define the size of the underlying texture
  52474. * @param scene Define the scene the refraction belongs to
  52475. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52476. */
  52477. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52478. /**
  52479. * Clone the refraction texture.
  52480. * @returns the cloned texture
  52481. */
  52482. clone(): RefractionTexture;
  52483. /**
  52484. * Serialize the texture to a JSON representation you could use in Parse later on
  52485. * @returns the serialized JSON representation
  52486. */
  52487. serialize(): any;
  52488. }
  52489. }
  52490. declare module BABYLON {
  52491. /**
  52492. * Defines the options related to the creation of an HtmlElementTexture
  52493. */
  52494. export interface IHtmlElementTextureOptions {
  52495. /**
  52496. * Defines wether mip maps should be created or not.
  52497. */
  52498. generateMipMaps?: boolean;
  52499. /**
  52500. * Defines the sampling mode of the texture.
  52501. */
  52502. samplingMode?: number;
  52503. /**
  52504. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52505. */
  52506. engine: Nullable<ThinEngine>;
  52507. /**
  52508. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52509. */
  52510. scene: Nullable<Scene>;
  52511. }
  52512. /**
  52513. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52514. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52515. * is automatically managed.
  52516. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52517. * in your application.
  52518. *
  52519. * As the update is not automatic, you need to call them manually.
  52520. */
  52521. export class HtmlElementTexture extends BaseTexture {
  52522. /**
  52523. * The texture URL.
  52524. */
  52525. element: HTMLVideoElement | HTMLCanvasElement;
  52526. private static readonly DefaultOptions;
  52527. private _textureMatrix;
  52528. private _engine;
  52529. private _isVideo;
  52530. private _generateMipMaps;
  52531. private _samplingMode;
  52532. /**
  52533. * Instantiates a HtmlElementTexture from the following parameters.
  52534. *
  52535. * @param name Defines the name of the texture
  52536. * @param element Defines the video or canvas the texture is filled with
  52537. * @param options Defines the other none mandatory texture creation options
  52538. */
  52539. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52540. private _createInternalTexture;
  52541. /**
  52542. * Returns the texture matrix used in most of the material.
  52543. */
  52544. getTextureMatrix(): Matrix;
  52545. /**
  52546. * Updates the content of the texture.
  52547. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52548. */
  52549. update(invertY?: Nullable<boolean>): void;
  52550. }
  52551. }
  52552. declare module BABYLON {
  52553. /**
  52554. * Enum used to define the target of a block
  52555. */
  52556. export enum NodeMaterialBlockTargets {
  52557. /** Vertex shader */
  52558. Vertex = 1,
  52559. /** Fragment shader */
  52560. Fragment = 2,
  52561. /** Neutral */
  52562. Neutral = 4,
  52563. /** Vertex and Fragment */
  52564. VertexAndFragment = 3
  52565. }
  52566. }
  52567. declare module BABYLON {
  52568. /**
  52569. * Defines the kind of connection point for node based material
  52570. */
  52571. export enum NodeMaterialBlockConnectionPointTypes {
  52572. /** Float */
  52573. Float = 1,
  52574. /** Int */
  52575. Int = 2,
  52576. /** Vector2 */
  52577. Vector2 = 4,
  52578. /** Vector3 */
  52579. Vector3 = 8,
  52580. /** Vector4 */
  52581. Vector4 = 16,
  52582. /** Color3 */
  52583. Color3 = 32,
  52584. /** Color4 */
  52585. Color4 = 64,
  52586. /** Matrix */
  52587. Matrix = 128,
  52588. /** Detect type based on connection */
  52589. AutoDetect = 1024,
  52590. /** Output type that will be defined by input type */
  52591. BasedOnInput = 2048
  52592. }
  52593. }
  52594. declare module BABYLON {
  52595. /**
  52596. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52597. */
  52598. export enum NodeMaterialBlockConnectionPointMode {
  52599. /** Value is an uniform */
  52600. Uniform = 0,
  52601. /** Value is a mesh attribute */
  52602. Attribute = 1,
  52603. /** Value is a varying between vertex and fragment shaders */
  52604. Varying = 2,
  52605. /** Mode is undefined */
  52606. Undefined = 3
  52607. }
  52608. }
  52609. declare module BABYLON {
  52610. /**
  52611. * Enum used to define system values e.g. values automatically provided by the system
  52612. */
  52613. export enum NodeMaterialSystemValues {
  52614. /** World */
  52615. World = 1,
  52616. /** View */
  52617. View = 2,
  52618. /** Projection */
  52619. Projection = 3,
  52620. /** ViewProjection */
  52621. ViewProjection = 4,
  52622. /** WorldView */
  52623. WorldView = 5,
  52624. /** WorldViewProjection */
  52625. WorldViewProjection = 6,
  52626. /** CameraPosition */
  52627. CameraPosition = 7,
  52628. /** Fog Color */
  52629. FogColor = 8,
  52630. /** Delta time */
  52631. DeltaTime = 9
  52632. }
  52633. }
  52634. declare module BABYLON {
  52635. /**
  52636. * Root class for all node material optimizers
  52637. */
  52638. export class NodeMaterialOptimizer {
  52639. /**
  52640. * Function used to optimize a NodeMaterial graph
  52641. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52642. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52643. */
  52644. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52645. }
  52646. }
  52647. declare module BABYLON {
  52648. /**
  52649. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52650. */
  52651. export class TransformBlock extends NodeMaterialBlock {
  52652. /**
  52653. * Defines the value to use to complement W value to transform it to a Vector4
  52654. */
  52655. complementW: number;
  52656. /**
  52657. * Defines the value to use to complement z value to transform it to a Vector4
  52658. */
  52659. complementZ: number;
  52660. /**
  52661. * Creates a new TransformBlock
  52662. * @param name defines the block name
  52663. */
  52664. constructor(name: string);
  52665. /**
  52666. * Gets the current class name
  52667. * @returns the class name
  52668. */
  52669. getClassName(): string;
  52670. /**
  52671. * Gets the vector input
  52672. */
  52673. readonly vector: NodeMaterialConnectionPoint;
  52674. /**
  52675. * Gets the output component
  52676. */
  52677. readonly output: NodeMaterialConnectionPoint;
  52678. /**
  52679. * Gets the matrix transform input
  52680. */
  52681. readonly transform: NodeMaterialConnectionPoint;
  52682. protected _buildBlock(state: NodeMaterialBuildState): this;
  52683. serialize(): any;
  52684. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52685. protected _dumpPropertiesCode(): string;
  52686. }
  52687. }
  52688. declare module BABYLON {
  52689. /**
  52690. * Block used to output the vertex position
  52691. */
  52692. export class VertexOutputBlock extends NodeMaterialBlock {
  52693. /**
  52694. * Creates a new VertexOutputBlock
  52695. * @param name defines the block name
  52696. */
  52697. constructor(name: string);
  52698. /**
  52699. * Gets the current class name
  52700. * @returns the class name
  52701. */
  52702. getClassName(): string;
  52703. /**
  52704. * Gets the vector input component
  52705. */
  52706. readonly vector: NodeMaterialConnectionPoint;
  52707. protected _buildBlock(state: NodeMaterialBuildState): this;
  52708. }
  52709. }
  52710. declare module BABYLON {
  52711. /**
  52712. * Block used to output the final color
  52713. */
  52714. export class FragmentOutputBlock extends NodeMaterialBlock {
  52715. /**
  52716. * Create a new FragmentOutputBlock
  52717. * @param name defines the block name
  52718. */
  52719. constructor(name: string);
  52720. /**
  52721. * Gets the current class name
  52722. * @returns the class name
  52723. */
  52724. getClassName(): string;
  52725. /**
  52726. * Gets the rgba input component
  52727. */
  52728. readonly rgba: NodeMaterialConnectionPoint;
  52729. /**
  52730. * Gets the rgb input component
  52731. */
  52732. readonly rgb: NodeMaterialConnectionPoint;
  52733. /**
  52734. * Gets the a input component
  52735. */
  52736. readonly a: NodeMaterialConnectionPoint;
  52737. protected _buildBlock(state: NodeMaterialBuildState): this;
  52738. }
  52739. }
  52740. declare module BABYLON {
  52741. /**
  52742. * Block used to read a reflection texture from a sampler
  52743. */
  52744. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52745. private _define3DName;
  52746. private _defineCubicName;
  52747. private _defineExplicitName;
  52748. private _defineProjectionName;
  52749. private _defineLocalCubicName;
  52750. private _defineSphericalName;
  52751. private _definePlanarName;
  52752. private _defineEquirectangularName;
  52753. private _defineMirroredEquirectangularFixedName;
  52754. private _defineEquirectangularFixedName;
  52755. private _defineSkyboxName;
  52756. private _cubeSamplerName;
  52757. private _2DSamplerName;
  52758. private _positionUVWName;
  52759. private _directionWName;
  52760. private _reflectionCoordsName;
  52761. private _reflection2DCoordsName;
  52762. private _reflectionColorName;
  52763. private _reflectionMatrixName;
  52764. /**
  52765. * Gets or sets the texture associated with the node
  52766. */
  52767. texture: Nullable<BaseTexture>;
  52768. /**
  52769. * Create a new TextureBlock
  52770. * @param name defines the block name
  52771. */
  52772. constructor(name: string);
  52773. /**
  52774. * Gets the current class name
  52775. * @returns the class name
  52776. */
  52777. getClassName(): string;
  52778. /**
  52779. * Gets the world position input component
  52780. */
  52781. readonly position: NodeMaterialConnectionPoint;
  52782. /**
  52783. * Gets the world position input component
  52784. */
  52785. readonly worldPosition: NodeMaterialConnectionPoint;
  52786. /**
  52787. * Gets the world normal input component
  52788. */
  52789. readonly worldNormal: NodeMaterialConnectionPoint;
  52790. /**
  52791. * Gets the world input component
  52792. */
  52793. readonly world: NodeMaterialConnectionPoint;
  52794. /**
  52795. * Gets the camera (or eye) position component
  52796. */
  52797. readonly cameraPosition: NodeMaterialConnectionPoint;
  52798. /**
  52799. * Gets the view input component
  52800. */
  52801. readonly view: NodeMaterialConnectionPoint;
  52802. /**
  52803. * Gets the rgb output component
  52804. */
  52805. readonly rgb: NodeMaterialConnectionPoint;
  52806. /**
  52807. * Gets the r output component
  52808. */
  52809. readonly r: NodeMaterialConnectionPoint;
  52810. /**
  52811. * Gets the g output component
  52812. */
  52813. readonly g: NodeMaterialConnectionPoint;
  52814. /**
  52815. * Gets the b output component
  52816. */
  52817. readonly b: NodeMaterialConnectionPoint;
  52818. autoConfigure(material: NodeMaterial): void;
  52819. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52820. isReady(): boolean;
  52821. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52822. private _injectVertexCode;
  52823. private _writeOutput;
  52824. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52825. serialize(): any;
  52826. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52827. }
  52828. }
  52829. declare module BABYLON {
  52830. /**
  52831. * Interface used to configure the node material editor
  52832. */
  52833. export interface INodeMaterialEditorOptions {
  52834. /** Define the URl to load node editor script */
  52835. editorURL?: string;
  52836. }
  52837. /** @hidden */
  52838. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52839. /** BONES */
  52840. NUM_BONE_INFLUENCERS: number;
  52841. BonesPerMesh: number;
  52842. BONETEXTURE: boolean;
  52843. /** MORPH TARGETS */
  52844. MORPHTARGETS: boolean;
  52845. MORPHTARGETS_NORMAL: boolean;
  52846. MORPHTARGETS_TANGENT: boolean;
  52847. MORPHTARGETS_UV: boolean;
  52848. NUM_MORPH_INFLUENCERS: number;
  52849. /** IMAGE PROCESSING */
  52850. IMAGEPROCESSING: boolean;
  52851. VIGNETTE: boolean;
  52852. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52853. VIGNETTEBLENDMODEOPAQUE: boolean;
  52854. TONEMAPPING: boolean;
  52855. TONEMAPPING_ACES: boolean;
  52856. CONTRAST: boolean;
  52857. EXPOSURE: boolean;
  52858. COLORCURVES: boolean;
  52859. COLORGRADING: boolean;
  52860. COLORGRADING3D: boolean;
  52861. SAMPLER3DGREENDEPTH: boolean;
  52862. SAMPLER3DBGRMAP: boolean;
  52863. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52864. /** MISC. */
  52865. BUMPDIRECTUV: number;
  52866. constructor();
  52867. setValue(name: string, value: boolean): void;
  52868. }
  52869. /**
  52870. * Class used to configure NodeMaterial
  52871. */
  52872. export interface INodeMaterialOptions {
  52873. /**
  52874. * Defines if blocks should emit comments
  52875. */
  52876. emitComments: boolean;
  52877. }
  52878. /**
  52879. * Class used to create a node based material built by assembling shader blocks
  52880. */
  52881. export class NodeMaterial extends PushMaterial {
  52882. private static _BuildIdGenerator;
  52883. private _options;
  52884. private _vertexCompilationState;
  52885. private _fragmentCompilationState;
  52886. private _sharedData;
  52887. private _buildId;
  52888. private _buildWasSuccessful;
  52889. private _cachedWorldViewMatrix;
  52890. private _cachedWorldViewProjectionMatrix;
  52891. private _optimizers;
  52892. private _animationFrame;
  52893. /** Define the URl to load node editor script */
  52894. static EditorURL: string;
  52895. private BJSNODEMATERIALEDITOR;
  52896. /** Get the inspector from bundle or global */
  52897. private _getGlobalNodeMaterialEditor;
  52898. /**
  52899. * 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)
  52900. */
  52901. ignoreAlpha: boolean;
  52902. /**
  52903. * Defines the maximum number of lights that can be used in the material
  52904. */
  52905. maxSimultaneousLights: number;
  52906. /**
  52907. * Observable raised when the material is built
  52908. */
  52909. onBuildObservable: Observable<NodeMaterial>;
  52910. /**
  52911. * Gets or sets the root nodes of the material vertex shader
  52912. */
  52913. _vertexOutputNodes: NodeMaterialBlock[];
  52914. /**
  52915. * Gets or sets the root nodes of the material fragment (pixel) shader
  52916. */
  52917. _fragmentOutputNodes: NodeMaterialBlock[];
  52918. /** Gets or sets options to control the node material overall behavior */
  52919. options: INodeMaterialOptions;
  52920. /**
  52921. * Default configuration related to image processing available in the standard Material.
  52922. */
  52923. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52924. /**
  52925. * Gets the image processing configuration used either in this material.
  52926. */
  52927. /**
  52928. * Sets the Default image processing configuration used either in the this material.
  52929. *
  52930. * If sets to null, the scene one is in use.
  52931. */
  52932. imageProcessingConfiguration: ImageProcessingConfiguration;
  52933. /**
  52934. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52935. */
  52936. attachedBlocks: NodeMaterialBlock[];
  52937. /**
  52938. * Create a new node based material
  52939. * @param name defines the material name
  52940. * @param scene defines the hosting scene
  52941. * @param options defines creation option
  52942. */
  52943. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52944. /**
  52945. * Gets the current class name of the material e.g. "NodeMaterial"
  52946. * @returns the class name
  52947. */
  52948. getClassName(): string;
  52949. /**
  52950. * Keep track of the image processing observer to allow dispose and replace.
  52951. */
  52952. private _imageProcessingObserver;
  52953. /**
  52954. * Attaches a new image processing configuration to the Standard Material.
  52955. * @param configuration
  52956. */
  52957. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52958. /**
  52959. * Get a block by its name
  52960. * @param name defines the name of the block to retrieve
  52961. * @returns the required block or null if not found
  52962. */
  52963. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52964. /**
  52965. * Get a block by its name
  52966. * @param predicate defines the predicate used to find the good candidate
  52967. * @returns the required block or null if not found
  52968. */
  52969. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52970. /**
  52971. * Get an input block by its name
  52972. * @param predicate defines the predicate used to find the good candidate
  52973. * @returns the required input block or null if not found
  52974. */
  52975. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52976. /**
  52977. * Gets the list of input blocks attached to this material
  52978. * @returns an array of InputBlocks
  52979. */
  52980. getInputBlocks(): InputBlock[];
  52981. /**
  52982. * Adds a new optimizer to the list of optimizers
  52983. * @param optimizer defines the optimizers to add
  52984. * @returns the current material
  52985. */
  52986. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52987. /**
  52988. * Remove an optimizer from the list of optimizers
  52989. * @param optimizer defines the optimizers to remove
  52990. * @returns the current material
  52991. */
  52992. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52993. /**
  52994. * Add a new block to the list of output nodes
  52995. * @param node defines the node to add
  52996. * @returns the current material
  52997. */
  52998. addOutputNode(node: NodeMaterialBlock): this;
  52999. /**
  53000. * Remove a block from the list of root nodes
  53001. * @param node defines the node to remove
  53002. * @returns the current material
  53003. */
  53004. removeOutputNode(node: NodeMaterialBlock): this;
  53005. private _addVertexOutputNode;
  53006. private _removeVertexOutputNode;
  53007. private _addFragmentOutputNode;
  53008. private _removeFragmentOutputNode;
  53009. /**
  53010. * Specifies if the material will require alpha blending
  53011. * @returns a boolean specifying if alpha blending is needed
  53012. */
  53013. needAlphaBlending(): boolean;
  53014. /**
  53015. * Specifies if this material should be rendered in alpha test mode
  53016. * @returns a boolean specifying if an alpha test is needed.
  53017. */
  53018. needAlphaTesting(): boolean;
  53019. private _initializeBlock;
  53020. private _resetDualBlocks;
  53021. /**
  53022. * Build the material and generates the inner effect
  53023. * @param verbose defines if the build should log activity
  53024. */
  53025. build(verbose?: boolean): void;
  53026. /**
  53027. * Runs an otpimization phase to try to improve the shader code
  53028. */
  53029. optimize(): void;
  53030. private _prepareDefinesForAttributes;
  53031. /**
  53032. * Get if the submesh is ready to be used and all its information available.
  53033. * Child classes can use it to update shaders
  53034. * @param mesh defines the mesh to check
  53035. * @param subMesh defines which submesh to check
  53036. * @param useInstances specifies that instances should be used
  53037. * @returns a boolean indicating that the submesh is ready or not
  53038. */
  53039. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53040. /**
  53041. * Get a string representing the shaders built by the current node graph
  53042. */
  53043. readonly compiledShaders: string;
  53044. /**
  53045. * Binds the world matrix to the material
  53046. * @param world defines the world transformation matrix
  53047. */
  53048. bindOnlyWorldMatrix(world: Matrix): void;
  53049. /**
  53050. * Binds the submesh to this material by preparing the effect and shader to draw
  53051. * @param world defines the world transformation matrix
  53052. * @param mesh defines the mesh containing the submesh
  53053. * @param subMesh defines the submesh to bind the material to
  53054. */
  53055. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53056. /**
  53057. * Gets the active textures from the material
  53058. * @returns an array of textures
  53059. */
  53060. getActiveTextures(): BaseTexture[];
  53061. /**
  53062. * Gets the list of texture blocks
  53063. * @returns an array of texture blocks
  53064. */
  53065. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  53066. /**
  53067. * Specifies if the material uses a texture
  53068. * @param texture defines the texture to check against the material
  53069. * @returns a boolean specifying if the material uses the texture
  53070. */
  53071. hasTexture(texture: BaseTexture): boolean;
  53072. /**
  53073. * Disposes the material
  53074. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53075. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53076. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53077. */
  53078. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53079. /** Creates the node editor window. */
  53080. private _createNodeEditor;
  53081. /**
  53082. * Launch the node material editor
  53083. * @param config Define the configuration of the editor
  53084. * @return a promise fulfilled when the node editor is visible
  53085. */
  53086. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53087. /**
  53088. * Clear the current material
  53089. */
  53090. clear(): void;
  53091. /**
  53092. * Clear the current material and set it to a default state
  53093. */
  53094. setToDefault(): void;
  53095. /**
  53096. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53097. * @param url defines the url to load from
  53098. * @returns a promise that will fullfil when the material is fully loaded
  53099. */
  53100. loadAsync(url: string): Promise<unknown>;
  53101. private _gatherBlocks;
  53102. /**
  53103. * Generate a string containing the code declaration required to create an equivalent of this material
  53104. * @returns a string
  53105. */
  53106. generateCode(): string;
  53107. /**
  53108. * Serializes this material in a JSON representation
  53109. * @returns the serialized material object
  53110. */
  53111. serialize(): any;
  53112. private _restoreConnections;
  53113. /**
  53114. * Clear the current graph and load a new one from a serialization object
  53115. * @param source defines the JSON representation of the material
  53116. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53117. */
  53118. loadFromSerialization(source: any, rootUrl?: string): void;
  53119. /**
  53120. * Creates a node material from parsed material data
  53121. * @param source defines the JSON representation of the material
  53122. * @param scene defines the hosting scene
  53123. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53124. * @returns a new node material
  53125. */
  53126. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53127. /**
  53128. * Creates a new node material set to default basic configuration
  53129. * @param name defines the name of the material
  53130. * @param scene defines the hosting scene
  53131. * @returns a new NodeMaterial
  53132. */
  53133. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53134. }
  53135. }
  53136. declare module BABYLON {
  53137. /**
  53138. * Block used to read a texture from a sampler
  53139. */
  53140. export class TextureBlock extends NodeMaterialBlock {
  53141. private _defineName;
  53142. private _linearDefineName;
  53143. private _samplerName;
  53144. private _transformedUVName;
  53145. private _textureTransformName;
  53146. private _textureInfoName;
  53147. private _mainUVName;
  53148. private _mainUVDefineName;
  53149. /**
  53150. * Gets or sets the texture associated with the node
  53151. */
  53152. texture: Nullable<Texture>;
  53153. /**
  53154. * Create a new TextureBlock
  53155. * @param name defines the block name
  53156. */
  53157. constructor(name: string);
  53158. /**
  53159. * Gets the current class name
  53160. * @returns the class name
  53161. */
  53162. getClassName(): string;
  53163. /**
  53164. * Gets the uv input component
  53165. */
  53166. readonly uv: NodeMaterialConnectionPoint;
  53167. /**
  53168. * Gets the rgba output component
  53169. */
  53170. readonly rgba: NodeMaterialConnectionPoint;
  53171. /**
  53172. * Gets the rgb output component
  53173. */
  53174. readonly rgb: NodeMaterialConnectionPoint;
  53175. /**
  53176. * Gets the r output component
  53177. */
  53178. readonly r: NodeMaterialConnectionPoint;
  53179. /**
  53180. * Gets the g output component
  53181. */
  53182. readonly g: NodeMaterialConnectionPoint;
  53183. /**
  53184. * Gets the b output component
  53185. */
  53186. readonly b: NodeMaterialConnectionPoint;
  53187. /**
  53188. * Gets the a output component
  53189. */
  53190. readonly a: NodeMaterialConnectionPoint;
  53191. readonly target: NodeMaterialBlockTargets;
  53192. autoConfigure(material: NodeMaterial): void;
  53193. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53195. isReady(): boolean;
  53196. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53197. private readonly _isMixed;
  53198. private _injectVertexCode;
  53199. private _writeOutput;
  53200. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53201. protected _dumpPropertiesCode(): string;
  53202. serialize(): any;
  53203. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53204. }
  53205. }
  53206. declare module BABYLON {
  53207. /**
  53208. * Class used to store shared data between 2 NodeMaterialBuildState
  53209. */
  53210. export class NodeMaterialBuildStateSharedData {
  53211. /**
  53212. * Gets the list of emitted varyings
  53213. */
  53214. temps: string[];
  53215. /**
  53216. * Gets the list of emitted varyings
  53217. */
  53218. varyings: string[];
  53219. /**
  53220. * Gets the varying declaration string
  53221. */
  53222. varyingDeclaration: string;
  53223. /**
  53224. * Input blocks
  53225. */
  53226. inputBlocks: InputBlock[];
  53227. /**
  53228. * Input blocks
  53229. */
  53230. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53231. /**
  53232. * Bindable blocks (Blocks that need to set data to the effect)
  53233. */
  53234. bindableBlocks: NodeMaterialBlock[];
  53235. /**
  53236. * List of blocks that can provide a compilation fallback
  53237. */
  53238. blocksWithFallbacks: NodeMaterialBlock[];
  53239. /**
  53240. * List of blocks that can provide a define update
  53241. */
  53242. blocksWithDefines: NodeMaterialBlock[];
  53243. /**
  53244. * List of blocks that can provide a repeatable content
  53245. */
  53246. repeatableContentBlocks: NodeMaterialBlock[];
  53247. /**
  53248. * List of blocks that can provide a dynamic list of uniforms
  53249. */
  53250. dynamicUniformBlocks: NodeMaterialBlock[];
  53251. /**
  53252. * List of blocks that can block the isReady function for the material
  53253. */
  53254. blockingBlocks: NodeMaterialBlock[];
  53255. /**
  53256. * Gets the list of animated inputs
  53257. */
  53258. animatedInputs: InputBlock[];
  53259. /**
  53260. * Build Id used to avoid multiple recompilations
  53261. */
  53262. buildId: number;
  53263. /** List of emitted variables */
  53264. variableNames: {
  53265. [key: string]: number;
  53266. };
  53267. /** List of emitted defines */
  53268. defineNames: {
  53269. [key: string]: number;
  53270. };
  53271. /** Should emit comments? */
  53272. emitComments: boolean;
  53273. /** Emit build activity */
  53274. verbose: boolean;
  53275. /** Gets or sets the hosting scene */
  53276. scene: Scene;
  53277. /**
  53278. * Gets the compilation hints emitted at compilation time
  53279. */
  53280. hints: {
  53281. needWorldViewMatrix: boolean;
  53282. needWorldViewProjectionMatrix: boolean;
  53283. needAlphaBlending: boolean;
  53284. needAlphaTesting: boolean;
  53285. };
  53286. /**
  53287. * List of compilation checks
  53288. */
  53289. checks: {
  53290. emitVertex: boolean;
  53291. emitFragment: boolean;
  53292. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53293. };
  53294. /** Creates a new shared data */
  53295. constructor();
  53296. /**
  53297. * Emits console errors and exceptions if there is a failing check
  53298. */
  53299. emitErrors(): void;
  53300. }
  53301. }
  53302. declare module BABYLON {
  53303. /**
  53304. * Class used to store node based material build state
  53305. */
  53306. export class NodeMaterialBuildState {
  53307. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53308. supportUniformBuffers: boolean;
  53309. /**
  53310. * Gets the list of emitted attributes
  53311. */
  53312. attributes: string[];
  53313. /**
  53314. * Gets the list of emitted uniforms
  53315. */
  53316. uniforms: string[];
  53317. /**
  53318. * Gets the list of emitted constants
  53319. */
  53320. constants: string[];
  53321. /**
  53322. * Gets the list of emitted samplers
  53323. */
  53324. samplers: string[];
  53325. /**
  53326. * Gets the list of emitted functions
  53327. */
  53328. functions: {
  53329. [key: string]: string;
  53330. };
  53331. /**
  53332. * Gets the list of emitted extensions
  53333. */
  53334. extensions: {
  53335. [key: string]: string;
  53336. };
  53337. /**
  53338. * Gets the target of the compilation state
  53339. */
  53340. target: NodeMaterialBlockTargets;
  53341. /**
  53342. * Gets the list of emitted counters
  53343. */
  53344. counters: {
  53345. [key: string]: number;
  53346. };
  53347. /**
  53348. * Shared data between multiple NodeMaterialBuildState instances
  53349. */
  53350. sharedData: NodeMaterialBuildStateSharedData;
  53351. /** @hidden */
  53352. _vertexState: NodeMaterialBuildState;
  53353. /** @hidden */
  53354. _attributeDeclaration: string;
  53355. /** @hidden */
  53356. _uniformDeclaration: string;
  53357. /** @hidden */
  53358. _constantDeclaration: string;
  53359. /** @hidden */
  53360. _samplerDeclaration: string;
  53361. /** @hidden */
  53362. _varyingTransfer: string;
  53363. private _repeatableContentAnchorIndex;
  53364. /** @hidden */
  53365. _builtCompilationString: string;
  53366. /**
  53367. * Gets the emitted compilation strings
  53368. */
  53369. compilationString: string;
  53370. /**
  53371. * Finalize the compilation strings
  53372. * @param state defines the current compilation state
  53373. */
  53374. finalize(state: NodeMaterialBuildState): void;
  53375. /** @hidden */
  53376. readonly _repeatableContentAnchor: string;
  53377. /** @hidden */
  53378. _getFreeVariableName(prefix: string): string;
  53379. /** @hidden */
  53380. _getFreeDefineName(prefix: string): string;
  53381. /** @hidden */
  53382. _excludeVariableName(name: string): void;
  53383. /** @hidden */
  53384. _emit2DSampler(name: string): void;
  53385. /** @hidden */
  53386. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53387. /** @hidden */
  53388. _emitExtension(name: string, extension: string): void;
  53389. /** @hidden */
  53390. _emitFunction(name: string, code: string, comments: string): void;
  53391. /** @hidden */
  53392. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53393. replaceStrings?: {
  53394. search: RegExp;
  53395. replace: string;
  53396. }[];
  53397. repeatKey?: string;
  53398. }): string;
  53399. /** @hidden */
  53400. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53401. repeatKey?: string;
  53402. removeAttributes?: boolean;
  53403. removeUniforms?: boolean;
  53404. removeVaryings?: boolean;
  53405. removeIfDef?: boolean;
  53406. replaceStrings?: {
  53407. search: RegExp;
  53408. replace: string;
  53409. }[];
  53410. }, storeKey?: string): void;
  53411. /** @hidden */
  53412. _registerTempVariable(name: string): boolean;
  53413. /** @hidden */
  53414. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53415. /** @hidden */
  53416. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53417. /** @hidden */
  53418. _emitFloat(value: number): string;
  53419. }
  53420. }
  53421. declare module BABYLON {
  53422. /**
  53423. * Defines a block that can be used inside a node based material
  53424. */
  53425. export class NodeMaterialBlock {
  53426. private _buildId;
  53427. private _buildTarget;
  53428. private _target;
  53429. private _isFinalMerger;
  53430. private _isInput;
  53431. /** @hidden */
  53432. _codeVariableName: string;
  53433. /** @hidden */
  53434. _inputs: NodeMaterialConnectionPoint[];
  53435. /** @hidden */
  53436. _outputs: NodeMaterialConnectionPoint[];
  53437. /** @hidden */
  53438. _preparationId: number;
  53439. /**
  53440. * Gets or sets the name of the block
  53441. */
  53442. name: string;
  53443. /**
  53444. * Gets or sets the unique id of the node
  53445. */
  53446. uniqueId: number;
  53447. /**
  53448. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53449. */
  53450. readonly isFinalMerger: boolean;
  53451. /**
  53452. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53453. */
  53454. readonly isInput: boolean;
  53455. /**
  53456. * Gets or sets the build Id
  53457. */
  53458. buildId: number;
  53459. /**
  53460. * Gets or sets the target of the block
  53461. */
  53462. target: NodeMaterialBlockTargets;
  53463. /**
  53464. * Gets the list of input points
  53465. */
  53466. readonly inputs: NodeMaterialConnectionPoint[];
  53467. /** Gets the list of output points */
  53468. readonly outputs: NodeMaterialConnectionPoint[];
  53469. /**
  53470. * Find an input by its name
  53471. * @param name defines the name of the input to look for
  53472. * @returns the input or null if not found
  53473. */
  53474. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53475. /**
  53476. * Find an output by its name
  53477. * @param name defines the name of the outputto look for
  53478. * @returns the output or null if not found
  53479. */
  53480. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53481. /**
  53482. * Creates a new NodeMaterialBlock
  53483. * @param name defines the block name
  53484. * @param target defines the target of that block (Vertex by default)
  53485. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53486. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53487. */
  53488. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53489. /**
  53490. * Initialize the block and prepare the context for build
  53491. * @param state defines the state that will be used for the build
  53492. */
  53493. initialize(state: NodeMaterialBuildState): void;
  53494. /**
  53495. * Bind data to effect. Will only be called for blocks with isBindable === true
  53496. * @param effect defines the effect to bind data to
  53497. * @param nodeMaterial defines the hosting NodeMaterial
  53498. * @param mesh defines the mesh that will be rendered
  53499. */
  53500. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53501. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53502. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53503. protected _writeFloat(value: number): string;
  53504. /**
  53505. * Gets the current class name e.g. "NodeMaterialBlock"
  53506. * @returns the class name
  53507. */
  53508. getClassName(): string;
  53509. /**
  53510. * Register a new input. Must be called inside a block constructor
  53511. * @param name defines the connection point name
  53512. * @param type defines the connection point type
  53513. * @param isOptional defines a boolean indicating that this input can be omitted
  53514. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53515. * @returns the current block
  53516. */
  53517. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53518. /**
  53519. * Register a new output. Must be called inside a block constructor
  53520. * @param name defines the connection point name
  53521. * @param type defines the connection point type
  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. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53526. /**
  53527. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53528. * @param forOutput defines an optional connection point to check compatibility with
  53529. * @returns the first available input or null
  53530. */
  53531. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53532. /**
  53533. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53534. * @param forBlock defines an optional block to check compatibility with
  53535. * @returns the first available input or null
  53536. */
  53537. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53538. /**
  53539. * Gets the sibling of the given output
  53540. * @param current defines the current output
  53541. * @returns the next output in the list or null
  53542. */
  53543. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53544. /**
  53545. * Connect current block with another block
  53546. * @param other defines the block to connect with
  53547. * @param options define the various options to help pick the right connections
  53548. * @returns the current block
  53549. */
  53550. connectTo(other: NodeMaterialBlock, options?: {
  53551. input?: string;
  53552. output?: string;
  53553. outputSwizzle?: string;
  53554. }): this | undefined;
  53555. protected _buildBlock(state: NodeMaterialBuildState): void;
  53556. /**
  53557. * Add uniforms, samplers and uniform buffers at compilation time
  53558. * @param state defines the state to update
  53559. * @param nodeMaterial defines the node material requesting the update
  53560. * @param defines defines the material defines to update
  53561. * @param uniformBuffers defines the list of uniform buffer names
  53562. */
  53563. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  53564. /**
  53565. * Add potential fallbacks if shader compilation fails
  53566. * @param mesh defines the mesh to be rendered
  53567. * @param fallbacks defines the current prioritized list of fallbacks
  53568. */
  53569. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53570. /**
  53571. * Initialize defines for shader compilation
  53572. * @param mesh defines the mesh to be rendered
  53573. * @param nodeMaterial defines the node material requesting the update
  53574. * @param defines defines the material defines to update
  53575. * @param useInstances specifies that instances should be used
  53576. */
  53577. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53578. /**
  53579. * Update 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. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53586. /**
  53587. * Lets the block try to connect some inputs automatically
  53588. * @param material defines the hosting NodeMaterial
  53589. */
  53590. autoConfigure(material: NodeMaterial): void;
  53591. /**
  53592. * Function called when a block is declared as repeatable content generator
  53593. * @param vertexShaderState defines the current compilation state for the vertex shader
  53594. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53595. * @param mesh defines the mesh to be rendered
  53596. * @param defines defines the material defines to update
  53597. */
  53598. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53599. /**
  53600. * Checks if the block is ready
  53601. * @param mesh defines the mesh to be rendered
  53602. * @param nodeMaterial defines the node material requesting the update
  53603. * @param defines defines the material defines to update
  53604. * @param useInstances specifies that instances should be used
  53605. * @returns true if the block is ready
  53606. */
  53607. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53608. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53609. private _processBuild;
  53610. /**
  53611. * Compile the current node and generate the shader code
  53612. * @param state defines the current compilation state (uniforms, samplers, current string)
  53613. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53614. * @returns true if already built
  53615. */
  53616. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53617. protected _inputRename(name: string): string;
  53618. protected _outputRename(name: string): string;
  53619. protected _dumpPropertiesCode(): string;
  53620. /** @hidden */
  53621. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53622. /**
  53623. * Clone the current block to a new identical block
  53624. * @param scene defines the hosting scene
  53625. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53626. * @returns a copy of the current block
  53627. */
  53628. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53629. /**
  53630. * Serializes this block in a JSON representation
  53631. * @returns the serialized block object
  53632. */
  53633. serialize(): any;
  53634. /** @hidden */
  53635. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53636. }
  53637. }
  53638. declare module BABYLON {
  53639. /**
  53640. * Enum defining the type of animations supported by InputBlock
  53641. */
  53642. export enum AnimatedInputBlockTypes {
  53643. /** No animation */
  53644. None = 0,
  53645. /** Time based animation. Will only work for floats */
  53646. Time = 1
  53647. }
  53648. }
  53649. declare module BABYLON {
  53650. /**
  53651. * Block used to expose an input value
  53652. */
  53653. export class InputBlock extends NodeMaterialBlock {
  53654. private _mode;
  53655. private _associatedVariableName;
  53656. private _storedValue;
  53657. private _valueCallback;
  53658. private _type;
  53659. private _animationType;
  53660. /** Gets or set a value used to limit the range of float values */
  53661. min: number;
  53662. /** Gets or set a value used to limit the range of float values */
  53663. max: number;
  53664. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53665. matrixMode: number;
  53666. /** @hidden */
  53667. _systemValue: Nullable<NodeMaterialSystemValues>;
  53668. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53669. visibleInInspector: boolean;
  53670. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53671. isConstant: boolean;
  53672. /**
  53673. * Gets or sets the connection point type (default is float)
  53674. */
  53675. readonly type: NodeMaterialBlockConnectionPointTypes;
  53676. /**
  53677. * Creates a new InputBlock
  53678. * @param name defines the block name
  53679. * @param target defines the target of that block (Vertex by default)
  53680. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53681. */
  53682. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53683. /**
  53684. * Gets the output component
  53685. */
  53686. readonly output: NodeMaterialConnectionPoint;
  53687. /**
  53688. * Set the source of this connection point to a vertex attribute
  53689. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53690. * @returns the current connection point
  53691. */
  53692. setAsAttribute(attributeName?: string): InputBlock;
  53693. /**
  53694. * Set the source of this connection point to a system value
  53695. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53696. * @returns the current connection point
  53697. */
  53698. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53699. /**
  53700. * Gets or sets the value of that point.
  53701. * Please note that this value will be ignored if valueCallback is defined
  53702. */
  53703. value: any;
  53704. /**
  53705. * Gets or sets a callback used to get the value of that point.
  53706. * Please note that setting this value will force the connection point to ignore the value property
  53707. */
  53708. valueCallback: () => any;
  53709. /**
  53710. * Gets or sets the associated variable name in the shader
  53711. */
  53712. associatedVariableName: string;
  53713. /** Gets or sets the type of animation applied to the input */
  53714. animationType: AnimatedInputBlockTypes;
  53715. /**
  53716. * Gets a boolean indicating that this connection point not defined yet
  53717. */
  53718. readonly isUndefined: boolean;
  53719. /**
  53720. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53721. * In this case the connection point name must be the name of the uniform to use.
  53722. * Can only be set on inputs
  53723. */
  53724. isUniform: boolean;
  53725. /**
  53726. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53727. * In this case the connection point name must be the name of the attribute to use
  53728. * Can only be set on inputs
  53729. */
  53730. isAttribute: boolean;
  53731. /**
  53732. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53733. * Can only be set on exit points
  53734. */
  53735. isVarying: boolean;
  53736. /**
  53737. * Gets a boolean indicating that the current connection point is a system value
  53738. */
  53739. readonly isSystemValue: boolean;
  53740. /**
  53741. * Gets or sets the current well known value or null if not defined as a system value
  53742. */
  53743. systemValue: Nullable<NodeMaterialSystemValues>;
  53744. /**
  53745. * Gets the current class name
  53746. * @returns the class name
  53747. */
  53748. getClassName(): string;
  53749. /**
  53750. * Animate the input if animationType !== None
  53751. * @param scene defines the rendering scene
  53752. */
  53753. animate(scene: Scene): void;
  53754. private _emitDefine;
  53755. initialize(state: NodeMaterialBuildState): void;
  53756. /**
  53757. * Set the input block to its default value (based on its type)
  53758. */
  53759. setDefaultValue(): void;
  53760. private _emitConstant;
  53761. private _emit;
  53762. /** @hidden */
  53763. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53764. /** @hidden */
  53765. _transmit(effect: Effect, scene: Scene): void;
  53766. protected _buildBlock(state: NodeMaterialBuildState): void;
  53767. protected _dumpPropertiesCode(): string;
  53768. serialize(): any;
  53769. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53770. }
  53771. }
  53772. declare module BABYLON {
  53773. /**
  53774. * Defines a connection point for a block
  53775. */
  53776. export class NodeMaterialConnectionPoint {
  53777. /** @hidden */
  53778. _ownerBlock: NodeMaterialBlock;
  53779. /** @hidden */
  53780. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53781. private _endpoints;
  53782. private _associatedVariableName;
  53783. /** @hidden */
  53784. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53785. /** @hidden */
  53786. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53787. private _type;
  53788. /** @hidden */
  53789. _enforceAssociatedVariableName: boolean;
  53790. /**
  53791. * Gets or sets the additional types supported by this connection point
  53792. */
  53793. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53794. /**
  53795. * Gets or sets the additional types excluded by this connection point
  53796. */
  53797. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53798. /**
  53799. * Gets or sets the associated variable name in the shader
  53800. */
  53801. associatedVariableName: string;
  53802. /**
  53803. * Gets or sets the connection point type (default is float)
  53804. */
  53805. type: NodeMaterialBlockConnectionPointTypes;
  53806. /**
  53807. * Gets or sets the connection point name
  53808. */
  53809. name: string;
  53810. /**
  53811. * Gets or sets a boolean indicating that this connection point can be omitted
  53812. */
  53813. isOptional: boolean;
  53814. /**
  53815. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53816. */
  53817. define: string;
  53818. /** Gets or sets the target of that connection point */
  53819. target: NodeMaterialBlockTargets;
  53820. /**
  53821. * Gets a boolean indicating that the current point is connected
  53822. */
  53823. readonly isConnected: boolean;
  53824. /**
  53825. * Gets a boolean indicating that the current point is connected to an input block
  53826. */
  53827. readonly isConnectedToInputBlock: boolean;
  53828. /**
  53829. * Gets a the connected input block (if any)
  53830. */
  53831. readonly connectInputBlock: Nullable<InputBlock>;
  53832. /** Get the other side of the connection (if any) */
  53833. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53834. /** Get the block that owns this connection point */
  53835. readonly ownerBlock: NodeMaterialBlock;
  53836. /** Get the block connected on the other side of this connection (if any) */
  53837. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53838. /** Get the block connected on the endpoints of this connection (if any) */
  53839. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53840. /** Gets the list of connected endpoints */
  53841. readonly endpoints: NodeMaterialConnectionPoint[];
  53842. /** Gets a boolean indicating if that output point is connected to at least one input */
  53843. readonly hasEndpoints: boolean;
  53844. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  53845. readonly isConnectedInVertexShader: boolean;
  53846. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  53847. readonly isConnectedInFragmentShader: boolean;
  53848. /**
  53849. * Creates a new connection point
  53850. * @param name defines the connection point name
  53851. * @param ownerBlock defines the block hosting this connection point
  53852. */
  53853. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53854. /**
  53855. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53856. * @returns the class name
  53857. */
  53858. getClassName(): string;
  53859. /**
  53860. * Gets an boolean indicating if the current point can be connected to another point
  53861. * @param connectionPoint defines the other connection point
  53862. * @returns true if the connection is possible
  53863. */
  53864. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53865. /**
  53866. * Connect this point to another connection point
  53867. * @param connectionPoint defines the other connection point
  53868. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53869. * @returns the current connection point
  53870. */
  53871. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53872. /**
  53873. * Disconnect this point from one of his endpoint
  53874. * @param endpoint defines the other connection point
  53875. * @returns the current connection point
  53876. */
  53877. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53878. /**
  53879. * Serializes this point in a JSON representation
  53880. * @returns the serialized point object
  53881. */
  53882. serialize(): any;
  53883. }
  53884. }
  53885. declare module BABYLON {
  53886. /**
  53887. * Block used to add support for vertex skinning (bones)
  53888. */
  53889. export class BonesBlock extends NodeMaterialBlock {
  53890. /**
  53891. * Creates a new BonesBlock
  53892. * @param name defines the block name
  53893. */
  53894. constructor(name: string);
  53895. /**
  53896. * Initialize the block and prepare the context for build
  53897. * @param state defines the state that will be used for the build
  53898. */
  53899. initialize(state: NodeMaterialBuildState): void;
  53900. /**
  53901. * Gets the current class name
  53902. * @returns the class name
  53903. */
  53904. getClassName(): string;
  53905. /**
  53906. * Gets the matrix indices input component
  53907. */
  53908. readonly matricesIndices: NodeMaterialConnectionPoint;
  53909. /**
  53910. * Gets the matrix weights input component
  53911. */
  53912. readonly matricesWeights: NodeMaterialConnectionPoint;
  53913. /**
  53914. * Gets the extra matrix indices input component
  53915. */
  53916. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53917. /**
  53918. * Gets the extra matrix weights input component
  53919. */
  53920. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53921. /**
  53922. * Gets the world input component
  53923. */
  53924. readonly world: NodeMaterialConnectionPoint;
  53925. /**
  53926. * Gets the output component
  53927. */
  53928. readonly output: NodeMaterialConnectionPoint;
  53929. autoConfigure(material: NodeMaterial): void;
  53930. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53932. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53933. protected _buildBlock(state: NodeMaterialBuildState): this;
  53934. }
  53935. }
  53936. declare module BABYLON {
  53937. /**
  53938. * Block used to add support for instances
  53939. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53940. */
  53941. export class InstancesBlock extends NodeMaterialBlock {
  53942. /**
  53943. * Creates a new InstancesBlock
  53944. * @param name defines the block name
  53945. */
  53946. constructor(name: string);
  53947. /**
  53948. * Gets the current class name
  53949. * @returns the class name
  53950. */
  53951. getClassName(): string;
  53952. /**
  53953. * Gets the first world row input component
  53954. */
  53955. readonly world0: NodeMaterialConnectionPoint;
  53956. /**
  53957. * Gets the second world row input component
  53958. */
  53959. readonly world1: NodeMaterialConnectionPoint;
  53960. /**
  53961. * Gets the third world row input component
  53962. */
  53963. readonly world2: NodeMaterialConnectionPoint;
  53964. /**
  53965. * Gets the forth world row input component
  53966. */
  53967. readonly world3: NodeMaterialConnectionPoint;
  53968. /**
  53969. * Gets the world input component
  53970. */
  53971. readonly world: NodeMaterialConnectionPoint;
  53972. /**
  53973. * Gets the output component
  53974. */
  53975. readonly output: NodeMaterialConnectionPoint;
  53976. autoConfigure(material: NodeMaterial): void;
  53977. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53978. protected _buildBlock(state: NodeMaterialBuildState): this;
  53979. }
  53980. }
  53981. declare module BABYLON {
  53982. /**
  53983. * Block used to add morph targets support to vertex shader
  53984. */
  53985. export class MorphTargetsBlock extends NodeMaterialBlock {
  53986. private _repeatableContentAnchor;
  53987. private _repeatebleContentGenerated;
  53988. /**
  53989. * Create a new MorphTargetsBlock
  53990. * @param name defines the block name
  53991. */
  53992. constructor(name: string);
  53993. /**
  53994. * Gets the current class name
  53995. * @returns the class name
  53996. */
  53997. getClassName(): string;
  53998. /**
  53999. * Gets the position input component
  54000. */
  54001. readonly position: NodeMaterialConnectionPoint;
  54002. /**
  54003. * Gets the normal input component
  54004. */
  54005. readonly normal: NodeMaterialConnectionPoint;
  54006. /**
  54007. * Gets the tangent input component
  54008. */
  54009. readonly tangent: NodeMaterialConnectionPoint;
  54010. /**
  54011. * Gets the tangent input component
  54012. */
  54013. readonly uv: NodeMaterialConnectionPoint;
  54014. /**
  54015. * Gets the position output component
  54016. */
  54017. readonly positionOutput: NodeMaterialConnectionPoint;
  54018. /**
  54019. * Gets the normal output component
  54020. */
  54021. readonly normalOutput: NodeMaterialConnectionPoint;
  54022. /**
  54023. * Gets the tangent output component
  54024. */
  54025. readonly tangentOutput: NodeMaterialConnectionPoint;
  54026. /**
  54027. * Gets the tangent output component
  54028. */
  54029. readonly uvOutput: NodeMaterialConnectionPoint;
  54030. initialize(state: NodeMaterialBuildState): void;
  54031. autoConfigure(material: NodeMaterial): void;
  54032. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54033. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54034. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54035. protected _buildBlock(state: NodeMaterialBuildState): this;
  54036. }
  54037. }
  54038. declare module BABYLON {
  54039. /**
  54040. * Block used to get data information from a light
  54041. */
  54042. export class LightInformationBlock extends NodeMaterialBlock {
  54043. private _lightDataUniformName;
  54044. private _lightColorUniformName;
  54045. private _lightTypeDefineName;
  54046. /**
  54047. * Gets or sets the light associated with this block
  54048. */
  54049. light: Nullable<Light>;
  54050. /**
  54051. * Creates a new LightInformationBlock
  54052. * @param name defines the block name
  54053. */
  54054. constructor(name: string);
  54055. /**
  54056. * Gets the current class name
  54057. * @returns the class name
  54058. */
  54059. getClassName(): string;
  54060. /**
  54061. * Gets the world position input component
  54062. */
  54063. readonly worldPosition: NodeMaterialConnectionPoint;
  54064. /**
  54065. * Gets the direction output component
  54066. */
  54067. readonly direction: NodeMaterialConnectionPoint;
  54068. /**
  54069. * Gets the direction output component
  54070. */
  54071. readonly color: NodeMaterialConnectionPoint;
  54072. /**
  54073. * Gets the direction output component
  54074. */
  54075. readonly intensity: NodeMaterialConnectionPoint;
  54076. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54078. protected _buildBlock(state: NodeMaterialBuildState): this;
  54079. serialize(): any;
  54080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54081. }
  54082. }
  54083. declare module BABYLON {
  54084. /**
  54085. * Block used to add image processing support to fragment shader
  54086. */
  54087. export class ImageProcessingBlock extends NodeMaterialBlock {
  54088. /**
  54089. * Create a new ImageProcessingBlock
  54090. * @param name defines the block name
  54091. */
  54092. constructor(name: string);
  54093. /**
  54094. * Gets the current class name
  54095. * @returns the class name
  54096. */
  54097. getClassName(): string;
  54098. /**
  54099. * Gets the color input component
  54100. */
  54101. readonly color: NodeMaterialConnectionPoint;
  54102. /**
  54103. * Gets the output component
  54104. */
  54105. readonly output: NodeMaterialConnectionPoint;
  54106. /**
  54107. * Initialize the block and prepare the context for build
  54108. * @param state defines the state that will be used for the build
  54109. */
  54110. initialize(state: NodeMaterialBuildState): void;
  54111. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54113. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54114. protected _buildBlock(state: NodeMaterialBuildState): this;
  54115. }
  54116. }
  54117. declare module BABYLON {
  54118. /**
  54119. * Block used to pertub normals based on a normal map
  54120. */
  54121. export class PerturbNormalBlock extends NodeMaterialBlock {
  54122. private _tangentSpaceParameterName;
  54123. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54124. invertX: boolean;
  54125. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54126. invertY: boolean;
  54127. /**
  54128. * Create a new PerturbNormalBlock
  54129. * @param name defines the block name
  54130. */
  54131. constructor(name: string);
  54132. /**
  54133. * Gets the current class name
  54134. * @returns the class name
  54135. */
  54136. getClassName(): string;
  54137. /**
  54138. * Gets the world position input component
  54139. */
  54140. readonly worldPosition: NodeMaterialConnectionPoint;
  54141. /**
  54142. * Gets the world normal input component
  54143. */
  54144. readonly worldNormal: NodeMaterialConnectionPoint;
  54145. /**
  54146. * Gets the uv input component
  54147. */
  54148. readonly uv: NodeMaterialConnectionPoint;
  54149. /**
  54150. * Gets the normal map color input component
  54151. */
  54152. readonly normalMapColor: NodeMaterialConnectionPoint;
  54153. /**
  54154. * Gets the strength input component
  54155. */
  54156. readonly strength: NodeMaterialConnectionPoint;
  54157. /**
  54158. * Gets the output component
  54159. */
  54160. readonly output: NodeMaterialConnectionPoint;
  54161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54162. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54163. autoConfigure(material: NodeMaterial): void;
  54164. protected _buildBlock(state: NodeMaterialBuildState): this;
  54165. protected _dumpPropertiesCode(): string;
  54166. serialize(): any;
  54167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54168. }
  54169. }
  54170. declare module BABYLON {
  54171. /**
  54172. * Block used to discard a pixel if a value is smaller than a cutoff
  54173. */
  54174. export class DiscardBlock extends NodeMaterialBlock {
  54175. /**
  54176. * Create a new DiscardBlock
  54177. * @param name defines the block name
  54178. */
  54179. constructor(name: string);
  54180. /**
  54181. * Gets the current class name
  54182. * @returns the class name
  54183. */
  54184. getClassName(): string;
  54185. /**
  54186. * Gets the color input component
  54187. */
  54188. readonly value: NodeMaterialConnectionPoint;
  54189. /**
  54190. * Gets the cutoff input component
  54191. */
  54192. readonly cutoff: NodeMaterialConnectionPoint;
  54193. protected _buildBlock(state: NodeMaterialBuildState): this;
  54194. }
  54195. }
  54196. declare module BABYLON {
  54197. /**
  54198. * Block used to add support for scene fog
  54199. */
  54200. export class FogBlock extends NodeMaterialBlock {
  54201. private _fogDistanceName;
  54202. private _fogParameters;
  54203. /**
  54204. * Create a new FogBlock
  54205. * @param name defines the block name
  54206. */
  54207. constructor(name: string);
  54208. /**
  54209. * Gets the current class name
  54210. * @returns the class name
  54211. */
  54212. getClassName(): string;
  54213. /**
  54214. * Gets the world position input component
  54215. */
  54216. readonly worldPosition: NodeMaterialConnectionPoint;
  54217. /**
  54218. * Gets the view input component
  54219. */
  54220. readonly view: NodeMaterialConnectionPoint;
  54221. /**
  54222. * Gets the color input component
  54223. */
  54224. readonly input: NodeMaterialConnectionPoint;
  54225. /**
  54226. * Gets the fog color input component
  54227. */
  54228. readonly fogColor: NodeMaterialConnectionPoint;
  54229. /**
  54230. * Gets the output component
  54231. */
  54232. readonly output: NodeMaterialConnectionPoint;
  54233. autoConfigure(material: NodeMaterial): void;
  54234. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54235. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54236. protected _buildBlock(state: NodeMaterialBuildState): this;
  54237. }
  54238. }
  54239. declare module BABYLON {
  54240. /**
  54241. * Block used to add light in the fragment shader
  54242. */
  54243. export class LightBlock extends NodeMaterialBlock {
  54244. private _lightId;
  54245. /**
  54246. * Gets or sets the light associated with this block
  54247. */
  54248. light: Nullable<Light>;
  54249. /**
  54250. * Create a new LightBlock
  54251. * @param name defines the block name
  54252. */
  54253. constructor(name: string);
  54254. /**
  54255. * Gets the current class name
  54256. * @returns the class name
  54257. */
  54258. getClassName(): string;
  54259. /**
  54260. * Gets the world position input component
  54261. */
  54262. readonly worldPosition: NodeMaterialConnectionPoint;
  54263. /**
  54264. * Gets the world normal input component
  54265. */
  54266. readonly worldNormal: NodeMaterialConnectionPoint;
  54267. /**
  54268. * Gets the camera (or eye) position component
  54269. */
  54270. readonly cameraPosition: NodeMaterialConnectionPoint;
  54271. /**
  54272. * Gets the glossiness component
  54273. */
  54274. readonly glossiness: NodeMaterialConnectionPoint;
  54275. /**
  54276. * Gets the glossinness power component
  54277. */
  54278. readonly glossPower: NodeMaterialConnectionPoint;
  54279. /**
  54280. * Gets the diffuse color component
  54281. */
  54282. readonly diffuseColor: NodeMaterialConnectionPoint;
  54283. /**
  54284. * Gets the specular color component
  54285. */
  54286. readonly specularColor: NodeMaterialConnectionPoint;
  54287. /**
  54288. * Gets the diffuse output component
  54289. */
  54290. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54291. /**
  54292. * Gets the specular output component
  54293. */
  54294. readonly specularOutput: NodeMaterialConnectionPoint;
  54295. autoConfigure(material: NodeMaterial): void;
  54296. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54297. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54298. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54299. private _injectVertexCode;
  54300. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54301. serialize(): any;
  54302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54303. }
  54304. }
  54305. declare module BABYLON {
  54306. /**
  54307. * Block used to multiply 2 values
  54308. */
  54309. export class MultiplyBlock extends NodeMaterialBlock {
  54310. /**
  54311. * Creates a new MultiplyBlock
  54312. * @param name defines the block name
  54313. */
  54314. constructor(name: string);
  54315. /**
  54316. * Gets the current class name
  54317. * @returns the class name
  54318. */
  54319. getClassName(): string;
  54320. /**
  54321. * Gets the left operand input component
  54322. */
  54323. readonly left: NodeMaterialConnectionPoint;
  54324. /**
  54325. * Gets the right operand input component
  54326. */
  54327. readonly right: NodeMaterialConnectionPoint;
  54328. /**
  54329. * Gets the output component
  54330. */
  54331. readonly output: NodeMaterialConnectionPoint;
  54332. protected _buildBlock(state: NodeMaterialBuildState): this;
  54333. }
  54334. }
  54335. declare module BABYLON {
  54336. /**
  54337. * Block used to add 2 vectors
  54338. */
  54339. export class AddBlock extends NodeMaterialBlock {
  54340. /**
  54341. * Creates a new AddBlock
  54342. * @param name defines the block name
  54343. */
  54344. constructor(name: string);
  54345. /**
  54346. * Gets the current class name
  54347. * @returns the class name
  54348. */
  54349. getClassName(): string;
  54350. /**
  54351. * Gets the left operand input component
  54352. */
  54353. readonly left: NodeMaterialConnectionPoint;
  54354. /**
  54355. * Gets the right operand input component
  54356. */
  54357. readonly right: NodeMaterialConnectionPoint;
  54358. /**
  54359. * Gets the output component
  54360. */
  54361. readonly output: NodeMaterialConnectionPoint;
  54362. protected _buildBlock(state: NodeMaterialBuildState): this;
  54363. }
  54364. }
  54365. declare module BABYLON {
  54366. /**
  54367. * Block used to scale a vector by a float
  54368. */
  54369. export class ScaleBlock extends NodeMaterialBlock {
  54370. /**
  54371. * Creates a new ScaleBlock
  54372. * @param name defines the block name
  54373. */
  54374. constructor(name: string);
  54375. /**
  54376. * Gets the current class name
  54377. * @returns the class name
  54378. */
  54379. getClassName(): string;
  54380. /**
  54381. * Gets the input component
  54382. */
  54383. readonly input: NodeMaterialConnectionPoint;
  54384. /**
  54385. * Gets the factor input component
  54386. */
  54387. readonly factor: NodeMaterialConnectionPoint;
  54388. /**
  54389. * Gets the output component
  54390. */
  54391. readonly output: NodeMaterialConnectionPoint;
  54392. protected _buildBlock(state: NodeMaterialBuildState): this;
  54393. }
  54394. }
  54395. declare module BABYLON {
  54396. /**
  54397. * Block used to clamp a float
  54398. */
  54399. export class ClampBlock extends NodeMaterialBlock {
  54400. /** Gets or sets the minimum range */
  54401. minimum: number;
  54402. /** Gets or sets the maximum range */
  54403. maximum: number;
  54404. /**
  54405. * Creates a new ClampBlock
  54406. * @param name defines the block name
  54407. */
  54408. constructor(name: string);
  54409. /**
  54410. * Gets the current class name
  54411. * @returns the class name
  54412. */
  54413. getClassName(): string;
  54414. /**
  54415. * Gets the value input component
  54416. */
  54417. readonly value: NodeMaterialConnectionPoint;
  54418. /**
  54419. * Gets the output component
  54420. */
  54421. readonly output: NodeMaterialConnectionPoint;
  54422. protected _buildBlock(state: NodeMaterialBuildState): this;
  54423. protected _dumpPropertiesCode(): string;
  54424. serialize(): any;
  54425. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54426. }
  54427. }
  54428. declare module BABYLON {
  54429. /**
  54430. * Block used to apply a cross product between 2 vectors
  54431. */
  54432. export class CrossBlock extends NodeMaterialBlock {
  54433. /**
  54434. * Creates a new CrossBlock
  54435. * @param name defines the block name
  54436. */
  54437. constructor(name: string);
  54438. /**
  54439. * Gets the current class name
  54440. * @returns the class name
  54441. */
  54442. getClassName(): string;
  54443. /**
  54444. * Gets the left operand input component
  54445. */
  54446. readonly left: NodeMaterialConnectionPoint;
  54447. /**
  54448. * Gets the right operand input component
  54449. */
  54450. readonly right: NodeMaterialConnectionPoint;
  54451. /**
  54452. * Gets the output component
  54453. */
  54454. readonly output: NodeMaterialConnectionPoint;
  54455. protected _buildBlock(state: NodeMaterialBuildState): this;
  54456. }
  54457. }
  54458. declare module BABYLON {
  54459. /**
  54460. * Block used to apply a dot product between 2 vectors
  54461. */
  54462. export class DotBlock extends NodeMaterialBlock {
  54463. /**
  54464. * Creates a new DotBlock
  54465. * @param name defines the block name
  54466. */
  54467. constructor(name: string);
  54468. /**
  54469. * Gets the current class name
  54470. * @returns the class name
  54471. */
  54472. getClassName(): string;
  54473. /**
  54474. * Gets the left operand input component
  54475. */
  54476. readonly left: NodeMaterialConnectionPoint;
  54477. /**
  54478. * Gets the right operand input component
  54479. */
  54480. readonly right: NodeMaterialConnectionPoint;
  54481. /**
  54482. * Gets the output component
  54483. */
  54484. readonly output: NodeMaterialConnectionPoint;
  54485. protected _buildBlock(state: NodeMaterialBuildState): this;
  54486. }
  54487. }
  54488. declare module BABYLON {
  54489. /**
  54490. * Block used to remap a float from a range to a new one
  54491. */
  54492. export class RemapBlock extends NodeMaterialBlock {
  54493. /**
  54494. * Gets or sets the source range
  54495. */
  54496. sourceRange: Vector2;
  54497. /**
  54498. * Gets or sets the target range
  54499. */
  54500. targetRange: Vector2;
  54501. /**
  54502. * Creates a new RemapBlock
  54503. * @param name defines the block name
  54504. */
  54505. constructor(name: string);
  54506. /**
  54507. * Gets the current class name
  54508. * @returns the class name
  54509. */
  54510. getClassName(): string;
  54511. /**
  54512. * Gets the input component
  54513. */
  54514. readonly input: NodeMaterialConnectionPoint;
  54515. /**
  54516. * Gets the source min input component
  54517. */
  54518. readonly sourceMin: NodeMaterialConnectionPoint;
  54519. /**
  54520. * Gets the source max input component
  54521. */
  54522. readonly sourceMax: NodeMaterialConnectionPoint;
  54523. /**
  54524. * Gets the target min input component
  54525. */
  54526. readonly targetMin: NodeMaterialConnectionPoint;
  54527. /**
  54528. * Gets the target max input component
  54529. */
  54530. readonly targetMax: NodeMaterialConnectionPoint;
  54531. /**
  54532. * Gets the output component
  54533. */
  54534. readonly output: NodeMaterialConnectionPoint;
  54535. protected _buildBlock(state: NodeMaterialBuildState): this;
  54536. protected _dumpPropertiesCode(): string;
  54537. serialize(): any;
  54538. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54539. }
  54540. }
  54541. declare module BABYLON {
  54542. /**
  54543. * Block used to normalize a vector
  54544. */
  54545. export class NormalizeBlock extends NodeMaterialBlock {
  54546. /**
  54547. * Creates a new NormalizeBlock
  54548. * @param name defines the block name
  54549. */
  54550. constructor(name: string);
  54551. /**
  54552. * Gets the current class name
  54553. * @returns the class name
  54554. */
  54555. getClassName(): string;
  54556. /**
  54557. * Gets the input component
  54558. */
  54559. readonly input: NodeMaterialConnectionPoint;
  54560. /**
  54561. * Gets the output component
  54562. */
  54563. readonly output: NodeMaterialConnectionPoint;
  54564. protected _buildBlock(state: NodeMaterialBuildState): this;
  54565. }
  54566. }
  54567. declare module BABYLON {
  54568. /**
  54569. * Operations supported by the Trigonometry block
  54570. */
  54571. export enum TrigonometryBlockOperations {
  54572. /** Cos */
  54573. Cos = 0,
  54574. /** Sin */
  54575. Sin = 1,
  54576. /** Abs */
  54577. Abs = 2,
  54578. /** Exp */
  54579. Exp = 3,
  54580. /** Exp2 */
  54581. Exp2 = 4,
  54582. /** Round */
  54583. Round = 5,
  54584. /** Floor */
  54585. Floor = 6,
  54586. /** Ceiling */
  54587. Ceiling = 7,
  54588. /** Square root */
  54589. Sqrt = 8,
  54590. /** Log */
  54591. Log = 9,
  54592. /** Tangent */
  54593. Tan = 10,
  54594. /** Arc tangent */
  54595. ArcTan = 11,
  54596. /** Arc cosinus */
  54597. ArcCos = 12,
  54598. /** Arc sinus */
  54599. ArcSin = 13,
  54600. /** Fraction */
  54601. Fract = 14,
  54602. /** Sign */
  54603. Sign = 15,
  54604. /** To radians (from degrees) */
  54605. Radians = 16,
  54606. /** To degrees (from radians) */
  54607. Degrees = 17
  54608. }
  54609. /**
  54610. * Block used to apply trigonometry operation to floats
  54611. */
  54612. export class TrigonometryBlock extends NodeMaterialBlock {
  54613. /**
  54614. * Gets or sets the operation applied by the block
  54615. */
  54616. operation: TrigonometryBlockOperations;
  54617. /**
  54618. * Creates a new TrigonometryBlock
  54619. * @param name defines the block name
  54620. */
  54621. constructor(name: string);
  54622. /**
  54623. * Gets the current class name
  54624. * @returns the class name
  54625. */
  54626. getClassName(): string;
  54627. /**
  54628. * Gets the input component
  54629. */
  54630. readonly input: NodeMaterialConnectionPoint;
  54631. /**
  54632. * Gets the output component
  54633. */
  54634. readonly output: NodeMaterialConnectionPoint;
  54635. protected _buildBlock(state: NodeMaterialBuildState): this;
  54636. serialize(): any;
  54637. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54638. }
  54639. }
  54640. declare module BABYLON {
  54641. /**
  54642. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54643. */
  54644. export class ColorMergerBlock extends NodeMaterialBlock {
  54645. /**
  54646. * Create a new ColorMergerBlock
  54647. * @param name defines the block name
  54648. */
  54649. constructor(name: string);
  54650. /**
  54651. * Gets the current class name
  54652. * @returns the class name
  54653. */
  54654. getClassName(): string;
  54655. /**
  54656. * Gets the r component (input)
  54657. */
  54658. readonly r: NodeMaterialConnectionPoint;
  54659. /**
  54660. * Gets the g component (input)
  54661. */
  54662. readonly g: NodeMaterialConnectionPoint;
  54663. /**
  54664. * Gets the b component (input)
  54665. */
  54666. readonly b: NodeMaterialConnectionPoint;
  54667. /**
  54668. * Gets the a component (input)
  54669. */
  54670. readonly a: NodeMaterialConnectionPoint;
  54671. /**
  54672. * Gets the rgba component (output)
  54673. */
  54674. readonly rgba: NodeMaterialConnectionPoint;
  54675. /**
  54676. * Gets the rgb component (output)
  54677. */
  54678. readonly rgb: NodeMaterialConnectionPoint;
  54679. protected _buildBlock(state: NodeMaterialBuildState): this;
  54680. }
  54681. }
  54682. declare module BABYLON {
  54683. /**
  54684. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54685. */
  54686. export class VectorMergerBlock extends NodeMaterialBlock {
  54687. /**
  54688. * Create a new VectorMergerBlock
  54689. * @param name defines the block name
  54690. */
  54691. constructor(name: string);
  54692. /**
  54693. * Gets the current class name
  54694. * @returns the class name
  54695. */
  54696. getClassName(): string;
  54697. /**
  54698. * Gets the x component (input)
  54699. */
  54700. readonly x: NodeMaterialConnectionPoint;
  54701. /**
  54702. * Gets the y component (input)
  54703. */
  54704. readonly y: NodeMaterialConnectionPoint;
  54705. /**
  54706. * Gets the z component (input)
  54707. */
  54708. readonly z: NodeMaterialConnectionPoint;
  54709. /**
  54710. * Gets the w component (input)
  54711. */
  54712. readonly w: NodeMaterialConnectionPoint;
  54713. /**
  54714. * Gets the xyzw component (output)
  54715. */
  54716. readonly xyzw: NodeMaterialConnectionPoint;
  54717. /**
  54718. * Gets the xyz component (output)
  54719. */
  54720. readonly xyz: NodeMaterialConnectionPoint;
  54721. /**
  54722. * Gets the xy component (output)
  54723. */
  54724. readonly xy: NodeMaterialConnectionPoint;
  54725. protected _buildBlock(state: NodeMaterialBuildState): this;
  54726. }
  54727. }
  54728. declare module BABYLON {
  54729. /**
  54730. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54731. */
  54732. export class ColorSplitterBlock extends NodeMaterialBlock {
  54733. /**
  54734. * Create a new ColorSplitterBlock
  54735. * @param name defines the block name
  54736. */
  54737. constructor(name: string);
  54738. /**
  54739. * Gets the current class name
  54740. * @returns the class name
  54741. */
  54742. getClassName(): string;
  54743. /**
  54744. * Gets the rgba component (input)
  54745. */
  54746. readonly rgba: NodeMaterialConnectionPoint;
  54747. /**
  54748. * Gets the rgb component (input)
  54749. */
  54750. readonly rgbIn: NodeMaterialConnectionPoint;
  54751. /**
  54752. * Gets the rgb component (output)
  54753. */
  54754. readonly rgbOut: NodeMaterialConnectionPoint;
  54755. /**
  54756. * Gets the r component (output)
  54757. */
  54758. readonly r: NodeMaterialConnectionPoint;
  54759. /**
  54760. * Gets the g component (output)
  54761. */
  54762. readonly g: NodeMaterialConnectionPoint;
  54763. /**
  54764. * Gets the b component (output)
  54765. */
  54766. readonly b: NodeMaterialConnectionPoint;
  54767. /**
  54768. * Gets the a component (output)
  54769. */
  54770. readonly a: NodeMaterialConnectionPoint;
  54771. protected _inputRename(name: string): string;
  54772. protected _outputRename(name: string): string;
  54773. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54774. }
  54775. }
  54776. declare module BABYLON {
  54777. /**
  54778. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54779. */
  54780. export class VectorSplitterBlock extends NodeMaterialBlock {
  54781. /**
  54782. * Create a new VectorSplitterBlock
  54783. * @param name defines the block name
  54784. */
  54785. constructor(name: string);
  54786. /**
  54787. * Gets the current class name
  54788. * @returns the class name
  54789. */
  54790. getClassName(): string;
  54791. /**
  54792. * Gets the xyzw component (input)
  54793. */
  54794. readonly xyzw: NodeMaterialConnectionPoint;
  54795. /**
  54796. * Gets the xyz component (input)
  54797. */
  54798. readonly xyzIn: NodeMaterialConnectionPoint;
  54799. /**
  54800. * Gets the xy component (input)
  54801. */
  54802. readonly xyIn: NodeMaterialConnectionPoint;
  54803. /**
  54804. * Gets the xyz component (output)
  54805. */
  54806. readonly xyzOut: NodeMaterialConnectionPoint;
  54807. /**
  54808. * Gets the xy component (output)
  54809. */
  54810. readonly xyOut: NodeMaterialConnectionPoint;
  54811. /**
  54812. * Gets the x component (output)
  54813. */
  54814. readonly x: NodeMaterialConnectionPoint;
  54815. /**
  54816. * Gets the y component (output)
  54817. */
  54818. readonly y: NodeMaterialConnectionPoint;
  54819. /**
  54820. * Gets the z component (output)
  54821. */
  54822. readonly z: NodeMaterialConnectionPoint;
  54823. /**
  54824. * Gets the w component (output)
  54825. */
  54826. readonly w: NodeMaterialConnectionPoint;
  54827. protected _inputRename(name: string): string;
  54828. protected _outputRename(name: string): string;
  54829. protected _buildBlock(state: NodeMaterialBuildState): this;
  54830. }
  54831. }
  54832. declare module BABYLON {
  54833. /**
  54834. * Block used to lerp between 2 values
  54835. */
  54836. export class LerpBlock extends NodeMaterialBlock {
  54837. /**
  54838. * Creates a new LerpBlock
  54839. * @param name defines the block name
  54840. */
  54841. constructor(name: string);
  54842. /**
  54843. * Gets the current class name
  54844. * @returns the class name
  54845. */
  54846. getClassName(): string;
  54847. /**
  54848. * Gets the left operand input component
  54849. */
  54850. readonly left: NodeMaterialConnectionPoint;
  54851. /**
  54852. * Gets the right operand input component
  54853. */
  54854. readonly right: NodeMaterialConnectionPoint;
  54855. /**
  54856. * Gets the gradient operand input component
  54857. */
  54858. readonly gradient: NodeMaterialConnectionPoint;
  54859. /**
  54860. * Gets the output component
  54861. */
  54862. readonly output: NodeMaterialConnectionPoint;
  54863. protected _buildBlock(state: NodeMaterialBuildState): this;
  54864. }
  54865. }
  54866. declare module BABYLON {
  54867. /**
  54868. * Block used to divide 2 vectors
  54869. */
  54870. export class DivideBlock extends NodeMaterialBlock {
  54871. /**
  54872. * Creates a new DivideBlock
  54873. * @param name defines the block name
  54874. */
  54875. constructor(name: string);
  54876. /**
  54877. * Gets the current class name
  54878. * @returns the class name
  54879. */
  54880. getClassName(): string;
  54881. /**
  54882. * Gets the left operand input component
  54883. */
  54884. readonly left: NodeMaterialConnectionPoint;
  54885. /**
  54886. * Gets the right operand input component
  54887. */
  54888. readonly right: NodeMaterialConnectionPoint;
  54889. /**
  54890. * Gets the output component
  54891. */
  54892. readonly output: NodeMaterialConnectionPoint;
  54893. protected _buildBlock(state: NodeMaterialBuildState): this;
  54894. }
  54895. }
  54896. declare module BABYLON {
  54897. /**
  54898. * Block used to subtract 2 vectors
  54899. */
  54900. export class SubtractBlock extends NodeMaterialBlock {
  54901. /**
  54902. * Creates a new SubtractBlock
  54903. * @param name defines the block name
  54904. */
  54905. constructor(name: string);
  54906. /**
  54907. * Gets the current class name
  54908. * @returns the class name
  54909. */
  54910. getClassName(): string;
  54911. /**
  54912. * Gets the left operand input component
  54913. */
  54914. readonly left: NodeMaterialConnectionPoint;
  54915. /**
  54916. * Gets the right operand input component
  54917. */
  54918. readonly right: NodeMaterialConnectionPoint;
  54919. /**
  54920. * Gets the output component
  54921. */
  54922. readonly output: NodeMaterialConnectionPoint;
  54923. protected _buildBlock(state: NodeMaterialBuildState): this;
  54924. }
  54925. }
  54926. declare module BABYLON {
  54927. /**
  54928. * Block used to step a value
  54929. */
  54930. export class StepBlock extends NodeMaterialBlock {
  54931. /**
  54932. * Creates a new StepBlock
  54933. * @param name defines the block name
  54934. */
  54935. constructor(name: string);
  54936. /**
  54937. * Gets the current class name
  54938. * @returns the class name
  54939. */
  54940. getClassName(): string;
  54941. /**
  54942. * Gets the value operand input component
  54943. */
  54944. readonly value: NodeMaterialConnectionPoint;
  54945. /**
  54946. * Gets the edge operand input component
  54947. */
  54948. readonly edge: NodeMaterialConnectionPoint;
  54949. /**
  54950. * Gets the output component
  54951. */
  54952. readonly output: NodeMaterialConnectionPoint;
  54953. protected _buildBlock(state: NodeMaterialBuildState): this;
  54954. }
  54955. }
  54956. declare module BABYLON {
  54957. /**
  54958. * Block used to get the opposite (1 - x) of a value
  54959. */
  54960. export class OneMinusBlock extends NodeMaterialBlock {
  54961. /**
  54962. * Creates a new OneMinusBlock
  54963. * @param name defines the block name
  54964. */
  54965. constructor(name: string);
  54966. /**
  54967. * Gets the current class name
  54968. * @returns the class name
  54969. */
  54970. getClassName(): string;
  54971. /**
  54972. * Gets the input component
  54973. */
  54974. readonly input: NodeMaterialConnectionPoint;
  54975. /**
  54976. * Gets the output component
  54977. */
  54978. readonly output: NodeMaterialConnectionPoint;
  54979. protected _buildBlock(state: NodeMaterialBuildState): this;
  54980. }
  54981. }
  54982. declare module BABYLON {
  54983. /**
  54984. * Block used to get the view direction
  54985. */
  54986. export class ViewDirectionBlock extends NodeMaterialBlock {
  54987. /**
  54988. * Creates a new ViewDirectionBlock
  54989. * @param name defines the block name
  54990. */
  54991. constructor(name: string);
  54992. /**
  54993. * Gets the current class name
  54994. * @returns the class name
  54995. */
  54996. getClassName(): string;
  54997. /**
  54998. * Gets the world position component
  54999. */
  55000. readonly worldPosition: NodeMaterialConnectionPoint;
  55001. /**
  55002. * Gets the camera position component
  55003. */
  55004. readonly cameraPosition: NodeMaterialConnectionPoint;
  55005. /**
  55006. * Gets the output component
  55007. */
  55008. readonly output: NodeMaterialConnectionPoint;
  55009. autoConfigure(material: NodeMaterial): void;
  55010. protected _buildBlock(state: NodeMaterialBuildState): this;
  55011. }
  55012. }
  55013. declare module BABYLON {
  55014. /**
  55015. * Block used to compute fresnel value
  55016. */
  55017. export class FresnelBlock extends NodeMaterialBlock {
  55018. /**
  55019. * Create a new FresnelBlock
  55020. * @param name defines the block name
  55021. */
  55022. constructor(name: string);
  55023. /**
  55024. * Gets the current class name
  55025. * @returns the class name
  55026. */
  55027. getClassName(): string;
  55028. /**
  55029. * Gets the world normal input component
  55030. */
  55031. readonly worldNormal: NodeMaterialConnectionPoint;
  55032. /**
  55033. * Gets the view direction input component
  55034. */
  55035. readonly viewDirection: NodeMaterialConnectionPoint;
  55036. /**
  55037. * Gets the bias input component
  55038. */
  55039. readonly bias: NodeMaterialConnectionPoint;
  55040. /**
  55041. * Gets the camera (or eye) position component
  55042. */
  55043. readonly power: NodeMaterialConnectionPoint;
  55044. /**
  55045. * Gets the fresnel output component
  55046. */
  55047. readonly fresnel: NodeMaterialConnectionPoint;
  55048. autoConfigure(material: NodeMaterial): void;
  55049. protected _buildBlock(state: NodeMaterialBuildState): this;
  55050. }
  55051. }
  55052. declare module BABYLON {
  55053. /**
  55054. * Block used to get the max of 2 values
  55055. */
  55056. export class MaxBlock extends NodeMaterialBlock {
  55057. /**
  55058. * Creates a new MaxBlock
  55059. * @param name defines the block name
  55060. */
  55061. constructor(name: string);
  55062. /**
  55063. * Gets the current class name
  55064. * @returns the class name
  55065. */
  55066. getClassName(): string;
  55067. /**
  55068. * Gets the left operand input component
  55069. */
  55070. readonly left: NodeMaterialConnectionPoint;
  55071. /**
  55072. * Gets the right operand input component
  55073. */
  55074. readonly right: NodeMaterialConnectionPoint;
  55075. /**
  55076. * Gets the output component
  55077. */
  55078. readonly output: NodeMaterialConnectionPoint;
  55079. protected _buildBlock(state: NodeMaterialBuildState): this;
  55080. }
  55081. }
  55082. declare module BABYLON {
  55083. /**
  55084. * Block used to get the min of 2 values
  55085. */
  55086. export class MinBlock extends NodeMaterialBlock {
  55087. /**
  55088. * Creates a new MinBlock
  55089. * @param name defines the block name
  55090. */
  55091. constructor(name: string);
  55092. /**
  55093. * Gets the current class name
  55094. * @returns the class name
  55095. */
  55096. getClassName(): string;
  55097. /**
  55098. * Gets the left operand input component
  55099. */
  55100. readonly left: NodeMaterialConnectionPoint;
  55101. /**
  55102. * Gets the right operand input component
  55103. */
  55104. readonly right: NodeMaterialConnectionPoint;
  55105. /**
  55106. * Gets the output component
  55107. */
  55108. readonly output: NodeMaterialConnectionPoint;
  55109. protected _buildBlock(state: NodeMaterialBuildState): this;
  55110. }
  55111. }
  55112. declare module BABYLON {
  55113. /**
  55114. * Block used to get the distance between 2 values
  55115. */
  55116. export class DistanceBlock extends NodeMaterialBlock {
  55117. /**
  55118. * Creates a new DistanceBlock
  55119. * @param name defines the block name
  55120. */
  55121. constructor(name: string);
  55122. /**
  55123. * Gets the current class name
  55124. * @returns the class name
  55125. */
  55126. getClassName(): string;
  55127. /**
  55128. * Gets the left operand input component
  55129. */
  55130. readonly left: NodeMaterialConnectionPoint;
  55131. /**
  55132. * Gets the right operand input component
  55133. */
  55134. readonly right: NodeMaterialConnectionPoint;
  55135. /**
  55136. * Gets the output component
  55137. */
  55138. readonly output: NodeMaterialConnectionPoint;
  55139. protected _buildBlock(state: NodeMaterialBuildState): this;
  55140. }
  55141. }
  55142. declare module BABYLON {
  55143. /**
  55144. * Block used to get the length of a vector
  55145. */
  55146. export class LengthBlock extends NodeMaterialBlock {
  55147. /**
  55148. * Creates a new LengthBlock
  55149. * @param name defines the block name
  55150. */
  55151. constructor(name: string);
  55152. /**
  55153. * Gets the current class name
  55154. * @returns the class name
  55155. */
  55156. getClassName(): string;
  55157. /**
  55158. * Gets the value input component
  55159. */
  55160. readonly value: NodeMaterialConnectionPoint;
  55161. /**
  55162. * Gets the output component
  55163. */
  55164. readonly output: NodeMaterialConnectionPoint;
  55165. protected _buildBlock(state: NodeMaterialBuildState): this;
  55166. }
  55167. }
  55168. declare module BABYLON {
  55169. /**
  55170. * Block used to get negative version of a value (i.e. x * -1)
  55171. */
  55172. export class NegateBlock extends NodeMaterialBlock {
  55173. /**
  55174. * Creates a new NegateBlock
  55175. * @param name defines the block name
  55176. */
  55177. constructor(name: string);
  55178. /**
  55179. * Gets the current class name
  55180. * @returns the class name
  55181. */
  55182. getClassName(): string;
  55183. /**
  55184. * Gets the value input component
  55185. */
  55186. readonly value: NodeMaterialConnectionPoint;
  55187. /**
  55188. * Gets the output component
  55189. */
  55190. readonly output: NodeMaterialConnectionPoint;
  55191. protected _buildBlock(state: NodeMaterialBuildState): this;
  55192. }
  55193. }
  55194. declare module BABYLON {
  55195. /**
  55196. * Block used to get the value of the first parameter raised to the power of the second
  55197. */
  55198. export class PowBlock extends NodeMaterialBlock {
  55199. /**
  55200. * Creates a new PowBlock
  55201. * @param name defines the block name
  55202. */
  55203. constructor(name: string);
  55204. /**
  55205. * Gets the current class name
  55206. * @returns the class name
  55207. */
  55208. getClassName(): string;
  55209. /**
  55210. * Gets the value operand input component
  55211. */
  55212. readonly value: NodeMaterialConnectionPoint;
  55213. /**
  55214. * Gets the power operand input component
  55215. */
  55216. readonly power: NodeMaterialConnectionPoint;
  55217. /**
  55218. * Gets the output component
  55219. */
  55220. readonly output: NodeMaterialConnectionPoint;
  55221. protected _buildBlock(state: NodeMaterialBuildState): this;
  55222. }
  55223. }
  55224. declare module BABYLON {
  55225. /**
  55226. * Block used to get a random number
  55227. */
  55228. export class RandomNumberBlock extends NodeMaterialBlock {
  55229. /**
  55230. * Creates a new RandomNumberBlock
  55231. * @param name defines the block name
  55232. */
  55233. constructor(name: string);
  55234. /**
  55235. * Gets the current class name
  55236. * @returns the class name
  55237. */
  55238. getClassName(): string;
  55239. /**
  55240. * Gets the seed input component
  55241. */
  55242. readonly seed: NodeMaterialConnectionPoint;
  55243. /**
  55244. * Gets the output component
  55245. */
  55246. readonly output: NodeMaterialConnectionPoint;
  55247. protected _buildBlock(state: NodeMaterialBuildState): this;
  55248. }
  55249. }
  55250. declare module BABYLON {
  55251. /**
  55252. * Block used to compute arc tangent of 2 values
  55253. */
  55254. export class ArcTan2Block extends NodeMaterialBlock {
  55255. /**
  55256. * Creates a new ArcTan2Block
  55257. * @param name defines the block name
  55258. */
  55259. constructor(name: string);
  55260. /**
  55261. * Gets the current class name
  55262. * @returns the class name
  55263. */
  55264. getClassName(): string;
  55265. /**
  55266. * Gets the x operand input component
  55267. */
  55268. readonly x: NodeMaterialConnectionPoint;
  55269. /**
  55270. * Gets the y operand input component
  55271. */
  55272. readonly y: NodeMaterialConnectionPoint;
  55273. /**
  55274. * Gets the output component
  55275. */
  55276. readonly output: NodeMaterialConnectionPoint;
  55277. protected _buildBlock(state: NodeMaterialBuildState): this;
  55278. }
  55279. }
  55280. declare module BABYLON {
  55281. /**
  55282. * Block used to smooth step a value
  55283. */
  55284. export class SmoothStepBlock extends NodeMaterialBlock {
  55285. /**
  55286. * Creates a new SmoothStepBlock
  55287. * @param name defines the block name
  55288. */
  55289. constructor(name: string);
  55290. /**
  55291. * Gets the current class name
  55292. * @returns the class name
  55293. */
  55294. getClassName(): string;
  55295. /**
  55296. * Gets the value operand input component
  55297. */
  55298. readonly value: NodeMaterialConnectionPoint;
  55299. /**
  55300. * Gets the first edge operand input component
  55301. */
  55302. readonly edge0: NodeMaterialConnectionPoint;
  55303. /**
  55304. * Gets the second edge operand input component
  55305. */
  55306. readonly edge1: NodeMaterialConnectionPoint;
  55307. /**
  55308. * Gets the output component
  55309. */
  55310. readonly output: NodeMaterialConnectionPoint;
  55311. protected _buildBlock(state: NodeMaterialBuildState): this;
  55312. }
  55313. }
  55314. declare module BABYLON {
  55315. /**
  55316. * Block used to get the reciprocal (1 / x) of a value
  55317. */
  55318. export class ReciprocalBlock extends NodeMaterialBlock {
  55319. /**
  55320. * Creates a new ReciprocalBlock
  55321. * @param name defines the block name
  55322. */
  55323. constructor(name: string);
  55324. /**
  55325. * Gets the current class name
  55326. * @returns the class name
  55327. */
  55328. getClassName(): string;
  55329. /**
  55330. * Gets the input component
  55331. */
  55332. readonly input: NodeMaterialConnectionPoint;
  55333. /**
  55334. * Gets the output component
  55335. */
  55336. readonly output: NodeMaterialConnectionPoint;
  55337. protected _buildBlock(state: NodeMaterialBuildState): this;
  55338. }
  55339. }
  55340. declare module BABYLON {
  55341. /**
  55342. * Block used to replace a color by another one
  55343. */
  55344. export class ReplaceColorBlock extends NodeMaterialBlock {
  55345. /**
  55346. * Creates a new ReplaceColorBlock
  55347. * @param name defines the block name
  55348. */
  55349. constructor(name: string);
  55350. /**
  55351. * Gets the current class name
  55352. * @returns the class name
  55353. */
  55354. getClassName(): string;
  55355. /**
  55356. * Gets the value input component
  55357. */
  55358. readonly value: NodeMaterialConnectionPoint;
  55359. /**
  55360. * Gets the reference input component
  55361. */
  55362. readonly reference: NodeMaterialConnectionPoint;
  55363. /**
  55364. * Gets the distance input component
  55365. */
  55366. readonly distance: NodeMaterialConnectionPoint;
  55367. /**
  55368. * Gets the replacement input component
  55369. */
  55370. readonly replacement: NodeMaterialConnectionPoint;
  55371. /**
  55372. * Gets the output component
  55373. */
  55374. readonly output: NodeMaterialConnectionPoint;
  55375. protected _buildBlock(state: NodeMaterialBuildState): this;
  55376. }
  55377. }
  55378. declare module BABYLON {
  55379. /**
  55380. * Block used to posterize a value
  55381. * @see https://en.wikipedia.org/wiki/Posterization
  55382. */
  55383. export class PosterizeBlock extends NodeMaterialBlock {
  55384. /**
  55385. * Creates a new PosterizeBlock
  55386. * @param name defines the block name
  55387. */
  55388. constructor(name: string);
  55389. /**
  55390. * Gets the current class name
  55391. * @returns the class name
  55392. */
  55393. getClassName(): string;
  55394. /**
  55395. * Gets the value input component
  55396. */
  55397. readonly value: NodeMaterialConnectionPoint;
  55398. /**
  55399. * Gets the steps input component
  55400. */
  55401. readonly steps: NodeMaterialConnectionPoint;
  55402. /**
  55403. * Gets the output component
  55404. */
  55405. readonly output: NodeMaterialConnectionPoint;
  55406. protected _buildBlock(state: NodeMaterialBuildState): this;
  55407. }
  55408. }
  55409. declare module BABYLON {
  55410. /**
  55411. * Operations supported by the Wave block
  55412. */
  55413. export enum WaveBlockKind {
  55414. /** SawTooth */
  55415. SawTooth = 0,
  55416. /** Square */
  55417. Square = 1,
  55418. /** Triangle */
  55419. Triangle = 2
  55420. }
  55421. /**
  55422. * Block used to apply wave operation to floats
  55423. */
  55424. export class WaveBlock extends NodeMaterialBlock {
  55425. /**
  55426. * Gets or sets the kibnd of wave to be applied by the block
  55427. */
  55428. kind: WaveBlockKind;
  55429. /**
  55430. * Creates a new WaveBlock
  55431. * @param name defines the block name
  55432. */
  55433. constructor(name: string);
  55434. /**
  55435. * Gets the current class name
  55436. * @returns the class name
  55437. */
  55438. getClassName(): string;
  55439. /**
  55440. * Gets the input component
  55441. */
  55442. readonly input: NodeMaterialConnectionPoint;
  55443. /**
  55444. * Gets the output component
  55445. */
  55446. readonly output: NodeMaterialConnectionPoint;
  55447. protected _buildBlock(state: NodeMaterialBuildState): this;
  55448. serialize(): any;
  55449. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55450. }
  55451. }
  55452. declare module BABYLON {
  55453. /**
  55454. * Class used to store a color step for the GradientBlock
  55455. */
  55456. export class GradientBlockColorStep {
  55457. /**
  55458. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55459. */
  55460. step: number;
  55461. /**
  55462. * Gets or sets the color associated with this step
  55463. */
  55464. color: Color3;
  55465. /**
  55466. * Creates a new GradientBlockColorStep
  55467. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  55468. * @param color defines the color associated with this step
  55469. */
  55470. constructor(
  55471. /**
  55472. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55473. */
  55474. step: number,
  55475. /**
  55476. * Gets or sets the color associated with this step
  55477. */
  55478. color: Color3);
  55479. }
  55480. /**
  55481. * Block used to return a color from a gradient based on an input value between 0 and 1
  55482. */
  55483. export class GradientBlock extends NodeMaterialBlock {
  55484. /**
  55485. * Gets or sets the list of color steps
  55486. */
  55487. colorSteps: GradientBlockColorStep[];
  55488. /**
  55489. * Creates a new GradientBlock
  55490. * @param name defines the block name
  55491. */
  55492. constructor(name: string);
  55493. /**
  55494. * Gets the current class name
  55495. * @returns the class name
  55496. */
  55497. getClassName(): string;
  55498. /**
  55499. * Gets the gradient input component
  55500. */
  55501. readonly gradient: NodeMaterialConnectionPoint;
  55502. /**
  55503. * Gets the output component
  55504. */
  55505. readonly output: NodeMaterialConnectionPoint;
  55506. private _writeColorConstant;
  55507. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55508. serialize(): any;
  55509. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55510. protected _dumpPropertiesCode(): string;
  55511. }
  55512. }
  55513. declare module BABYLON {
  55514. /**
  55515. * Block used to normalize lerp between 2 values
  55516. */
  55517. export class NLerpBlock extends NodeMaterialBlock {
  55518. /**
  55519. * Creates a new NLerpBlock
  55520. * @param name defines the block name
  55521. */
  55522. constructor(name: string);
  55523. /**
  55524. * Gets the current class name
  55525. * @returns the class name
  55526. */
  55527. getClassName(): string;
  55528. /**
  55529. * Gets the left operand input component
  55530. */
  55531. readonly left: NodeMaterialConnectionPoint;
  55532. /**
  55533. * Gets the right operand input component
  55534. */
  55535. readonly right: NodeMaterialConnectionPoint;
  55536. /**
  55537. * Gets the gradient operand input component
  55538. */
  55539. readonly gradient: NodeMaterialConnectionPoint;
  55540. /**
  55541. * Gets the output component
  55542. */
  55543. readonly output: NodeMaterialConnectionPoint;
  55544. protected _buildBlock(state: NodeMaterialBuildState): this;
  55545. }
  55546. }
  55547. declare module BABYLON {
  55548. /**
  55549. * Effect Render Options
  55550. */
  55551. export interface IEffectRendererOptions {
  55552. /**
  55553. * Defines the vertices positions.
  55554. */
  55555. positions?: number[];
  55556. /**
  55557. * Defines the indices.
  55558. */
  55559. indices?: number[];
  55560. }
  55561. /**
  55562. * Helper class to render one or more effects
  55563. */
  55564. export class EffectRenderer {
  55565. private engine;
  55566. private static _DefaultOptions;
  55567. private _vertexBuffers;
  55568. private _indexBuffer;
  55569. private _ringBufferIndex;
  55570. private _ringScreenBuffer;
  55571. private _fullscreenViewport;
  55572. private _getNextFrameBuffer;
  55573. /**
  55574. * Creates an effect renderer
  55575. * @param engine the engine to use for rendering
  55576. * @param options defines the options of the effect renderer
  55577. */
  55578. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  55579. /**
  55580. * Sets the current viewport in normalized coordinates 0-1
  55581. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55582. */
  55583. setViewport(viewport?: Viewport): void;
  55584. /**
  55585. * Binds the embedded attributes buffer to the effect.
  55586. * @param effect Defines the effect to bind the attributes for
  55587. */
  55588. bindBuffers(effect: Effect): void;
  55589. /**
  55590. * Sets the current effect wrapper to use during draw.
  55591. * The effect needs to be ready before calling this api.
  55592. * This also sets the default full screen position attribute.
  55593. * @param effectWrapper Defines the effect to draw with
  55594. */
  55595. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55596. /**
  55597. * Draws a full screen quad.
  55598. */
  55599. draw(): void;
  55600. /**
  55601. * renders one or more effects to a specified texture
  55602. * @param effectWrappers list of effects to renderer
  55603. * @param outputTexture texture to draw to, if null it will render to the screen
  55604. */
  55605. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55606. /**
  55607. * Disposes of the effect renderer
  55608. */
  55609. dispose(): void;
  55610. }
  55611. /**
  55612. * Options to create an EffectWrapper
  55613. */
  55614. interface EffectWrapperCreationOptions {
  55615. /**
  55616. * Engine to use to create the effect
  55617. */
  55618. engine: ThinEngine;
  55619. /**
  55620. * Fragment shader for the effect
  55621. */
  55622. fragmentShader: string;
  55623. /**
  55624. * Vertex shader for the effect
  55625. */
  55626. vertexShader?: string;
  55627. /**
  55628. * Attributes to use in the shader
  55629. */
  55630. attributeNames?: Array<string>;
  55631. /**
  55632. * Uniforms to use in the shader
  55633. */
  55634. uniformNames?: Array<string>;
  55635. /**
  55636. * Texture sampler names to use in the shader
  55637. */
  55638. samplerNames?: Array<string>;
  55639. /**
  55640. * The friendly name of the effect displayed in Spector.
  55641. */
  55642. name?: string;
  55643. }
  55644. /**
  55645. * Wraps an effect to be used for rendering
  55646. */
  55647. export class EffectWrapper {
  55648. /**
  55649. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55650. */
  55651. onApplyObservable: Observable<{}>;
  55652. /**
  55653. * The underlying effect
  55654. */
  55655. effect: Effect;
  55656. /**
  55657. * Creates an effect to be renderer
  55658. * @param creationOptions options to create the effect
  55659. */
  55660. constructor(creationOptions: EffectWrapperCreationOptions);
  55661. /**
  55662. * Disposes of the effect wrapper
  55663. */
  55664. dispose(): void;
  55665. }
  55666. }
  55667. declare module BABYLON {
  55668. /**
  55669. * Helper class to push actions to a pool of workers.
  55670. */
  55671. export class WorkerPool implements IDisposable {
  55672. private _workerInfos;
  55673. private _pendingActions;
  55674. /**
  55675. * Constructor
  55676. * @param workers Array of workers to use for actions
  55677. */
  55678. constructor(workers: Array<Worker>);
  55679. /**
  55680. * Terminates all workers and clears any pending actions.
  55681. */
  55682. dispose(): void;
  55683. /**
  55684. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55685. * pended until a worker has completed its action.
  55686. * @param action The action to perform. Call onComplete when the action is complete.
  55687. */
  55688. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55689. private _execute;
  55690. }
  55691. }
  55692. declare module BABYLON {
  55693. /**
  55694. * Configuration for Draco compression
  55695. */
  55696. export interface IDracoCompressionConfiguration {
  55697. /**
  55698. * Configuration for the decoder.
  55699. */
  55700. decoder: {
  55701. /**
  55702. * The url to the WebAssembly module.
  55703. */
  55704. wasmUrl?: string;
  55705. /**
  55706. * The url to the WebAssembly binary.
  55707. */
  55708. wasmBinaryUrl?: string;
  55709. /**
  55710. * The url to the fallback JavaScript module.
  55711. */
  55712. fallbackUrl?: string;
  55713. };
  55714. }
  55715. /**
  55716. * Draco compression (https://google.github.io/draco/)
  55717. *
  55718. * This class wraps the Draco module.
  55719. *
  55720. * **Encoder**
  55721. *
  55722. * The encoder is not currently implemented.
  55723. *
  55724. * **Decoder**
  55725. *
  55726. * 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.
  55727. *
  55728. * To update the configuration, use the following code:
  55729. * ```javascript
  55730. * DracoCompression.Configuration = {
  55731. * decoder: {
  55732. * wasmUrl: "<url to the WebAssembly library>",
  55733. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55734. * fallbackUrl: "<url to the fallback JavaScript library>",
  55735. * }
  55736. * };
  55737. * ```
  55738. *
  55739. * 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.
  55740. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55741. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55742. *
  55743. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55744. * ```javascript
  55745. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55746. * ```
  55747. *
  55748. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55749. */
  55750. export class DracoCompression implements IDisposable {
  55751. private _workerPoolPromise?;
  55752. private _decoderModulePromise?;
  55753. /**
  55754. * The configuration. Defaults to the following urls:
  55755. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55756. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55757. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55758. */
  55759. static Configuration: IDracoCompressionConfiguration;
  55760. /**
  55761. * Returns true if the decoder configuration is available.
  55762. */
  55763. static readonly DecoderAvailable: boolean;
  55764. /**
  55765. * Default number of workers to create when creating the draco compression object.
  55766. */
  55767. static DefaultNumWorkers: number;
  55768. private static GetDefaultNumWorkers;
  55769. private static _Default;
  55770. /**
  55771. * Default instance for the draco compression object.
  55772. */
  55773. static readonly Default: DracoCompression;
  55774. /**
  55775. * Constructor
  55776. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55777. */
  55778. constructor(numWorkers?: number);
  55779. /**
  55780. * Stop all async operations and release resources.
  55781. */
  55782. dispose(): void;
  55783. /**
  55784. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55785. * @returns a promise that resolves when ready
  55786. */
  55787. whenReadyAsync(): Promise<void>;
  55788. /**
  55789. * Decode Draco compressed mesh data to vertex data.
  55790. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55791. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55792. * @returns A promise that resolves with the decoded vertex data
  55793. */
  55794. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55795. [kind: string]: number;
  55796. }): Promise<VertexData>;
  55797. }
  55798. }
  55799. declare module BABYLON {
  55800. /**
  55801. * Class for building Constructive Solid Geometry
  55802. */
  55803. export class CSG {
  55804. private polygons;
  55805. /**
  55806. * The world matrix
  55807. */
  55808. matrix: Matrix;
  55809. /**
  55810. * Stores the position
  55811. */
  55812. position: Vector3;
  55813. /**
  55814. * Stores the rotation
  55815. */
  55816. rotation: Vector3;
  55817. /**
  55818. * Stores the rotation quaternion
  55819. */
  55820. rotationQuaternion: Nullable<Quaternion>;
  55821. /**
  55822. * Stores the scaling vector
  55823. */
  55824. scaling: Vector3;
  55825. /**
  55826. * Convert the Mesh to CSG
  55827. * @param mesh The Mesh to convert to CSG
  55828. * @returns A new CSG from the Mesh
  55829. */
  55830. static FromMesh(mesh: Mesh): CSG;
  55831. /**
  55832. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55833. * @param polygons Polygons used to construct a CSG solid
  55834. */
  55835. private static FromPolygons;
  55836. /**
  55837. * Clones, or makes a deep copy, of the CSG
  55838. * @returns A new CSG
  55839. */
  55840. clone(): CSG;
  55841. /**
  55842. * Unions this CSG with another CSG
  55843. * @param csg The CSG to union against this CSG
  55844. * @returns The unioned CSG
  55845. */
  55846. union(csg: CSG): CSG;
  55847. /**
  55848. * Unions this CSG with another CSG in place
  55849. * @param csg The CSG to union against this CSG
  55850. */
  55851. unionInPlace(csg: CSG): void;
  55852. /**
  55853. * Subtracts this CSG with another CSG
  55854. * @param csg The CSG to subtract against this CSG
  55855. * @returns A new CSG
  55856. */
  55857. subtract(csg: CSG): CSG;
  55858. /**
  55859. * Subtracts this CSG with another CSG in place
  55860. * @param csg The CSG to subtact against this CSG
  55861. */
  55862. subtractInPlace(csg: CSG): void;
  55863. /**
  55864. * Intersect this CSG with another CSG
  55865. * @param csg The CSG to intersect against this CSG
  55866. * @returns A new CSG
  55867. */
  55868. intersect(csg: CSG): CSG;
  55869. /**
  55870. * Intersects this CSG with another CSG in place
  55871. * @param csg The CSG to intersect against this CSG
  55872. */
  55873. intersectInPlace(csg: CSG): void;
  55874. /**
  55875. * Return a new CSG solid with solid and empty space switched. This solid is
  55876. * not modified.
  55877. * @returns A new CSG solid with solid and empty space switched
  55878. */
  55879. inverse(): CSG;
  55880. /**
  55881. * Inverses the CSG in place
  55882. */
  55883. inverseInPlace(): void;
  55884. /**
  55885. * This is used to keep meshes transformations so they can be restored
  55886. * when we build back a Babylon Mesh
  55887. * NB : All CSG operations are performed in world coordinates
  55888. * @param csg The CSG to copy the transform attributes from
  55889. * @returns This CSG
  55890. */
  55891. copyTransformAttributes(csg: CSG): CSG;
  55892. /**
  55893. * Build Raw mesh from CSG
  55894. * Coordinates here are in world space
  55895. * @param name The name of the mesh geometry
  55896. * @param scene The Scene
  55897. * @param keepSubMeshes Specifies if the submeshes should be kept
  55898. * @returns A new Mesh
  55899. */
  55900. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55901. /**
  55902. * Build Mesh from CSG taking material and transforms into account
  55903. * @param name The name of the Mesh
  55904. * @param material The material of the Mesh
  55905. * @param scene The Scene
  55906. * @param keepSubMeshes Specifies if submeshes should be kept
  55907. * @returns The new Mesh
  55908. */
  55909. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55910. }
  55911. }
  55912. declare module BABYLON {
  55913. /**
  55914. * Class used to create a trail following a mesh
  55915. */
  55916. export class TrailMesh extends Mesh {
  55917. private _generator;
  55918. private _autoStart;
  55919. private _running;
  55920. private _diameter;
  55921. private _length;
  55922. private _sectionPolygonPointsCount;
  55923. private _sectionVectors;
  55924. private _sectionNormalVectors;
  55925. private _beforeRenderObserver;
  55926. /**
  55927. * @constructor
  55928. * @param name The value used by scene.getMeshByName() to do a lookup.
  55929. * @param generator The mesh to generate a trail.
  55930. * @param scene The scene to add this mesh to.
  55931. * @param diameter Diameter of trailing mesh. Default is 1.
  55932. * @param length Length of trailing mesh. Default is 60.
  55933. * @param autoStart Automatically start trailing mesh. Default true.
  55934. */
  55935. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55936. /**
  55937. * "TrailMesh"
  55938. * @returns "TrailMesh"
  55939. */
  55940. getClassName(): string;
  55941. private _createMesh;
  55942. /**
  55943. * Start trailing mesh.
  55944. */
  55945. start(): void;
  55946. /**
  55947. * Stop trailing mesh.
  55948. */
  55949. stop(): void;
  55950. /**
  55951. * Update trailing mesh geometry.
  55952. */
  55953. update(): void;
  55954. /**
  55955. * Returns a new TrailMesh object.
  55956. * @param name is a string, the name given to the new mesh
  55957. * @param newGenerator use new generator object for cloned trail mesh
  55958. * @returns a new mesh
  55959. */
  55960. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55961. /**
  55962. * Serializes this trail mesh
  55963. * @param serializationObject object to write serialization to
  55964. */
  55965. serialize(serializationObject: any): void;
  55966. /**
  55967. * Parses a serialized trail mesh
  55968. * @param parsedMesh the serialized mesh
  55969. * @param scene the scene to create the trail mesh in
  55970. * @returns the created trail mesh
  55971. */
  55972. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55973. }
  55974. }
  55975. declare module BABYLON {
  55976. /**
  55977. * Class containing static functions to help procedurally build meshes
  55978. */
  55979. export class TiledBoxBuilder {
  55980. /**
  55981. * Creates a box mesh
  55982. * 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)
  55983. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55985. * * 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
  55986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55987. * @param name defines the name of the mesh
  55988. * @param options defines the options used to create the mesh
  55989. * @param scene defines the hosting scene
  55990. * @returns the box mesh
  55991. */
  55992. static CreateTiledBox(name: string, options: {
  55993. pattern?: number;
  55994. width?: number;
  55995. height?: number;
  55996. depth?: number;
  55997. tileSize?: number;
  55998. tileWidth?: number;
  55999. tileHeight?: number;
  56000. alignHorizontal?: number;
  56001. alignVertical?: number;
  56002. faceUV?: Vector4[];
  56003. faceColors?: Color4[];
  56004. sideOrientation?: number;
  56005. updatable?: boolean;
  56006. }, scene?: Nullable<Scene>): Mesh;
  56007. }
  56008. }
  56009. declare module BABYLON {
  56010. /**
  56011. * Class containing static functions to help procedurally build meshes
  56012. */
  56013. export class TorusKnotBuilder {
  56014. /**
  56015. * Creates a torus knot mesh
  56016. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56017. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56018. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56019. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56021. * * 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
  56022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56023. * @param name defines the name of the mesh
  56024. * @param options defines the options used to create the mesh
  56025. * @param scene defines the hosting scene
  56026. * @returns the torus knot mesh
  56027. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56028. */
  56029. static CreateTorusKnot(name: string, options: {
  56030. radius?: number;
  56031. tube?: number;
  56032. radialSegments?: number;
  56033. tubularSegments?: number;
  56034. p?: number;
  56035. q?: number;
  56036. updatable?: boolean;
  56037. sideOrientation?: number;
  56038. frontUVs?: Vector4;
  56039. backUVs?: Vector4;
  56040. }, scene: any): Mesh;
  56041. }
  56042. }
  56043. declare module BABYLON {
  56044. /**
  56045. * Polygon
  56046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56047. */
  56048. export class Polygon {
  56049. /**
  56050. * Creates a rectangle
  56051. * @param xmin bottom X coord
  56052. * @param ymin bottom Y coord
  56053. * @param xmax top X coord
  56054. * @param ymax top Y coord
  56055. * @returns points that make the resulting rectation
  56056. */
  56057. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56058. /**
  56059. * Creates a circle
  56060. * @param radius radius of circle
  56061. * @param cx scale in x
  56062. * @param cy scale in y
  56063. * @param numberOfSides number of sides that make up the circle
  56064. * @returns points that make the resulting circle
  56065. */
  56066. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56067. /**
  56068. * Creates a polygon from input string
  56069. * @param input Input polygon data
  56070. * @returns the parsed points
  56071. */
  56072. static Parse(input: string): Vector2[];
  56073. /**
  56074. * Starts building a polygon from x and y coordinates
  56075. * @param x x coordinate
  56076. * @param y y coordinate
  56077. * @returns the started path2
  56078. */
  56079. static StartingAt(x: number, y: number): Path2;
  56080. }
  56081. /**
  56082. * Builds a polygon
  56083. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56084. */
  56085. export class PolygonMeshBuilder {
  56086. private _points;
  56087. private _outlinepoints;
  56088. private _holes;
  56089. private _name;
  56090. private _scene;
  56091. private _epoints;
  56092. private _eholes;
  56093. private _addToepoint;
  56094. /**
  56095. * Babylon reference to the earcut plugin.
  56096. */
  56097. bjsEarcut: any;
  56098. /**
  56099. * Creates a PolygonMeshBuilder
  56100. * @param name name of the builder
  56101. * @param contours Path of the polygon
  56102. * @param scene scene to add to when creating the mesh
  56103. * @param earcutInjection can be used to inject your own earcut reference
  56104. */
  56105. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56106. /**
  56107. * Adds a whole within the polygon
  56108. * @param hole Array of points defining the hole
  56109. * @returns this
  56110. */
  56111. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56112. /**
  56113. * Creates the polygon
  56114. * @param updatable If the mesh should be updatable
  56115. * @param depth The depth of the mesh created
  56116. * @returns the created mesh
  56117. */
  56118. build(updatable?: boolean, depth?: number): Mesh;
  56119. /**
  56120. * Creates the polygon
  56121. * @param depth The depth of the mesh created
  56122. * @returns the created VertexData
  56123. */
  56124. buildVertexData(depth?: number): VertexData;
  56125. /**
  56126. * Adds a side to the polygon
  56127. * @param positions points that make the polygon
  56128. * @param normals normals of the polygon
  56129. * @param uvs uvs of the polygon
  56130. * @param indices indices of the polygon
  56131. * @param bounds bounds of the polygon
  56132. * @param points points of the polygon
  56133. * @param depth depth of the polygon
  56134. * @param flip flip of the polygon
  56135. */
  56136. private addSide;
  56137. }
  56138. }
  56139. declare module BABYLON {
  56140. /**
  56141. * Class containing static functions to help procedurally build meshes
  56142. */
  56143. export class PolygonBuilder {
  56144. /**
  56145. * Creates a polygon mesh
  56146. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56147. * * 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
  56148. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56150. * * 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)
  56151. * * Remember you can only change the shape positions, not their number when updating a polygon
  56152. * @param name defines the name of the mesh
  56153. * @param options defines the options used to create the mesh
  56154. * @param scene defines the hosting scene
  56155. * @param earcutInjection can be used to inject your own earcut reference
  56156. * @returns the polygon mesh
  56157. */
  56158. static CreatePolygon(name: string, options: {
  56159. shape: Vector3[];
  56160. holes?: Vector3[][];
  56161. depth?: number;
  56162. faceUV?: Vector4[];
  56163. faceColors?: Color4[];
  56164. updatable?: boolean;
  56165. sideOrientation?: number;
  56166. frontUVs?: Vector4;
  56167. backUVs?: Vector4;
  56168. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56169. /**
  56170. * Creates an extruded polygon mesh, with depth in the Y direction.
  56171. * * 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)
  56172. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56173. * @param name defines the name of the mesh
  56174. * @param options defines the options used to create the mesh
  56175. * @param scene defines the hosting scene
  56176. * @param earcutInjection can be used to inject your own earcut reference
  56177. * @returns the polygon mesh
  56178. */
  56179. static ExtrudePolygon(name: string, options: {
  56180. shape: Vector3[];
  56181. holes?: Vector3[][];
  56182. depth?: number;
  56183. faceUV?: Vector4[];
  56184. faceColors?: Color4[];
  56185. updatable?: boolean;
  56186. sideOrientation?: number;
  56187. frontUVs?: Vector4;
  56188. backUVs?: Vector4;
  56189. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56190. }
  56191. }
  56192. declare module BABYLON {
  56193. /**
  56194. * Class containing static functions to help procedurally build meshes
  56195. */
  56196. export class LatheBuilder {
  56197. /**
  56198. * Creates lathe mesh.
  56199. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56200. * * 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
  56201. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56202. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56203. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56204. * * 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
  56205. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56206. * * 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
  56207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56208. * * 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
  56209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56211. * @param name defines the name of the mesh
  56212. * @param options defines the options used to create the mesh
  56213. * @param scene defines the hosting scene
  56214. * @returns the lathe mesh
  56215. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56216. */
  56217. static CreateLathe(name: string, options: {
  56218. shape: Vector3[];
  56219. radius?: number;
  56220. tessellation?: number;
  56221. clip?: number;
  56222. arc?: number;
  56223. closed?: boolean;
  56224. updatable?: boolean;
  56225. sideOrientation?: number;
  56226. frontUVs?: Vector4;
  56227. backUVs?: Vector4;
  56228. cap?: number;
  56229. invertUV?: boolean;
  56230. }, scene?: Nullable<Scene>): Mesh;
  56231. }
  56232. }
  56233. declare module BABYLON {
  56234. /**
  56235. * Class containing static functions to help procedurally build meshes
  56236. */
  56237. export class TiledPlaneBuilder {
  56238. /**
  56239. * Creates a tiled plane mesh
  56240. * * The parameter `pattern` will, depending on value, do nothing or
  56241. * * * flip (reflect about central vertical) alternate tiles across and up
  56242. * * * flip every tile on alternate rows
  56243. * * * rotate (180 degs) alternate tiles across and up
  56244. * * * rotate every tile on alternate rows
  56245. * * * flip and rotate alternate tiles across and up
  56246. * * * flip and rotate every tile on alternate rows
  56247. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56248. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56249. * * 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
  56250. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56251. * * 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)
  56252. * * 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)
  56253. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56254. * @param name defines the name of the mesh
  56255. * @param options defines the options used to create the mesh
  56256. * @param scene defines the hosting scene
  56257. * @returns the box mesh
  56258. */
  56259. static CreateTiledPlane(name: string, options: {
  56260. pattern?: number;
  56261. tileSize?: number;
  56262. tileWidth?: number;
  56263. tileHeight?: number;
  56264. size?: number;
  56265. width?: number;
  56266. height?: number;
  56267. alignHorizontal?: number;
  56268. alignVertical?: number;
  56269. sideOrientation?: number;
  56270. frontUVs?: Vector4;
  56271. backUVs?: Vector4;
  56272. updatable?: boolean;
  56273. }, scene?: Nullable<Scene>): Mesh;
  56274. }
  56275. }
  56276. declare module BABYLON {
  56277. /**
  56278. * Class containing static functions to help procedurally build meshes
  56279. */
  56280. export class TubeBuilder {
  56281. /**
  56282. * Creates a tube mesh.
  56283. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56284. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56285. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56286. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56287. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56288. * * 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)
  56289. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56290. * * 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
  56291. * * 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
  56292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56293. * * 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
  56294. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56296. * @param name defines the name of the mesh
  56297. * @param options defines the options used to create the mesh
  56298. * @param scene defines the hosting scene
  56299. * @returns the tube mesh
  56300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56301. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56302. */
  56303. static CreateTube(name: string, options: {
  56304. path: Vector3[];
  56305. radius?: number;
  56306. tessellation?: number;
  56307. radiusFunction?: {
  56308. (i: number, distance: number): number;
  56309. };
  56310. cap?: number;
  56311. arc?: number;
  56312. updatable?: boolean;
  56313. sideOrientation?: number;
  56314. frontUVs?: Vector4;
  56315. backUVs?: Vector4;
  56316. instance?: Mesh;
  56317. invertUV?: boolean;
  56318. }, scene?: Nullable<Scene>): Mesh;
  56319. }
  56320. }
  56321. declare module BABYLON {
  56322. /**
  56323. * Class containing static functions to help procedurally build meshes
  56324. */
  56325. export class IcoSphereBuilder {
  56326. /**
  56327. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56328. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56329. * * 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`)
  56330. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56331. * * 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
  56332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56333. * * 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
  56334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56335. * @param name defines the name of the mesh
  56336. * @param options defines the options used to create the mesh
  56337. * @param scene defines the hosting scene
  56338. * @returns the icosahedron mesh
  56339. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56340. */
  56341. static CreateIcoSphere(name: string, options: {
  56342. radius?: number;
  56343. radiusX?: number;
  56344. radiusY?: number;
  56345. radiusZ?: number;
  56346. flat?: boolean;
  56347. subdivisions?: number;
  56348. sideOrientation?: number;
  56349. frontUVs?: Vector4;
  56350. backUVs?: Vector4;
  56351. updatable?: boolean;
  56352. }, scene?: Nullable<Scene>): Mesh;
  56353. }
  56354. }
  56355. declare module BABYLON {
  56356. /**
  56357. * Class containing static functions to help procedurally build meshes
  56358. */
  56359. export class DecalBuilder {
  56360. /**
  56361. * Creates a decal mesh.
  56362. * 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
  56363. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56364. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56365. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56366. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56367. * @param name defines the name of the mesh
  56368. * @param sourceMesh defines the mesh where the decal must be applied
  56369. * @param options defines the options used to create the mesh
  56370. * @param scene defines the hosting scene
  56371. * @returns the decal mesh
  56372. * @see https://doc.babylonjs.com/how_to/decals
  56373. */
  56374. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56375. position?: Vector3;
  56376. normal?: Vector3;
  56377. size?: Vector3;
  56378. angle?: number;
  56379. }): Mesh;
  56380. }
  56381. }
  56382. declare module BABYLON {
  56383. /**
  56384. * Class containing static functions to help procedurally build meshes
  56385. */
  56386. export class MeshBuilder {
  56387. /**
  56388. * Creates a box mesh
  56389. * * The parameter `size` sets the size (float) of each box side (default 1)
  56390. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56391. * * 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)
  56392. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56394. * * 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
  56395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56396. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56397. * @param name defines the name of the mesh
  56398. * @param options defines the options used to create the mesh
  56399. * @param scene defines the hosting scene
  56400. * @returns the box mesh
  56401. */
  56402. static CreateBox(name: string, options: {
  56403. size?: number;
  56404. width?: number;
  56405. height?: number;
  56406. depth?: number;
  56407. faceUV?: Vector4[];
  56408. faceColors?: Color4[];
  56409. sideOrientation?: number;
  56410. frontUVs?: Vector4;
  56411. backUVs?: Vector4;
  56412. updatable?: boolean;
  56413. }, scene?: Nullable<Scene>): Mesh;
  56414. /**
  56415. * Creates a tiled box mesh
  56416. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56418. * @param name defines the name of the mesh
  56419. * @param options defines the options used to create the mesh
  56420. * @param scene defines the hosting scene
  56421. * @returns the tiled box mesh
  56422. */
  56423. static CreateTiledBox(name: string, options: {
  56424. pattern?: number;
  56425. size?: number;
  56426. width?: number;
  56427. height?: number;
  56428. depth: number;
  56429. tileSize?: number;
  56430. tileWidth?: number;
  56431. tileHeight?: number;
  56432. faceUV?: Vector4[];
  56433. faceColors?: Color4[];
  56434. alignHorizontal?: number;
  56435. alignVertical?: number;
  56436. sideOrientation?: number;
  56437. updatable?: boolean;
  56438. }, scene?: Nullable<Scene>): Mesh;
  56439. /**
  56440. * Creates a sphere mesh
  56441. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56442. * * 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`)
  56443. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56444. * * 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
  56445. * * 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)
  56446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56447. * * 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
  56448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56449. * @param name defines the name of the mesh
  56450. * @param options defines the options used to create the mesh
  56451. * @param scene defines the hosting scene
  56452. * @returns the sphere mesh
  56453. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56454. */
  56455. static CreateSphere(name: string, options: {
  56456. segments?: number;
  56457. diameter?: number;
  56458. diameterX?: number;
  56459. diameterY?: number;
  56460. diameterZ?: number;
  56461. arc?: number;
  56462. slice?: number;
  56463. sideOrientation?: number;
  56464. frontUVs?: Vector4;
  56465. backUVs?: Vector4;
  56466. updatable?: boolean;
  56467. }, scene?: Nullable<Scene>): Mesh;
  56468. /**
  56469. * Creates a plane polygonal mesh. By default, this is a disc
  56470. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56471. * * 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
  56472. * * 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
  56473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56474. * * 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
  56475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56476. * @param name defines the name of the mesh
  56477. * @param options defines the options used to create the mesh
  56478. * @param scene defines the hosting scene
  56479. * @returns the plane polygonal mesh
  56480. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56481. */
  56482. static CreateDisc(name: string, options: {
  56483. radius?: number;
  56484. tessellation?: number;
  56485. arc?: number;
  56486. updatable?: boolean;
  56487. sideOrientation?: number;
  56488. frontUVs?: Vector4;
  56489. backUVs?: Vector4;
  56490. }, scene?: Nullable<Scene>): Mesh;
  56491. /**
  56492. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56493. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56494. * * 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`)
  56495. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56496. * * 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
  56497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56498. * * 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
  56499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56500. * @param name defines the name of the mesh
  56501. * @param options defines the options used to create the mesh
  56502. * @param scene defines the hosting scene
  56503. * @returns the icosahedron mesh
  56504. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56505. */
  56506. static CreateIcoSphere(name: string, options: {
  56507. radius?: number;
  56508. radiusX?: number;
  56509. radiusY?: number;
  56510. radiusZ?: number;
  56511. flat?: boolean;
  56512. subdivisions?: number;
  56513. sideOrientation?: number;
  56514. frontUVs?: Vector4;
  56515. backUVs?: Vector4;
  56516. updatable?: boolean;
  56517. }, scene?: Nullable<Scene>): Mesh;
  56518. /**
  56519. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56520. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56521. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56522. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56523. * * 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
  56524. * * 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
  56525. * * 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
  56526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56527. * * 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
  56528. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56529. * * 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
  56530. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56531. * * 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
  56532. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56534. * @param name defines the name of the mesh
  56535. * @param options defines the options used to create the mesh
  56536. * @param scene defines the hosting scene
  56537. * @returns the ribbon mesh
  56538. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56539. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56540. */
  56541. static CreateRibbon(name: string, options: {
  56542. pathArray: Vector3[][];
  56543. closeArray?: boolean;
  56544. closePath?: boolean;
  56545. offset?: number;
  56546. updatable?: boolean;
  56547. sideOrientation?: number;
  56548. frontUVs?: Vector4;
  56549. backUVs?: Vector4;
  56550. instance?: Mesh;
  56551. invertUV?: boolean;
  56552. uvs?: Vector2[];
  56553. colors?: Color4[];
  56554. }, scene?: Nullable<Scene>): Mesh;
  56555. /**
  56556. * Creates a cylinder or a cone mesh
  56557. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56558. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56559. * * 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.
  56560. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56561. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56562. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56563. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56564. * * 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).
  56565. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56566. * * 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).
  56567. * * 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
  56568. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56569. * * 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
  56570. * * 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.
  56571. * * If `enclose` is false, a ring surface is one element.
  56572. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56573. * * 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
  56574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56575. * * 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
  56576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56577. * @param name defines the name of the mesh
  56578. * @param options defines the options used to create the mesh
  56579. * @param scene defines the hosting scene
  56580. * @returns the cylinder mesh
  56581. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56582. */
  56583. static CreateCylinder(name: string, options: {
  56584. height?: number;
  56585. diameterTop?: number;
  56586. diameterBottom?: number;
  56587. diameter?: number;
  56588. tessellation?: number;
  56589. subdivisions?: number;
  56590. arc?: number;
  56591. faceColors?: Color4[];
  56592. faceUV?: Vector4[];
  56593. updatable?: boolean;
  56594. hasRings?: boolean;
  56595. enclose?: boolean;
  56596. cap?: number;
  56597. sideOrientation?: number;
  56598. frontUVs?: Vector4;
  56599. backUVs?: Vector4;
  56600. }, scene?: Nullable<Scene>): Mesh;
  56601. /**
  56602. * Creates a torus mesh
  56603. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56604. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56605. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56607. * * 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
  56608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56609. * @param name defines the name of the mesh
  56610. * @param options defines the options used to create the mesh
  56611. * @param scene defines the hosting scene
  56612. * @returns the torus mesh
  56613. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56614. */
  56615. static CreateTorus(name: string, options: {
  56616. diameter?: number;
  56617. thickness?: number;
  56618. tessellation?: number;
  56619. updatable?: boolean;
  56620. sideOrientation?: number;
  56621. frontUVs?: Vector4;
  56622. backUVs?: Vector4;
  56623. }, scene?: Nullable<Scene>): Mesh;
  56624. /**
  56625. * Creates a torus knot mesh
  56626. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56627. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56628. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56629. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56631. * * 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
  56632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56633. * @param name defines the name of the mesh
  56634. * @param options defines the options used to create the mesh
  56635. * @param scene defines the hosting scene
  56636. * @returns the torus knot mesh
  56637. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56638. */
  56639. static CreateTorusKnot(name: string, options: {
  56640. radius?: number;
  56641. tube?: number;
  56642. radialSegments?: number;
  56643. tubularSegments?: number;
  56644. p?: number;
  56645. q?: number;
  56646. updatable?: boolean;
  56647. sideOrientation?: number;
  56648. frontUVs?: Vector4;
  56649. backUVs?: Vector4;
  56650. }, scene?: Nullable<Scene>): Mesh;
  56651. /**
  56652. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56653. * * 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
  56654. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56655. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56656. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56657. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56658. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56659. * * 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
  56660. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56662. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56663. * @param name defines the name of the new line system
  56664. * @param options defines the options used to create the line system
  56665. * @param scene defines the hosting scene
  56666. * @returns a new line system mesh
  56667. */
  56668. static CreateLineSystem(name: string, options: {
  56669. lines: Vector3[][];
  56670. updatable?: boolean;
  56671. instance?: Nullable<LinesMesh>;
  56672. colors?: Nullable<Color4[][]>;
  56673. useVertexAlpha?: boolean;
  56674. }, scene: Nullable<Scene>): LinesMesh;
  56675. /**
  56676. * Creates a line mesh
  56677. * 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
  56678. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56679. * * The parameter `points` is an array successive Vector3
  56680. * * 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
  56681. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56682. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56683. * * When updating an instance, remember that only point positions can change, not the number of points
  56684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56685. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56686. * @param name defines the name of the new line system
  56687. * @param options defines the options used to create the line system
  56688. * @param scene defines the hosting scene
  56689. * @returns a new line mesh
  56690. */
  56691. static CreateLines(name: string, options: {
  56692. points: Vector3[];
  56693. updatable?: boolean;
  56694. instance?: Nullable<LinesMesh>;
  56695. colors?: Color4[];
  56696. useVertexAlpha?: boolean;
  56697. }, scene?: Nullable<Scene>): LinesMesh;
  56698. /**
  56699. * Creates a dashed line mesh
  56700. * * 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
  56701. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56702. * * The parameter `points` is an array successive Vector3
  56703. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56704. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56705. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56706. * * 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
  56707. * * When updating an instance, remember that only point positions can change, not the number of points
  56708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56709. * @param name defines the name of the mesh
  56710. * @param options defines the options used to create the mesh
  56711. * @param scene defines the hosting scene
  56712. * @returns the dashed line mesh
  56713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56714. */
  56715. static CreateDashedLines(name: string, options: {
  56716. points: Vector3[];
  56717. dashSize?: number;
  56718. gapSize?: number;
  56719. dashNb?: number;
  56720. updatable?: boolean;
  56721. instance?: LinesMesh;
  56722. }, scene?: Nullable<Scene>): LinesMesh;
  56723. /**
  56724. * 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.
  56725. * * 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.
  56726. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56727. * * 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.
  56728. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56729. * * 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
  56730. * * 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
  56731. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56733. * * 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
  56734. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56736. * @param name defines the name of the mesh
  56737. * @param options defines the options used to create the mesh
  56738. * @param scene defines the hosting scene
  56739. * @returns the extruded shape mesh
  56740. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56742. */
  56743. static ExtrudeShape(name: string, options: {
  56744. shape: Vector3[];
  56745. path: Vector3[];
  56746. scale?: number;
  56747. rotation?: number;
  56748. cap?: number;
  56749. updatable?: boolean;
  56750. sideOrientation?: number;
  56751. frontUVs?: Vector4;
  56752. backUVs?: Vector4;
  56753. instance?: Mesh;
  56754. invertUV?: boolean;
  56755. }, scene?: Nullable<Scene>): Mesh;
  56756. /**
  56757. * Creates an custom extruded shape mesh.
  56758. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56759. * * 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.
  56760. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56761. * * 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
  56762. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56763. * * 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
  56764. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56765. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56766. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56767. * * 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
  56768. * * 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
  56769. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56771. * * 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
  56772. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56774. * @param name defines the name of the mesh
  56775. * @param options defines the options used to create the mesh
  56776. * @param scene defines the hosting scene
  56777. * @returns the custom extruded shape mesh
  56778. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56779. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56781. */
  56782. static ExtrudeShapeCustom(name: string, options: {
  56783. shape: Vector3[];
  56784. path: Vector3[];
  56785. scaleFunction?: any;
  56786. rotationFunction?: any;
  56787. ribbonCloseArray?: boolean;
  56788. ribbonClosePath?: boolean;
  56789. cap?: number;
  56790. updatable?: boolean;
  56791. sideOrientation?: number;
  56792. frontUVs?: Vector4;
  56793. backUVs?: Vector4;
  56794. instance?: Mesh;
  56795. invertUV?: boolean;
  56796. }, scene?: Nullable<Scene>): Mesh;
  56797. /**
  56798. * Creates lathe mesh.
  56799. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56800. * * 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
  56801. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56802. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56803. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56804. * * 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
  56805. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56806. * * 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
  56807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56808. * * 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
  56809. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56811. * @param name defines the name of the mesh
  56812. * @param options defines the options used to create the mesh
  56813. * @param scene defines the hosting scene
  56814. * @returns the lathe mesh
  56815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56816. */
  56817. static CreateLathe(name: string, options: {
  56818. shape: Vector3[];
  56819. radius?: number;
  56820. tessellation?: number;
  56821. clip?: number;
  56822. arc?: number;
  56823. closed?: boolean;
  56824. updatable?: boolean;
  56825. sideOrientation?: number;
  56826. frontUVs?: Vector4;
  56827. backUVs?: Vector4;
  56828. cap?: number;
  56829. invertUV?: boolean;
  56830. }, scene?: Nullable<Scene>): Mesh;
  56831. /**
  56832. * Creates a tiled plane mesh
  56833. * * You can set a limited pattern arrangement with the tiles
  56834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56835. * * 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
  56836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56837. * @param name defines the name of the mesh
  56838. * @param options defines the options used to create the mesh
  56839. * @param scene defines the hosting scene
  56840. * @returns the plane mesh
  56841. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56842. */
  56843. static CreateTiledPlane(name: string, options: {
  56844. pattern?: number;
  56845. tileSize?: number;
  56846. tileWidth?: number;
  56847. tileHeight?: number;
  56848. size?: number;
  56849. width?: number;
  56850. height?: number;
  56851. alignHorizontal?: number;
  56852. alignVertical?: number;
  56853. sideOrientation?: number;
  56854. frontUVs?: Vector4;
  56855. backUVs?: Vector4;
  56856. updatable?: boolean;
  56857. }, scene?: Nullable<Scene>): Mesh;
  56858. /**
  56859. * Creates a plane mesh
  56860. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56861. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56862. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56864. * * 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
  56865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56866. * @param name defines the name of the mesh
  56867. * @param options defines the options used to create the mesh
  56868. * @param scene defines the hosting scene
  56869. * @returns the plane mesh
  56870. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56871. */
  56872. static CreatePlane(name: string, options: {
  56873. size?: number;
  56874. width?: number;
  56875. height?: number;
  56876. sideOrientation?: number;
  56877. frontUVs?: Vector4;
  56878. backUVs?: Vector4;
  56879. updatable?: boolean;
  56880. sourcePlane?: Plane;
  56881. }, scene?: Nullable<Scene>): Mesh;
  56882. /**
  56883. * Creates a ground mesh
  56884. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56885. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56887. * @param name defines the name of the mesh
  56888. * @param options defines the options used to create the mesh
  56889. * @param scene defines the hosting scene
  56890. * @returns the ground mesh
  56891. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56892. */
  56893. static CreateGround(name: string, options: {
  56894. width?: number;
  56895. height?: number;
  56896. subdivisions?: number;
  56897. subdivisionsX?: number;
  56898. subdivisionsY?: number;
  56899. updatable?: boolean;
  56900. }, scene?: Nullable<Scene>): Mesh;
  56901. /**
  56902. * Creates a tiled ground mesh
  56903. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56904. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56905. * * 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
  56906. * * 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
  56907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56908. * @param name defines the name of the mesh
  56909. * @param options defines the options used to create the mesh
  56910. * @param scene defines the hosting scene
  56911. * @returns the tiled ground mesh
  56912. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56913. */
  56914. static CreateTiledGround(name: string, options: {
  56915. xmin: number;
  56916. zmin: number;
  56917. xmax: number;
  56918. zmax: number;
  56919. subdivisions?: {
  56920. w: number;
  56921. h: number;
  56922. };
  56923. precision?: {
  56924. w: number;
  56925. h: number;
  56926. };
  56927. updatable?: boolean;
  56928. }, scene?: Nullable<Scene>): Mesh;
  56929. /**
  56930. * Creates a ground mesh from a height map
  56931. * * The parameter `url` sets the URL of the height map image resource.
  56932. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56933. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56934. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56935. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56936. * * 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.
  56937. * * 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).
  56938. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56940. * @param name defines the name of the mesh
  56941. * @param url defines the url to the height map
  56942. * @param options defines the options used to create the mesh
  56943. * @param scene defines the hosting scene
  56944. * @returns the ground mesh
  56945. * @see https://doc.babylonjs.com/babylon101/height_map
  56946. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56947. */
  56948. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56949. width?: number;
  56950. height?: number;
  56951. subdivisions?: number;
  56952. minHeight?: number;
  56953. maxHeight?: number;
  56954. colorFilter?: Color3;
  56955. alphaFilter?: number;
  56956. updatable?: boolean;
  56957. onReady?: (mesh: GroundMesh) => void;
  56958. }, scene?: Nullable<Scene>): GroundMesh;
  56959. /**
  56960. * Creates a polygon mesh
  56961. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56962. * * 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
  56963. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56965. * * 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)
  56966. * * Remember you can only change the shape positions, not their number when updating a polygon
  56967. * @param name defines the name of the mesh
  56968. * @param options defines the options used to create the mesh
  56969. * @param scene defines the hosting scene
  56970. * @param earcutInjection can be used to inject your own earcut reference
  56971. * @returns the polygon mesh
  56972. */
  56973. static CreatePolygon(name: string, options: {
  56974. shape: Vector3[];
  56975. holes?: Vector3[][];
  56976. depth?: number;
  56977. faceUV?: Vector4[];
  56978. faceColors?: Color4[];
  56979. updatable?: boolean;
  56980. sideOrientation?: number;
  56981. frontUVs?: Vector4;
  56982. backUVs?: Vector4;
  56983. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56984. /**
  56985. * Creates an extruded polygon mesh, with depth in the Y direction.
  56986. * * 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)
  56987. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56988. * @param name defines the name of the mesh
  56989. * @param options defines the options used to create the mesh
  56990. * @param scene defines the hosting scene
  56991. * @param earcutInjection can be used to inject your own earcut reference
  56992. * @returns the polygon mesh
  56993. */
  56994. static ExtrudePolygon(name: string, options: {
  56995. shape: Vector3[];
  56996. holes?: Vector3[][];
  56997. depth?: number;
  56998. faceUV?: Vector4[];
  56999. faceColors?: Color4[];
  57000. updatable?: boolean;
  57001. sideOrientation?: number;
  57002. frontUVs?: Vector4;
  57003. backUVs?: Vector4;
  57004. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57005. /**
  57006. * Creates a tube mesh.
  57007. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57008. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57009. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57010. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57011. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57012. * * 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)
  57013. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57014. * * 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
  57015. * * 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
  57016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57017. * * 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
  57018. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57020. * @param name defines the name of the mesh
  57021. * @param options defines the options used to create the mesh
  57022. * @param scene defines the hosting scene
  57023. * @returns the tube mesh
  57024. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57025. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57026. */
  57027. static CreateTube(name: string, options: {
  57028. path: Vector3[];
  57029. radius?: number;
  57030. tessellation?: number;
  57031. radiusFunction?: {
  57032. (i: number, distance: number): number;
  57033. };
  57034. cap?: number;
  57035. arc?: number;
  57036. updatable?: boolean;
  57037. sideOrientation?: number;
  57038. frontUVs?: Vector4;
  57039. backUVs?: Vector4;
  57040. instance?: Mesh;
  57041. invertUV?: boolean;
  57042. }, scene?: Nullable<Scene>): Mesh;
  57043. /**
  57044. * Creates a polyhedron mesh
  57045. * * 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
  57046. * * The parameter `size` (positive float, default 1) sets the polygon size
  57047. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57048. * * 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`
  57049. * * 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
  57050. * * 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)`)
  57051. * * 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
  57052. * * 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
  57053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57054. * * 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
  57055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57056. * @param name defines the name of the mesh
  57057. * @param options defines the options used to create the mesh
  57058. * @param scene defines the hosting scene
  57059. * @returns the polyhedron mesh
  57060. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57061. */
  57062. static CreatePolyhedron(name: string, options: {
  57063. type?: number;
  57064. size?: number;
  57065. sizeX?: number;
  57066. sizeY?: number;
  57067. sizeZ?: number;
  57068. custom?: any;
  57069. faceUV?: Vector4[];
  57070. faceColors?: Color4[];
  57071. flat?: boolean;
  57072. updatable?: boolean;
  57073. sideOrientation?: number;
  57074. frontUVs?: Vector4;
  57075. backUVs?: Vector4;
  57076. }, scene?: Nullable<Scene>): Mesh;
  57077. /**
  57078. * Creates a decal mesh.
  57079. * 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
  57080. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57081. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57082. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57083. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57084. * @param name defines the name of the mesh
  57085. * @param sourceMesh defines the mesh where the decal must be applied
  57086. * @param options defines the options used to create the mesh
  57087. * @param scene defines the hosting scene
  57088. * @returns the decal mesh
  57089. * @see https://doc.babylonjs.com/how_to/decals
  57090. */
  57091. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57092. position?: Vector3;
  57093. normal?: Vector3;
  57094. size?: Vector3;
  57095. angle?: number;
  57096. }): Mesh;
  57097. }
  57098. }
  57099. declare module BABYLON {
  57100. /**
  57101. * A simplifier interface for future simplification implementations
  57102. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57103. */
  57104. export interface ISimplifier {
  57105. /**
  57106. * Simplification of a given mesh according to the given settings.
  57107. * Since this requires computation, it is assumed that the function runs async.
  57108. * @param settings The settings of the simplification, including quality and distance
  57109. * @param successCallback A callback that will be called after the mesh was simplified.
  57110. * @param errorCallback in case of an error, this callback will be called. optional.
  57111. */
  57112. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57113. }
  57114. /**
  57115. * Expected simplification settings.
  57116. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57117. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57118. */
  57119. export interface ISimplificationSettings {
  57120. /**
  57121. * Gets or sets the expected quality
  57122. */
  57123. quality: number;
  57124. /**
  57125. * Gets or sets the distance when this optimized version should be used
  57126. */
  57127. distance: number;
  57128. /**
  57129. * Gets an already optimized mesh
  57130. */
  57131. optimizeMesh?: boolean;
  57132. }
  57133. /**
  57134. * Class used to specify simplification options
  57135. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57136. */
  57137. export class SimplificationSettings implements ISimplificationSettings {
  57138. /** expected quality */
  57139. quality: number;
  57140. /** distance when this optimized version should be used */
  57141. distance: number;
  57142. /** already optimized mesh */
  57143. optimizeMesh?: boolean | undefined;
  57144. /**
  57145. * Creates a SimplificationSettings
  57146. * @param quality expected quality
  57147. * @param distance distance when this optimized version should be used
  57148. * @param optimizeMesh already optimized mesh
  57149. */
  57150. constructor(
  57151. /** expected quality */
  57152. quality: number,
  57153. /** distance when this optimized version should be used */
  57154. distance: number,
  57155. /** already optimized mesh */
  57156. optimizeMesh?: boolean | undefined);
  57157. }
  57158. /**
  57159. * Interface used to define a simplification task
  57160. */
  57161. export interface ISimplificationTask {
  57162. /**
  57163. * Array of settings
  57164. */
  57165. settings: Array<ISimplificationSettings>;
  57166. /**
  57167. * Simplification type
  57168. */
  57169. simplificationType: SimplificationType;
  57170. /**
  57171. * Mesh to simplify
  57172. */
  57173. mesh: Mesh;
  57174. /**
  57175. * Callback called on success
  57176. */
  57177. successCallback?: () => void;
  57178. /**
  57179. * Defines if parallel processing can be used
  57180. */
  57181. parallelProcessing: boolean;
  57182. }
  57183. /**
  57184. * Queue used to order the simplification tasks
  57185. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57186. */
  57187. export class SimplificationQueue {
  57188. private _simplificationArray;
  57189. /**
  57190. * Gets a boolean indicating that the process is still running
  57191. */
  57192. running: boolean;
  57193. /**
  57194. * Creates a new queue
  57195. */
  57196. constructor();
  57197. /**
  57198. * Adds a new simplification task
  57199. * @param task defines a task to add
  57200. */
  57201. addTask(task: ISimplificationTask): void;
  57202. /**
  57203. * Execute next task
  57204. */
  57205. executeNext(): void;
  57206. /**
  57207. * Execute a simplification task
  57208. * @param task defines the task to run
  57209. */
  57210. runSimplification(task: ISimplificationTask): void;
  57211. private getSimplifier;
  57212. }
  57213. /**
  57214. * The implemented types of simplification
  57215. * At the moment only Quadratic Error Decimation is implemented
  57216. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57217. */
  57218. export enum SimplificationType {
  57219. /** Quadratic error decimation */
  57220. QUADRATIC = 0
  57221. }
  57222. }
  57223. declare module BABYLON {
  57224. interface Scene {
  57225. /** @hidden (Backing field) */
  57226. _simplificationQueue: SimplificationQueue;
  57227. /**
  57228. * Gets or sets the simplification queue attached to the scene
  57229. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57230. */
  57231. simplificationQueue: SimplificationQueue;
  57232. }
  57233. interface Mesh {
  57234. /**
  57235. * Simplify the mesh according to the given array of settings.
  57236. * Function will return immediately and will simplify async
  57237. * @param settings a collection of simplification settings
  57238. * @param parallelProcessing should all levels calculate parallel or one after the other
  57239. * @param simplificationType the type of simplification to run
  57240. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57241. * @returns the current mesh
  57242. */
  57243. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57244. }
  57245. /**
  57246. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57247. * created in a scene
  57248. */
  57249. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57250. /**
  57251. * The component name helpfull to identify the component in the list of scene components.
  57252. */
  57253. readonly name: string;
  57254. /**
  57255. * The scene the component belongs to.
  57256. */
  57257. scene: Scene;
  57258. /**
  57259. * Creates a new instance of the component for the given scene
  57260. * @param scene Defines the scene to register the component in
  57261. */
  57262. constructor(scene: Scene);
  57263. /**
  57264. * Registers the component in a given scene
  57265. */
  57266. register(): void;
  57267. /**
  57268. * Rebuilds the elements related to this component in case of
  57269. * context lost for instance.
  57270. */
  57271. rebuild(): void;
  57272. /**
  57273. * Disposes the component and the associated ressources
  57274. */
  57275. dispose(): void;
  57276. private _beforeCameraUpdate;
  57277. }
  57278. }
  57279. declare module BABYLON {
  57280. /**
  57281. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57282. */
  57283. export interface INavigationEnginePlugin {
  57284. /**
  57285. * plugin name
  57286. */
  57287. name: string;
  57288. /**
  57289. * Creates a navigation mesh
  57290. * @param meshes array of all the geometry used to compute the navigatio mesh
  57291. * @param parameters bunch of parameters used to filter geometry
  57292. */
  57293. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57294. /**
  57295. * Create a navigation mesh debug mesh
  57296. * @param scene is where the mesh will be added
  57297. * @returns debug display mesh
  57298. */
  57299. createDebugNavMesh(scene: Scene): Mesh;
  57300. /**
  57301. * Get a navigation mesh constrained position, closest to the parameter position
  57302. * @param position world position
  57303. * @returns the closest point to position constrained by the navigation mesh
  57304. */
  57305. getClosestPoint(position: Vector3): Vector3;
  57306. /**
  57307. * Get a navigation mesh constrained position, within a particular radius
  57308. * @param position world position
  57309. * @param maxRadius the maximum distance to the constrained world position
  57310. * @returns the closest point to position constrained by the navigation mesh
  57311. */
  57312. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57313. /**
  57314. * Compute the final position from a segment made of destination-position
  57315. * @param position world position
  57316. * @param destination world position
  57317. * @returns the resulting point along the navmesh
  57318. */
  57319. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57320. /**
  57321. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57322. * @param start world position
  57323. * @param end world position
  57324. * @returns array containing world position composing the path
  57325. */
  57326. computePath(start: Vector3, end: Vector3): Vector3[];
  57327. /**
  57328. * If this plugin is supported
  57329. * @returns true if plugin is supported
  57330. */
  57331. isSupported(): boolean;
  57332. /**
  57333. * Create a new Crowd so you can add agents
  57334. * @param maxAgents the maximum agent count in the crowd
  57335. * @param maxAgentRadius the maximum radius an agent can have
  57336. * @param scene to attach the crowd to
  57337. * @returns the crowd you can add agents to
  57338. */
  57339. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57340. /**
  57341. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57342. * The queries will try to find a solution within those bounds
  57343. * default is (1,1,1)
  57344. * @param extent x,y,z value that define the extent around the queries point of reference
  57345. */
  57346. setDefaultQueryExtent(extent: Vector3): void;
  57347. /**
  57348. * Get the Bounding box extent specified by setDefaultQueryExtent
  57349. * @returns the box extent values
  57350. */
  57351. getDefaultQueryExtent(): Vector3;
  57352. /**
  57353. * Release all resources
  57354. */
  57355. dispose(): void;
  57356. }
  57357. /**
  57358. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57359. */
  57360. export interface ICrowd {
  57361. /**
  57362. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57363. * You can attach anything to that node. The node position is updated in the scene update tick.
  57364. * @param pos world position that will be constrained by the navigation mesh
  57365. * @param parameters agent parameters
  57366. * @param transform hooked to the agent that will be update by the scene
  57367. * @returns agent index
  57368. */
  57369. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57370. /**
  57371. * Returns the agent position in world space
  57372. * @param index agent index returned by addAgent
  57373. * @returns world space position
  57374. */
  57375. getAgentPosition(index: number): Vector3;
  57376. /**
  57377. * Gets the agent velocity in world space
  57378. * @param index agent index returned by addAgent
  57379. * @returns world space velocity
  57380. */
  57381. getAgentVelocity(index: number): Vector3;
  57382. /**
  57383. * remove a particular agent previously created
  57384. * @param index agent index returned by addAgent
  57385. */
  57386. removeAgent(index: number): void;
  57387. /**
  57388. * get the list of all agents attached to this crowd
  57389. * @returns list of agent indices
  57390. */
  57391. getAgents(): number[];
  57392. /**
  57393. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57394. * @param deltaTime in seconds
  57395. */
  57396. update(deltaTime: number): void;
  57397. /**
  57398. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57399. * @param index agent index returned by addAgent
  57400. * @param destination targeted world position
  57401. */
  57402. agentGoto(index: number, destination: Vector3): void;
  57403. /**
  57404. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57405. * The queries will try to find a solution within those bounds
  57406. * default is (1,1,1)
  57407. * @param extent x,y,z value that define the extent around the queries point of reference
  57408. */
  57409. setDefaultQueryExtent(extent: Vector3): void;
  57410. /**
  57411. * Get the Bounding box extent specified by setDefaultQueryExtent
  57412. * @returns the box extent values
  57413. */
  57414. getDefaultQueryExtent(): Vector3;
  57415. /**
  57416. * Release all resources
  57417. */
  57418. dispose(): void;
  57419. }
  57420. /**
  57421. * Configures an agent
  57422. */
  57423. export interface IAgentParameters {
  57424. /**
  57425. * Agent radius. [Limit: >= 0]
  57426. */
  57427. radius: number;
  57428. /**
  57429. * Agent height. [Limit: > 0]
  57430. */
  57431. height: number;
  57432. /**
  57433. * Maximum allowed acceleration. [Limit: >= 0]
  57434. */
  57435. maxAcceleration: number;
  57436. /**
  57437. * Maximum allowed speed. [Limit: >= 0]
  57438. */
  57439. maxSpeed: number;
  57440. /**
  57441. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57442. */
  57443. collisionQueryRange: number;
  57444. /**
  57445. * The path visibility optimization range. [Limit: > 0]
  57446. */
  57447. pathOptimizationRange: number;
  57448. /**
  57449. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57450. */
  57451. separationWeight: number;
  57452. }
  57453. /**
  57454. * Configures the navigation mesh creation
  57455. */
  57456. export interface INavMeshParameters {
  57457. /**
  57458. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57459. */
  57460. cs: number;
  57461. /**
  57462. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57463. */
  57464. ch: number;
  57465. /**
  57466. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57467. */
  57468. walkableSlopeAngle: number;
  57469. /**
  57470. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57471. * be considered walkable. [Limit: >= 3] [Units: vx]
  57472. */
  57473. walkableHeight: number;
  57474. /**
  57475. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57476. */
  57477. walkableClimb: number;
  57478. /**
  57479. * The distance to erode/shrink the walkable area of the heightfield away from
  57480. * obstructions. [Limit: >=0] [Units: vx]
  57481. */
  57482. walkableRadius: number;
  57483. /**
  57484. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57485. */
  57486. maxEdgeLen: number;
  57487. /**
  57488. * The maximum distance a simplfied contour's border edges should deviate
  57489. * the original raw contour. [Limit: >=0] [Units: vx]
  57490. */
  57491. maxSimplificationError: number;
  57492. /**
  57493. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57494. */
  57495. minRegionArea: number;
  57496. /**
  57497. * Any regions with a span count smaller than this value will, if possible,
  57498. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57499. */
  57500. mergeRegionArea: number;
  57501. /**
  57502. * The maximum number of vertices allowed for polygons generated during the
  57503. * contour to polygon conversion process. [Limit: >= 3]
  57504. */
  57505. maxVertsPerPoly: number;
  57506. /**
  57507. * Sets the sampling distance to use when generating the detail mesh.
  57508. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57509. */
  57510. detailSampleDist: number;
  57511. /**
  57512. * The maximum distance the detail mesh surface should deviate from heightfield
  57513. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57514. */
  57515. detailSampleMaxError: number;
  57516. }
  57517. }
  57518. declare module BABYLON {
  57519. /**
  57520. * RecastJS navigation plugin
  57521. */
  57522. export class RecastJSPlugin implements INavigationEnginePlugin {
  57523. /**
  57524. * Reference to the Recast library
  57525. */
  57526. bjsRECAST: any;
  57527. /**
  57528. * plugin name
  57529. */
  57530. name: string;
  57531. /**
  57532. * the first navmesh created. We might extend this to support multiple navmeshes
  57533. */
  57534. navMesh: any;
  57535. /**
  57536. * Initializes the recastJS plugin
  57537. * @param recastInjection can be used to inject your own recast reference
  57538. */
  57539. constructor(recastInjection?: any);
  57540. /**
  57541. * Creates a navigation mesh
  57542. * @param meshes array of all the geometry used to compute the navigatio mesh
  57543. * @param parameters bunch of parameters used to filter geometry
  57544. */
  57545. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57546. /**
  57547. * Create a navigation mesh debug mesh
  57548. * @param scene is where the mesh will be added
  57549. * @returns debug display mesh
  57550. */
  57551. createDebugNavMesh(scene: Scene): Mesh;
  57552. /**
  57553. * Get a navigation mesh constrained position, closest to the parameter position
  57554. * @param position world position
  57555. * @returns the closest point to position constrained by the navigation mesh
  57556. */
  57557. getClosestPoint(position: Vector3): Vector3;
  57558. /**
  57559. * Get a navigation mesh constrained position, within a particular radius
  57560. * @param position world position
  57561. * @param maxRadius the maximum distance to the constrained world position
  57562. * @returns the closest point to position constrained by the navigation mesh
  57563. */
  57564. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57565. /**
  57566. * Compute the final position from a segment made of destination-position
  57567. * @param position world position
  57568. * @param destination world position
  57569. * @returns the resulting point along the navmesh
  57570. */
  57571. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57572. /**
  57573. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57574. * @param start world position
  57575. * @param end world position
  57576. * @returns array containing world position composing the path
  57577. */
  57578. computePath(start: Vector3, end: Vector3): Vector3[];
  57579. /**
  57580. * Create a new Crowd so you can add agents
  57581. * @param maxAgents the maximum agent count in the crowd
  57582. * @param maxAgentRadius the maximum radius an agent can have
  57583. * @param scene to attach the crowd to
  57584. * @returns the crowd you can add agents to
  57585. */
  57586. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57587. /**
  57588. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57589. * The queries will try to find a solution within those bounds
  57590. * default is (1,1,1)
  57591. * @param extent x,y,z value that define the extent around the queries point of reference
  57592. */
  57593. setDefaultQueryExtent(extent: Vector3): void;
  57594. /**
  57595. * Get the Bounding box extent specified by setDefaultQueryExtent
  57596. * @returns the box extent values
  57597. */
  57598. getDefaultQueryExtent(): Vector3;
  57599. /**
  57600. * Disposes
  57601. */
  57602. dispose(): void;
  57603. /**
  57604. * If this plugin is supported
  57605. * @returns true if plugin is supported
  57606. */
  57607. isSupported(): boolean;
  57608. }
  57609. /**
  57610. * Recast detour crowd implementation
  57611. */
  57612. export class RecastJSCrowd implements ICrowd {
  57613. /**
  57614. * Recast/detour plugin
  57615. */
  57616. bjsRECASTPlugin: RecastJSPlugin;
  57617. /**
  57618. * Link to the detour crowd
  57619. */
  57620. recastCrowd: any;
  57621. /**
  57622. * One transform per agent
  57623. */
  57624. transforms: TransformNode[];
  57625. /**
  57626. * All agents created
  57627. */
  57628. agents: number[];
  57629. /**
  57630. * Link to the scene is kept to unregister the crowd from the scene
  57631. */
  57632. private _scene;
  57633. /**
  57634. * Observer for crowd updates
  57635. */
  57636. private _onBeforeAnimationsObserver;
  57637. /**
  57638. * Constructor
  57639. * @param plugin recastJS plugin
  57640. * @param maxAgents the maximum agent count in the crowd
  57641. * @param maxAgentRadius the maximum radius an agent can have
  57642. * @param scene to attach the crowd to
  57643. * @returns the crowd you can add agents to
  57644. */
  57645. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57646. /**
  57647. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57648. * You can attach anything to that node. The node position is updated in the scene update tick.
  57649. * @param pos world position that will be constrained by the navigation mesh
  57650. * @param parameters agent parameters
  57651. * @param transform hooked to the agent that will be update by the scene
  57652. * @returns agent index
  57653. */
  57654. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57655. /**
  57656. * Returns the agent position in world space
  57657. * @param index agent index returned by addAgent
  57658. * @returns world space position
  57659. */
  57660. getAgentPosition(index: number): Vector3;
  57661. /**
  57662. * Returns the agent velocity in world space
  57663. * @param index agent index returned by addAgent
  57664. * @returns world space velocity
  57665. */
  57666. getAgentVelocity(index: number): Vector3;
  57667. /**
  57668. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57669. * @param index agent index returned by addAgent
  57670. * @param destination targeted world position
  57671. */
  57672. agentGoto(index: number, destination: Vector3): void;
  57673. /**
  57674. * remove a particular agent previously created
  57675. * @param index agent index returned by addAgent
  57676. */
  57677. removeAgent(index: number): void;
  57678. /**
  57679. * get the list of all agents attached to this crowd
  57680. * @returns list of agent indices
  57681. */
  57682. getAgents(): number[];
  57683. /**
  57684. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57685. * @param deltaTime in seconds
  57686. */
  57687. update(deltaTime: number): void;
  57688. /**
  57689. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57690. * The queries will try to find a solution within those bounds
  57691. * default is (1,1,1)
  57692. * @param extent x,y,z value that define the extent around the queries point of reference
  57693. */
  57694. setDefaultQueryExtent(extent: Vector3): void;
  57695. /**
  57696. * Get the Bounding box extent specified by setDefaultQueryExtent
  57697. * @returns the box extent values
  57698. */
  57699. getDefaultQueryExtent(): Vector3;
  57700. /**
  57701. * Release all resources
  57702. */
  57703. dispose(): void;
  57704. }
  57705. }
  57706. declare module BABYLON {
  57707. /**
  57708. * Class used to enable access to IndexedDB
  57709. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57710. */
  57711. export class Database implements IOfflineProvider {
  57712. private _callbackManifestChecked;
  57713. private _currentSceneUrl;
  57714. private _db;
  57715. private _enableSceneOffline;
  57716. private _enableTexturesOffline;
  57717. private _manifestVersionFound;
  57718. private _mustUpdateRessources;
  57719. private _hasReachedQuota;
  57720. private _isSupported;
  57721. private _idbFactory;
  57722. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57723. private static IsUASupportingBlobStorage;
  57724. /**
  57725. * Gets a boolean indicating if Database storate is enabled (off by default)
  57726. */
  57727. static IDBStorageEnabled: boolean;
  57728. /**
  57729. * Gets a boolean indicating if scene must be saved in the database
  57730. */
  57731. readonly enableSceneOffline: boolean;
  57732. /**
  57733. * Gets a boolean indicating if textures must be saved in the database
  57734. */
  57735. readonly enableTexturesOffline: boolean;
  57736. /**
  57737. * Creates a new Database
  57738. * @param urlToScene defines the url to load the scene
  57739. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57740. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57741. */
  57742. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57743. private static _ParseURL;
  57744. private static _ReturnFullUrlLocation;
  57745. private _checkManifestFile;
  57746. /**
  57747. * Open the database and make it available
  57748. * @param successCallback defines the callback to call on success
  57749. * @param errorCallback defines the callback to call on error
  57750. */
  57751. open(successCallback: () => void, errorCallback: () => void): void;
  57752. /**
  57753. * Loads an image from the database
  57754. * @param url defines the url to load from
  57755. * @param image defines the target DOM image
  57756. */
  57757. loadImage(url: string, image: HTMLImageElement): void;
  57758. private _loadImageFromDBAsync;
  57759. private _saveImageIntoDBAsync;
  57760. private _checkVersionFromDB;
  57761. private _loadVersionFromDBAsync;
  57762. private _saveVersionIntoDBAsync;
  57763. /**
  57764. * Loads a file from database
  57765. * @param url defines the URL to load from
  57766. * @param sceneLoaded defines a callback to call on success
  57767. * @param progressCallBack defines a callback to call when progress changed
  57768. * @param errorCallback defines a callback to call on error
  57769. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57770. */
  57771. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57772. private _loadFileAsync;
  57773. private _saveFileAsync;
  57774. /**
  57775. * Validates if xhr data is correct
  57776. * @param xhr defines the request to validate
  57777. * @param dataType defines the expected data type
  57778. * @returns true if data is correct
  57779. */
  57780. private static _ValidateXHRData;
  57781. }
  57782. }
  57783. declare module BABYLON {
  57784. /** @hidden */
  57785. export var gpuUpdateParticlesPixelShader: {
  57786. name: string;
  57787. shader: string;
  57788. };
  57789. }
  57790. declare module BABYLON {
  57791. /** @hidden */
  57792. export var gpuUpdateParticlesVertexShader: {
  57793. name: string;
  57794. shader: string;
  57795. };
  57796. }
  57797. declare module BABYLON {
  57798. /** @hidden */
  57799. export var clipPlaneFragmentDeclaration2: {
  57800. name: string;
  57801. shader: string;
  57802. };
  57803. }
  57804. declare module BABYLON {
  57805. /** @hidden */
  57806. export var gpuRenderParticlesPixelShader: {
  57807. name: string;
  57808. shader: string;
  57809. };
  57810. }
  57811. declare module BABYLON {
  57812. /** @hidden */
  57813. export var clipPlaneVertexDeclaration2: {
  57814. name: string;
  57815. shader: string;
  57816. };
  57817. }
  57818. declare module BABYLON {
  57819. /** @hidden */
  57820. export var gpuRenderParticlesVertexShader: {
  57821. name: string;
  57822. shader: string;
  57823. };
  57824. }
  57825. declare module BABYLON {
  57826. /**
  57827. * This represents a GPU particle system in Babylon
  57828. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57829. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57830. */
  57831. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57832. /**
  57833. * The layer mask we are rendering the particles through.
  57834. */
  57835. layerMask: number;
  57836. private _capacity;
  57837. private _activeCount;
  57838. private _currentActiveCount;
  57839. private _accumulatedCount;
  57840. private _renderEffect;
  57841. private _updateEffect;
  57842. private _buffer0;
  57843. private _buffer1;
  57844. private _spriteBuffer;
  57845. private _updateVAO;
  57846. private _renderVAO;
  57847. private _targetIndex;
  57848. private _sourceBuffer;
  57849. private _targetBuffer;
  57850. private _engine;
  57851. private _currentRenderId;
  57852. private _started;
  57853. private _stopped;
  57854. private _timeDelta;
  57855. private _randomTexture;
  57856. private _randomTexture2;
  57857. private _attributesStrideSize;
  57858. private _updateEffectOptions;
  57859. private _randomTextureSize;
  57860. private _actualFrame;
  57861. private readonly _rawTextureWidth;
  57862. /**
  57863. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57864. */
  57865. static readonly IsSupported: boolean;
  57866. /**
  57867. * An event triggered when the system is disposed.
  57868. */
  57869. onDisposeObservable: Observable<GPUParticleSystem>;
  57870. /**
  57871. * Gets the maximum number of particles active at the same time.
  57872. * @returns The max number of active particles.
  57873. */
  57874. getCapacity(): number;
  57875. /**
  57876. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57877. * to override the particles.
  57878. */
  57879. forceDepthWrite: boolean;
  57880. /**
  57881. * Gets or set the number of active particles
  57882. */
  57883. activeParticleCount: number;
  57884. private _preWarmDone;
  57885. /**
  57886. * Is this system ready to be used/rendered
  57887. * @return true if the system is ready
  57888. */
  57889. isReady(): boolean;
  57890. /**
  57891. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57892. * @returns True if it has been started, otherwise false.
  57893. */
  57894. isStarted(): boolean;
  57895. /**
  57896. * Starts the particle system and begins to emit
  57897. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57898. */
  57899. start(delay?: number): void;
  57900. /**
  57901. * Stops the particle system.
  57902. */
  57903. stop(): void;
  57904. /**
  57905. * Remove all active particles
  57906. */
  57907. reset(): void;
  57908. /**
  57909. * Returns the string "GPUParticleSystem"
  57910. * @returns a string containing the class name
  57911. */
  57912. getClassName(): string;
  57913. private _colorGradientsTexture;
  57914. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57915. /**
  57916. * Adds a new color gradient
  57917. * @param gradient defines the gradient to use (between 0 and 1)
  57918. * @param color1 defines the color to affect to the specified gradient
  57919. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57920. * @returns the current particle system
  57921. */
  57922. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57923. /**
  57924. * Remove a specific color gradient
  57925. * @param gradient defines the gradient to remove
  57926. * @returns the current particle system
  57927. */
  57928. removeColorGradient(gradient: number): GPUParticleSystem;
  57929. private _angularSpeedGradientsTexture;
  57930. private _sizeGradientsTexture;
  57931. private _velocityGradientsTexture;
  57932. private _limitVelocityGradientsTexture;
  57933. private _dragGradientsTexture;
  57934. private _addFactorGradient;
  57935. /**
  57936. * Adds a new size gradient
  57937. * @param gradient defines the gradient to use (between 0 and 1)
  57938. * @param factor defines the size factor to affect to the specified gradient
  57939. * @returns the current particle system
  57940. */
  57941. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57942. /**
  57943. * Remove a specific size gradient
  57944. * @param gradient defines the gradient to remove
  57945. * @returns the current particle system
  57946. */
  57947. removeSizeGradient(gradient: number): GPUParticleSystem;
  57948. /**
  57949. * Adds a new angular speed gradient
  57950. * @param gradient defines the gradient to use (between 0 and 1)
  57951. * @param factor defines the angular speed to affect to the specified gradient
  57952. * @returns the current particle system
  57953. */
  57954. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57955. /**
  57956. * Remove a specific angular speed gradient
  57957. * @param gradient defines the gradient to remove
  57958. * @returns the current particle system
  57959. */
  57960. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57961. /**
  57962. * Adds a new velocity gradient
  57963. * @param gradient defines the gradient to use (between 0 and 1)
  57964. * @param factor defines the velocity to affect to the specified gradient
  57965. * @returns the current particle system
  57966. */
  57967. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57968. /**
  57969. * Remove a specific velocity gradient
  57970. * @param gradient defines the gradient to remove
  57971. * @returns the current particle system
  57972. */
  57973. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57974. /**
  57975. * Adds a new limit velocity gradient
  57976. * @param gradient defines the gradient to use (between 0 and 1)
  57977. * @param factor defines the limit velocity value to affect to the specified gradient
  57978. * @returns the current particle system
  57979. */
  57980. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57981. /**
  57982. * Remove a specific limit velocity gradient
  57983. * @param gradient defines the gradient to remove
  57984. * @returns the current particle system
  57985. */
  57986. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57987. /**
  57988. * Adds a new drag gradient
  57989. * @param gradient defines the gradient to use (between 0 and 1)
  57990. * @param factor defines the drag value to affect to the specified gradient
  57991. * @returns the current particle system
  57992. */
  57993. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57994. /**
  57995. * Remove a specific drag gradient
  57996. * @param gradient defines the gradient to remove
  57997. * @returns the current particle system
  57998. */
  57999. removeDragGradient(gradient: number): GPUParticleSystem;
  58000. /**
  58001. * Not supported by GPUParticleSystem
  58002. * @param gradient defines the gradient to use (between 0 and 1)
  58003. * @param factor defines the emit rate value to affect to the specified gradient
  58004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58005. * @returns the current particle system
  58006. */
  58007. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58008. /**
  58009. * Not supported by GPUParticleSystem
  58010. * @param gradient defines the gradient to remove
  58011. * @returns the current particle system
  58012. */
  58013. removeEmitRateGradient(gradient: number): IParticleSystem;
  58014. /**
  58015. * Not supported by GPUParticleSystem
  58016. * @param gradient defines the gradient to use (between 0 and 1)
  58017. * @param factor defines the start size value to affect to the specified gradient
  58018. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58019. * @returns the current particle system
  58020. */
  58021. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58022. /**
  58023. * Not supported by GPUParticleSystem
  58024. * @param gradient defines the gradient to remove
  58025. * @returns the current particle system
  58026. */
  58027. removeStartSizeGradient(gradient: number): IParticleSystem;
  58028. /**
  58029. * Not supported by GPUParticleSystem
  58030. * @param gradient defines the gradient to use (between 0 and 1)
  58031. * @param min defines the color remap minimal range
  58032. * @param max defines the color remap maximal range
  58033. * @returns the current particle system
  58034. */
  58035. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58036. /**
  58037. * Not supported by GPUParticleSystem
  58038. * @param gradient defines the gradient to remove
  58039. * @returns the current particle system
  58040. */
  58041. removeColorRemapGradient(): IParticleSystem;
  58042. /**
  58043. * Not supported by GPUParticleSystem
  58044. * @param gradient defines the gradient to use (between 0 and 1)
  58045. * @param min defines the alpha remap minimal range
  58046. * @param max defines the alpha remap maximal range
  58047. * @returns the current particle system
  58048. */
  58049. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58050. /**
  58051. * Not supported by GPUParticleSystem
  58052. * @param gradient defines the gradient to remove
  58053. * @returns the current particle system
  58054. */
  58055. removeAlphaRemapGradient(): IParticleSystem;
  58056. /**
  58057. * Not supported by GPUParticleSystem
  58058. * @param gradient defines the gradient to use (between 0 and 1)
  58059. * @param color defines the color to affect to the specified gradient
  58060. * @returns the current particle system
  58061. */
  58062. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58063. /**
  58064. * Not supported by GPUParticleSystem
  58065. * @param gradient defines the gradient to remove
  58066. * @returns the current particle system
  58067. */
  58068. removeRampGradient(): IParticleSystem;
  58069. /**
  58070. * Not supported by GPUParticleSystem
  58071. * @returns the list of ramp gradients
  58072. */
  58073. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58074. /**
  58075. * Not supported by GPUParticleSystem
  58076. * Gets or sets a boolean indicating that ramp gradients must be used
  58077. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58078. */
  58079. useRampGradients: boolean;
  58080. /**
  58081. * Not supported by GPUParticleSystem
  58082. * @param gradient defines the gradient to use (between 0 and 1)
  58083. * @param factor defines the life time factor to affect to the specified gradient
  58084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58085. * @returns the current particle system
  58086. */
  58087. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58088. /**
  58089. * Not supported by GPUParticleSystem
  58090. * @param gradient defines the gradient to remove
  58091. * @returns the current particle system
  58092. */
  58093. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58094. /**
  58095. * Instantiates a GPU particle system.
  58096. * 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.
  58097. * @param name The name of the particle system
  58098. * @param options The options used to create the system
  58099. * @param scene The scene the particle system belongs to
  58100. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58101. */
  58102. constructor(name: string, options: Partial<{
  58103. capacity: number;
  58104. randomTextureSize: number;
  58105. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58106. protected _reset(): void;
  58107. private _createUpdateVAO;
  58108. private _createRenderVAO;
  58109. private _initialize;
  58110. /** @hidden */
  58111. _recreateUpdateEffect(): void;
  58112. /** @hidden */
  58113. _recreateRenderEffect(): void;
  58114. /**
  58115. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58116. * @param preWarm defines if we are in the pre-warmimg phase
  58117. */
  58118. animate(preWarm?: boolean): void;
  58119. private _createFactorGradientTexture;
  58120. private _createSizeGradientTexture;
  58121. private _createAngularSpeedGradientTexture;
  58122. private _createVelocityGradientTexture;
  58123. private _createLimitVelocityGradientTexture;
  58124. private _createDragGradientTexture;
  58125. private _createColorGradientTexture;
  58126. /**
  58127. * Renders the particle system in its current state
  58128. * @param preWarm defines if the system should only update the particles but not render them
  58129. * @returns the current number of particles
  58130. */
  58131. render(preWarm?: boolean): number;
  58132. /**
  58133. * Rebuilds the particle system
  58134. */
  58135. rebuild(): void;
  58136. private _releaseBuffers;
  58137. private _releaseVAOs;
  58138. /**
  58139. * Disposes the particle system and free the associated resources
  58140. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58141. */
  58142. dispose(disposeTexture?: boolean): void;
  58143. /**
  58144. * Clones the particle system.
  58145. * @param name The name of the cloned object
  58146. * @param newEmitter The new emitter to use
  58147. * @returns the cloned particle system
  58148. */
  58149. clone(name: string, newEmitter: any): GPUParticleSystem;
  58150. /**
  58151. * Serializes the particle system to a JSON object.
  58152. * @returns the JSON object
  58153. */
  58154. serialize(): any;
  58155. /**
  58156. * Parses a JSON object to create a GPU particle system.
  58157. * @param parsedParticleSystem The JSON object to parse
  58158. * @param scene The scene to create the particle system in
  58159. * @param rootUrl The root url to use to load external dependencies like texture
  58160. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58161. * @returns the parsed GPU particle system
  58162. */
  58163. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58164. }
  58165. }
  58166. declare module BABYLON {
  58167. /**
  58168. * Represents a set of particle systems working together to create a specific effect
  58169. */
  58170. export class ParticleSystemSet implements IDisposable {
  58171. private _emitterCreationOptions;
  58172. private _emitterNode;
  58173. /**
  58174. * Gets the particle system list
  58175. */
  58176. systems: IParticleSystem[];
  58177. /**
  58178. * Gets the emitter node used with this set
  58179. */
  58180. readonly emitterNode: Nullable<TransformNode>;
  58181. /**
  58182. * Creates a new emitter mesh as a sphere
  58183. * @param options defines the options used to create the sphere
  58184. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58185. * @param scene defines the hosting scene
  58186. */
  58187. setEmitterAsSphere(options: {
  58188. diameter: number;
  58189. segments: number;
  58190. color: Color3;
  58191. }, renderingGroupId: number, scene: Scene): void;
  58192. /**
  58193. * Starts all particle systems of the set
  58194. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58195. */
  58196. start(emitter?: AbstractMesh): void;
  58197. /**
  58198. * Release all associated resources
  58199. */
  58200. dispose(): void;
  58201. /**
  58202. * Serialize the set into a JSON compatible object
  58203. * @returns a JSON compatible representation of the set
  58204. */
  58205. serialize(): any;
  58206. /**
  58207. * Parse a new ParticleSystemSet from a serialized source
  58208. * @param data defines a JSON compatible representation of the set
  58209. * @param scene defines the hosting scene
  58210. * @param gpu defines if we want GPU particles or CPU particles
  58211. * @returns a new ParticleSystemSet
  58212. */
  58213. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58214. }
  58215. }
  58216. declare module BABYLON {
  58217. /**
  58218. * This class is made for on one-liner static method to help creating particle system set.
  58219. */
  58220. export class ParticleHelper {
  58221. /**
  58222. * Gets or sets base Assets URL
  58223. */
  58224. static BaseAssetsUrl: string;
  58225. /**
  58226. * Create a default particle system that you can tweak
  58227. * @param emitter defines the emitter to use
  58228. * @param capacity defines the system capacity (default is 500 particles)
  58229. * @param scene defines the hosting scene
  58230. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58231. * @returns the new Particle system
  58232. */
  58233. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58234. /**
  58235. * This is the main static method (one-liner) of this helper to create different particle systems
  58236. * @param type This string represents the type to the particle system to create
  58237. * @param scene The scene where the particle system should live
  58238. * @param gpu If the system will use gpu
  58239. * @returns the ParticleSystemSet created
  58240. */
  58241. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58242. /**
  58243. * Static function used to export a particle system to a ParticleSystemSet variable.
  58244. * Please note that the emitter shape is not exported
  58245. * @param systems defines the particle systems to export
  58246. * @returns the created particle system set
  58247. */
  58248. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58249. }
  58250. }
  58251. declare module BABYLON {
  58252. interface Engine {
  58253. /**
  58254. * Create an effect to use with particle systems.
  58255. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58256. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58257. * @param uniformsNames defines a list of attribute names
  58258. * @param samplers defines an array of string used to represent textures
  58259. * @param defines defines the string containing the defines to use to compile the shaders
  58260. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58261. * @param onCompiled defines a function to call when the effect creation is successful
  58262. * @param onError defines a function to call when the effect creation has failed
  58263. * @returns the new Effect
  58264. */
  58265. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58266. }
  58267. interface Mesh {
  58268. /**
  58269. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58270. * @returns an array of IParticleSystem
  58271. */
  58272. getEmittedParticleSystems(): IParticleSystem[];
  58273. /**
  58274. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58275. * @returns an array of IParticleSystem
  58276. */
  58277. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58278. }
  58279. /**
  58280. * @hidden
  58281. */
  58282. export var _IDoNeedToBeInTheBuild: number;
  58283. }
  58284. declare module BABYLON {
  58285. /** Defines the 4 color options */
  58286. export enum PointColor {
  58287. /** color value */
  58288. Color = 2,
  58289. /** uv value */
  58290. UV = 1,
  58291. /** random value */
  58292. Random = 0,
  58293. /** stated value */
  58294. Stated = 3
  58295. }
  58296. /**
  58297. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  58298. * 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.
  58299. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  58300. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  58301. *
  58302. * Full documentation here : TO BE ENTERED
  58303. */
  58304. export class PointsCloudSystem implements IDisposable {
  58305. /**
  58306. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  58307. * Example : var p = SPS.particles[i];
  58308. */
  58309. particles: CloudPoint[];
  58310. /**
  58311. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  58312. */
  58313. nbParticles: number;
  58314. /**
  58315. * This a counter for your own usage. It's not set by any SPS functions.
  58316. */
  58317. counter: number;
  58318. /**
  58319. * The PCS name. This name is also given to the underlying mesh.
  58320. */
  58321. name: string;
  58322. /**
  58323. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  58324. */
  58325. mesh: Mesh;
  58326. /**
  58327. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  58328. * Please read :
  58329. */
  58330. vars: any;
  58331. /**
  58332. * @hidden
  58333. */
  58334. _size: number;
  58335. private _scene;
  58336. private _promises;
  58337. private _positions;
  58338. private _indices;
  58339. private _normals;
  58340. private _colors;
  58341. private _uvs;
  58342. private _indices32;
  58343. private _positions32;
  58344. private _colors32;
  58345. private _uvs32;
  58346. private _updatable;
  58347. private _isVisibilityBoxLocked;
  58348. private _alwaysVisible;
  58349. private _groups;
  58350. private _groupCounter;
  58351. private _computeParticleColor;
  58352. private _computeParticleTexture;
  58353. private _computeParticleRotation;
  58354. private _computeBoundingBox;
  58355. private _isReady;
  58356. /**
  58357. * Creates a PCS (Points Cloud System) object
  58358. * @param name (String) is the PCS name, this will be the underlying mesh name
  58359. * @param pointSize (number) is the size for each point
  58360. * @param scene (Scene) is the scene in which the PCS is added
  58361. * @param options defines the options of the PCS e.g.
  58362. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  58363. */
  58364. constructor(name: string, pointSize: number, scene: Scene, options?: {
  58365. updatable?: boolean;
  58366. });
  58367. /**
  58368. * Builds the PCS underlying mesh. Returns a standard Mesh.
  58369. * If no points were added to the PCS, the returned mesh is just a single point.
  58370. * @returns a promise for the created mesh
  58371. */
  58372. buildMeshAsync(): Promise<Mesh>;
  58373. /**
  58374. * @hidden
  58375. */
  58376. private _buildMesh;
  58377. private _addParticle;
  58378. private _randomUnitVector;
  58379. private _getColorIndicesForCoord;
  58380. private _setPointsColorOrUV;
  58381. private _colorFromTexture;
  58382. private _calculateDensity;
  58383. /**
  58384. * Adds points to the PCS in random positions within a unit sphere
  58385. * @param nb (positive integer) the number of particles to be created from this model
  58386. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  58387. * @returns the number of groups in the system
  58388. */
  58389. addPoints(nb: number, pointFunction?: any): number;
  58390. /**
  58391. * Adds points to the PCS from the surface of the model shape
  58392. * @param mesh is any Mesh object that will be used as a surface model for the points
  58393. * @param nb (positive integer) the number of particles to be created from this model
  58394. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  58395. * @param color (color3) to be used when colorWith is stated
  58396. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58397. * @returns the number of groups in the system
  58398. */
  58399. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58400. /**
  58401. * Adds points to the PCS inside the model shape
  58402. * @param mesh is any Mesh object that will be used as a surface model for the points
  58403. * @param nb (positive integer) the number of particles to be created from this model
  58404. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  58405. * @param color (color4) to be used when colorWith is stated
  58406. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58407. * @returns the number of groups in the system
  58408. */
  58409. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58410. /**
  58411. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  58412. * This method calls `updateParticle()` for each particle of the SPS.
  58413. * For an animated SPS, it is usually called within the render loop.
  58414. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  58415. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  58416. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  58417. * @returns the PCS.
  58418. */
  58419. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  58420. /**
  58421. * Disposes the PCS.
  58422. */
  58423. dispose(): void;
  58424. /**
  58425. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  58426. * doc :
  58427. * @returns the PCS.
  58428. */
  58429. refreshVisibleSize(): PointsCloudSystem;
  58430. /**
  58431. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  58432. * @param size the size (float) of the visibility box
  58433. * note : this doesn't lock the PCS mesh bounding box.
  58434. * doc :
  58435. */
  58436. setVisibilityBox(size: number): void;
  58437. /**
  58438. * Gets whether the PCS is always visible or not
  58439. * doc :
  58440. */
  58441. /**
  58442. * Sets the PCS as always visible or not
  58443. * doc :
  58444. */
  58445. isAlwaysVisible: boolean;
  58446. /**
  58447. * Tells to `setParticles()` to compute the particle rotations or not
  58448. * Default value : false. The PCS is faster when it's set to false
  58449. * Note : particle rotations are only applied to parent particles
  58450. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  58451. */
  58452. computeParticleRotation: boolean;
  58453. /**
  58454. * Tells to `setParticles()` to compute the particle colors or not.
  58455. * Default value : true. The PCS is faster when it's set to false.
  58456. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58457. */
  58458. /**
  58459. * Gets if `setParticles()` computes the particle colors or not.
  58460. * Default value : false. The PCS is faster when it's set to false.
  58461. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58462. */
  58463. computeParticleColor: boolean;
  58464. /**
  58465. * Gets if `setParticles()` computes the particle textures or not.
  58466. * Default value : false. The PCS is faster when it's set to false.
  58467. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  58468. */
  58469. computeParticleTexture: boolean;
  58470. /**
  58471. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  58472. */
  58473. /**
  58474. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  58475. */
  58476. computeBoundingBox: boolean;
  58477. /**
  58478. * This function does nothing. It may be overwritten to set all the particle first values.
  58479. * The PCS doesn't call this function, you may have to call it by your own.
  58480. * doc :
  58481. */
  58482. initParticles(): void;
  58483. /**
  58484. * This function does nothing. It may be overwritten to recycle a particle
  58485. * The PCS doesn't call this function, you can to call it
  58486. * doc :
  58487. * @param particle The particle to recycle
  58488. * @returns the recycled particle
  58489. */
  58490. recycleParticle(particle: CloudPoint): CloudPoint;
  58491. /**
  58492. * Updates a particle : this function should be overwritten by the user.
  58493. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  58494. * doc :
  58495. * @example : just set a particle position or velocity and recycle conditions
  58496. * @param particle The particle to update
  58497. * @returns the updated particle
  58498. */
  58499. updateParticle(particle: CloudPoint): CloudPoint;
  58500. /**
  58501. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  58502. * This does nothing and may be overwritten by the user.
  58503. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58504. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58505. * @param update the boolean update value actually passed to setParticles()
  58506. */
  58507. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58508. /**
  58509. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  58510. * This will be passed three parameters.
  58511. * This does nothing and may be overwritten by the user.
  58512. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58513. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58514. * @param update the boolean update value actually passed to setParticles()
  58515. */
  58516. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58517. }
  58518. }
  58519. declare module BABYLON {
  58520. /**
  58521. * Represents one particle of a points cloud system.
  58522. */
  58523. export class CloudPoint {
  58524. /**
  58525. * particle global index
  58526. */
  58527. idx: number;
  58528. /**
  58529. * The color of the particle
  58530. */
  58531. color: Nullable<Color4>;
  58532. /**
  58533. * The world space position of the particle.
  58534. */
  58535. position: Vector3;
  58536. /**
  58537. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  58538. */
  58539. rotation: Vector3;
  58540. /**
  58541. * The world space rotation quaternion of the particle.
  58542. */
  58543. rotationQuaternion: Nullable<Quaternion>;
  58544. /**
  58545. * The uv of the particle.
  58546. */
  58547. uv: Nullable<Vector2>;
  58548. /**
  58549. * The current speed of the particle.
  58550. */
  58551. velocity: Vector3;
  58552. /**
  58553. * The pivot point in the particle local space.
  58554. */
  58555. pivot: Vector3;
  58556. /**
  58557. * Must the particle be translated from its pivot point in its local space ?
  58558. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  58559. * Default : false
  58560. */
  58561. translateFromPivot: boolean;
  58562. /**
  58563. * Index of this particle in the global "positions" array (Internal use)
  58564. * @hidden
  58565. */
  58566. _pos: number;
  58567. /**
  58568. * @hidden Index of this particle in the global "indices" array (Internal use)
  58569. */
  58570. _ind: number;
  58571. /**
  58572. * Group this particle belongs to
  58573. */
  58574. _group: PointsGroup;
  58575. /**
  58576. * Group id of this particle
  58577. */
  58578. groupId: number;
  58579. /**
  58580. * Index of the particle in its group id (Internal use)
  58581. */
  58582. idxInGroup: number;
  58583. /**
  58584. * @hidden Particle BoundingInfo object (Internal use)
  58585. */
  58586. _boundingInfo: BoundingInfo;
  58587. /**
  58588. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  58589. */
  58590. _pcs: PointsCloudSystem;
  58591. /**
  58592. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  58593. */
  58594. _stillInvisible: boolean;
  58595. /**
  58596. * @hidden Last computed particle rotation matrix
  58597. */
  58598. _rotationMatrix: number[];
  58599. /**
  58600. * Parent particle Id, if any.
  58601. * Default null.
  58602. */
  58603. parentId: Nullable<number>;
  58604. /**
  58605. * @hidden Internal global position in the PCS.
  58606. */
  58607. _globalPosition: Vector3;
  58608. /**
  58609. * Creates a Point Cloud object.
  58610. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  58611. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  58612. * @param group (PointsGroup) is the group the particle belongs to
  58613. * @param groupId (integer) is the group identifier in the PCS.
  58614. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  58615. * @param pcs defines the PCS it is associated to
  58616. */
  58617. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  58618. /**
  58619. * get point size
  58620. */
  58621. /**
  58622. * Set point size
  58623. */
  58624. size: Vector3;
  58625. /**
  58626. * Legacy support, changed quaternion to rotationQuaternion
  58627. */
  58628. /**
  58629. * Legacy support, changed quaternion to rotationQuaternion
  58630. */
  58631. quaternion: Nullable<Quaternion>;
  58632. /**
  58633. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  58634. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  58635. * @param target is the object (point or mesh) what the intersection is computed against.
  58636. * @returns true if it intersects
  58637. */
  58638. intersectsMesh(target: Mesh | CloudPoint): boolean;
  58639. /**
  58640. * get the rotation matrix of the particle
  58641. * @hidden
  58642. */
  58643. getRotationMatrix(m: Matrix): void;
  58644. }
  58645. /**
  58646. * Represents a group of points in a points cloud system
  58647. * * PCS internal tool, don't use it manually.
  58648. */
  58649. export class PointsGroup {
  58650. /**
  58651. * The group id
  58652. * @hidden
  58653. */
  58654. groupID: number;
  58655. /**
  58656. * image data for group (internal use)
  58657. * @hidden
  58658. */
  58659. _groupImageData: Nullable<ArrayBufferView>;
  58660. /**
  58661. * Image Width (internal use)
  58662. * @hidden
  58663. */
  58664. _groupImgWidth: number;
  58665. /**
  58666. * Image Height (internal use)
  58667. * @hidden
  58668. */
  58669. _groupImgHeight: number;
  58670. /**
  58671. * Custom position function (internal use)
  58672. * @hidden
  58673. */
  58674. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  58675. /**
  58676. * density per facet for surface points
  58677. * @hidden
  58678. */
  58679. _groupDensity: number[];
  58680. /**
  58681. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  58682. * PCS internal tool, don't use it manually.
  58683. * @hidden
  58684. */
  58685. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  58686. }
  58687. }
  58688. declare module BABYLON {
  58689. interface Scene {
  58690. /** @hidden (Backing field) */
  58691. _physicsEngine: Nullable<IPhysicsEngine>;
  58692. /**
  58693. * Gets the current physics engine
  58694. * @returns a IPhysicsEngine or null if none attached
  58695. */
  58696. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58697. /**
  58698. * Enables physics to the current scene
  58699. * @param gravity defines the scene's gravity for the physics engine
  58700. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58701. * @return a boolean indicating if the physics engine was initialized
  58702. */
  58703. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58704. /**
  58705. * Disables and disposes the physics engine associated with the scene
  58706. */
  58707. disablePhysicsEngine(): void;
  58708. /**
  58709. * Gets a boolean indicating if there is an active physics engine
  58710. * @returns a boolean indicating if there is an active physics engine
  58711. */
  58712. isPhysicsEnabled(): boolean;
  58713. /**
  58714. * Deletes a physics compound impostor
  58715. * @param compound defines the compound to delete
  58716. */
  58717. deleteCompoundImpostor(compound: any): void;
  58718. /**
  58719. * An event triggered when physic simulation is about to be run
  58720. */
  58721. onBeforePhysicsObservable: Observable<Scene>;
  58722. /**
  58723. * An event triggered when physic simulation has been done
  58724. */
  58725. onAfterPhysicsObservable: Observable<Scene>;
  58726. }
  58727. interface AbstractMesh {
  58728. /** @hidden */
  58729. _physicsImpostor: Nullable<PhysicsImpostor>;
  58730. /**
  58731. * Gets or sets impostor used for physic simulation
  58732. * @see http://doc.babylonjs.com/features/physics_engine
  58733. */
  58734. physicsImpostor: Nullable<PhysicsImpostor>;
  58735. /**
  58736. * Gets the current physics impostor
  58737. * @see http://doc.babylonjs.com/features/physics_engine
  58738. * @returns a physics impostor or null
  58739. */
  58740. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58741. /** Apply a physic impulse to the mesh
  58742. * @param force defines the force to apply
  58743. * @param contactPoint defines where to apply the force
  58744. * @returns the current mesh
  58745. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58746. */
  58747. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58748. /**
  58749. * Creates a physic joint between two meshes
  58750. * @param otherMesh defines the other mesh to use
  58751. * @param pivot1 defines the pivot to use on this mesh
  58752. * @param pivot2 defines the pivot to use on the other mesh
  58753. * @param options defines additional options (can be plugin dependent)
  58754. * @returns the current mesh
  58755. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58756. */
  58757. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58758. /** @hidden */
  58759. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58760. }
  58761. /**
  58762. * Defines the physics engine scene component responsible to manage a physics engine
  58763. */
  58764. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58765. /**
  58766. * The component name helpful to identify the component in the list of scene components.
  58767. */
  58768. readonly name: string;
  58769. /**
  58770. * The scene the component belongs to.
  58771. */
  58772. scene: Scene;
  58773. /**
  58774. * Creates a new instance of the component for the given scene
  58775. * @param scene Defines the scene to register the component in
  58776. */
  58777. constructor(scene: Scene);
  58778. /**
  58779. * Registers the component in a given scene
  58780. */
  58781. register(): void;
  58782. /**
  58783. * Rebuilds the elements related to this component in case of
  58784. * context lost for instance.
  58785. */
  58786. rebuild(): void;
  58787. /**
  58788. * Disposes the component and the associated ressources
  58789. */
  58790. dispose(): void;
  58791. }
  58792. }
  58793. declare module BABYLON {
  58794. /**
  58795. * A helper for physics simulations
  58796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58797. */
  58798. export class PhysicsHelper {
  58799. private _scene;
  58800. private _physicsEngine;
  58801. /**
  58802. * Initializes the Physics helper
  58803. * @param scene Babylon.js scene
  58804. */
  58805. constructor(scene: Scene);
  58806. /**
  58807. * Applies a radial explosion impulse
  58808. * @param origin the origin of the explosion
  58809. * @param radiusOrEventOptions the radius or the options of radial explosion
  58810. * @param strength the explosion strength
  58811. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58812. * @returns A physics radial explosion event, or null
  58813. */
  58814. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58815. /**
  58816. * Applies a radial explosion force
  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. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58824. /**
  58825. * Creates a gravitational field
  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 gravitational field event, or null
  58831. */
  58832. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58833. /**
  58834. * Creates a physics updraft event
  58835. * @param origin the origin of the updraft
  58836. * @param radiusOrEventOptions the radius or the options of the updraft
  58837. * @param strength the strength of the updraft
  58838. * @param height the height of the updraft
  58839. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58840. * @returns A physics updraft event, or null
  58841. */
  58842. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58843. /**
  58844. * Creates a physics vortex event
  58845. * @param origin the of the vortex
  58846. * @param radiusOrEventOptions the radius or the options of the vortex
  58847. * @param strength the strength of the vortex
  58848. * @param height the height of the vortex
  58849. * @returns a Physics vortex event, or null
  58850. * A physics vortex event or null
  58851. */
  58852. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58853. }
  58854. /**
  58855. * Represents a physics radial explosion event
  58856. */
  58857. class PhysicsRadialExplosionEvent {
  58858. private _scene;
  58859. private _options;
  58860. private _sphere;
  58861. private _dataFetched;
  58862. /**
  58863. * Initializes a radial explosioin event
  58864. * @param _scene BabylonJS scene
  58865. * @param _options The options for the vortex event
  58866. */
  58867. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58868. /**
  58869. * Returns the data related to the radial explosion event (sphere).
  58870. * @returns The radial explosion event data
  58871. */
  58872. getData(): PhysicsRadialExplosionEventData;
  58873. /**
  58874. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58875. * @param impostor A physics imposter
  58876. * @param origin the origin of the explosion
  58877. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58878. */
  58879. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58880. /**
  58881. * Triggers affecterd impostors callbacks
  58882. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58883. */
  58884. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58885. /**
  58886. * Disposes the sphere.
  58887. * @param force Specifies if the sphere should be disposed by force
  58888. */
  58889. dispose(force?: boolean): void;
  58890. /*** Helpers ***/
  58891. private _prepareSphere;
  58892. private _intersectsWithSphere;
  58893. }
  58894. /**
  58895. * Represents a gravitational field event
  58896. */
  58897. class PhysicsGravitationalFieldEvent {
  58898. private _physicsHelper;
  58899. private _scene;
  58900. private _origin;
  58901. private _options;
  58902. private _tickCallback;
  58903. private _sphere;
  58904. private _dataFetched;
  58905. /**
  58906. * Initializes the physics gravitational field event
  58907. * @param _physicsHelper A physics helper
  58908. * @param _scene BabylonJS scene
  58909. * @param _origin The origin position of the gravitational field event
  58910. * @param _options The options for the vortex event
  58911. */
  58912. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58913. /**
  58914. * Returns the data related to the gravitational field event (sphere).
  58915. * @returns A gravitational field event
  58916. */
  58917. getData(): PhysicsGravitationalFieldEventData;
  58918. /**
  58919. * Enables the gravitational field.
  58920. */
  58921. enable(): void;
  58922. /**
  58923. * Disables the gravitational field.
  58924. */
  58925. disable(): void;
  58926. /**
  58927. * Disposes the sphere.
  58928. * @param force The force to dispose from the gravitational field event
  58929. */
  58930. dispose(force?: boolean): void;
  58931. private _tick;
  58932. }
  58933. /**
  58934. * Represents a physics updraft event
  58935. */
  58936. class PhysicsUpdraftEvent {
  58937. private _scene;
  58938. private _origin;
  58939. private _options;
  58940. private _physicsEngine;
  58941. private _originTop;
  58942. private _originDirection;
  58943. private _tickCallback;
  58944. private _cylinder;
  58945. private _cylinderPosition;
  58946. private _dataFetched;
  58947. /**
  58948. * Initializes the physics updraft event
  58949. * @param _scene BabylonJS scene
  58950. * @param _origin The origin position of the updraft
  58951. * @param _options The options for the updraft event
  58952. */
  58953. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58954. /**
  58955. * Returns the data related to the updraft event (cylinder).
  58956. * @returns A physics updraft event
  58957. */
  58958. getData(): PhysicsUpdraftEventData;
  58959. /**
  58960. * Enables the updraft.
  58961. */
  58962. enable(): void;
  58963. /**
  58964. * Disables the updraft.
  58965. */
  58966. disable(): void;
  58967. /**
  58968. * Disposes the cylinder.
  58969. * @param force Specifies if the updraft should be disposed by force
  58970. */
  58971. dispose(force?: boolean): void;
  58972. private getImpostorHitData;
  58973. private _tick;
  58974. /*** Helpers ***/
  58975. private _prepareCylinder;
  58976. private _intersectsWithCylinder;
  58977. }
  58978. /**
  58979. * Represents a physics vortex event
  58980. */
  58981. class PhysicsVortexEvent {
  58982. private _scene;
  58983. private _origin;
  58984. private _options;
  58985. private _physicsEngine;
  58986. private _originTop;
  58987. private _tickCallback;
  58988. private _cylinder;
  58989. private _cylinderPosition;
  58990. private _dataFetched;
  58991. /**
  58992. * Initializes the physics vortex event
  58993. * @param _scene The BabylonJS scene
  58994. * @param _origin The origin position of the vortex
  58995. * @param _options The options for the vortex event
  58996. */
  58997. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58998. /**
  58999. * Returns the data related to the vortex event (cylinder).
  59000. * @returns The physics vortex event data
  59001. */
  59002. getData(): PhysicsVortexEventData;
  59003. /**
  59004. * Enables the vortex.
  59005. */
  59006. enable(): void;
  59007. /**
  59008. * Disables the cortex.
  59009. */
  59010. disable(): void;
  59011. /**
  59012. * Disposes the sphere.
  59013. * @param force
  59014. */
  59015. dispose(force?: boolean): void;
  59016. private getImpostorHitData;
  59017. private _tick;
  59018. /*** Helpers ***/
  59019. private _prepareCylinder;
  59020. private _intersectsWithCylinder;
  59021. }
  59022. /**
  59023. * Options fot the radial explosion event
  59024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59025. */
  59026. export class PhysicsRadialExplosionEventOptions {
  59027. /**
  59028. * The radius of the sphere for the radial explosion.
  59029. */
  59030. radius: number;
  59031. /**
  59032. * The strenth of the explosion.
  59033. */
  59034. strength: number;
  59035. /**
  59036. * The strenght of the force in correspondence to the distance of the affected object
  59037. */
  59038. falloff: PhysicsRadialImpulseFalloff;
  59039. /**
  59040. * Sphere options for the radial explosion.
  59041. */
  59042. sphere: {
  59043. segments: number;
  59044. diameter: number;
  59045. };
  59046. /**
  59047. * Sphere options for the radial explosion.
  59048. */
  59049. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59050. }
  59051. /**
  59052. * Options fot the updraft event
  59053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59054. */
  59055. export class PhysicsUpdraftEventOptions {
  59056. /**
  59057. * The radius of the cylinder for the vortex
  59058. */
  59059. radius: number;
  59060. /**
  59061. * The strenth of the updraft.
  59062. */
  59063. strength: number;
  59064. /**
  59065. * The height of the cylinder for the updraft.
  59066. */
  59067. height: number;
  59068. /**
  59069. * The mode for the the updraft.
  59070. */
  59071. updraftMode: PhysicsUpdraftMode;
  59072. }
  59073. /**
  59074. * Options fot the vortex event
  59075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59076. */
  59077. export class PhysicsVortexEventOptions {
  59078. /**
  59079. * The radius of the cylinder for the vortex
  59080. */
  59081. radius: number;
  59082. /**
  59083. * The strenth of the vortex.
  59084. */
  59085. strength: number;
  59086. /**
  59087. * The height of the cylinder for the vortex.
  59088. */
  59089. height: number;
  59090. /**
  59091. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59092. */
  59093. centripetalForceThreshold: number;
  59094. /**
  59095. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59096. */
  59097. centripetalForceMultiplier: number;
  59098. /**
  59099. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59100. */
  59101. centrifugalForceMultiplier: number;
  59102. /**
  59103. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59104. */
  59105. updraftForceMultiplier: number;
  59106. }
  59107. /**
  59108. * The strenght of the force in correspondence to the distance of the affected object
  59109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59110. */
  59111. export enum PhysicsRadialImpulseFalloff {
  59112. /** Defines that impulse is constant in strength across it's whole radius */
  59113. Constant = 0,
  59114. /** Defines that impulse gets weaker if it's further from the origin */
  59115. Linear = 1
  59116. }
  59117. /**
  59118. * The strength of the force in correspondence to the distance of the affected object
  59119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59120. */
  59121. export enum PhysicsUpdraftMode {
  59122. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59123. Center = 0,
  59124. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59125. Perpendicular = 1
  59126. }
  59127. /**
  59128. * Interface for a physics hit data
  59129. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59130. */
  59131. export interface PhysicsHitData {
  59132. /**
  59133. * The force applied at the contact point
  59134. */
  59135. force: Vector3;
  59136. /**
  59137. * The contact point
  59138. */
  59139. contactPoint: Vector3;
  59140. /**
  59141. * The distance from the origin to the contact point
  59142. */
  59143. distanceFromOrigin: number;
  59144. }
  59145. /**
  59146. * Interface for radial explosion event data
  59147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59148. */
  59149. export interface PhysicsRadialExplosionEventData {
  59150. /**
  59151. * A sphere used for the radial explosion event
  59152. */
  59153. sphere: Mesh;
  59154. }
  59155. /**
  59156. * Interface for gravitational field event data
  59157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59158. */
  59159. export interface PhysicsGravitationalFieldEventData {
  59160. /**
  59161. * A sphere mesh used for the gravitational field event
  59162. */
  59163. sphere: Mesh;
  59164. }
  59165. /**
  59166. * Interface for updraft event data
  59167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59168. */
  59169. export interface PhysicsUpdraftEventData {
  59170. /**
  59171. * A cylinder used for the updraft event
  59172. */
  59173. cylinder: Mesh;
  59174. }
  59175. /**
  59176. * Interface for vortex event data
  59177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59178. */
  59179. export interface PhysicsVortexEventData {
  59180. /**
  59181. * A cylinder used for the vortex event
  59182. */
  59183. cylinder: Mesh;
  59184. }
  59185. /**
  59186. * Interface for an affected physics impostor
  59187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59188. */
  59189. export interface PhysicsAffectedImpostorWithData {
  59190. /**
  59191. * The impostor affected by the effect
  59192. */
  59193. impostor: PhysicsImpostor;
  59194. /**
  59195. * The data about the hit/horce from the explosion
  59196. */
  59197. hitData: PhysicsHitData;
  59198. }
  59199. }
  59200. declare module BABYLON {
  59201. /** @hidden */
  59202. export var blackAndWhitePixelShader: {
  59203. name: string;
  59204. shader: string;
  59205. };
  59206. }
  59207. declare module BABYLON {
  59208. /**
  59209. * Post process used to render in black and white
  59210. */
  59211. export class BlackAndWhitePostProcess extends PostProcess {
  59212. /**
  59213. * Linear about to convert he result to black and white (default: 1)
  59214. */
  59215. degree: number;
  59216. /**
  59217. * Creates a black and white post process
  59218. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59219. * @param name The name of the effect.
  59220. * @param options The required width/height ratio to downsize to before computing the render pass.
  59221. * @param camera The camera to apply the render pass to.
  59222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59223. * @param engine The engine which the post process will be applied. (default: current engine)
  59224. * @param reusable If the post process can be reused on the same frame. (default: false)
  59225. */
  59226. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59227. }
  59228. }
  59229. declare module BABYLON {
  59230. /**
  59231. * This represents a set of one or more post processes in Babylon.
  59232. * A post process can be used to apply a shader to a texture after it is rendered.
  59233. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59234. */
  59235. export class PostProcessRenderEffect {
  59236. private _postProcesses;
  59237. private _getPostProcesses;
  59238. private _singleInstance;
  59239. private _cameras;
  59240. private _indicesForCamera;
  59241. /**
  59242. * Name of the effect
  59243. * @hidden
  59244. */
  59245. _name: string;
  59246. /**
  59247. * Instantiates a post process render effect.
  59248. * A post process can be used to apply a shader to a texture after it is rendered.
  59249. * @param engine The engine the effect is tied to
  59250. * @param name The name of the effect
  59251. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59252. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59253. */
  59254. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59255. /**
  59256. * Checks if all the post processes in the effect are supported.
  59257. */
  59258. readonly isSupported: boolean;
  59259. /**
  59260. * Updates the current state of the effect
  59261. * @hidden
  59262. */
  59263. _update(): void;
  59264. /**
  59265. * Attaches the effect on cameras
  59266. * @param cameras The camera to attach to.
  59267. * @hidden
  59268. */
  59269. _attachCameras(cameras: Camera): void;
  59270. /**
  59271. * Attaches the effect on cameras
  59272. * @param cameras The camera to attach to.
  59273. * @hidden
  59274. */
  59275. _attachCameras(cameras: Camera[]): void;
  59276. /**
  59277. * Detaches the effect on cameras
  59278. * @param cameras The camera to detatch from.
  59279. * @hidden
  59280. */
  59281. _detachCameras(cameras: Camera): void;
  59282. /**
  59283. * Detatches the effect on cameras
  59284. * @param cameras The camera to detatch from.
  59285. * @hidden
  59286. */
  59287. _detachCameras(cameras: Camera[]): void;
  59288. /**
  59289. * Enables the effect on given cameras
  59290. * @param cameras The camera to enable.
  59291. * @hidden
  59292. */
  59293. _enable(cameras: Camera): void;
  59294. /**
  59295. * Enables the effect on given cameras
  59296. * @param cameras The camera to enable.
  59297. * @hidden
  59298. */
  59299. _enable(cameras: Nullable<Camera[]>): void;
  59300. /**
  59301. * Disables the effect on the given cameras
  59302. * @param cameras The camera to disable.
  59303. * @hidden
  59304. */
  59305. _disable(cameras: Camera): void;
  59306. /**
  59307. * Disables the effect on the given cameras
  59308. * @param cameras The camera to disable.
  59309. * @hidden
  59310. */
  59311. _disable(cameras: Nullable<Camera[]>): void;
  59312. /**
  59313. * Gets a list of the post processes contained in the effect.
  59314. * @param camera The camera to get the post processes on.
  59315. * @returns The list of the post processes in the effect.
  59316. */
  59317. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59318. }
  59319. }
  59320. declare module BABYLON {
  59321. /** @hidden */
  59322. export var extractHighlightsPixelShader: {
  59323. name: string;
  59324. shader: string;
  59325. };
  59326. }
  59327. declare module BABYLON {
  59328. /**
  59329. * 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.
  59330. */
  59331. export class ExtractHighlightsPostProcess extends PostProcess {
  59332. /**
  59333. * The luminance threshold, pixels below this value will be set to black.
  59334. */
  59335. threshold: number;
  59336. /** @hidden */
  59337. _exposure: number;
  59338. /**
  59339. * Post process which has the input texture to be used when performing highlight extraction
  59340. * @hidden
  59341. */
  59342. _inputPostProcess: Nullable<PostProcess>;
  59343. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59344. }
  59345. }
  59346. declare module BABYLON {
  59347. /** @hidden */
  59348. export var bloomMergePixelShader: {
  59349. name: string;
  59350. shader: string;
  59351. };
  59352. }
  59353. declare module BABYLON {
  59354. /**
  59355. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59356. */
  59357. export class BloomMergePostProcess extends PostProcess {
  59358. /** Weight of the bloom to be added to the original input. */
  59359. weight: number;
  59360. /**
  59361. * Creates a new instance of @see BloomMergePostProcess
  59362. * @param name The name of the effect.
  59363. * @param originalFromInput Post process which's input will be used for the merge.
  59364. * @param blurred Blurred highlights post process which's output will be used.
  59365. * @param weight Weight of the bloom to be added to the original input.
  59366. * @param options The required width/height ratio to downsize to before computing the render pass.
  59367. * @param camera The camera to apply the render pass to.
  59368. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59369. * @param engine The engine which the post process will be applied. (default: current engine)
  59370. * @param reusable If the post process can be reused on the same frame. (default: false)
  59371. * @param textureType Type of textures used when performing the post process. (default: 0)
  59372. * @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)
  59373. */
  59374. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59375. /** Weight of the bloom to be added to the original input. */
  59376. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59377. }
  59378. }
  59379. declare module BABYLON {
  59380. /**
  59381. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59382. */
  59383. export class BloomEffect extends PostProcessRenderEffect {
  59384. private bloomScale;
  59385. /**
  59386. * @hidden Internal
  59387. */
  59388. _effects: Array<PostProcess>;
  59389. /**
  59390. * @hidden Internal
  59391. */
  59392. _downscale: ExtractHighlightsPostProcess;
  59393. private _blurX;
  59394. private _blurY;
  59395. private _merge;
  59396. /**
  59397. * The luminance threshold to find bright areas of the image to bloom.
  59398. */
  59399. threshold: number;
  59400. /**
  59401. * The strength of the bloom.
  59402. */
  59403. weight: number;
  59404. /**
  59405. * Specifies the size of the bloom blur kernel, relative to the final output size
  59406. */
  59407. kernel: number;
  59408. /**
  59409. * Creates a new instance of @see BloomEffect
  59410. * @param scene The scene the effect belongs to.
  59411. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59412. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59413. * @param bloomWeight The the strength of bloom.
  59414. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59415. * @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)
  59416. */
  59417. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59418. /**
  59419. * Disposes each of the internal effects for a given camera.
  59420. * @param camera The camera to dispose the effect on.
  59421. */
  59422. disposeEffects(camera: Camera): void;
  59423. /**
  59424. * @hidden Internal
  59425. */
  59426. _updateEffects(): void;
  59427. /**
  59428. * Internal
  59429. * @returns if all the contained post processes are ready.
  59430. * @hidden
  59431. */
  59432. _isReady(): boolean;
  59433. }
  59434. }
  59435. declare module BABYLON {
  59436. /** @hidden */
  59437. export var chromaticAberrationPixelShader: {
  59438. name: string;
  59439. shader: string;
  59440. };
  59441. }
  59442. declare module BABYLON {
  59443. /**
  59444. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59445. */
  59446. export class ChromaticAberrationPostProcess extends PostProcess {
  59447. /**
  59448. * The amount of seperation of rgb channels (default: 30)
  59449. */
  59450. aberrationAmount: number;
  59451. /**
  59452. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59453. */
  59454. radialIntensity: number;
  59455. /**
  59456. * 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))
  59457. */
  59458. direction: Vector2;
  59459. /**
  59460. * 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))
  59461. */
  59462. centerPosition: Vector2;
  59463. /**
  59464. * Creates a new instance ChromaticAberrationPostProcess
  59465. * @param name The name of the effect.
  59466. * @param screenWidth The width of the screen to apply the effect on.
  59467. * @param screenHeight The height of the screen to apply the effect on.
  59468. * @param options The required width/height ratio to downsize to before computing the render pass.
  59469. * @param camera The camera to apply the render pass to.
  59470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59471. * @param engine The engine which the post process will be applied. (default: current engine)
  59472. * @param reusable If the post process can be reused on the same frame. (default: false)
  59473. * @param textureType Type of textures used when performing the post process. (default: 0)
  59474. * @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)
  59475. */
  59476. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59477. }
  59478. }
  59479. declare module BABYLON {
  59480. /** @hidden */
  59481. export var circleOfConfusionPixelShader: {
  59482. name: string;
  59483. shader: string;
  59484. };
  59485. }
  59486. declare module BABYLON {
  59487. /**
  59488. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59489. */
  59490. export class CircleOfConfusionPostProcess extends PostProcess {
  59491. /**
  59492. * 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.
  59493. */
  59494. lensSize: number;
  59495. /**
  59496. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59497. */
  59498. fStop: number;
  59499. /**
  59500. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59501. */
  59502. focusDistance: number;
  59503. /**
  59504. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59505. */
  59506. focalLength: number;
  59507. private _depthTexture;
  59508. /**
  59509. * Creates a new instance CircleOfConfusionPostProcess
  59510. * @param name The name of the effect.
  59511. * @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.
  59512. * @param options The required width/height ratio to downsize to before computing the render pass.
  59513. * @param camera The camera to apply the render pass to.
  59514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59515. * @param engine The engine which the post process will be applied. (default: current engine)
  59516. * @param reusable If the post process can be reused on the same frame. (default: false)
  59517. * @param textureType Type of textures used when performing the post process. (default: 0)
  59518. * @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)
  59519. */
  59520. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59521. /**
  59522. * 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.
  59523. */
  59524. depthTexture: RenderTargetTexture;
  59525. }
  59526. }
  59527. declare module BABYLON {
  59528. /** @hidden */
  59529. export var colorCorrectionPixelShader: {
  59530. name: string;
  59531. shader: string;
  59532. };
  59533. }
  59534. declare module BABYLON {
  59535. /**
  59536. *
  59537. * This post-process allows the modification of rendered colors by using
  59538. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59539. *
  59540. * The object needs to be provided an url to a texture containing the color
  59541. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59542. * Use an image editing software to tweak the LUT to match your needs.
  59543. *
  59544. * For an example of a color LUT, see here:
  59545. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59546. * For explanations on color grading, see here:
  59547. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59548. *
  59549. */
  59550. export class ColorCorrectionPostProcess extends PostProcess {
  59551. private _colorTableTexture;
  59552. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59553. }
  59554. }
  59555. declare module BABYLON {
  59556. /** @hidden */
  59557. export var convolutionPixelShader: {
  59558. name: string;
  59559. shader: string;
  59560. };
  59561. }
  59562. declare module BABYLON {
  59563. /**
  59564. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59565. * input texture to perform effects such as edge detection or sharpening
  59566. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59567. */
  59568. export class ConvolutionPostProcess extends PostProcess {
  59569. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59570. kernel: number[];
  59571. /**
  59572. * Creates a new instance ConvolutionPostProcess
  59573. * @param name The name of the effect.
  59574. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59575. * @param options The required width/height ratio to downsize to before computing the render pass.
  59576. * @param camera The camera to apply the render pass to.
  59577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59578. * @param engine The engine which the post process will be applied. (default: current engine)
  59579. * @param reusable If the post process can be reused on the same frame. (default: false)
  59580. * @param textureType Type of textures used when performing the post process. (default: 0)
  59581. */
  59582. constructor(name: string,
  59583. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59584. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59585. /**
  59586. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59587. */
  59588. static EdgeDetect0Kernel: number[];
  59589. /**
  59590. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59591. */
  59592. static EdgeDetect1Kernel: number[];
  59593. /**
  59594. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59595. */
  59596. static EdgeDetect2Kernel: number[];
  59597. /**
  59598. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59599. */
  59600. static SharpenKernel: number[];
  59601. /**
  59602. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59603. */
  59604. static EmbossKernel: number[];
  59605. /**
  59606. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59607. */
  59608. static GaussianKernel: number[];
  59609. }
  59610. }
  59611. declare module BABYLON {
  59612. /**
  59613. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59614. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59615. * based on samples that have a large difference in distance than the center pixel.
  59616. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59617. */
  59618. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59619. direction: Vector2;
  59620. /**
  59621. * Creates a new instance CircleOfConfusionPostProcess
  59622. * @param name The name of the effect.
  59623. * @param scene The scene the effect belongs to.
  59624. * @param direction The direction the blur should be applied.
  59625. * @param kernel The size of the kernel used to blur.
  59626. * @param options The required width/height ratio to downsize to before computing the render pass.
  59627. * @param camera The camera to apply the render pass to.
  59628. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59629. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59631. * @param engine The engine which the post process will be applied. (default: current engine)
  59632. * @param reusable If the post process can be reused on the same frame. (default: false)
  59633. * @param textureType Type of textures used when performing the post process. (default: 0)
  59634. * @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)
  59635. */
  59636. 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);
  59637. }
  59638. }
  59639. declare module BABYLON {
  59640. /** @hidden */
  59641. export var depthOfFieldMergePixelShader: {
  59642. name: string;
  59643. shader: string;
  59644. };
  59645. }
  59646. declare module BABYLON {
  59647. /**
  59648. * Options to be set when merging outputs from the default pipeline.
  59649. */
  59650. export class DepthOfFieldMergePostProcessOptions {
  59651. /**
  59652. * The original image to merge on top of
  59653. */
  59654. originalFromInput: PostProcess;
  59655. /**
  59656. * Parameters to perform the merge of the depth of field effect
  59657. */
  59658. depthOfField?: {
  59659. circleOfConfusion: PostProcess;
  59660. blurSteps: Array<PostProcess>;
  59661. };
  59662. /**
  59663. * Parameters to perform the merge of bloom effect
  59664. */
  59665. bloom?: {
  59666. blurred: PostProcess;
  59667. weight: number;
  59668. };
  59669. }
  59670. /**
  59671. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59672. */
  59673. export class DepthOfFieldMergePostProcess extends PostProcess {
  59674. private blurSteps;
  59675. /**
  59676. * Creates a new instance of DepthOfFieldMergePostProcess
  59677. * @param name The name of the effect.
  59678. * @param originalFromInput Post process which's input will be used for the merge.
  59679. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59680. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59681. * @param options The required width/height ratio to downsize to before computing the render pass.
  59682. * @param camera The camera to apply the render pass to.
  59683. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59684. * @param engine The engine which the post process will be applied. (default: current engine)
  59685. * @param reusable If the post process can be reused on the same frame. (default: false)
  59686. * @param textureType Type of textures used when performing the post process. (default: 0)
  59687. * @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)
  59688. */
  59689. 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);
  59690. /**
  59691. * Updates the effect with the current post process compile time values and recompiles the shader.
  59692. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59693. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59694. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59695. * @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
  59696. * @param onCompiled Called when the shader has been compiled.
  59697. * @param onError Called if there is an error when compiling a shader.
  59698. */
  59699. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59700. }
  59701. }
  59702. declare module BABYLON {
  59703. /**
  59704. * Specifies the level of max blur that should be applied when using the depth of field effect
  59705. */
  59706. export enum DepthOfFieldEffectBlurLevel {
  59707. /**
  59708. * Subtle blur
  59709. */
  59710. Low = 0,
  59711. /**
  59712. * Medium blur
  59713. */
  59714. Medium = 1,
  59715. /**
  59716. * Large blur
  59717. */
  59718. High = 2
  59719. }
  59720. /**
  59721. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59722. */
  59723. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59724. private _circleOfConfusion;
  59725. /**
  59726. * @hidden Internal, blurs from high to low
  59727. */
  59728. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59729. private _depthOfFieldBlurY;
  59730. private _dofMerge;
  59731. /**
  59732. * @hidden Internal post processes in depth of field effect
  59733. */
  59734. _effects: Array<PostProcess>;
  59735. /**
  59736. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59737. */
  59738. focalLength: number;
  59739. /**
  59740. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59741. */
  59742. fStop: number;
  59743. /**
  59744. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59745. */
  59746. focusDistance: number;
  59747. /**
  59748. * 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.
  59749. */
  59750. lensSize: number;
  59751. /**
  59752. * Creates a new instance DepthOfFieldEffect
  59753. * @param scene The scene the effect belongs to.
  59754. * @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.
  59755. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59756. * @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)
  59757. */
  59758. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59759. /**
  59760. * Get the current class name of the current effet
  59761. * @returns "DepthOfFieldEffect"
  59762. */
  59763. getClassName(): string;
  59764. /**
  59765. * 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.
  59766. */
  59767. depthTexture: RenderTargetTexture;
  59768. /**
  59769. * Disposes each of the internal effects for a given camera.
  59770. * @param camera The camera to dispose the effect on.
  59771. */
  59772. disposeEffects(camera: Camera): void;
  59773. /**
  59774. * @hidden Internal
  59775. */
  59776. _updateEffects(): void;
  59777. /**
  59778. * Internal
  59779. * @returns if all the contained post processes are ready.
  59780. * @hidden
  59781. */
  59782. _isReady(): boolean;
  59783. }
  59784. }
  59785. declare module BABYLON {
  59786. /** @hidden */
  59787. export var displayPassPixelShader: {
  59788. name: string;
  59789. shader: string;
  59790. };
  59791. }
  59792. declare module BABYLON {
  59793. /**
  59794. * DisplayPassPostProcess which produces an output the same as it's input
  59795. */
  59796. export class DisplayPassPostProcess extends PostProcess {
  59797. /**
  59798. * Creates the DisplayPassPostProcess
  59799. * @param name The name of the effect.
  59800. * @param options The required width/height ratio to downsize to before computing the render pass.
  59801. * @param camera The camera to apply the render pass to.
  59802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59803. * @param engine The engine which the post process will be applied. (default: current engine)
  59804. * @param reusable If the post process can be reused on the same frame. (default: false)
  59805. */
  59806. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59807. }
  59808. }
  59809. declare module BABYLON {
  59810. /** @hidden */
  59811. export var filterPixelShader: {
  59812. name: string;
  59813. shader: string;
  59814. };
  59815. }
  59816. declare module BABYLON {
  59817. /**
  59818. * Applies a kernel filter to the image
  59819. */
  59820. export class FilterPostProcess extends PostProcess {
  59821. /** The matrix to be applied to the image */
  59822. kernelMatrix: Matrix;
  59823. /**
  59824. *
  59825. * @param name The name of the effect.
  59826. * @param kernelMatrix The matrix to be applied to the image
  59827. * @param options The required width/height ratio to downsize to before computing the render pass.
  59828. * @param camera The camera to apply the render pass to.
  59829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59830. * @param engine The engine which the post process will be applied. (default: current engine)
  59831. * @param reusable If the post process can be reused on the same frame. (default: false)
  59832. */
  59833. constructor(name: string,
  59834. /** The matrix to be applied to the image */
  59835. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59836. }
  59837. }
  59838. declare module BABYLON {
  59839. /** @hidden */
  59840. export var fxaaPixelShader: {
  59841. name: string;
  59842. shader: string;
  59843. };
  59844. }
  59845. declare module BABYLON {
  59846. /** @hidden */
  59847. export var fxaaVertexShader: {
  59848. name: string;
  59849. shader: string;
  59850. };
  59851. }
  59852. declare module BABYLON {
  59853. /**
  59854. * Fxaa post process
  59855. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59856. */
  59857. export class FxaaPostProcess extends PostProcess {
  59858. /** @hidden */
  59859. texelWidth: number;
  59860. /** @hidden */
  59861. texelHeight: number;
  59862. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59863. private _getDefines;
  59864. }
  59865. }
  59866. declare module BABYLON {
  59867. /** @hidden */
  59868. export var grainPixelShader: {
  59869. name: string;
  59870. shader: string;
  59871. };
  59872. }
  59873. declare module BABYLON {
  59874. /**
  59875. * The GrainPostProcess adds noise to the image at mid luminance levels
  59876. */
  59877. export class GrainPostProcess extends PostProcess {
  59878. /**
  59879. * The intensity of the grain added (default: 30)
  59880. */
  59881. intensity: number;
  59882. /**
  59883. * If the grain should be randomized on every frame
  59884. */
  59885. animated: boolean;
  59886. /**
  59887. * Creates a new instance of @see GrainPostProcess
  59888. * @param name The name of the effect.
  59889. * @param options The required width/height ratio to downsize to before computing the render pass.
  59890. * @param camera The camera to apply the render pass to.
  59891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59892. * @param engine The engine which the post process will be applied. (default: current engine)
  59893. * @param reusable If the post process can be reused on the same frame. (default: false)
  59894. * @param textureType Type of textures used when performing the post process. (default: 0)
  59895. * @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)
  59896. */
  59897. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59898. }
  59899. }
  59900. declare module BABYLON {
  59901. /** @hidden */
  59902. export var highlightsPixelShader: {
  59903. name: string;
  59904. shader: string;
  59905. };
  59906. }
  59907. declare module BABYLON {
  59908. /**
  59909. * Extracts highlights from the image
  59910. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59911. */
  59912. export class HighlightsPostProcess extends PostProcess {
  59913. /**
  59914. * Extracts highlights from the image
  59915. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59916. * @param name The name of the effect.
  59917. * @param options The required width/height ratio to downsize to before computing the render pass.
  59918. * @param camera The camera to apply the render pass to.
  59919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59920. * @param engine The engine which the post process will be applied. (default: current engine)
  59921. * @param reusable If the post process can be reused on the same frame. (default: false)
  59922. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59923. */
  59924. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59925. }
  59926. }
  59927. declare module BABYLON {
  59928. /** @hidden */
  59929. export var mrtFragmentDeclaration: {
  59930. name: string;
  59931. shader: string;
  59932. };
  59933. }
  59934. declare module BABYLON {
  59935. /** @hidden */
  59936. export var geometryPixelShader: {
  59937. name: string;
  59938. shader: string;
  59939. };
  59940. }
  59941. declare module BABYLON {
  59942. /** @hidden */
  59943. export var geometryVertexShader: {
  59944. name: string;
  59945. shader: string;
  59946. };
  59947. }
  59948. declare module BABYLON {
  59949. /** @hidden */
  59950. interface ISavedTransformationMatrix {
  59951. world: Matrix;
  59952. viewProjection: Matrix;
  59953. }
  59954. /**
  59955. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59956. */
  59957. export class GeometryBufferRenderer {
  59958. /**
  59959. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59960. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59961. */
  59962. static readonly POSITION_TEXTURE_TYPE: number;
  59963. /**
  59964. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59965. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59966. */
  59967. static readonly VELOCITY_TEXTURE_TYPE: number;
  59968. /**
  59969. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59970. * in order to compute objects velocities when enableVelocity is set to "true"
  59971. * @hidden
  59972. */
  59973. _previousTransformationMatrices: {
  59974. [index: number]: ISavedTransformationMatrix;
  59975. };
  59976. /**
  59977. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59978. * in order to compute objects velocities when enableVelocity is set to "true"
  59979. * @hidden
  59980. */
  59981. _previousBonesTransformationMatrices: {
  59982. [index: number]: Float32Array;
  59983. };
  59984. /**
  59985. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59986. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59987. */
  59988. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59989. private _scene;
  59990. private _multiRenderTarget;
  59991. private _ratio;
  59992. private _enablePosition;
  59993. private _enableVelocity;
  59994. private _positionIndex;
  59995. private _velocityIndex;
  59996. protected _effect: Effect;
  59997. protected _cachedDefines: string;
  59998. /**
  59999. * Set the render list (meshes to be rendered) used in the G buffer.
  60000. */
  60001. renderList: Mesh[];
  60002. /**
  60003. * Gets wether or not G buffer are supported by the running hardware.
  60004. * This requires draw buffer supports
  60005. */
  60006. readonly isSupported: boolean;
  60007. /**
  60008. * Returns the index of the given texture type in the G-Buffer textures array
  60009. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60010. * @returns the index of the given texture type in the G-Buffer textures array
  60011. */
  60012. getTextureIndex(textureType: number): number;
  60013. /**
  60014. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60015. */
  60016. /**
  60017. * Sets whether or not objects positions are enabled for the G buffer.
  60018. */
  60019. enablePosition: boolean;
  60020. /**
  60021. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60022. */
  60023. /**
  60024. * Sets wether or not objects velocities are enabled for the G buffer.
  60025. */
  60026. enableVelocity: boolean;
  60027. /**
  60028. * Gets the scene associated with the buffer.
  60029. */
  60030. readonly scene: Scene;
  60031. /**
  60032. * Gets the ratio used by the buffer during its creation.
  60033. * How big is the buffer related to the main canvas.
  60034. */
  60035. readonly ratio: number;
  60036. /** @hidden */
  60037. static _SceneComponentInitialization: (scene: Scene) => void;
  60038. /**
  60039. * Creates a new G Buffer for the scene
  60040. * @param scene The scene the buffer belongs to
  60041. * @param ratio How big is the buffer related to the main canvas.
  60042. */
  60043. constructor(scene: Scene, ratio?: number);
  60044. /**
  60045. * Checks wether everything is ready to render a submesh to the G buffer.
  60046. * @param subMesh the submesh to check readiness for
  60047. * @param useInstances is the mesh drawn using instance or not
  60048. * @returns true if ready otherwise false
  60049. */
  60050. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60051. /**
  60052. * Gets the current underlying G Buffer.
  60053. * @returns the buffer
  60054. */
  60055. getGBuffer(): MultiRenderTarget;
  60056. /**
  60057. * Gets the number of samples used to render the buffer (anti aliasing).
  60058. */
  60059. /**
  60060. * Sets the number of samples used to render the buffer (anti aliasing).
  60061. */
  60062. samples: number;
  60063. /**
  60064. * Disposes the renderer and frees up associated resources.
  60065. */
  60066. dispose(): void;
  60067. protected _createRenderTargets(): void;
  60068. private _copyBonesTransformationMatrices;
  60069. }
  60070. }
  60071. declare module BABYLON {
  60072. interface Scene {
  60073. /** @hidden (Backing field) */
  60074. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60075. /**
  60076. * Gets or Sets the current geometry buffer associated to the scene.
  60077. */
  60078. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60079. /**
  60080. * Enables a GeometryBufferRender and associates it with the scene
  60081. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60082. * @returns the GeometryBufferRenderer
  60083. */
  60084. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60085. /**
  60086. * Disables the GeometryBufferRender associated with the scene
  60087. */
  60088. disableGeometryBufferRenderer(): void;
  60089. }
  60090. /**
  60091. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60092. * in several rendering techniques.
  60093. */
  60094. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60095. /**
  60096. * The component name helpful to identify the component in the list of scene components.
  60097. */
  60098. readonly name: string;
  60099. /**
  60100. * The scene the component belongs to.
  60101. */
  60102. scene: Scene;
  60103. /**
  60104. * Creates a new instance of the component for the given scene
  60105. * @param scene Defines the scene to register the component in
  60106. */
  60107. constructor(scene: Scene);
  60108. /**
  60109. * Registers the component in a given scene
  60110. */
  60111. register(): void;
  60112. /**
  60113. * Rebuilds the elements related to this component in case of
  60114. * context lost for instance.
  60115. */
  60116. rebuild(): void;
  60117. /**
  60118. * Disposes the component and the associated ressources
  60119. */
  60120. dispose(): void;
  60121. private _gatherRenderTargets;
  60122. }
  60123. }
  60124. declare module BABYLON {
  60125. /** @hidden */
  60126. export var motionBlurPixelShader: {
  60127. name: string;
  60128. shader: string;
  60129. };
  60130. }
  60131. declare module BABYLON {
  60132. /**
  60133. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60134. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60135. * As an example, all you have to do is to create the post-process:
  60136. * var mb = new BABYLON.MotionBlurPostProcess(
  60137. * 'mb', // The name of the effect.
  60138. * scene, // The scene containing the objects to blur according to their velocity.
  60139. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60140. * camera // The camera to apply the render pass to.
  60141. * );
  60142. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60143. */
  60144. export class MotionBlurPostProcess extends PostProcess {
  60145. /**
  60146. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60147. */
  60148. motionStrength: number;
  60149. /**
  60150. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60151. */
  60152. /**
  60153. * Sets the number of iterations to be used for motion blur quality
  60154. */
  60155. motionBlurSamples: number;
  60156. private _motionBlurSamples;
  60157. private _geometryBufferRenderer;
  60158. /**
  60159. * Creates a new instance MotionBlurPostProcess
  60160. * @param name The name of the effect.
  60161. * @param scene The scene containing the objects to blur according to their velocity.
  60162. * @param options The required width/height ratio to downsize to before computing the render pass.
  60163. * @param camera The camera to apply the render pass to.
  60164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60165. * @param engine The engine which the post process will be applied. (default: current engine)
  60166. * @param reusable If the post process can be reused on the same frame. (default: false)
  60167. * @param textureType Type of textures used when performing the post process. (default: 0)
  60168. * @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)
  60169. */
  60170. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60171. /**
  60172. * Excludes the given skinned mesh from computing bones velocities.
  60173. * 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.
  60174. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60175. */
  60176. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60177. /**
  60178. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60179. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60180. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60181. */
  60182. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60183. /**
  60184. * Disposes the post process.
  60185. * @param camera The camera to dispose the post process on.
  60186. */
  60187. dispose(camera?: Camera): void;
  60188. }
  60189. }
  60190. declare module BABYLON {
  60191. /** @hidden */
  60192. export var refractionPixelShader: {
  60193. name: string;
  60194. shader: string;
  60195. };
  60196. }
  60197. declare module BABYLON {
  60198. /**
  60199. * Post process which applies a refractin texture
  60200. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60201. */
  60202. export class RefractionPostProcess extends PostProcess {
  60203. /** the base color of the refraction (used to taint the rendering) */
  60204. color: Color3;
  60205. /** simulated refraction depth */
  60206. depth: number;
  60207. /** the coefficient of the base color (0 to remove base color tainting) */
  60208. colorLevel: number;
  60209. private _refTexture;
  60210. private _ownRefractionTexture;
  60211. /**
  60212. * Gets or sets the refraction texture
  60213. * Please note that you are responsible for disposing the texture if you set it manually
  60214. */
  60215. refractionTexture: Texture;
  60216. /**
  60217. * Initializes the RefractionPostProcess
  60218. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60219. * @param name The name of the effect.
  60220. * @param refractionTextureUrl Url of the refraction texture to use
  60221. * @param color the base color of the refraction (used to taint the rendering)
  60222. * @param depth simulated refraction depth
  60223. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60224. * @param camera The camera to apply the render pass to.
  60225. * @param options The required width/height ratio to downsize to before computing the render pass.
  60226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60227. * @param engine The engine which the post process will be applied. (default: current engine)
  60228. * @param reusable If the post process can be reused on the same frame. (default: false)
  60229. */
  60230. constructor(name: string, refractionTextureUrl: string,
  60231. /** the base color of the refraction (used to taint the rendering) */
  60232. color: Color3,
  60233. /** simulated refraction depth */
  60234. depth: number,
  60235. /** the coefficient of the base color (0 to remove base color tainting) */
  60236. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60237. /**
  60238. * Disposes of the post process
  60239. * @param camera Camera to dispose post process on
  60240. */
  60241. dispose(camera: Camera): void;
  60242. }
  60243. }
  60244. declare module BABYLON {
  60245. /** @hidden */
  60246. export var sharpenPixelShader: {
  60247. name: string;
  60248. shader: string;
  60249. };
  60250. }
  60251. declare module BABYLON {
  60252. /**
  60253. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60254. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60255. */
  60256. export class SharpenPostProcess extends PostProcess {
  60257. /**
  60258. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60259. */
  60260. colorAmount: number;
  60261. /**
  60262. * How much sharpness should be applied (default: 0.3)
  60263. */
  60264. edgeAmount: number;
  60265. /**
  60266. * Creates a new instance ConvolutionPostProcess
  60267. * @param name The name of the effect.
  60268. * @param options The required width/height ratio to downsize to before computing the render pass.
  60269. * @param camera The camera to apply the render pass to.
  60270. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60271. * @param engine The engine which the post process will be applied. (default: current engine)
  60272. * @param reusable If the post process can be reused on the same frame. (default: false)
  60273. * @param textureType Type of textures used when performing the post process. (default: 0)
  60274. * @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)
  60275. */
  60276. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60277. }
  60278. }
  60279. declare module BABYLON {
  60280. /**
  60281. * PostProcessRenderPipeline
  60282. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60283. */
  60284. export class PostProcessRenderPipeline {
  60285. private engine;
  60286. private _renderEffects;
  60287. private _renderEffectsForIsolatedPass;
  60288. /**
  60289. * List of inspectable custom properties (used by the Inspector)
  60290. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60291. */
  60292. inspectableCustomProperties: IInspectable[];
  60293. /**
  60294. * @hidden
  60295. */
  60296. protected _cameras: Camera[];
  60297. /** @hidden */
  60298. _name: string;
  60299. /**
  60300. * Gets pipeline name
  60301. */
  60302. readonly name: string;
  60303. /**
  60304. * Initializes a PostProcessRenderPipeline
  60305. * @param engine engine to add the pipeline to
  60306. * @param name name of the pipeline
  60307. */
  60308. constructor(engine: Engine, name: string);
  60309. /**
  60310. * Gets the class name
  60311. * @returns "PostProcessRenderPipeline"
  60312. */
  60313. getClassName(): string;
  60314. /**
  60315. * If all the render effects in the pipeline are supported
  60316. */
  60317. readonly isSupported: boolean;
  60318. /**
  60319. * Adds an effect to the pipeline
  60320. * @param renderEffect the effect to add
  60321. */
  60322. addEffect(renderEffect: PostProcessRenderEffect): void;
  60323. /** @hidden */
  60324. _rebuild(): void;
  60325. /** @hidden */
  60326. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60327. /** @hidden */
  60328. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60329. /** @hidden */
  60330. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60331. /** @hidden */
  60332. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60333. /** @hidden */
  60334. _attachCameras(cameras: Camera, unique: boolean): void;
  60335. /** @hidden */
  60336. _attachCameras(cameras: Camera[], unique: boolean): void;
  60337. /** @hidden */
  60338. _detachCameras(cameras: Camera): void;
  60339. /** @hidden */
  60340. _detachCameras(cameras: Nullable<Camera[]>): void;
  60341. /** @hidden */
  60342. _update(): void;
  60343. /** @hidden */
  60344. _reset(): void;
  60345. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60346. /**
  60347. * Disposes of the pipeline
  60348. */
  60349. dispose(): void;
  60350. }
  60351. }
  60352. declare module BABYLON {
  60353. /**
  60354. * PostProcessRenderPipelineManager class
  60355. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60356. */
  60357. export class PostProcessRenderPipelineManager {
  60358. private _renderPipelines;
  60359. /**
  60360. * Initializes a PostProcessRenderPipelineManager
  60361. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60362. */
  60363. constructor();
  60364. /**
  60365. * Gets the list of supported render pipelines
  60366. */
  60367. readonly supportedPipelines: PostProcessRenderPipeline[];
  60368. /**
  60369. * Adds a pipeline to the manager
  60370. * @param renderPipeline The pipeline to add
  60371. */
  60372. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60373. /**
  60374. * Attaches a camera to the pipeline
  60375. * @param renderPipelineName The name of the pipeline to attach to
  60376. * @param cameras the camera to attach
  60377. * @param unique if the camera can be attached multiple times to the pipeline
  60378. */
  60379. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60380. /**
  60381. * Detaches a camera from the pipeline
  60382. * @param renderPipelineName The name of the pipeline to detach from
  60383. * @param cameras the camera to detach
  60384. */
  60385. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60386. /**
  60387. * Enables an effect by name on a pipeline
  60388. * @param renderPipelineName the name of the pipeline to enable the effect in
  60389. * @param renderEffectName the name of the effect to enable
  60390. * @param cameras the cameras that the effect should be enabled on
  60391. */
  60392. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60393. /**
  60394. * Disables an effect by name on a pipeline
  60395. * @param renderPipelineName the name of the pipeline to disable the effect in
  60396. * @param renderEffectName the name of the effect to disable
  60397. * @param cameras the cameras that the effect should be disabled on
  60398. */
  60399. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60400. /**
  60401. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60402. */
  60403. update(): void;
  60404. /** @hidden */
  60405. _rebuild(): void;
  60406. /**
  60407. * Disposes of the manager and pipelines
  60408. */
  60409. dispose(): void;
  60410. }
  60411. }
  60412. declare module BABYLON {
  60413. interface Scene {
  60414. /** @hidden (Backing field) */
  60415. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60416. /**
  60417. * Gets the postprocess render pipeline manager
  60418. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60419. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60420. */
  60421. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60422. }
  60423. /**
  60424. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60425. */
  60426. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60427. /**
  60428. * The component name helpfull to identify the component in the list of scene components.
  60429. */
  60430. readonly name: string;
  60431. /**
  60432. * The scene the component belongs to.
  60433. */
  60434. scene: Scene;
  60435. /**
  60436. * Creates a new instance of the component for the given scene
  60437. * @param scene Defines the scene to register the component in
  60438. */
  60439. constructor(scene: Scene);
  60440. /**
  60441. * Registers the component in a given scene
  60442. */
  60443. register(): void;
  60444. /**
  60445. * Rebuilds the elements related to this component in case of
  60446. * context lost for instance.
  60447. */
  60448. rebuild(): void;
  60449. /**
  60450. * Disposes the component and the associated ressources
  60451. */
  60452. dispose(): void;
  60453. private _gatherRenderTargets;
  60454. }
  60455. }
  60456. declare module BABYLON {
  60457. /**
  60458. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60459. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60460. */
  60461. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60462. private _scene;
  60463. private _camerasToBeAttached;
  60464. /**
  60465. * ID of the sharpen post process,
  60466. */
  60467. private readonly SharpenPostProcessId;
  60468. /**
  60469. * @ignore
  60470. * ID of the image processing post process;
  60471. */
  60472. readonly ImageProcessingPostProcessId: string;
  60473. /**
  60474. * @ignore
  60475. * ID of the Fast Approximate Anti-Aliasing post process;
  60476. */
  60477. readonly FxaaPostProcessId: string;
  60478. /**
  60479. * ID of the chromatic aberration post process,
  60480. */
  60481. private readonly ChromaticAberrationPostProcessId;
  60482. /**
  60483. * ID of the grain post process
  60484. */
  60485. private readonly GrainPostProcessId;
  60486. /**
  60487. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60488. */
  60489. sharpen: SharpenPostProcess;
  60490. private _sharpenEffect;
  60491. private bloom;
  60492. /**
  60493. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60494. */
  60495. depthOfField: DepthOfFieldEffect;
  60496. /**
  60497. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60498. */
  60499. fxaa: FxaaPostProcess;
  60500. /**
  60501. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60502. */
  60503. imageProcessing: ImageProcessingPostProcess;
  60504. /**
  60505. * Chromatic aberration post process which will shift rgb colors in the image
  60506. */
  60507. chromaticAberration: ChromaticAberrationPostProcess;
  60508. private _chromaticAberrationEffect;
  60509. /**
  60510. * Grain post process which add noise to the image
  60511. */
  60512. grain: GrainPostProcess;
  60513. private _grainEffect;
  60514. /**
  60515. * Glow post process which adds a glow to emissive areas of the image
  60516. */
  60517. private _glowLayer;
  60518. /**
  60519. * Animations which can be used to tweak settings over a period of time
  60520. */
  60521. animations: Animation[];
  60522. private _imageProcessingConfigurationObserver;
  60523. private _sharpenEnabled;
  60524. private _bloomEnabled;
  60525. private _depthOfFieldEnabled;
  60526. private _depthOfFieldBlurLevel;
  60527. private _fxaaEnabled;
  60528. private _imageProcessingEnabled;
  60529. private _defaultPipelineTextureType;
  60530. private _bloomScale;
  60531. private _chromaticAberrationEnabled;
  60532. private _grainEnabled;
  60533. private _buildAllowed;
  60534. /**
  60535. * Gets active scene
  60536. */
  60537. readonly scene: Scene;
  60538. /**
  60539. * Enable or disable the sharpen process from the pipeline
  60540. */
  60541. sharpenEnabled: boolean;
  60542. private _resizeObserver;
  60543. private _hardwareScaleLevel;
  60544. private _bloomKernel;
  60545. /**
  60546. * Specifies the size of the bloom blur kernel, relative to the final output size
  60547. */
  60548. bloomKernel: number;
  60549. /**
  60550. * Specifies the weight of the bloom in the final rendering
  60551. */
  60552. private _bloomWeight;
  60553. /**
  60554. * Specifies the luma threshold for the area that will be blurred by the bloom
  60555. */
  60556. private _bloomThreshold;
  60557. private _hdr;
  60558. /**
  60559. * The strength of the bloom.
  60560. */
  60561. bloomWeight: number;
  60562. /**
  60563. * The strength of the bloom.
  60564. */
  60565. bloomThreshold: number;
  60566. /**
  60567. * The scale of the bloom, lower value will provide better performance.
  60568. */
  60569. bloomScale: number;
  60570. /**
  60571. * Enable or disable the bloom from the pipeline
  60572. */
  60573. bloomEnabled: boolean;
  60574. private _rebuildBloom;
  60575. /**
  60576. * If the depth of field is enabled.
  60577. */
  60578. depthOfFieldEnabled: boolean;
  60579. /**
  60580. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60581. */
  60582. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60583. /**
  60584. * If the anti aliasing is enabled.
  60585. */
  60586. fxaaEnabled: boolean;
  60587. private _samples;
  60588. /**
  60589. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60590. */
  60591. samples: number;
  60592. /**
  60593. * If image processing is enabled.
  60594. */
  60595. imageProcessingEnabled: boolean;
  60596. /**
  60597. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60598. */
  60599. glowLayerEnabled: boolean;
  60600. /**
  60601. * Gets the glow layer (or null if not defined)
  60602. */
  60603. readonly glowLayer: Nullable<GlowLayer>;
  60604. /**
  60605. * Enable or disable the chromaticAberration process from the pipeline
  60606. */
  60607. chromaticAberrationEnabled: boolean;
  60608. /**
  60609. * Enable or disable the grain process from the pipeline
  60610. */
  60611. grainEnabled: boolean;
  60612. /**
  60613. * @constructor
  60614. * @param name - The rendering pipeline name (default: "")
  60615. * @param hdr - If high dynamic range textures should be used (default: true)
  60616. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60617. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60618. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60619. */
  60620. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60621. /**
  60622. * Get the class name
  60623. * @returns "DefaultRenderingPipeline"
  60624. */
  60625. getClassName(): string;
  60626. /**
  60627. * Force the compilation of the entire pipeline.
  60628. */
  60629. prepare(): void;
  60630. private _hasCleared;
  60631. private _prevPostProcess;
  60632. private _prevPrevPostProcess;
  60633. private _setAutoClearAndTextureSharing;
  60634. private _depthOfFieldSceneObserver;
  60635. private _buildPipeline;
  60636. private _disposePostProcesses;
  60637. /**
  60638. * Adds a camera to the pipeline
  60639. * @param camera the camera to be added
  60640. */
  60641. addCamera(camera: Camera): void;
  60642. /**
  60643. * Removes a camera from the pipeline
  60644. * @param camera the camera to remove
  60645. */
  60646. removeCamera(camera: Camera): void;
  60647. /**
  60648. * Dispose of the pipeline and stop all post processes
  60649. */
  60650. dispose(): void;
  60651. /**
  60652. * Serialize the rendering pipeline (Used when exporting)
  60653. * @returns the serialized object
  60654. */
  60655. serialize(): any;
  60656. /**
  60657. * Parse the serialized pipeline
  60658. * @param source Source pipeline.
  60659. * @param scene The scene to load the pipeline to.
  60660. * @param rootUrl The URL of the serialized pipeline.
  60661. * @returns An instantiated pipeline from the serialized object.
  60662. */
  60663. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60664. }
  60665. }
  60666. declare module BABYLON {
  60667. /** @hidden */
  60668. export var lensHighlightsPixelShader: {
  60669. name: string;
  60670. shader: string;
  60671. };
  60672. }
  60673. declare module BABYLON {
  60674. /** @hidden */
  60675. export var depthOfFieldPixelShader: {
  60676. name: string;
  60677. shader: string;
  60678. };
  60679. }
  60680. declare module BABYLON {
  60681. /**
  60682. * BABYLON.JS Chromatic Aberration GLSL Shader
  60683. * Author: Olivier Guyot
  60684. * Separates very slightly R, G and B colors on the edges of the screen
  60685. * Inspired by Francois Tarlier & Martins Upitis
  60686. */
  60687. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60688. /**
  60689. * @ignore
  60690. * The chromatic aberration PostProcess id in the pipeline
  60691. */
  60692. LensChromaticAberrationEffect: string;
  60693. /**
  60694. * @ignore
  60695. * The highlights enhancing PostProcess id in the pipeline
  60696. */
  60697. HighlightsEnhancingEffect: string;
  60698. /**
  60699. * @ignore
  60700. * The depth-of-field PostProcess id in the pipeline
  60701. */
  60702. LensDepthOfFieldEffect: string;
  60703. private _scene;
  60704. private _depthTexture;
  60705. private _grainTexture;
  60706. private _chromaticAberrationPostProcess;
  60707. private _highlightsPostProcess;
  60708. private _depthOfFieldPostProcess;
  60709. private _edgeBlur;
  60710. private _grainAmount;
  60711. private _chromaticAberration;
  60712. private _distortion;
  60713. private _highlightsGain;
  60714. private _highlightsThreshold;
  60715. private _dofDistance;
  60716. private _dofAperture;
  60717. private _dofDarken;
  60718. private _dofPentagon;
  60719. private _blurNoise;
  60720. /**
  60721. * @constructor
  60722. *
  60723. * Effect parameters are as follow:
  60724. * {
  60725. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60726. * edge_blur: number; // from 0 to x (1 for realism)
  60727. * distortion: number; // from 0 to x (1 for realism)
  60728. * grain_amount: number; // from 0 to 1
  60729. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60730. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60731. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60732. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60733. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60734. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60735. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60736. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60737. * }
  60738. * Note: if an effect parameter is unset, effect is disabled
  60739. *
  60740. * @param name The rendering pipeline name
  60741. * @param parameters - An object containing all parameters (see above)
  60742. * @param scene The scene linked to this pipeline
  60743. * @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)
  60744. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60745. */
  60746. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60747. /**
  60748. * Get the class name
  60749. * @returns "LensRenderingPipeline"
  60750. */
  60751. getClassName(): string;
  60752. /**
  60753. * Gets associated scene
  60754. */
  60755. readonly scene: Scene;
  60756. /**
  60757. * Gets or sets the edge blur
  60758. */
  60759. edgeBlur: number;
  60760. /**
  60761. * Gets or sets the grain amount
  60762. */
  60763. grainAmount: number;
  60764. /**
  60765. * Gets or sets the chromatic aberration amount
  60766. */
  60767. chromaticAberration: number;
  60768. /**
  60769. * Gets or sets the depth of field aperture
  60770. */
  60771. dofAperture: number;
  60772. /**
  60773. * Gets or sets the edge distortion
  60774. */
  60775. edgeDistortion: number;
  60776. /**
  60777. * Gets or sets the depth of field distortion
  60778. */
  60779. dofDistortion: number;
  60780. /**
  60781. * Gets or sets the darken out of focus amount
  60782. */
  60783. darkenOutOfFocus: number;
  60784. /**
  60785. * Gets or sets a boolean indicating if blur noise is enabled
  60786. */
  60787. blurNoise: boolean;
  60788. /**
  60789. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60790. */
  60791. pentagonBokeh: boolean;
  60792. /**
  60793. * Gets or sets the highlight grain amount
  60794. */
  60795. highlightsGain: number;
  60796. /**
  60797. * Gets or sets the highlight threshold
  60798. */
  60799. highlightsThreshold: number;
  60800. /**
  60801. * Sets the amount of blur at the edges
  60802. * @param amount blur amount
  60803. */
  60804. setEdgeBlur(amount: number): void;
  60805. /**
  60806. * Sets edge blur to 0
  60807. */
  60808. disableEdgeBlur(): void;
  60809. /**
  60810. * Sets the amout of grain
  60811. * @param amount Amount of grain
  60812. */
  60813. setGrainAmount(amount: number): void;
  60814. /**
  60815. * Set grain amount to 0
  60816. */
  60817. disableGrain(): void;
  60818. /**
  60819. * Sets the chromatic aberration amount
  60820. * @param amount amount of chromatic aberration
  60821. */
  60822. setChromaticAberration(amount: number): void;
  60823. /**
  60824. * Sets chromatic aberration amount to 0
  60825. */
  60826. disableChromaticAberration(): void;
  60827. /**
  60828. * Sets the EdgeDistortion amount
  60829. * @param amount amount of EdgeDistortion
  60830. */
  60831. setEdgeDistortion(amount: number): void;
  60832. /**
  60833. * Sets edge distortion to 0
  60834. */
  60835. disableEdgeDistortion(): void;
  60836. /**
  60837. * Sets the FocusDistance amount
  60838. * @param amount amount of FocusDistance
  60839. */
  60840. setFocusDistance(amount: number): void;
  60841. /**
  60842. * Disables depth of field
  60843. */
  60844. disableDepthOfField(): void;
  60845. /**
  60846. * Sets the Aperture amount
  60847. * @param amount amount of Aperture
  60848. */
  60849. setAperture(amount: number): void;
  60850. /**
  60851. * Sets the DarkenOutOfFocus amount
  60852. * @param amount amount of DarkenOutOfFocus
  60853. */
  60854. setDarkenOutOfFocus(amount: number): void;
  60855. private _pentagonBokehIsEnabled;
  60856. /**
  60857. * Creates a pentagon bokeh effect
  60858. */
  60859. enablePentagonBokeh(): void;
  60860. /**
  60861. * Disables the pentagon bokeh effect
  60862. */
  60863. disablePentagonBokeh(): void;
  60864. /**
  60865. * Enables noise blur
  60866. */
  60867. enableNoiseBlur(): void;
  60868. /**
  60869. * Disables noise blur
  60870. */
  60871. disableNoiseBlur(): void;
  60872. /**
  60873. * Sets the HighlightsGain amount
  60874. * @param amount amount of HighlightsGain
  60875. */
  60876. setHighlightsGain(amount: number): void;
  60877. /**
  60878. * Sets the HighlightsThreshold amount
  60879. * @param amount amount of HighlightsThreshold
  60880. */
  60881. setHighlightsThreshold(amount: number): void;
  60882. /**
  60883. * Disables highlights
  60884. */
  60885. disableHighlights(): void;
  60886. /**
  60887. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60888. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60889. */
  60890. dispose(disableDepthRender?: boolean): void;
  60891. private _createChromaticAberrationPostProcess;
  60892. private _createHighlightsPostProcess;
  60893. private _createDepthOfFieldPostProcess;
  60894. private _createGrainTexture;
  60895. }
  60896. }
  60897. declare module BABYLON {
  60898. /** @hidden */
  60899. export var ssao2PixelShader: {
  60900. name: string;
  60901. shader: string;
  60902. };
  60903. }
  60904. declare module BABYLON {
  60905. /** @hidden */
  60906. export var ssaoCombinePixelShader: {
  60907. name: string;
  60908. shader: string;
  60909. };
  60910. }
  60911. declare module BABYLON {
  60912. /**
  60913. * Render pipeline to produce ssao effect
  60914. */
  60915. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60916. /**
  60917. * @ignore
  60918. * The PassPostProcess id in the pipeline that contains the original scene color
  60919. */
  60920. SSAOOriginalSceneColorEffect: string;
  60921. /**
  60922. * @ignore
  60923. * The SSAO PostProcess id in the pipeline
  60924. */
  60925. SSAORenderEffect: string;
  60926. /**
  60927. * @ignore
  60928. * The horizontal blur PostProcess id in the pipeline
  60929. */
  60930. SSAOBlurHRenderEffect: string;
  60931. /**
  60932. * @ignore
  60933. * The vertical blur PostProcess id in the pipeline
  60934. */
  60935. SSAOBlurVRenderEffect: string;
  60936. /**
  60937. * @ignore
  60938. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60939. */
  60940. SSAOCombineRenderEffect: string;
  60941. /**
  60942. * The output strength of the SSAO post-process. Default value is 1.0.
  60943. */
  60944. totalStrength: number;
  60945. /**
  60946. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60947. */
  60948. maxZ: number;
  60949. /**
  60950. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60951. */
  60952. minZAspect: number;
  60953. private _samples;
  60954. /**
  60955. * Number of samples used for the SSAO calculations. Default value is 8
  60956. */
  60957. samples: number;
  60958. private _textureSamples;
  60959. /**
  60960. * Number of samples to use for antialiasing
  60961. */
  60962. textureSamples: number;
  60963. /**
  60964. * Ratio object used for SSAO ratio and blur ratio
  60965. */
  60966. private _ratio;
  60967. /**
  60968. * Dynamically generated sphere sampler.
  60969. */
  60970. private _sampleSphere;
  60971. /**
  60972. * Blur filter offsets
  60973. */
  60974. private _samplerOffsets;
  60975. private _expensiveBlur;
  60976. /**
  60977. * If bilateral blur should be used
  60978. */
  60979. expensiveBlur: boolean;
  60980. /**
  60981. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60982. */
  60983. radius: number;
  60984. /**
  60985. * The base color of the SSAO post-process
  60986. * The final result is "base + ssao" between [0, 1]
  60987. */
  60988. base: number;
  60989. /**
  60990. * Support test.
  60991. */
  60992. static readonly IsSupported: boolean;
  60993. private _scene;
  60994. private _depthTexture;
  60995. private _normalTexture;
  60996. private _randomTexture;
  60997. private _originalColorPostProcess;
  60998. private _ssaoPostProcess;
  60999. private _blurHPostProcess;
  61000. private _blurVPostProcess;
  61001. private _ssaoCombinePostProcess;
  61002. private _firstUpdate;
  61003. /**
  61004. * Gets active scene
  61005. */
  61006. readonly scene: Scene;
  61007. /**
  61008. * @constructor
  61009. * @param name The rendering pipeline name
  61010. * @param scene The scene linked to this pipeline
  61011. * @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 }
  61012. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61013. */
  61014. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61015. /**
  61016. * Get the class name
  61017. * @returns "SSAO2RenderingPipeline"
  61018. */
  61019. getClassName(): string;
  61020. /**
  61021. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61022. */
  61023. dispose(disableGeometryBufferRenderer?: boolean): void;
  61024. private _createBlurPostProcess;
  61025. /** @hidden */
  61026. _rebuild(): void;
  61027. private _bits;
  61028. private _radicalInverse_VdC;
  61029. private _hammersley;
  61030. private _hemisphereSample_uniform;
  61031. private _generateHemisphere;
  61032. private _createSSAOPostProcess;
  61033. private _createSSAOCombinePostProcess;
  61034. private _createRandomTexture;
  61035. /**
  61036. * Serialize the rendering pipeline (Used when exporting)
  61037. * @returns the serialized object
  61038. */
  61039. serialize(): any;
  61040. /**
  61041. * Parse the serialized pipeline
  61042. * @param source Source pipeline.
  61043. * @param scene The scene to load the pipeline to.
  61044. * @param rootUrl The URL of the serialized pipeline.
  61045. * @returns An instantiated pipeline from the serialized object.
  61046. */
  61047. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61048. }
  61049. }
  61050. declare module BABYLON {
  61051. /** @hidden */
  61052. export var ssaoPixelShader: {
  61053. name: string;
  61054. shader: string;
  61055. };
  61056. }
  61057. declare module BABYLON {
  61058. /**
  61059. * Render pipeline to produce ssao effect
  61060. */
  61061. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61062. /**
  61063. * @ignore
  61064. * The PassPostProcess id in the pipeline that contains the original scene color
  61065. */
  61066. SSAOOriginalSceneColorEffect: string;
  61067. /**
  61068. * @ignore
  61069. * The SSAO PostProcess id in the pipeline
  61070. */
  61071. SSAORenderEffect: string;
  61072. /**
  61073. * @ignore
  61074. * The horizontal blur PostProcess id in the pipeline
  61075. */
  61076. SSAOBlurHRenderEffect: string;
  61077. /**
  61078. * @ignore
  61079. * The vertical blur PostProcess id in the pipeline
  61080. */
  61081. SSAOBlurVRenderEffect: string;
  61082. /**
  61083. * @ignore
  61084. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61085. */
  61086. SSAOCombineRenderEffect: string;
  61087. /**
  61088. * The output strength of the SSAO post-process. Default value is 1.0.
  61089. */
  61090. totalStrength: number;
  61091. /**
  61092. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61093. */
  61094. radius: number;
  61095. /**
  61096. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61097. * Must not be equal to fallOff and superior to fallOff.
  61098. * Default value is 0.0075
  61099. */
  61100. area: number;
  61101. /**
  61102. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61103. * Must not be equal to area and inferior to area.
  61104. * Default value is 0.000001
  61105. */
  61106. fallOff: number;
  61107. /**
  61108. * The base color of the SSAO post-process
  61109. * The final result is "base + ssao" between [0, 1]
  61110. */
  61111. base: number;
  61112. private _scene;
  61113. private _depthTexture;
  61114. private _randomTexture;
  61115. private _originalColorPostProcess;
  61116. private _ssaoPostProcess;
  61117. private _blurHPostProcess;
  61118. private _blurVPostProcess;
  61119. private _ssaoCombinePostProcess;
  61120. private _firstUpdate;
  61121. /**
  61122. * Gets active scene
  61123. */
  61124. readonly scene: Scene;
  61125. /**
  61126. * @constructor
  61127. * @param name - The rendering pipeline name
  61128. * @param scene - The scene linked to this pipeline
  61129. * @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 }
  61130. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61131. */
  61132. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61133. /**
  61134. * Get the class name
  61135. * @returns "SSAORenderingPipeline"
  61136. */
  61137. getClassName(): string;
  61138. /**
  61139. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61140. */
  61141. dispose(disableDepthRender?: boolean): void;
  61142. private _createBlurPostProcess;
  61143. /** @hidden */
  61144. _rebuild(): void;
  61145. private _createSSAOPostProcess;
  61146. private _createSSAOCombinePostProcess;
  61147. private _createRandomTexture;
  61148. }
  61149. }
  61150. declare module BABYLON {
  61151. /** @hidden */
  61152. export var standardPixelShader: {
  61153. name: string;
  61154. shader: string;
  61155. };
  61156. }
  61157. declare module BABYLON {
  61158. /**
  61159. * Standard rendering pipeline
  61160. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61161. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61162. */
  61163. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61164. /**
  61165. * Public members
  61166. */
  61167. /**
  61168. * Post-process which contains the original scene color before the pipeline applies all the effects
  61169. */
  61170. originalPostProcess: Nullable<PostProcess>;
  61171. /**
  61172. * Post-process used to down scale an image x4
  61173. */
  61174. downSampleX4PostProcess: Nullable<PostProcess>;
  61175. /**
  61176. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61177. */
  61178. brightPassPostProcess: Nullable<PostProcess>;
  61179. /**
  61180. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61181. */
  61182. blurHPostProcesses: PostProcess[];
  61183. /**
  61184. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61185. */
  61186. blurVPostProcesses: PostProcess[];
  61187. /**
  61188. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61189. */
  61190. textureAdderPostProcess: Nullable<PostProcess>;
  61191. /**
  61192. * Post-process used to create volumetric lighting effect
  61193. */
  61194. volumetricLightPostProcess: Nullable<PostProcess>;
  61195. /**
  61196. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61197. */
  61198. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61199. /**
  61200. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61201. */
  61202. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61203. /**
  61204. * Post-process used to merge the volumetric light effect and the real scene color
  61205. */
  61206. volumetricLightMergePostProces: Nullable<PostProcess>;
  61207. /**
  61208. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61209. */
  61210. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61211. /**
  61212. * Base post-process used to calculate the average luminance of the final image for HDR
  61213. */
  61214. luminancePostProcess: Nullable<PostProcess>;
  61215. /**
  61216. * Post-processes used to create down sample post-processes in order to get
  61217. * the average luminance of the final image for HDR
  61218. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61219. */
  61220. luminanceDownSamplePostProcesses: PostProcess[];
  61221. /**
  61222. * Post-process used to create a HDR effect (light adaptation)
  61223. */
  61224. hdrPostProcess: Nullable<PostProcess>;
  61225. /**
  61226. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61227. */
  61228. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61229. /**
  61230. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61231. */
  61232. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61233. /**
  61234. * Post-process used to merge the final HDR post-process and the real scene color
  61235. */
  61236. hdrFinalPostProcess: Nullable<PostProcess>;
  61237. /**
  61238. * Post-process used to create a lens flare effect
  61239. */
  61240. lensFlarePostProcess: Nullable<PostProcess>;
  61241. /**
  61242. * Post-process that merges the result of the lens flare post-process and the real scene color
  61243. */
  61244. lensFlareComposePostProcess: Nullable<PostProcess>;
  61245. /**
  61246. * Post-process used to create a motion blur effect
  61247. */
  61248. motionBlurPostProcess: Nullable<PostProcess>;
  61249. /**
  61250. * Post-process used to create a depth of field effect
  61251. */
  61252. depthOfFieldPostProcess: Nullable<PostProcess>;
  61253. /**
  61254. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61255. */
  61256. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61257. /**
  61258. * Represents the brightness threshold in order to configure the illuminated surfaces
  61259. */
  61260. brightThreshold: number;
  61261. /**
  61262. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61263. */
  61264. blurWidth: number;
  61265. /**
  61266. * Sets if the blur for highlighted surfaces must be only horizontal
  61267. */
  61268. horizontalBlur: boolean;
  61269. /**
  61270. * Gets the overall exposure used by the pipeline
  61271. */
  61272. /**
  61273. * Sets the overall exposure used by the pipeline
  61274. */
  61275. exposure: number;
  61276. /**
  61277. * Texture used typically to simulate "dirty" on camera lens
  61278. */
  61279. lensTexture: Nullable<Texture>;
  61280. /**
  61281. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61282. */
  61283. volumetricLightCoefficient: number;
  61284. /**
  61285. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61286. */
  61287. volumetricLightPower: number;
  61288. /**
  61289. * Used the set the blur intensity to smooth the volumetric lights
  61290. */
  61291. volumetricLightBlurScale: number;
  61292. /**
  61293. * Light (spot or directional) used to generate the volumetric lights rays
  61294. * The source light must have a shadow generate so the pipeline can get its
  61295. * depth map
  61296. */
  61297. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61298. /**
  61299. * For eye adaptation, represents the minimum luminance the eye can see
  61300. */
  61301. hdrMinimumLuminance: number;
  61302. /**
  61303. * For eye adaptation, represents the decrease luminance speed
  61304. */
  61305. hdrDecreaseRate: number;
  61306. /**
  61307. * For eye adaptation, represents the increase luminance speed
  61308. */
  61309. hdrIncreaseRate: number;
  61310. /**
  61311. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61312. */
  61313. /**
  61314. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61315. */
  61316. hdrAutoExposure: boolean;
  61317. /**
  61318. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61319. */
  61320. lensColorTexture: Nullable<Texture>;
  61321. /**
  61322. * The overall strengh for the lens flare effect
  61323. */
  61324. lensFlareStrength: number;
  61325. /**
  61326. * Dispersion coefficient for lens flare ghosts
  61327. */
  61328. lensFlareGhostDispersal: number;
  61329. /**
  61330. * Main lens flare halo width
  61331. */
  61332. lensFlareHaloWidth: number;
  61333. /**
  61334. * Based on the lens distortion effect, defines how much the lens flare result
  61335. * is distorted
  61336. */
  61337. lensFlareDistortionStrength: number;
  61338. /**
  61339. * Configures the blur intensity used for for lens flare (halo)
  61340. */
  61341. lensFlareBlurWidth: number;
  61342. /**
  61343. * Lens star texture must be used to simulate rays on the flares and is available
  61344. * in the documentation
  61345. */
  61346. lensStarTexture: Nullable<Texture>;
  61347. /**
  61348. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61349. * flare effect by taking account of the dirt texture
  61350. */
  61351. lensFlareDirtTexture: Nullable<Texture>;
  61352. /**
  61353. * Represents the focal length for the depth of field effect
  61354. */
  61355. depthOfFieldDistance: number;
  61356. /**
  61357. * Represents the blur intensity for the blurred part of the depth of field effect
  61358. */
  61359. depthOfFieldBlurWidth: number;
  61360. /**
  61361. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61362. */
  61363. /**
  61364. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61365. */
  61366. motionStrength: number;
  61367. /**
  61368. * Gets wether or not the motion blur post-process is object based or screen based.
  61369. */
  61370. /**
  61371. * Sets wether or not the motion blur post-process should be object based or screen based
  61372. */
  61373. objectBasedMotionBlur: boolean;
  61374. /**
  61375. * List of animations for the pipeline (IAnimatable implementation)
  61376. */
  61377. animations: Animation[];
  61378. /**
  61379. * Private members
  61380. */
  61381. private _scene;
  61382. private _currentDepthOfFieldSource;
  61383. private _basePostProcess;
  61384. private _fixedExposure;
  61385. private _currentExposure;
  61386. private _hdrAutoExposure;
  61387. private _hdrCurrentLuminance;
  61388. private _motionStrength;
  61389. private _isObjectBasedMotionBlur;
  61390. private _floatTextureType;
  61391. private _camerasToBeAttached;
  61392. private _ratio;
  61393. private _bloomEnabled;
  61394. private _depthOfFieldEnabled;
  61395. private _vlsEnabled;
  61396. private _lensFlareEnabled;
  61397. private _hdrEnabled;
  61398. private _motionBlurEnabled;
  61399. private _fxaaEnabled;
  61400. private _motionBlurSamples;
  61401. private _volumetricLightStepsCount;
  61402. private _samples;
  61403. /**
  61404. * @ignore
  61405. * Specifies if the bloom pipeline is enabled
  61406. */
  61407. BloomEnabled: boolean;
  61408. /**
  61409. * @ignore
  61410. * Specifies if the depth of field pipeline is enabed
  61411. */
  61412. DepthOfFieldEnabled: boolean;
  61413. /**
  61414. * @ignore
  61415. * Specifies if the lens flare pipeline is enabed
  61416. */
  61417. LensFlareEnabled: boolean;
  61418. /**
  61419. * @ignore
  61420. * Specifies if the HDR pipeline is enabled
  61421. */
  61422. HDREnabled: boolean;
  61423. /**
  61424. * @ignore
  61425. * Specifies if the volumetric lights scattering effect is enabled
  61426. */
  61427. VLSEnabled: boolean;
  61428. /**
  61429. * @ignore
  61430. * Specifies if the motion blur effect is enabled
  61431. */
  61432. MotionBlurEnabled: boolean;
  61433. /**
  61434. * Specifies if anti-aliasing is enabled
  61435. */
  61436. fxaaEnabled: boolean;
  61437. /**
  61438. * Specifies the number of steps used to calculate the volumetric lights
  61439. * Typically in interval [50, 200]
  61440. */
  61441. volumetricLightStepsCount: number;
  61442. /**
  61443. * Specifies the number of samples used for the motion blur effect
  61444. * Typically in interval [16, 64]
  61445. */
  61446. motionBlurSamples: number;
  61447. /**
  61448. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61449. */
  61450. samples: number;
  61451. /**
  61452. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61453. * @constructor
  61454. * @param name The rendering pipeline name
  61455. * @param scene The scene linked to this pipeline
  61456. * @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)
  61457. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61458. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61459. */
  61460. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61461. private _buildPipeline;
  61462. private _createDownSampleX4PostProcess;
  61463. private _createBrightPassPostProcess;
  61464. private _createBlurPostProcesses;
  61465. private _createTextureAdderPostProcess;
  61466. private _createVolumetricLightPostProcess;
  61467. private _createLuminancePostProcesses;
  61468. private _createHdrPostProcess;
  61469. private _createLensFlarePostProcess;
  61470. private _createDepthOfFieldPostProcess;
  61471. private _createMotionBlurPostProcess;
  61472. private _getDepthTexture;
  61473. private _disposePostProcesses;
  61474. /**
  61475. * Dispose of the pipeline and stop all post processes
  61476. */
  61477. dispose(): void;
  61478. /**
  61479. * Serialize the rendering pipeline (Used when exporting)
  61480. * @returns the serialized object
  61481. */
  61482. serialize(): any;
  61483. /**
  61484. * Parse the serialized pipeline
  61485. * @param source Source pipeline.
  61486. * @param scene The scene to load the pipeline to.
  61487. * @param rootUrl The URL of the serialized pipeline.
  61488. * @returns An instantiated pipeline from the serialized object.
  61489. */
  61490. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61491. /**
  61492. * Luminance steps
  61493. */
  61494. static LuminanceSteps: number;
  61495. }
  61496. }
  61497. declare module BABYLON {
  61498. /** @hidden */
  61499. export var tonemapPixelShader: {
  61500. name: string;
  61501. shader: string;
  61502. };
  61503. }
  61504. declare module BABYLON {
  61505. /** Defines operator used for tonemapping */
  61506. export enum TonemappingOperator {
  61507. /** Hable */
  61508. Hable = 0,
  61509. /** Reinhard */
  61510. Reinhard = 1,
  61511. /** HejiDawson */
  61512. HejiDawson = 2,
  61513. /** Photographic */
  61514. Photographic = 3
  61515. }
  61516. /**
  61517. * Defines a post process to apply tone mapping
  61518. */
  61519. export class TonemapPostProcess extends PostProcess {
  61520. private _operator;
  61521. /** Defines the required exposure adjustement */
  61522. exposureAdjustment: number;
  61523. /**
  61524. * Creates a new TonemapPostProcess
  61525. * @param name defines the name of the postprocess
  61526. * @param _operator defines the operator to use
  61527. * @param exposureAdjustment defines the required exposure adjustement
  61528. * @param camera defines the camera to use (can be null)
  61529. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61530. * @param engine defines the hosting engine (can be ignore if camera is set)
  61531. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61532. */
  61533. constructor(name: string, _operator: TonemappingOperator,
  61534. /** Defines the required exposure adjustement */
  61535. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61536. }
  61537. }
  61538. declare module BABYLON {
  61539. /** @hidden */
  61540. export var depthVertexShader: {
  61541. name: string;
  61542. shader: string;
  61543. };
  61544. }
  61545. declare module BABYLON {
  61546. /** @hidden */
  61547. export var volumetricLightScatteringPixelShader: {
  61548. name: string;
  61549. shader: string;
  61550. };
  61551. }
  61552. declare module BABYLON {
  61553. /** @hidden */
  61554. export var volumetricLightScatteringPassVertexShader: {
  61555. name: string;
  61556. shader: string;
  61557. };
  61558. }
  61559. declare module BABYLON {
  61560. /** @hidden */
  61561. export var volumetricLightScatteringPassPixelShader: {
  61562. name: string;
  61563. shader: string;
  61564. };
  61565. }
  61566. declare module BABYLON {
  61567. /**
  61568. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61569. */
  61570. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61571. private _volumetricLightScatteringPass;
  61572. private _volumetricLightScatteringRTT;
  61573. private _viewPort;
  61574. private _screenCoordinates;
  61575. private _cachedDefines;
  61576. /**
  61577. * If not undefined, the mesh position is computed from the attached node position
  61578. */
  61579. attachedNode: {
  61580. position: Vector3;
  61581. };
  61582. /**
  61583. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61584. */
  61585. customMeshPosition: Vector3;
  61586. /**
  61587. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61588. */
  61589. useCustomMeshPosition: boolean;
  61590. /**
  61591. * If the post-process should inverse the light scattering direction
  61592. */
  61593. invert: boolean;
  61594. /**
  61595. * The internal mesh used by the post-process
  61596. */
  61597. mesh: Mesh;
  61598. /**
  61599. * @hidden
  61600. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61601. */
  61602. useDiffuseColor: boolean;
  61603. /**
  61604. * Array containing the excluded meshes not rendered in the internal pass
  61605. */
  61606. excludedMeshes: AbstractMesh[];
  61607. /**
  61608. * Controls the overall intensity of the post-process
  61609. */
  61610. exposure: number;
  61611. /**
  61612. * Dissipates each sample's contribution in range [0, 1]
  61613. */
  61614. decay: number;
  61615. /**
  61616. * Controls the overall intensity of each sample
  61617. */
  61618. weight: number;
  61619. /**
  61620. * Controls the density of each sample
  61621. */
  61622. density: number;
  61623. /**
  61624. * @constructor
  61625. * @param name The post-process name
  61626. * @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)
  61627. * @param camera The camera that the post-process will be attached to
  61628. * @param mesh The mesh used to create the light scattering
  61629. * @param samples The post-process quality, default 100
  61630. * @param samplingModeThe post-process filtering mode
  61631. * @param engine The babylon engine
  61632. * @param reusable If the post-process is reusable
  61633. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61634. */
  61635. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61636. /**
  61637. * Returns the string "VolumetricLightScatteringPostProcess"
  61638. * @returns "VolumetricLightScatteringPostProcess"
  61639. */
  61640. getClassName(): string;
  61641. private _isReady;
  61642. /**
  61643. * Sets the new light position for light scattering effect
  61644. * @param position The new custom light position
  61645. */
  61646. setCustomMeshPosition(position: Vector3): void;
  61647. /**
  61648. * Returns the light position for light scattering effect
  61649. * @return Vector3 The custom light position
  61650. */
  61651. getCustomMeshPosition(): Vector3;
  61652. /**
  61653. * Disposes the internal assets and detaches the post-process from the camera
  61654. */
  61655. dispose(camera: Camera): void;
  61656. /**
  61657. * Returns the render target texture used by the post-process
  61658. * @return the render target texture used by the post-process
  61659. */
  61660. getPass(): RenderTargetTexture;
  61661. private _meshExcluded;
  61662. private _createPass;
  61663. private _updateMeshScreenCoordinates;
  61664. /**
  61665. * Creates a default mesh for the Volumeric Light Scattering post-process
  61666. * @param name The mesh name
  61667. * @param scene The scene where to create the mesh
  61668. * @return the default mesh
  61669. */
  61670. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61671. }
  61672. }
  61673. declare module BABYLON {
  61674. interface Scene {
  61675. /** @hidden (Backing field) */
  61676. _boundingBoxRenderer: BoundingBoxRenderer;
  61677. /** @hidden (Backing field) */
  61678. _forceShowBoundingBoxes: boolean;
  61679. /**
  61680. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61681. */
  61682. forceShowBoundingBoxes: boolean;
  61683. /**
  61684. * Gets the bounding box renderer associated with the scene
  61685. * @returns a BoundingBoxRenderer
  61686. */
  61687. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61688. }
  61689. interface AbstractMesh {
  61690. /** @hidden (Backing field) */
  61691. _showBoundingBox: boolean;
  61692. /**
  61693. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61694. */
  61695. showBoundingBox: boolean;
  61696. }
  61697. /**
  61698. * Component responsible of rendering the bounding box of the meshes in a scene.
  61699. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61700. */
  61701. export class BoundingBoxRenderer implements ISceneComponent {
  61702. /**
  61703. * The component name helpfull to identify the component in the list of scene components.
  61704. */
  61705. readonly name: string;
  61706. /**
  61707. * The scene the component belongs to.
  61708. */
  61709. scene: Scene;
  61710. /**
  61711. * Color of the bounding box lines placed in front of an object
  61712. */
  61713. frontColor: Color3;
  61714. /**
  61715. * Color of the bounding box lines placed behind an object
  61716. */
  61717. backColor: Color3;
  61718. /**
  61719. * Defines if the renderer should show the back lines or not
  61720. */
  61721. showBackLines: boolean;
  61722. /**
  61723. * @hidden
  61724. */
  61725. renderList: SmartArray<BoundingBox>;
  61726. private _colorShader;
  61727. private _vertexBuffers;
  61728. private _indexBuffer;
  61729. private _fillIndexBuffer;
  61730. private _fillIndexData;
  61731. /**
  61732. * Instantiates a new bounding box renderer in a scene.
  61733. * @param scene the scene the renderer renders in
  61734. */
  61735. constructor(scene: Scene);
  61736. /**
  61737. * Registers the component in a given scene
  61738. */
  61739. register(): void;
  61740. private _evaluateSubMesh;
  61741. private _activeMesh;
  61742. private _prepareRessources;
  61743. private _createIndexBuffer;
  61744. /**
  61745. * Rebuilds the elements related to this component in case of
  61746. * context lost for instance.
  61747. */
  61748. rebuild(): void;
  61749. /**
  61750. * @hidden
  61751. */
  61752. reset(): void;
  61753. /**
  61754. * Render the bounding boxes of a specific rendering group
  61755. * @param renderingGroupId defines the rendering group to render
  61756. */
  61757. render(renderingGroupId: number): void;
  61758. /**
  61759. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61760. * @param mesh Define the mesh to render the occlusion bounding box for
  61761. */
  61762. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61763. /**
  61764. * Dispose and release the resources attached to this renderer.
  61765. */
  61766. dispose(): void;
  61767. }
  61768. }
  61769. declare module BABYLON {
  61770. /** @hidden */
  61771. export var depthPixelShader: {
  61772. name: string;
  61773. shader: string;
  61774. };
  61775. }
  61776. declare module BABYLON {
  61777. /**
  61778. * This represents a depth renderer in Babylon.
  61779. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61780. */
  61781. export class DepthRenderer {
  61782. private _scene;
  61783. private _depthMap;
  61784. private _effect;
  61785. private readonly _storeNonLinearDepth;
  61786. private readonly _clearColor;
  61787. /** Get if the depth renderer is using packed depth or not */
  61788. readonly isPacked: boolean;
  61789. private _cachedDefines;
  61790. private _camera;
  61791. /**
  61792. * Specifiess that the depth renderer will only be used within
  61793. * the camera it is created for.
  61794. * This can help forcing its rendering during the camera processing.
  61795. */
  61796. useOnlyInActiveCamera: boolean;
  61797. /** @hidden */
  61798. static _SceneComponentInitialization: (scene: Scene) => void;
  61799. /**
  61800. * Instantiates a depth renderer
  61801. * @param scene The scene the renderer belongs to
  61802. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61803. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61804. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61805. */
  61806. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61807. /**
  61808. * Creates the depth rendering effect and checks if the effect is ready.
  61809. * @param subMesh The submesh to be used to render the depth map of
  61810. * @param useInstances If multiple world instances should be used
  61811. * @returns if the depth renderer is ready to render the depth map
  61812. */
  61813. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61814. /**
  61815. * Gets the texture which the depth map will be written to.
  61816. * @returns The depth map texture
  61817. */
  61818. getDepthMap(): RenderTargetTexture;
  61819. /**
  61820. * Disposes of the depth renderer.
  61821. */
  61822. dispose(): void;
  61823. }
  61824. }
  61825. declare module BABYLON {
  61826. interface Scene {
  61827. /** @hidden (Backing field) */
  61828. _depthRenderer: {
  61829. [id: string]: DepthRenderer;
  61830. };
  61831. /**
  61832. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61833. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61834. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61835. * @returns the created depth renderer
  61836. */
  61837. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61838. /**
  61839. * Disables a depth renderer for a given camera
  61840. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61841. */
  61842. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61843. }
  61844. /**
  61845. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61846. * in several rendering techniques.
  61847. */
  61848. export class DepthRendererSceneComponent implements ISceneComponent {
  61849. /**
  61850. * The component name helpfull to identify the component in the list of scene components.
  61851. */
  61852. readonly name: string;
  61853. /**
  61854. * The scene the component belongs to.
  61855. */
  61856. scene: Scene;
  61857. /**
  61858. * Creates a new instance of the component for the given scene
  61859. * @param scene Defines the scene to register the component in
  61860. */
  61861. constructor(scene: Scene);
  61862. /**
  61863. * Registers the component in a given scene
  61864. */
  61865. register(): void;
  61866. /**
  61867. * Rebuilds the elements related to this component in case of
  61868. * context lost for instance.
  61869. */
  61870. rebuild(): void;
  61871. /**
  61872. * Disposes the component and the associated ressources
  61873. */
  61874. dispose(): void;
  61875. private _gatherRenderTargets;
  61876. private _gatherActiveCameraRenderTargets;
  61877. }
  61878. }
  61879. declare module BABYLON {
  61880. /** @hidden */
  61881. export var outlinePixelShader: {
  61882. name: string;
  61883. shader: string;
  61884. };
  61885. }
  61886. declare module BABYLON {
  61887. /** @hidden */
  61888. export var outlineVertexShader: {
  61889. name: string;
  61890. shader: string;
  61891. };
  61892. }
  61893. declare module BABYLON {
  61894. interface Scene {
  61895. /** @hidden */
  61896. _outlineRenderer: OutlineRenderer;
  61897. /**
  61898. * Gets the outline renderer associated with the scene
  61899. * @returns a OutlineRenderer
  61900. */
  61901. getOutlineRenderer(): OutlineRenderer;
  61902. }
  61903. interface AbstractMesh {
  61904. /** @hidden (Backing field) */
  61905. _renderOutline: boolean;
  61906. /**
  61907. * Gets or sets a boolean indicating if the outline must be rendered as well
  61908. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61909. */
  61910. renderOutline: boolean;
  61911. /** @hidden (Backing field) */
  61912. _renderOverlay: boolean;
  61913. /**
  61914. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61915. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61916. */
  61917. renderOverlay: boolean;
  61918. }
  61919. /**
  61920. * This class is responsible to draw bothe outline/overlay of meshes.
  61921. * It should not be used directly but through the available method on mesh.
  61922. */
  61923. export class OutlineRenderer implements ISceneComponent {
  61924. /**
  61925. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61926. */
  61927. private static _StencilReference;
  61928. /**
  61929. * The name of the component. Each component must have a unique name.
  61930. */
  61931. name: string;
  61932. /**
  61933. * The scene the component belongs to.
  61934. */
  61935. scene: Scene;
  61936. /**
  61937. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61938. */
  61939. zOffset: number;
  61940. private _engine;
  61941. private _effect;
  61942. private _cachedDefines;
  61943. private _savedDepthWrite;
  61944. /**
  61945. * Instantiates a new outline renderer. (There could be only one per scene).
  61946. * @param scene Defines the scene it belongs to
  61947. */
  61948. constructor(scene: Scene);
  61949. /**
  61950. * Register the component to one instance of a scene.
  61951. */
  61952. register(): void;
  61953. /**
  61954. * Rebuilds the elements related to this component in case of
  61955. * context lost for instance.
  61956. */
  61957. rebuild(): void;
  61958. /**
  61959. * Disposes the component and the associated ressources.
  61960. */
  61961. dispose(): void;
  61962. /**
  61963. * Renders the outline in the canvas.
  61964. * @param subMesh Defines the sumesh to render
  61965. * @param batch Defines the batch of meshes in case of instances
  61966. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61967. */
  61968. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61969. /**
  61970. * Returns whether or not the outline renderer is ready for a given submesh.
  61971. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61972. * @param subMesh Defines the submesh to check readyness for
  61973. * @param useInstances Defines wheter wee are trying to render instances or not
  61974. * @returns true if ready otherwise false
  61975. */
  61976. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61977. private _beforeRenderingMesh;
  61978. private _afterRenderingMesh;
  61979. }
  61980. }
  61981. declare module BABYLON {
  61982. /**
  61983. * Class used to manage multiple sprites of different sizes on the same spritesheet
  61984. * @see http://doc.babylonjs.com/babylon101/sprites
  61985. */
  61986. export class SpritePackedManager extends SpriteManager {
  61987. /** defines the packed manager's name */
  61988. name: string;
  61989. /**
  61990. * Creates a new sprite manager from a packed sprite sheet
  61991. * @param name defines the manager's name
  61992. * @param imgUrl defines the sprite sheet url
  61993. * @param capacity defines the maximum allowed number of sprites
  61994. * @param scene defines the hosting scene
  61995. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  61996. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  61997. * @param samplingMode defines the smapling mode to use with spritesheet
  61998. * @param fromPacked set to true; do not alter
  61999. */
  62000. constructor(
  62001. /** defines the packed manager's name */
  62002. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62003. }
  62004. }
  62005. declare module BABYLON {
  62006. /**
  62007. * Defines the list of states available for a task inside a AssetsManager
  62008. */
  62009. export enum AssetTaskState {
  62010. /**
  62011. * Initialization
  62012. */
  62013. INIT = 0,
  62014. /**
  62015. * Running
  62016. */
  62017. RUNNING = 1,
  62018. /**
  62019. * Done
  62020. */
  62021. DONE = 2,
  62022. /**
  62023. * Error
  62024. */
  62025. ERROR = 3
  62026. }
  62027. /**
  62028. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62029. */
  62030. export abstract class AbstractAssetTask {
  62031. /**
  62032. * Task name
  62033. */ name: string;
  62034. /**
  62035. * Callback called when the task is successful
  62036. */
  62037. onSuccess: (task: any) => void;
  62038. /**
  62039. * Callback called when the task is not successful
  62040. */
  62041. onError: (task: any, message?: string, exception?: any) => void;
  62042. /**
  62043. * Creates a new AssetsManager
  62044. * @param name defines the name of the task
  62045. */
  62046. constructor(
  62047. /**
  62048. * Task name
  62049. */ name: string);
  62050. private _isCompleted;
  62051. private _taskState;
  62052. private _errorObject;
  62053. /**
  62054. * Get if the task is completed
  62055. */
  62056. readonly isCompleted: boolean;
  62057. /**
  62058. * Gets the current state of the task
  62059. */
  62060. readonly taskState: AssetTaskState;
  62061. /**
  62062. * Gets the current error object (if task is in error)
  62063. */
  62064. readonly errorObject: {
  62065. message?: string;
  62066. exception?: any;
  62067. };
  62068. /**
  62069. * Internal only
  62070. * @hidden
  62071. */
  62072. _setErrorObject(message?: string, exception?: any): void;
  62073. /**
  62074. * Execute the current task
  62075. * @param scene defines the scene where you want your assets to be loaded
  62076. * @param onSuccess is a callback called when the task is successfully executed
  62077. * @param onError is a callback called if an error occurs
  62078. */
  62079. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62080. /**
  62081. * Execute the current task
  62082. * @param scene defines the scene where you want your assets to be loaded
  62083. * @param onSuccess is a callback called when the task is successfully executed
  62084. * @param onError is a callback called if an error occurs
  62085. */
  62086. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62087. /**
  62088. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62089. * This can be used with failed tasks that have the reason for failure fixed.
  62090. */
  62091. reset(): void;
  62092. private onErrorCallback;
  62093. private onDoneCallback;
  62094. }
  62095. /**
  62096. * Define the interface used by progress events raised during assets loading
  62097. */
  62098. export interface IAssetsProgressEvent {
  62099. /**
  62100. * Defines the number of remaining tasks to process
  62101. */
  62102. remainingCount: number;
  62103. /**
  62104. * Defines the total number of tasks
  62105. */
  62106. totalCount: number;
  62107. /**
  62108. * Defines the task that was just processed
  62109. */
  62110. task: AbstractAssetTask;
  62111. }
  62112. /**
  62113. * Class used to share progress information about assets loading
  62114. */
  62115. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62116. /**
  62117. * Defines the number of remaining tasks to process
  62118. */
  62119. remainingCount: number;
  62120. /**
  62121. * Defines the total number of tasks
  62122. */
  62123. totalCount: number;
  62124. /**
  62125. * Defines the task that was just processed
  62126. */
  62127. task: AbstractAssetTask;
  62128. /**
  62129. * Creates a AssetsProgressEvent
  62130. * @param remainingCount defines the number of remaining tasks to process
  62131. * @param totalCount defines the total number of tasks
  62132. * @param task defines the task that was just processed
  62133. */
  62134. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62135. }
  62136. /**
  62137. * Define a task used by AssetsManager to load meshes
  62138. */
  62139. export class MeshAssetTask extends AbstractAssetTask {
  62140. /**
  62141. * Defines the name of the task
  62142. */
  62143. name: string;
  62144. /**
  62145. * Defines the list of mesh's names you want to load
  62146. */
  62147. meshesNames: any;
  62148. /**
  62149. * Defines the root url to use as a base to load your meshes and associated resources
  62150. */
  62151. rootUrl: string;
  62152. /**
  62153. * Defines the filename of the scene to load from
  62154. */
  62155. sceneFilename: string;
  62156. /**
  62157. * Gets the list of loaded meshes
  62158. */
  62159. loadedMeshes: Array<AbstractMesh>;
  62160. /**
  62161. * Gets the list of loaded particle systems
  62162. */
  62163. loadedParticleSystems: Array<IParticleSystem>;
  62164. /**
  62165. * Gets the list of loaded skeletons
  62166. */
  62167. loadedSkeletons: Array<Skeleton>;
  62168. /**
  62169. * Gets the list of loaded animation groups
  62170. */
  62171. loadedAnimationGroups: Array<AnimationGroup>;
  62172. /**
  62173. * Callback called when the task is successful
  62174. */
  62175. onSuccess: (task: MeshAssetTask) => void;
  62176. /**
  62177. * Callback called when the task is successful
  62178. */
  62179. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62180. /**
  62181. * Creates a new MeshAssetTask
  62182. * @param name defines the name of the task
  62183. * @param meshesNames defines the list of mesh's names you want to load
  62184. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62185. * @param sceneFilename defines the filename of the scene to load from
  62186. */
  62187. constructor(
  62188. /**
  62189. * Defines the name of the task
  62190. */
  62191. name: string,
  62192. /**
  62193. * Defines the list of mesh's names you want to load
  62194. */
  62195. meshesNames: any,
  62196. /**
  62197. * Defines the root url to use as a base to load your meshes and associated resources
  62198. */
  62199. rootUrl: string,
  62200. /**
  62201. * Defines the filename of the scene to load from
  62202. */
  62203. sceneFilename: string);
  62204. /**
  62205. * Execute the current task
  62206. * @param scene defines the scene where you want your assets to be loaded
  62207. * @param onSuccess is a callback called when the task is successfully executed
  62208. * @param onError is a callback called if an error occurs
  62209. */
  62210. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62211. }
  62212. /**
  62213. * Define a task used by AssetsManager to load text content
  62214. */
  62215. export class TextFileAssetTask extends AbstractAssetTask {
  62216. /**
  62217. * Defines the name of the task
  62218. */
  62219. name: string;
  62220. /**
  62221. * Defines the location of the file to load
  62222. */
  62223. url: string;
  62224. /**
  62225. * Gets the loaded text string
  62226. */
  62227. text: string;
  62228. /**
  62229. * Callback called when the task is successful
  62230. */
  62231. onSuccess: (task: TextFileAssetTask) => void;
  62232. /**
  62233. * Callback called when the task is successful
  62234. */
  62235. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62236. /**
  62237. * Creates a new TextFileAssetTask object
  62238. * @param name defines the name of the task
  62239. * @param url defines the location of the file to load
  62240. */
  62241. constructor(
  62242. /**
  62243. * Defines the name of the task
  62244. */
  62245. name: string,
  62246. /**
  62247. * Defines the location of the file to load
  62248. */
  62249. url: string);
  62250. /**
  62251. * Execute the current task
  62252. * @param scene defines the scene where you want your assets to be loaded
  62253. * @param onSuccess is a callback called when the task is successfully executed
  62254. * @param onError is a callback called if an error occurs
  62255. */
  62256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62257. }
  62258. /**
  62259. * Define a task used by AssetsManager to load binary data
  62260. */
  62261. export class BinaryFileAssetTask extends AbstractAssetTask {
  62262. /**
  62263. * Defines the name of the task
  62264. */
  62265. name: string;
  62266. /**
  62267. * Defines the location of the file to load
  62268. */
  62269. url: string;
  62270. /**
  62271. * Gets the lodaded data (as an array buffer)
  62272. */
  62273. data: ArrayBuffer;
  62274. /**
  62275. * Callback called when the task is successful
  62276. */
  62277. onSuccess: (task: BinaryFileAssetTask) => void;
  62278. /**
  62279. * Callback called when the task is successful
  62280. */
  62281. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62282. /**
  62283. * Creates a new BinaryFileAssetTask object
  62284. * @param name defines the name of the new task
  62285. * @param url defines the location of the file to load
  62286. */
  62287. constructor(
  62288. /**
  62289. * Defines the name of the task
  62290. */
  62291. name: string,
  62292. /**
  62293. * Defines the location of the file to load
  62294. */
  62295. url: string);
  62296. /**
  62297. * Execute the current task
  62298. * @param scene defines the scene where you want your assets to be loaded
  62299. * @param onSuccess is a callback called when the task is successfully executed
  62300. * @param onError is a callback called if an error occurs
  62301. */
  62302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62303. }
  62304. /**
  62305. * Define a task used by AssetsManager to load images
  62306. */
  62307. export class ImageAssetTask extends AbstractAssetTask {
  62308. /**
  62309. * Defines the name of the task
  62310. */
  62311. name: string;
  62312. /**
  62313. * Defines the location of the image to load
  62314. */
  62315. url: string;
  62316. /**
  62317. * Gets the loaded images
  62318. */
  62319. image: HTMLImageElement;
  62320. /**
  62321. * Callback called when the task is successful
  62322. */
  62323. onSuccess: (task: ImageAssetTask) => void;
  62324. /**
  62325. * Callback called when the task is successful
  62326. */
  62327. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62328. /**
  62329. * Creates a new ImageAssetTask
  62330. * @param name defines the name of the task
  62331. * @param url defines the location of the image to load
  62332. */
  62333. constructor(
  62334. /**
  62335. * Defines the name of the task
  62336. */
  62337. name: string,
  62338. /**
  62339. * Defines the location of the image to load
  62340. */
  62341. url: string);
  62342. /**
  62343. * Execute the current task
  62344. * @param scene defines the scene where you want your assets to be loaded
  62345. * @param onSuccess is a callback called when the task is successfully executed
  62346. * @param onError is a callback called if an error occurs
  62347. */
  62348. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62349. }
  62350. /**
  62351. * Defines the interface used by texture loading tasks
  62352. */
  62353. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62354. /**
  62355. * Gets the loaded texture
  62356. */
  62357. texture: TEX;
  62358. }
  62359. /**
  62360. * Define a task used by AssetsManager to load 2D textures
  62361. */
  62362. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62363. /**
  62364. * Defines the name of the task
  62365. */
  62366. name: string;
  62367. /**
  62368. * Defines the location of the file to load
  62369. */
  62370. url: string;
  62371. /**
  62372. * Defines if mipmap should not be generated (default is false)
  62373. */
  62374. noMipmap?: boolean | undefined;
  62375. /**
  62376. * Defines if texture must be inverted on Y axis (default is false)
  62377. */
  62378. invertY?: boolean | undefined;
  62379. /**
  62380. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62381. */
  62382. samplingMode: number;
  62383. /**
  62384. * Gets the loaded texture
  62385. */
  62386. texture: Texture;
  62387. /**
  62388. * Callback called when the task is successful
  62389. */
  62390. onSuccess: (task: TextureAssetTask) => void;
  62391. /**
  62392. * Callback called when the task is successful
  62393. */
  62394. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62395. /**
  62396. * Creates a new TextureAssetTask object
  62397. * @param name defines the name of the task
  62398. * @param url defines the location of the file to load
  62399. * @param noMipmap defines if mipmap should not be generated (default is false)
  62400. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62401. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62402. */
  62403. constructor(
  62404. /**
  62405. * Defines the name of the task
  62406. */
  62407. name: string,
  62408. /**
  62409. * Defines the location of the file to load
  62410. */
  62411. url: string,
  62412. /**
  62413. * Defines if mipmap should not be generated (default is false)
  62414. */
  62415. noMipmap?: boolean | undefined,
  62416. /**
  62417. * Defines if texture must be inverted on Y axis (default is false)
  62418. */
  62419. invertY?: boolean | undefined,
  62420. /**
  62421. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62422. */
  62423. samplingMode?: number);
  62424. /**
  62425. * Execute the current task
  62426. * @param scene defines the scene where you want your assets to be loaded
  62427. * @param onSuccess is a callback called when the task is successfully executed
  62428. * @param onError is a callback called if an error occurs
  62429. */
  62430. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62431. }
  62432. /**
  62433. * Define a task used by AssetsManager to load cube textures
  62434. */
  62435. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62436. /**
  62437. * Defines the name of the task
  62438. */
  62439. name: string;
  62440. /**
  62441. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62442. */
  62443. url: string;
  62444. /**
  62445. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62446. */
  62447. extensions?: string[] | undefined;
  62448. /**
  62449. * Defines if mipmaps should not be generated (default is false)
  62450. */
  62451. noMipmap?: boolean | undefined;
  62452. /**
  62453. * Defines the explicit list of files (undefined by default)
  62454. */
  62455. files?: string[] | undefined;
  62456. /**
  62457. * Gets the loaded texture
  62458. */
  62459. texture: CubeTexture;
  62460. /**
  62461. * Callback called when the task is successful
  62462. */
  62463. onSuccess: (task: CubeTextureAssetTask) => void;
  62464. /**
  62465. * Callback called when the task is successful
  62466. */
  62467. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62468. /**
  62469. * Creates a new CubeTextureAssetTask
  62470. * @param name defines the name of the task
  62471. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62472. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62473. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62474. * @param files defines the explicit list of files (undefined by default)
  62475. */
  62476. constructor(
  62477. /**
  62478. * Defines the name of the task
  62479. */
  62480. name: string,
  62481. /**
  62482. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62483. */
  62484. url: string,
  62485. /**
  62486. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62487. */
  62488. extensions?: string[] | undefined,
  62489. /**
  62490. * Defines if mipmaps should not be generated (default is false)
  62491. */
  62492. noMipmap?: boolean | undefined,
  62493. /**
  62494. * Defines the explicit list of files (undefined by default)
  62495. */
  62496. files?: string[] | undefined);
  62497. /**
  62498. * Execute the current task
  62499. * @param scene defines the scene where you want your assets to be loaded
  62500. * @param onSuccess is a callback called when the task is successfully executed
  62501. * @param onError is a callback called if an error occurs
  62502. */
  62503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62504. }
  62505. /**
  62506. * Define a task used by AssetsManager to load HDR cube textures
  62507. */
  62508. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62509. /**
  62510. * Defines the name of the task
  62511. */
  62512. name: string;
  62513. /**
  62514. * Defines the location of the file to load
  62515. */
  62516. url: string;
  62517. /**
  62518. * Defines the desired size (the more it increases the longer the generation will be)
  62519. */
  62520. size: number;
  62521. /**
  62522. * Defines if mipmaps should not be generated (default is false)
  62523. */
  62524. noMipmap: boolean;
  62525. /**
  62526. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62527. */
  62528. generateHarmonics: boolean;
  62529. /**
  62530. * 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)
  62531. */
  62532. gammaSpace: boolean;
  62533. /**
  62534. * Internal Use Only
  62535. */
  62536. reserved: boolean;
  62537. /**
  62538. * Gets the loaded texture
  62539. */
  62540. texture: HDRCubeTexture;
  62541. /**
  62542. * Callback called when the task is successful
  62543. */
  62544. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62545. /**
  62546. * Callback called when the task is successful
  62547. */
  62548. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62549. /**
  62550. * Creates a new HDRCubeTextureAssetTask object
  62551. * @param name defines the name of the task
  62552. * @param url defines the location of the file to load
  62553. * @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.
  62554. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62555. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62556. * @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)
  62557. * @param reserved Internal use only
  62558. */
  62559. constructor(
  62560. /**
  62561. * Defines the name of the task
  62562. */
  62563. name: string,
  62564. /**
  62565. * Defines the location of the file to load
  62566. */
  62567. url: string,
  62568. /**
  62569. * Defines the desired size (the more it increases the longer the generation will be)
  62570. */
  62571. size: number,
  62572. /**
  62573. * Defines if mipmaps should not be generated (default is false)
  62574. */
  62575. noMipmap?: boolean,
  62576. /**
  62577. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62578. */
  62579. generateHarmonics?: boolean,
  62580. /**
  62581. * 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)
  62582. */
  62583. gammaSpace?: boolean,
  62584. /**
  62585. * Internal Use Only
  62586. */
  62587. reserved?: boolean);
  62588. /**
  62589. * Execute the current task
  62590. * @param scene defines the scene where you want your assets to be loaded
  62591. * @param onSuccess is a callback called when the task is successfully executed
  62592. * @param onError is a callback called if an error occurs
  62593. */
  62594. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62595. }
  62596. /**
  62597. * Define a task used by AssetsManager to load Equirectangular cube textures
  62598. */
  62599. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62600. /**
  62601. * Defines the name of the task
  62602. */
  62603. name: string;
  62604. /**
  62605. * Defines the location of the file to load
  62606. */
  62607. url: string;
  62608. /**
  62609. * Defines the desired size (the more it increases the longer the generation will be)
  62610. */
  62611. size: number;
  62612. /**
  62613. * Defines if mipmaps should not be generated (default is false)
  62614. */
  62615. noMipmap: boolean;
  62616. /**
  62617. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62618. * but the standard material would require them in Gamma space) (default is true)
  62619. */
  62620. gammaSpace: boolean;
  62621. /**
  62622. * Gets the loaded texture
  62623. */
  62624. texture: EquiRectangularCubeTexture;
  62625. /**
  62626. * Callback called when the task is successful
  62627. */
  62628. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62629. /**
  62630. * Callback called when the task is successful
  62631. */
  62632. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62633. /**
  62634. * Creates a new EquiRectangularCubeTextureAssetTask object
  62635. * @param name defines the name of the task
  62636. * @param url defines the location of the file to load
  62637. * @param size defines the desired size (the more it increases the longer the generation will be)
  62638. * If the size is omitted this implies you are using a preprocessed cubemap.
  62639. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62640. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62641. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62642. * (default is true)
  62643. */
  62644. constructor(
  62645. /**
  62646. * Defines the name of the task
  62647. */
  62648. name: string,
  62649. /**
  62650. * Defines the location of the file to load
  62651. */
  62652. url: string,
  62653. /**
  62654. * Defines the desired size (the more it increases the longer the generation will be)
  62655. */
  62656. size: number,
  62657. /**
  62658. * Defines if mipmaps should not be generated (default is false)
  62659. */
  62660. noMipmap?: boolean,
  62661. /**
  62662. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62663. * but the standard material would require them in Gamma space) (default is true)
  62664. */
  62665. gammaSpace?: boolean);
  62666. /**
  62667. * Execute the current task
  62668. * @param scene defines the scene where you want your assets to be loaded
  62669. * @param onSuccess is a callback called when the task is successfully executed
  62670. * @param onError is a callback called if an error occurs
  62671. */
  62672. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62673. }
  62674. /**
  62675. * This class can be used to easily import assets into a scene
  62676. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62677. */
  62678. export class AssetsManager {
  62679. private _scene;
  62680. private _isLoading;
  62681. protected _tasks: AbstractAssetTask[];
  62682. protected _waitingTasksCount: number;
  62683. protected _totalTasksCount: number;
  62684. /**
  62685. * Callback called when all tasks are processed
  62686. */
  62687. onFinish: (tasks: AbstractAssetTask[]) => void;
  62688. /**
  62689. * Callback called when a task is successful
  62690. */
  62691. onTaskSuccess: (task: AbstractAssetTask) => void;
  62692. /**
  62693. * Callback called when a task had an error
  62694. */
  62695. onTaskError: (task: AbstractAssetTask) => void;
  62696. /**
  62697. * Callback called when a task is done (whatever the result is)
  62698. */
  62699. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62700. /**
  62701. * Observable called when all tasks are processed
  62702. */
  62703. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62704. /**
  62705. * Observable called when a task had an error
  62706. */
  62707. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62708. /**
  62709. * Observable called when all tasks were executed
  62710. */
  62711. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62712. /**
  62713. * Observable called when a task is done (whatever the result is)
  62714. */
  62715. onProgressObservable: Observable<IAssetsProgressEvent>;
  62716. /**
  62717. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62718. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62719. */
  62720. useDefaultLoadingScreen: boolean;
  62721. /**
  62722. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62723. * when all assets have been downloaded.
  62724. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62725. */
  62726. autoHideLoadingUI: boolean;
  62727. /**
  62728. * Creates a new AssetsManager
  62729. * @param scene defines the scene to work on
  62730. */
  62731. constructor(scene: Scene);
  62732. /**
  62733. * Add a MeshAssetTask to the list of active tasks
  62734. * @param taskName defines the name of the new task
  62735. * @param meshesNames defines the name of meshes to load
  62736. * @param rootUrl defines the root url to use to locate files
  62737. * @param sceneFilename defines the filename of the scene file
  62738. * @returns a new MeshAssetTask object
  62739. */
  62740. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62741. /**
  62742. * Add a TextFileAssetTask to the list of active tasks
  62743. * @param taskName defines the name of the new task
  62744. * @param url defines the url of the file to load
  62745. * @returns a new TextFileAssetTask object
  62746. */
  62747. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62748. /**
  62749. * Add a BinaryFileAssetTask to the list of active tasks
  62750. * @param taskName defines the name of the new task
  62751. * @param url defines the url of the file to load
  62752. * @returns a new BinaryFileAssetTask object
  62753. */
  62754. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62755. /**
  62756. * Add a ImageAssetTask to the list of active tasks
  62757. * @param taskName defines the name of the new task
  62758. * @param url defines the url of the file to load
  62759. * @returns a new ImageAssetTask object
  62760. */
  62761. addImageTask(taskName: string, url: string): ImageAssetTask;
  62762. /**
  62763. * Add a TextureAssetTask to the list of active tasks
  62764. * @param taskName defines the name of the new task
  62765. * @param url defines the url of the file to load
  62766. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62767. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62768. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62769. * @returns a new TextureAssetTask object
  62770. */
  62771. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62772. /**
  62773. * Add a CubeTextureAssetTask to the list of active tasks
  62774. * @param taskName defines the name of the new task
  62775. * @param url defines the url of the file to load
  62776. * @param extensions defines the extension to use to load the cube map (can be null)
  62777. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62778. * @param files defines the list of files to load (can be null)
  62779. * @returns a new CubeTextureAssetTask object
  62780. */
  62781. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62782. /**
  62783. *
  62784. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62785. * @param taskName defines the name of the new task
  62786. * @param url defines the url of the file to load
  62787. * @param size defines the size you want for the cubemap (can be null)
  62788. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62789. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62790. * @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)
  62791. * @param reserved Internal use only
  62792. * @returns a new HDRCubeTextureAssetTask object
  62793. */
  62794. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62795. /**
  62796. *
  62797. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62798. * @param taskName defines the name of the new task
  62799. * @param url defines the url of the file to load
  62800. * @param size defines the size you want for the cubemap (can be null)
  62801. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62802. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62803. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62804. * @returns a new EquiRectangularCubeTextureAssetTask object
  62805. */
  62806. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62807. /**
  62808. * Remove a task from the assets manager.
  62809. * @param task the task to remove
  62810. */
  62811. removeTask(task: AbstractAssetTask): void;
  62812. private _decreaseWaitingTasksCount;
  62813. private _runTask;
  62814. /**
  62815. * Reset the AssetsManager and remove all tasks
  62816. * @return the current instance of the AssetsManager
  62817. */
  62818. reset(): AssetsManager;
  62819. /**
  62820. * Start the loading process
  62821. * @return the current instance of the AssetsManager
  62822. */
  62823. load(): AssetsManager;
  62824. /**
  62825. * Start the loading process as an async operation
  62826. * @return a promise returning the list of failed tasks
  62827. */
  62828. loadAsync(): Promise<void>;
  62829. }
  62830. }
  62831. declare module BABYLON {
  62832. /**
  62833. * Wrapper class for promise with external resolve and reject.
  62834. */
  62835. export class Deferred<T> {
  62836. /**
  62837. * The promise associated with this deferred object.
  62838. */
  62839. readonly promise: Promise<T>;
  62840. private _resolve;
  62841. private _reject;
  62842. /**
  62843. * The resolve method of the promise associated with this deferred object.
  62844. */
  62845. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62846. /**
  62847. * The reject method of the promise associated with this deferred object.
  62848. */
  62849. readonly reject: (reason?: any) => void;
  62850. /**
  62851. * Constructor for this deferred object.
  62852. */
  62853. constructor();
  62854. }
  62855. }
  62856. declare module BABYLON {
  62857. /**
  62858. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62859. */
  62860. export class MeshExploder {
  62861. private _centerMesh;
  62862. private _meshes;
  62863. private _meshesOrigins;
  62864. private _toCenterVectors;
  62865. private _scaledDirection;
  62866. private _newPosition;
  62867. private _centerPosition;
  62868. /**
  62869. * Explodes meshes from a center mesh.
  62870. * @param meshes The meshes to explode.
  62871. * @param centerMesh The mesh to be center of explosion.
  62872. */
  62873. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62874. private _setCenterMesh;
  62875. /**
  62876. * Get class name
  62877. * @returns "MeshExploder"
  62878. */
  62879. getClassName(): string;
  62880. /**
  62881. * "Exploded meshes"
  62882. * @returns Array of meshes with the centerMesh at index 0.
  62883. */
  62884. getMeshes(): Array<Mesh>;
  62885. /**
  62886. * Explodes meshes giving a specific direction
  62887. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62888. */
  62889. explode(direction?: number): void;
  62890. }
  62891. }
  62892. declare module BABYLON {
  62893. /**
  62894. * Class used to help managing file picking and drag'n'drop
  62895. */
  62896. export class FilesInput {
  62897. /**
  62898. * List of files ready to be loaded
  62899. */
  62900. static readonly FilesToLoad: {
  62901. [key: string]: File;
  62902. };
  62903. /**
  62904. * Callback called when a file is processed
  62905. */
  62906. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62907. private _engine;
  62908. private _currentScene;
  62909. private _sceneLoadedCallback;
  62910. private _progressCallback;
  62911. private _additionalRenderLoopLogicCallback;
  62912. private _textureLoadingCallback;
  62913. private _startingProcessingFilesCallback;
  62914. private _onReloadCallback;
  62915. private _errorCallback;
  62916. private _elementToMonitor;
  62917. private _sceneFileToLoad;
  62918. private _filesToLoad;
  62919. /**
  62920. * Creates a new FilesInput
  62921. * @param engine defines the rendering engine
  62922. * @param scene defines the hosting scene
  62923. * @param sceneLoadedCallback callback called when scene is loaded
  62924. * @param progressCallback callback called to track progress
  62925. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62926. * @param textureLoadingCallback callback called when a texture is loading
  62927. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62928. * @param onReloadCallback callback called when a reload is requested
  62929. * @param errorCallback callback call if an error occurs
  62930. */
  62931. 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);
  62932. private _dragEnterHandler;
  62933. private _dragOverHandler;
  62934. private _dropHandler;
  62935. /**
  62936. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62937. * @param elementToMonitor defines the DOM element to track
  62938. */
  62939. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62940. /**
  62941. * Release all associated resources
  62942. */
  62943. dispose(): void;
  62944. private renderFunction;
  62945. private drag;
  62946. private drop;
  62947. private _traverseFolder;
  62948. private _processFiles;
  62949. /**
  62950. * Load files from a drop event
  62951. * @param event defines the drop event to use as source
  62952. */
  62953. loadFiles(event: any): void;
  62954. private _processReload;
  62955. /**
  62956. * Reload the current scene from the loaded files
  62957. */
  62958. reload(): void;
  62959. }
  62960. }
  62961. declare module BABYLON {
  62962. /**
  62963. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62964. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62965. */
  62966. export class SceneOptimization {
  62967. /**
  62968. * Defines the priority of this optimization (0 by default which means first in the list)
  62969. */
  62970. priority: number;
  62971. /**
  62972. * Gets a string describing the action executed by the current optimization
  62973. * @returns description string
  62974. */
  62975. getDescription(): string;
  62976. /**
  62977. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62978. * @param scene defines the current scene where to apply this optimization
  62979. * @param optimizer defines the current optimizer
  62980. * @returns true if everything that can be done was applied
  62981. */
  62982. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62983. /**
  62984. * Creates the SceneOptimization object
  62985. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62986. * @param desc defines the description associated with the optimization
  62987. */
  62988. constructor(
  62989. /**
  62990. * Defines the priority of this optimization (0 by default which means first in the list)
  62991. */
  62992. priority?: number);
  62993. }
  62994. /**
  62995. * Defines an optimization used to reduce the size of render target textures
  62996. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62997. */
  62998. export class TextureOptimization extends SceneOptimization {
  62999. /**
  63000. * Defines the priority of this optimization (0 by default which means first in the list)
  63001. */
  63002. priority: number;
  63003. /**
  63004. * 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
  63005. */
  63006. maximumSize: number;
  63007. /**
  63008. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63009. */
  63010. step: number;
  63011. /**
  63012. * Gets a string describing the action executed by the current optimization
  63013. * @returns description string
  63014. */
  63015. getDescription(): string;
  63016. /**
  63017. * Creates the TextureOptimization object
  63018. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63019. * @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
  63020. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63021. */
  63022. constructor(
  63023. /**
  63024. * Defines the priority of this optimization (0 by default which means first in the list)
  63025. */
  63026. priority?: number,
  63027. /**
  63028. * 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. */
  63030. maximumSize?: number,
  63031. /**
  63032. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63033. */
  63034. step?: number);
  63035. /**
  63036. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63037. * @param scene defines the current scene where to apply this optimization
  63038. * @param optimizer defines the current optimizer
  63039. * @returns true if everything that can be done was applied
  63040. */
  63041. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63042. }
  63043. /**
  63044. * Defines an optimization used to increase or decrease the rendering resolution
  63045. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63046. */
  63047. export class HardwareScalingOptimization extends SceneOptimization {
  63048. /**
  63049. * Defines the priority of this optimization (0 by default which means first in the list)
  63050. */
  63051. priority: number;
  63052. /**
  63053. * Defines the maximum scale to use (2 by default)
  63054. */
  63055. maximumScale: number;
  63056. /**
  63057. * Defines the step to use between two passes (0.5 by default)
  63058. */
  63059. step: number;
  63060. private _currentScale;
  63061. private _directionOffset;
  63062. /**
  63063. * Gets a string describing the action executed by the current optimization
  63064. * @return description string
  63065. */
  63066. getDescription(): string;
  63067. /**
  63068. * Creates the HardwareScalingOptimization object
  63069. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63070. * @param maximumScale defines the maximum scale to use (2 by default)
  63071. * @param step defines the step to use between two passes (0.5 by default)
  63072. */
  63073. constructor(
  63074. /**
  63075. * Defines the priority of this optimization (0 by default which means first in the list)
  63076. */
  63077. priority?: number,
  63078. /**
  63079. * Defines the maximum scale to use (2 by default)
  63080. */
  63081. maximumScale?: number,
  63082. /**
  63083. * Defines the step to use between two passes (0.5 by default)
  63084. */
  63085. step?: number);
  63086. /**
  63087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63088. * @param scene defines the current scene where to apply this optimization
  63089. * @param optimizer defines the current optimizer
  63090. * @returns true if everything that can be done was applied
  63091. */
  63092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63093. }
  63094. /**
  63095. * Defines an optimization used to remove shadows
  63096. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63097. */
  63098. export class ShadowsOptimization extends SceneOptimization {
  63099. /**
  63100. * Gets a string describing the action executed by the current optimization
  63101. * @return description string
  63102. */
  63103. getDescription(): string;
  63104. /**
  63105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63106. * @param scene defines the current scene where to apply this optimization
  63107. * @param optimizer defines the current optimizer
  63108. * @returns true if everything that can be done was applied
  63109. */
  63110. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63111. }
  63112. /**
  63113. * Defines an optimization used to turn post-processes off
  63114. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63115. */
  63116. export class PostProcessesOptimization extends SceneOptimization {
  63117. /**
  63118. * Gets a string describing the action executed by the current optimization
  63119. * @return description string
  63120. */
  63121. getDescription(): string;
  63122. /**
  63123. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63124. * @param scene defines the current scene where to apply this optimization
  63125. * @param optimizer defines the current optimizer
  63126. * @returns true if everything that can be done was applied
  63127. */
  63128. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63129. }
  63130. /**
  63131. * Defines an optimization used to turn lens flares off
  63132. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63133. */
  63134. export class LensFlaresOptimization extends SceneOptimization {
  63135. /**
  63136. * Gets a string describing the action executed by the current optimization
  63137. * @return description string
  63138. */
  63139. getDescription(): string;
  63140. /**
  63141. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63142. * @param scene defines the current scene where to apply this optimization
  63143. * @param optimizer defines the current optimizer
  63144. * @returns true if everything that can be done was applied
  63145. */
  63146. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63147. }
  63148. /**
  63149. * Defines an optimization based on user defined callback.
  63150. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63151. */
  63152. export class CustomOptimization extends SceneOptimization {
  63153. /**
  63154. * Callback called to apply the custom optimization.
  63155. */
  63156. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63157. /**
  63158. * Callback called to get custom description
  63159. */
  63160. onGetDescription: () => string;
  63161. /**
  63162. * Gets a string describing the action executed by the current optimization
  63163. * @returns description string
  63164. */
  63165. getDescription(): string;
  63166. /**
  63167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63168. * @param scene defines the current scene where to apply this optimization
  63169. * @param optimizer defines the current optimizer
  63170. * @returns true if everything that can be done was applied
  63171. */
  63172. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63173. }
  63174. /**
  63175. * Defines an optimization used to turn particles off
  63176. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63177. */
  63178. export class ParticlesOptimization extends SceneOptimization {
  63179. /**
  63180. * Gets a string describing the action executed by the current optimization
  63181. * @return description string
  63182. */
  63183. getDescription(): string;
  63184. /**
  63185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63186. * @param scene defines the current scene where to apply this optimization
  63187. * @param optimizer defines the current optimizer
  63188. * @returns true if everything that can be done was applied
  63189. */
  63190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63191. }
  63192. /**
  63193. * Defines an optimization used to turn render targets off
  63194. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63195. */
  63196. export class RenderTargetsOptimization extends SceneOptimization {
  63197. /**
  63198. * Gets a string describing the action executed by the current optimization
  63199. * @return description string
  63200. */
  63201. getDescription(): string;
  63202. /**
  63203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63204. * @param scene defines the current scene where to apply this optimization
  63205. * @param optimizer defines the current optimizer
  63206. * @returns true if everything that can be done was applied
  63207. */
  63208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63209. }
  63210. /**
  63211. * Defines an optimization used to merge meshes with compatible materials
  63212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63213. */
  63214. export class MergeMeshesOptimization extends SceneOptimization {
  63215. private static _UpdateSelectionTree;
  63216. /**
  63217. * Gets or sets a boolean which defines if optimization octree has to be updated
  63218. */
  63219. /**
  63220. * Gets or sets a boolean which defines if optimization octree has to be updated
  63221. */
  63222. static UpdateSelectionTree: boolean;
  63223. /**
  63224. * Gets a string describing the action executed by the current optimization
  63225. * @return description string
  63226. */
  63227. getDescription(): string;
  63228. private _canBeMerged;
  63229. /**
  63230. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63231. * @param scene defines the current scene where to apply this optimization
  63232. * @param optimizer defines the current optimizer
  63233. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63234. * @returns true if everything that can be done was applied
  63235. */
  63236. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63237. }
  63238. /**
  63239. * Defines a list of options used by SceneOptimizer
  63240. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63241. */
  63242. export class SceneOptimizerOptions {
  63243. /**
  63244. * Defines the target frame rate to reach (60 by default)
  63245. */
  63246. targetFrameRate: number;
  63247. /**
  63248. * Defines the interval between two checkes (2000ms by default)
  63249. */
  63250. trackerDuration: number;
  63251. /**
  63252. * Gets the list of optimizations to apply
  63253. */
  63254. optimizations: SceneOptimization[];
  63255. /**
  63256. * Creates a new list of options used by SceneOptimizer
  63257. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63258. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63259. */
  63260. constructor(
  63261. /**
  63262. * Defines the target frame rate to reach (60 by default)
  63263. */
  63264. targetFrameRate?: number,
  63265. /**
  63266. * Defines the interval between two checkes (2000ms by default)
  63267. */
  63268. trackerDuration?: number);
  63269. /**
  63270. * Add a new optimization
  63271. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63272. * @returns the current SceneOptimizerOptions
  63273. */
  63274. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63275. /**
  63276. * Add a new custom optimization
  63277. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63278. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63279. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63280. * @returns the current SceneOptimizerOptions
  63281. */
  63282. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63283. /**
  63284. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63285. * @param targetFrameRate defines the target frame rate (60 by default)
  63286. * @returns a SceneOptimizerOptions object
  63287. */
  63288. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63289. /**
  63290. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63291. * @param targetFrameRate defines the target frame rate (60 by default)
  63292. * @returns a SceneOptimizerOptions object
  63293. */
  63294. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63295. /**
  63296. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63297. * @param targetFrameRate defines the target frame rate (60 by default)
  63298. * @returns a SceneOptimizerOptions object
  63299. */
  63300. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63301. }
  63302. /**
  63303. * Class used to run optimizations in order to reach a target frame rate
  63304. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63305. */
  63306. export class SceneOptimizer implements IDisposable {
  63307. private _isRunning;
  63308. private _options;
  63309. private _scene;
  63310. private _currentPriorityLevel;
  63311. private _targetFrameRate;
  63312. private _trackerDuration;
  63313. private _currentFrameRate;
  63314. private _sceneDisposeObserver;
  63315. private _improvementMode;
  63316. /**
  63317. * Defines an observable called when the optimizer reaches the target frame rate
  63318. */
  63319. onSuccessObservable: Observable<SceneOptimizer>;
  63320. /**
  63321. * Defines an observable called when the optimizer enables an optimization
  63322. */
  63323. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63324. /**
  63325. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63326. */
  63327. onFailureObservable: Observable<SceneOptimizer>;
  63328. /**
  63329. * Gets a boolean indicating if the optimizer is in improvement mode
  63330. */
  63331. readonly isInImprovementMode: boolean;
  63332. /**
  63333. * Gets the current priority level (0 at start)
  63334. */
  63335. readonly currentPriorityLevel: number;
  63336. /**
  63337. * Gets the current frame rate checked by the SceneOptimizer
  63338. */
  63339. readonly currentFrameRate: number;
  63340. /**
  63341. * Gets or sets the current target frame rate (60 by default)
  63342. */
  63343. /**
  63344. * Gets or sets the current target frame rate (60 by default)
  63345. */
  63346. targetFrameRate: number;
  63347. /**
  63348. * Gets or sets the current interval between two checks (every 2000ms by default)
  63349. */
  63350. /**
  63351. * Gets or sets the current interval between two checks (every 2000ms by default)
  63352. */
  63353. trackerDuration: number;
  63354. /**
  63355. * Gets the list of active optimizations
  63356. */
  63357. readonly optimizations: SceneOptimization[];
  63358. /**
  63359. * Creates a new SceneOptimizer
  63360. * @param scene defines the scene to work on
  63361. * @param options defines the options to use with the SceneOptimizer
  63362. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63363. * @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)
  63364. */
  63365. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63366. /**
  63367. * Stops the current optimizer
  63368. */
  63369. stop(): void;
  63370. /**
  63371. * Reset the optimizer to initial step (current priority level = 0)
  63372. */
  63373. reset(): void;
  63374. /**
  63375. * Start the optimizer. By default it will try to reach a specific framerate
  63376. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63377. */
  63378. start(): void;
  63379. private _checkCurrentState;
  63380. /**
  63381. * Release all resources
  63382. */
  63383. dispose(): void;
  63384. /**
  63385. * Helper function to create a SceneOptimizer with one single line of code
  63386. * @param scene defines the scene to work on
  63387. * @param options defines the options to use with the SceneOptimizer
  63388. * @param onSuccess defines a callback to call on success
  63389. * @param onFailure defines a callback to call on failure
  63390. * @returns the new SceneOptimizer object
  63391. */
  63392. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63393. }
  63394. }
  63395. declare module BABYLON {
  63396. /**
  63397. * Class used to serialize a scene into a string
  63398. */
  63399. export class SceneSerializer {
  63400. /**
  63401. * Clear cache used by a previous serialization
  63402. */
  63403. static ClearCache(): void;
  63404. /**
  63405. * Serialize a scene into a JSON compatible object
  63406. * @param scene defines the scene to serialize
  63407. * @returns a JSON compatible object
  63408. */
  63409. static Serialize(scene: Scene): any;
  63410. /**
  63411. * Serialize a mesh into a JSON compatible object
  63412. * @param toSerialize defines the mesh to serialize
  63413. * @param withParents defines if parents must be serialized as well
  63414. * @param withChildren defines if children must be serialized as well
  63415. * @returns a JSON compatible object
  63416. */
  63417. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63418. }
  63419. }
  63420. declare module BABYLON {
  63421. /**
  63422. * Class used to host texture specific utilities
  63423. */
  63424. export class TextureTools {
  63425. /**
  63426. * Uses the GPU to create a copy texture rescaled at a given size
  63427. * @param texture Texture to copy from
  63428. * @param width defines the desired width
  63429. * @param height defines the desired height
  63430. * @param useBilinearMode defines if bilinear mode has to be used
  63431. * @return the generated texture
  63432. */
  63433. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63434. }
  63435. }
  63436. declare module BABYLON {
  63437. /**
  63438. * This represents the different options available for the video capture.
  63439. */
  63440. export interface VideoRecorderOptions {
  63441. /** Defines the mime type of the video. */
  63442. mimeType: string;
  63443. /** Defines the FPS the video should be recorded at. */
  63444. fps: number;
  63445. /** Defines the chunk size for the recording data. */
  63446. recordChunckSize: number;
  63447. /** The audio tracks to attach to the recording. */
  63448. audioTracks?: MediaStreamTrack[];
  63449. }
  63450. /**
  63451. * This can help with recording videos from BabylonJS.
  63452. * This is based on the available WebRTC functionalities of the browser.
  63453. *
  63454. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63455. */
  63456. export class VideoRecorder {
  63457. private static readonly _defaultOptions;
  63458. /**
  63459. * Returns whether or not the VideoRecorder is available in your browser.
  63460. * @param engine Defines the Babylon Engine.
  63461. * @returns true if supported otherwise false.
  63462. */
  63463. static IsSupported(engine: Engine): boolean;
  63464. private readonly _options;
  63465. private _canvas;
  63466. private _mediaRecorder;
  63467. private _recordedChunks;
  63468. private _fileName;
  63469. private _resolve;
  63470. private _reject;
  63471. /**
  63472. * True when a recording is already in progress.
  63473. */
  63474. readonly isRecording: boolean;
  63475. /**
  63476. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63477. * @param engine Defines the BabylonJS Engine you wish to record.
  63478. * @param options Defines options that can be used to customize the capture.
  63479. */
  63480. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63481. /**
  63482. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63483. */
  63484. stopRecording(): void;
  63485. /**
  63486. * Starts recording the canvas for a max duration specified in parameters.
  63487. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63488. * If null no automatic download will start and you can rely on the promise to get the data back.
  63489. * @param maxDuration Defines the maximum recording time in seconds.
  63490. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63491. * @return A promise callback at the end of the recording with the video data in Blob.
  63492. */
  63493. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63494. /**
  63495. * Releases internal resources used during the recording.
  63496. */
  63497. dispose(): void;
  63498. private _handleDataAvailable;
  63499. private _handleError;
  63500. private _handleStop;
  63501. }
  63502. }
  63503. declare module BABYLON {
  63504. /**
  63505. * Class containing a set of static utilities functions for screenshots
  63506. */
  63507. export class ScreenshotTools {
  63508. /**
  63509. * Captures a screenshot of the current rendering
  63510. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63511. * @param engine defines the rendering engine
  63512. * @param camera defines the source camera
  63513. * @param size This parameter can be set to a single number or to an object with the
  63514. * following (optional) properties: precision, width, height. If a single number is passed,
  63515. * it will be used for both width and height. If an object is passed, the screenshot size
  63516. * will be derived from the parameters. The precision property is a multiplier allowing
  63517. * rendering at a higher or lower resolution
  63518. * @param successCallback defines the callback receives a single parameter which contains the
  63519. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63520. * src parameter of an <img> to display it
  63521. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63522. * Check your browser for supported MIME types
  63523. */
  63524. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63525. /**
  63526. * Captures a screenshot of the current rendering
  63527. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63528. * @param engine defines the rendering engine
  63529. * @param camera defines the source camera
  63530. * @param size This parameter can be set to a single number or to an object with the
  63531. * following (optional) properties: precision, width, height. If a single number is passed,
  63532. * it will be used for both width and height. If an object is passed, the screenshot size
  63533. * will be derived from the parameters. The precision property is a multiplier allowing
  63534. * rendering at a higher or lower resolution
  63535. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63536. * Check your browser for supported MIME types
  63537. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63538. * to the src parameter of an <img> to display it
  63539. */
  63540. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63541. /**
  63542. * Generates an image screenshot from the specified camera.
  63543. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63544. * @param engine The engine to use for rendering
  63545. * @param camera The camera to use for rendering
  63546. * @param size This parameter can be set to a single number or to an object with the
  63547. * following (optional) properties: precision, width, height. If a single number is passed,
  63548. * it will be used for both width and height. If an object is passed, the screenshot size
  63549. * will be derived from the parameters. The precision property is a multiplier allowing
  63550. * rendering at a higher or lower resolution
  63551. * @param successCallback The callback receives a single parameter which contains the
  63552. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63553. * src parameter of an <img> to display it
  63554. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63555. * Check your browser for supported MIME types
  63556. * @param samples Texture samples (default: 1)
  63557. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63558. * @param fileName A name for for the downloaded file.
  63559. */
  63560. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63561. /**
  63562. * Generates an image screenshot from the specified camera.
  63563. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63564. * @param engine The engine to use for rendering
  63565. * @param camera The camera to use for rendering
  63566. * @param size This parameter can be set to a single number or to an object with the
  63567. * following (optional) properties: precision, width, height. If a single number is passed,
  63568. * it will be used for both width and height. If an object is passed, the screenshot size
  63569. * will be derived from the parameters. The precision property is a multiplier allowing
  63570. * rendering at a higher or lower resolution
  63571. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63572. * Check your browser for supported MIME types
  63573. * @param samples Texture samples (default: 1)
  63574. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63575. * @param fileName A name for for the downloaded file.
  63576. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63577. * to the src parameter of an <img> to display it
  63578. */
  63579. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63580. /**
  63581. * Gets height and width for screenshot size
  63582. * @private
  63583. */
  63584. private static _getScreenshotSize;
  63585. }
  63586. }
  63587. declare module BABYLON {
  63588. /**
  63589. * A cursor which tracks a point on a path
  63590. */
  63591. export class PathCursor {
  63592. private path;
  63593. /**
  63594. * Stores path cursor callbacks for when an onchange event is triggered
  63595. */
  63596. private _onchange;
  63597. /**
  63598. * The value of the path cursor
  63599. */
  63600. value: number;
  63601. /**
  63602. * The animation array of the path cursor
  63603. */
  63604. animations: Animation[];
  63605. /**
  63606. * Initializes the path cursor
  63607. * @param path The path to track
  63608. */
  63609. constructor(path: Path2);
  63610. /**
  63611. * Gets the cursor point on the path
  63612. * @returns A point on the path cursor at the cursor location
  63613. */
  63614. getPoint(): Vector3;
  63615. /**
  63616. * Moves the cursor ahead by the step amount
  63617. * @param step The amount to move the cursor forward
  63618. * @returns This path cursor
  63619. */
  63620. moveAhead(step?: number): PathCursor;
  63621. /**
  63622. * Moves the cursor behind by the step amount
  63623. * @param step The amount to move the cursor back
  63624. * @returns This path cursor
  63625. */
  63626. moveBack(step?: number): PathCursor;
  63627. /**
  63628. * Moves the cursor by the step amount
  63629. * If the step amount is greater than one, an exception is thrown
  63630. * @param step The amount to move the cursor
  63631. * @returns This path cursor
  63632. */
  63633. move(step: number): PathCursor;
  63634. /**
  63635. * Ensures that the value is limited between zero and one
  63636. * @returns This path cursor
  63637. */
  63638. private ensureLimits;
  63639. /**
  63640. * Runs onchange callbacks on change (used by the animation engine)
  63641. * @returns This path cursor
  63642. */
  63643. private raiseOnChange;
  63644. /**
  63645. * Executes a function on change
  63646. * @param f A path cursor onchange callback
  63647. * @returns This path cursor
  63648. */
  63649. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63650. }
  63651. }
  63652. declare module BABYLON {
  63653. /** @hidden */
  63654. export var blurPixelShader: {
  63655. name: string;
  63656. shader: string;
  63657. };
  63658. }
  63659. declare module BABYLON {
  63660. /** @hidden */
  63661. export var pointCloudVertexDeclaration: {
  63662. name: string;
  63663. shader: string;
  63664. };
  63665. }
  63666. // Mixins
  63667. interface Window {
  63668. mozIndexedDB: IDBFactory;
  63669. webkitIndexedDB: IDBFactory;
  63670. msIndexedDB: IDBFactory;
  63671. webkitURL: typeof URL;
  63672. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  63673. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  63674. WebGLRenderingContext: WebGLRenderingContext;
  63675. MSGesture: MSGesture;
  63676. CANNON: any;
  63677. AudioContext: AudioContext;
  63678. webkitAudioContext: AudioContext;
  63679. PointerEvent: any;
  63680. Math: Math;
  63681. Uint8Array: Uint8ArrayConstructor;
  63682. Float32Array: Float32ArrayConstructor;
  63683. mozURL: typeof URL;
  63684. msURL: typeof URL;
  63685. VRFrameData: any; // WebVR, from specs 1.1
  63686. DracoDecoderModule: any;
  63687. setImmediate(handler: (...args: any[]) => void): number;
  63688. }
  63689. interface HTMLCanvasElement {
  63690. requestPointerLock(): void;
  63691. msRequestPointerLock?(): void;
  63692. mozRequestPointerLock?(): void;
  63693. webkitRequestPointerLock?(): void;
  63694. /** Track wether a record is in progress */
  63695. isRecording: boolean;
  63696. /** Capture Stream method defined by some browsers */
  63697. captureStream(fps?: number): MediaStream;
  63698. }
  63699. interface CanvasRenderingContext2D {
  63700. msImageSmoothingEnabled: boolean;
  63701. }
  63702. interface MouseEvent {
  63703. mozMovementX: number;
  63704. mozMovementY: number;
  63705. webkitMovementX: number;
  63706. webkitMovementY: number;
  63707. msMovementX: number;
  63708. msMovementY: number;
  63709. }
  63710. interface Navigator {
  63711. mozGetVRDevices: (any: any) => any;
  63712. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63713. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63714. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63715. webkitGetGamepads(): Gamepad[];
  63716. msGetGamepads(): Gamepad[];
  63717. webkitGamepads(): Gamepad[];
  63718. }
  63719. interface HTMLVideoElement {
  63720. mozSrcObject: any;
  63721. }
  63722. interface Math {
  63723. fround(x: number): number;
  63724. imul(a: number, b: number): number;
  63725. }
  63726. interface WebGLRenderingContext {
  63727. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  63728. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  63729. vertexAttribDivisor(index: number, divisor: number): void;
  63730. createVertexArray(): any;
  63731. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  63732. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  63733. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  63734. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  63735. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  63736. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  63737. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  63738. // Queries
  63739. createQuery(): WebGLQuery;
  63740. deleteQuery(query: WebGLQuery): void;
  63741. beginQuery(target: number, query: WebGLQuery): void;
  63742. endQuery(target: number): void;
  63743. getQueryParameter(query: WebGLQuery, pname: number): any;
  63744. getQuery(target: number, pname: number): any;
  63745. MAX_SAMPLES: number;
  63746. RGBA8: number;
  63747. READ_FRAMEBUFFER: number;
  63748. DRAW_FRAMEBUFFER: number;
  63749. UNIFORM_BUFFER: number;
  63750. HALF_FLOAT_OES: number;
  63751. RGBA16F: number;
  63752. RGBA32F: number;
  63753. R32F: number;
  63754. RG32F: number;
  63755. RGB32F: number;
  63756. R16F: number;
  63757. RG16F: number;
  63758. RGB16F: number;
  63759. RED: number;
  63760. RG: number;
  63761. R8: number;
  63762. RG8: number;
  63763. UNSIGNED_INT_24_8: number;
  63764. DEPTH24_STENCIL8: number;
  63765. MIN: number;
  63766. MAX: number;
  63767. /* Multiple Render Targets */
  63768. drawBuffers(buffers: number[]): void;
  63769. readBuffer(src: number): void;
  63770. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  63771. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  63772. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  63773. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  63774. // Occlusion Query
  63775. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  63776. ANY_SAMPLES_PASSED: number;
  63777. QUERY_RESULT_AVAILABLE: number;
  63778. QUERY_RESULT: number;
  63779. }
  63780. interface WebGLProgram {
  63781. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  63782. }
  63783. interface EXT_disjoint_timer_query {
  63784. QUERY_COUNTER_BITS_EXT: number;
  63785. TIME_ELAPSED_EXT: number;
  63786. TIMESTAMP_EXT: number;
  63787. GPU_DISJOINT_EXT: number;
  63788. QUERY_RESULT_EXT: number;
  63789. QUERY_RESULT_AVAILABLE_EXT: number;
  63790. queryCounterEXT(query: WebGLQuery, target: number): void;
  63791. createQueryEXT(): WebGLQuery;
  63792. beginQueryEXT(target: number, query: WebGLQuery): void;
  63793. endQueryEXT(target: number): void;
  63794. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  63795. deleteQueryEXT(query: WebGLQuery): void;
  63796. }
  63797. interface WebGLUniformLocation {
  63798. _currentState: any;
  63799. }
  63800. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  63801. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  63802. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  63803. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63804. interface WebGLRenderingContext {
  63805. readonly RASTERIZER_DISCARD: number;
  63806. readonly DEPTH_COMPONENT24: number;
  63807. readonly TEXTURE_3D: number;
  63808. readonly TEXTURE_2D_ARRAY: number;
  63809. readonly TEXTURE_COMPARE_FUNC: number;
  63810. readonly TEXTURE_COMPARE_MODE: number;
  63811. readonly COMPARE_REF_TO_TEXTURE: number;
  63812. readonly TEXTURE_WRAP_R: number;
  63813. readonly HALF_FLOAT: number;
  63814. readonly RGB8: number;
  63815. readonly RED_INTEGER: number;
  63816. readonly RG_INTEGER: number;
  63817. readonly RGB_INTEGER: number;
  63818. readonly RGBA_INTEGER: number;
  63819. readonly R8_SNORM: number;
  63820. readonly RG8_SNORM: number;
  63821. readonly RGB8_SNORM: number;
  63822. readonly RGBA8_SNORM: number;
  63823. readonly R8I: number;
  63824. readonly RG8I: number;
  63825. readonly RGB8I: number;
  63826. readonly RGBA8I: number;
  63827. readonly R8UI: number;
  63828. readonly RG8UI: number;
  63829. readonly RGB8UI: number;
  63830. readonly RGBA8UI: number;
  63831. readonly R16I: number;
  63832. readonly RG16I: number;
  63833. readonly RGB16I: number;
  63834. readonly RGBA16I: number;
  63835. readonly R16UI: number;
  63836. readonly RG16UI: number;
  63837. readonly RGB16UI: number;
  63838. readonly RGBA16UI: number;
  63839. readonly R32I: number;
  63840. readonly RG32I: number;
  63841. readonly RGB32I: number;
  63842. readonly RGBA32I: number;
  63843. readonly R32UI: number;
  63844. readonly RG32UI: number;
  63845. readonly RGB32UI: number;
  63846. readonly RGBA32UI: number;
  63847. readonly RGB10_A2UI: number;
  63848. readonly R11F_G11F_B10F: number;
  63849. readonly RGB9_E5: number;
  63850. readonly RGB10_A2: number;
  63851. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  63852. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  63853. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  63854. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63855. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  63856. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  63857. 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;
  63858. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  63859. readonly TRANSFORM_FEEDBACK: number;
  63860. readonly INTERLEAVED_ATTRIBS: number;
  63861. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  63862. createTransformFeedback(): WebGLTransformFeedback;
  63863. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  63864. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  63865. beginTransformFeedback(primitiveMode: number): void;
  63866. endTransformFeedback(): void;
  63867. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  63868. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63869. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63870. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63871. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  63872. }
  63873. interface ImageBitmap {
  63874. readonly width: number;
  63875. readonly height: number;
  63876. close(): void;
  63877. }
  63878. interface WebGLQuery extends WebGLObject {
  63879. }
  63880. declare var WebGLQuery: {
  63881. prototype: WebGLQuery;
  63882. new(): WebGLQuery;
  63883. };
  63884. interface WebGLSampler extends WebGLObject {
  63885. }
  63886. declare var WebGLSampler: {
  63887. prototype: WebGLSampler;
  63888. new(): WebGLSampler;
  63889. };
  63890. interface WebGLSync extends WebGLObject {
  63891. }
  63892. declare var WebGLSync: {
  63893. prototype: WebGLSync;
  63894. new(): WebGLSync;
  63895. };
  63896. interface WebGLTransformFeedback extends WebGLObject {
  63897. }
  63898. declare var WebGLTransformFeedback: {
  63899. prototype: WebGLTransformFeedback;
  63900. new(): WebGLTransformFeedback;
  63901. };
  63902. interface WebGLVertexArrayObject extends WebGLObject {
  63903. }
  63904. declare var WebGLVertexArrayObject: {
  63905. prototype: WebGLVertexArrayObject;
  63906. new(): WebGLVertexArrayObject;
  63907. };
  63908. // Type definitions for WebVR API
  63909. // Project: https://w3c.github.io/webvr/
  63910. // Definitions by: six a <https://github.com/lostfictions>
  63911. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63912. interface VRDisplay extends EventTarget {
  63913. /**
  63914. * Dictionary of capabilities describing the VRDisplay.
  63915. */
  63916. readonly capabilities: VRDisplayCapabilities;
  63917. /**
  63918. * z-depth defining the far plane of the eye view frustum
  63919. * enables mapping of values in the render target depth
  63920. * attachment to scene coordinates. Initially set to 10000.0.
  63921. */
  63922. depthFar: number;
  63923. /**
  63924. * z-depth defining the near plane of the eye view frustum
  63925. * enables mapping of values in the render target depth
  63926. * attachment to scene coordinates. Initially set to 0.01.
  63927. */
  63928. depthNear: number;
  63929. /**
  63930. * An identifier for this distinct VRDisplay. Used as an
  63931. * association point in the Gamepad API.
  63932. */
  63933. readonly displayId: number;
  63934. /**
  63935. * A display name, a user-readable name identifying it.
  63936. */
  63937. readonly displayName: string;
  63938. readonly isConnected: boolean;
  63939. readonly isPresenting: boolean;
  63940. /**
  63941. * If this VRDisplay supports room-scale experiences, the optional
  63942. * stage attribute contains details on the room-scale parameters.
  63943. */
  63944. readonly stageParameters: VRStageParameters | null;
  63945. /**
  63946. * Passing the value returned by `requestAnimationFrame` to
  63947. * `cancelAnimationFrame` will unregister the callback.
  63948. * @param handle Define the hanle of the request to cancel
  63949. */
  63950. cancelAnimationFrame(handle: number): void;
  63951. /**
  63952. * Stops presenting to the VRDisplay.
  63953. * @returns a promise to know when it stopped
  63954. */
  63955. exitPresent(): Promise<void>;
  63956. /**
  63957. * Return the current VREyeParameters for the given eye.
  63958. * @param whichEye Define the eye we want the parameter for
  63959. * @returns the eye parameters
  63960. */
  63961. getEyeParameters(whichEye: string): VREyeParameters;
  63962. /**
  63963. * Populates the passed VRFrameData with the information required to render
  63964. * the current frame.
  63965. * @param frameData Define the data structure to populate
  63966. * @returns true if ok otherwise false
  63967. */
  63968. getFrameData(frameData: VRFrameData): boolean;
  63969. /**
  63970. * Get the layers currently being presented.
  63971. * @returns the list of VR layers
  63972. */
  63973. getLayers(): VRLayer[];
  63974. /**
  63975. * Return a VRPose containing the future predicted pose of the VRDisplay
  63976. * when the current frame will be presented. The value returned will not
  63977. * change until JavaScript has returned control to the browser.
  63978. *
  63979. * The VRPose will contain the position, orientation, velocity,
  63980. * and acceleration of each of these properties.
  63981. * @returns the pose object
  63982. */
  63983. getPose(): VRPose;
  63984. /**
  63985. * Return the current instantaneous pose of the VRDisplay, with no
  63986. * prediction applied.
  63987. * @returns the current instantaneous pose
  63988. */
  63989. getImmediatePose(): VRPose;
  63990. /**
  63991. * The callback passed to `requestAnimationFrame` will be called
  63992. * any time a new frame should be rendered. When the VRDisplay is
  63993. * presenting the callback will be called at the native refresh
  63994. * rate of the HMD. When not presenting this function acts
  63995. * identically to how window.requestAnimationFrame acts. Content should
  63996. * make no assumptions of frame rate or vsync behavior as the HMD runs
  63997. * asynchronously from other displays and at differing refresh rates.
  63998. * @param callback Define the eaction to run next frame
  63999. * @returns the request handle it
  64000. */
  64001. requestAnimationFrame(callback: FrameRequestCallback): number;
  64002. /**
  64003. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  64004. * Repeat calls while already presenting will update the VRLayers being displayed.
  64005. * @param layers Define the list of layer to present
  64006. * @returns a promise to know when the request has been fulfilled
  64007. */
  64008. requestPresent(layers: VRLayer[]): Promise<void>;
  64009. /**
  64010. * Reset the pose for this display, treating its current position and
  64011. * orientation as the "origin/zero" values. VRPose.position,
  64012. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  64013. * updated when calling resetPose(). This should be called in only
  64014. * sitting-space experiences.
  64015. */
  64016. resetPose(): void;
  64017. /**
  64018. * The VRLayer provided to the VRDisplay will be captured and presented
  64019. * in the HMD. Calling this function has the same effect on the source
  64020. * canvas as any other operation that uses its source image, and canvases
  64021. * created without preserveDrawingBuffer set to true will be cleared.
  64022. * @param pose Define the pose to submit
  64023. */
  64024. submitFrame(pose?: VRPose): void;
  64025. }
  64026. declare var VRDisplay: {
  64027. prototype: VRDisplay;
  64028. new(): VRDisplay;
  64029. };
  64030. interface VRLayer {
  64031. leftBounds?: number[] | Float32Array | null;
  64032. rightBounds?: number[] | Float32Array | null;
  64033. source?: HTMLCanvasElement | null;
  64034. }
  64035. interface VRDisplayCapabilities {
  64036. readonly canPresent: boolean;
  64037. readonly hasExternalDisplay: boolean;
  64038. readonly hasOrientation: boolean;
  64039. readonly hasPosition: boolean;
  64040. readonly maxLayers: number;
  64041. }
  64042. interface VREyeParameters {
  64043. /** @deprecated */
  64044. readonly fieldOfView: VRFieldOfView;
  64045. readonly offset: Float32Array;
  64046. readonly renderHeight: number;
  64047. readonly renderWidth: number;
  64048. }
  64049. interface VRFieldOfView {
  64050. readonly downDegrees: number;
  64051. readonly leftDegrees: number;
  64052. readonly rightDegrees: number;
  64053. readonly upDegrees: number;
  64054. }
  64055. interface VRFrameData {
  64056. readonly leftProjectionMatrix: Float32Array;
  64057. readonly leftViewMatrix: Float32Array;
  64058. readonly pose: VRPose;
  64059. readonly rightProjectionMatrix: Float32Array;
  64060. readonly rightViewMatrix: Float32Array;
  64061. readonly timestamp: number;
  64062. }
  64063. interface VRPose {
  64064. readonly angularAcceleration: Float32Array | null;
  64065. readonly angularVelocity: Float32Array | null;
  64066. readonly linearAcceleration: Float32Array | null;
  64067. readonly linearVelocity: Float32Array | null;
  64068. readonly orientation: Float32Array | null;
  64069. readonly position: Float32Array | null;
  64070. readonly timestamp: number;
  64071. }
  64072. interface VRStageParameters {
  64073. sittingToStandingTransform?: Float32Array;
  64074. sizeX?: number;
  64075. sizeY?: number;
  64076. }
  64077. interface Navigator {
  64078. getVRDisplays(): Promise<VRDisplay[]>;
  64079. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  64080. }
  64081. interface Window {
  64082. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  64083. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  64084. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  64085. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64086. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64087. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  64088. }
  64089. interface Gamepad {
  64090. readonly displayId: number;
  64091. }
  64092. type XRSessionMode =
  64093. | "inline"
  64094. | "immersive-vr"
  64095. | "immersive-ar";
  64096. type XRReferenceSpaceType =
  64097. | "viewer"
  64098. | "local"
  64099. | "local-floor"
  64100. | "bounded-floor"
  64101. | "unbounded";
  64102. type XREnvironmentBlendMode =
  64103. | "opaque"
  64104. | "additive"
  64105. | "alpha-blend";
  64106. type XRVisibilityState =
  64107. | "visible"
  64108. | "visible-blurred"
  64109. | "hidden";
  64110. type XRHandedness =
  64111. | "none"
  64112. | "left"
  64113. | "right";
  64114. type XRTargetRayMode =
  64115. | "gaze"
  64116. | "tracked-pointer"
  64117. | "screen";
  64118. type XREye =
  64119. | "none"
  64120. | "left"
  64121. | "right";
  64122. interface XRSpace extends EventTarget {
  64123. }
  64124. interface XRRenderState {
  64125. depthNear?: number;
  64126. depthFar?: number;
  64127. inlineVerticalFieldOfView?: number;
  64128. baseLayer?: XRWebGLLayer;
  64129. }
  64130. interface XRInputSource {
  64131. handedness: XRHandedness;
  64132. targetRayMode: XRTargetRayMode;
  64133. targetRaySpace: XRSpace;
  64134. gripSpace: XRSpace | undefined;
  64135. gamepad: Gamepad | undefined;
  64136. profiles: Array<string>;
  64137. }
  64138. interface XRSession {
  64139. addEventListener: Function;
  64140. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  64141. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  64142. requestAnimationFrame: Function;
  64143. end(): Promise<void>;
  64144. renderState: XRRenderState;
  64145. inputSources: Array<XRInputSource>;
  64146. }
  64147. interface XRReferenceSpace extends XRSpace {
  64148. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  64149. onreset: any;
  64150. }
  64151. interface XRFrame {
  64152. session: XRSession;
  64153. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  64154. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  64155. }
  64156. interface XRViewerPose extends XRPose {
  64157. views: Array<XRView>;
  64158. }
  64159. interface XRPose {
  64160. transform: XRRigidTransform;
  64161. emulatedPosition: boolean;
  64162. }
  64163. declare var XRWebGLLayer: {
  64164. prototype: XRWebGLLayer;
  64165. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  64166. };
  64167. interface XRWebGLLayer {
  64168. framebuffer: WebGLFramebuffer;
  64169. framebufferWidth: number;
  64170. framebufferHeight: number;
  64171. getViewport: Function;
  64172. }
  64173. interface XRRigidTransform {
  64174. position: DOMPointReadOnly;
  64175. orientation: DOMPointReadOnly;
  64176. matrix: Float32Array;
  64177. inverse: XRRigidTransform;
  64178. }
  64179. interface XRView {
  64180. eye: XREye;
  64181. projectionMatrix: Float32Array;
  64182. transform: XRRigidTransform;
  64183. }
  64184. interface XRInputSourceChangeEvent {
  64185. session: XRSession;
  64186. removed: Array<XRInputSource>;
  64187. added: Array<XRInputSource>;
  64188. }
  64189. /**
  64190. * @ignore
  64191. */
  64192. declare module BABYLON.GLTF2.Exporter {
  64193. }
  64194. /**
  64195. * @ignore
  64196. */
  64197. declare module BABYLON.GLTF1 {
  64198. }
  64199. declare module BABYLON.GUI {
  64200. /**
  64201. * Class used to specific a value and its associated unit
  64202. */
  64203. export class ValueAndUnit {
  64204. /** defines the unit to store */
  64205. unit: number;
  64206. /** defines a boolean indicating if the value can be negative */
  64207. negativeValueAllowed: boolean;
  64208. private _value;
  64209. private _originalUnit;
  64210. /**
  64211. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  64212. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64213. */
  64214. ignoreAdaptiveScaling: boolean;
  64215. /**
  64216. * Creates a new ValueAndUnit
  64217. * @param value defines the value to store
  64218. * @param unit defines the unit to store
  64219. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  64220. */
  64221. constructor(value: number,
  64222. /** defines the unit to store */
  64223. unit?: number,
  64224. /** defines a boolean indicating if the value can be negative */
  64225. negativeValueAllowed?: boolean);
  64226. /** Gets a boolean indicating if the value is a percentage */
  64227. readonly isPercentage: boolean;
  64228. /** Gets a boolean indicating if the value is store as pixel */
  64229. readonly isPixel: boolean;
  64230. /** Gets direct internal value */
  64231. readonly internalValue: number;
  64232. /**
  64233. * Gets value as pixel
  64234. * @param host defines the root host
  64235. * @param refValue defines the reference value for percentages
  64236. * @returns the value as pixel
  64237. */
  64238. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  64239. /**
  64240. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  64241. * @param value defines the value to store
  64242. * @param unit defines the unit to store
  64243. * @returns the current ValueAndUnit
  64244. */
  64245. updateInPlace(value: number, unit?: number): ValueAndUnit;
  64246. /**
  64247. * Gets the value accordingly to its unit
  64248. * @param host defines the root host
  64249. * @returns the value
  64250. */
  64251. getValue(host: AdvancedDynamicTexture): number;
  64252. /**
  64253. * Gets a string representation of the value
  64254. * @param host defines the root host
  64255. * @param decimals defines an optional number of decimals to display
  64256. * @returns a string
  64257. */
  64258. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  64259. /**
  64260. * Store a value parsed from a string
  64261. * @param source defines the source string
  64262. * @returns true if the value was successfully parsed
  64263. */
  64264. fromString(source: string | number): boolean;
  64265. private static _Regex;
  64266. private static _UNITMODE_PERCENTAGE;
  64267. private static _UNITMODE_PIXEL;
  64268. /** UNITMODE_PERCENTAGE */
  64269. static readonly UNITMODE_PERCENTAGE: number;
  64270. /** UNITMODE_PIXEL */
  64271. static readonly UNITMODE_PIXEL: number;
  64272. }
  64273. }
  64274. declare module BABYLON.GUI {
  64275. /**
  64276. * Define a style used by control to automatically setup properties based on a template.
  64277. * Only support font related properties so far
  64278. */
  64279. export class Style implements BABYLON.IDisposable {
  64280. private _fontFamily;
  64281. private _fontStyle;
  64282. private _fontWeight;
  64283. /** @hidden */
  64284. _host: AdvancedDynamicTexture;
  64285. /** @hidden */
  64286. _fontSize: ValueAndUnit;
  64287. /**
  64288. * BABYLON.Observable raised when the style values are changed
  64289. */
  64290. onChangedObservable: BABYLON.Observable<Style>;
  64291. /**
  64292. * Creates a new style object
  64293. * @param host defines the AdvancedDynamicTexture which hosts this style
  64294. */
  64295. constructor(host: AdvancedDynamicTexture);
  64296. /**
  64297. * Gets or sets the font size
  64298. */
  64299. fontSize: string | number;
  64300. /**
  64301. * Gets or sets the font family
  64302. */
  64303. fontFamily: string;
  64304. /**
  64305. * Gets or sets the font style
  64306. */
  64307. fontStyle: string;
  64308. /** Gets or sets font weight */
  64309. fontWeight: string;
  64310. /** Dispose all associated resources */
  64311. dispose(): void;
  64312. }
  64313. }
  64314. declare module BABYLON.GUI {
  64315. /**
  64316. * Class used to transport BABYLON.Vector2 information for pointer events
  64317. */
  64318. export class Vector2WithInfo extends BABYLON.Vector2 {
  64319. /** defines the current mouse button index */
  64320. buttonIndex: number;
  64321. /**
  64322. * Creates a new Vector2WithInfo
  64323. * @param source defines the vector2 data to transport
  64324. * @param buttonIndex defines the current mouse button index
  64325. */
  64326. constructor(source: BABYLON.Vector2,
  64327. /** defines the current mouse button index */
  64328. buttonIndex?: number);
  64329. }
  64330. /** Class used to provide 2D matrix features */
  64331. export class Matrix2D {
  64332. /** Gets the internal array of 6 floats used to store matrix data */
  64333. m: Float32Array;
  64334. /**
  64335. * Creates a new matrix
  64336. * @param m00 defines value for (0, 0)
  64337. * @param m01 defines value for (0, 1)
  64338. * @param m10 defines value for (1, 0)
  64339. * @param m11 defines value for (1, 1)
  64340. * @param m20 defines value for (2, 0)
  64341. * @param m21 defines value for (2, 1)
  64342. */
  64343. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  64344. /**
  64345. * Fills the matrix from direct values
  64346. * @param m00 defines value for (0, 0)
  64347. * @param m01 defines value for (0, 1)
  64348. * @param m10 defines value for (1, 0)
  64349. * @param m11 defines value for (1, 1)
  64350. * @param m20 defines value for (2, 0)
  64351. * @param m21 defines value for (2, 1)
  64352. * @returns the current modified matrix
  64353. */
  64354. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  64355. /**
  64356. * Gets matrix determinant
  64357. * @returns the determinant
  64358. */
  64359. determinant(): number;
  64360. /**
  64361. * Inverses the matrix and stores it in a target matrix
  64362. * @param result defines the target matrix
  64363. * @returns the current matrix
  64364. */
  64365. invertToRef(result: Matrix2D): Matrix2D;
  64366. /**
  64367. * Multiplies the current matrix with another one
  64368. * @param other defines the second operand
  64369. * @param result defines the target matrix
  64370. * @returns the current matrix
  64371. */
  64372. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  64373. /**
  64374. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  64375. * @param x defines the x coordinate to transform
  64376. * @param y defines the x coordinate to transform
  64377. * @param result defines the target vector2
  64378. * @returns the current matrix
  64379. */
  64380. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  64381. /**
  64382. * Creates an identity matrix
  64383. * @returns a new matrix
  64384. */
  64385. static Identity(): Matrix2D;
  64386. /**
  64387. * Creates a translation matrix and stores it in a target matrix
  64388. * @param x defines the x coordinate of the translation
  64389. * @param y defines the y coordinate of the translation
  64390. * @param result defines the target matrix
  64391. */
  64392. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  64393. /**
  64394. * Creates a scaling matrix and stores it in a target matrix
  64395. * @param x defines the x coordinate of the scaling
  64396. * @param y defines the y coordinate of the scaling
  64397. * @param result defines the target matrix
  64398. */
  64399. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  64400. /**
  64401. * Creates a rotation matrix and stores it in a target matrix
  64402. * @param angle defines the rotation angle
  64403. * @param result defines the target matrix
  64404. */
  64405. static RotationToRef(angle: number, result: Matrix2D): void;
  64406. private static _TempPreTranslationMatrix;
  64407. private static _TempPostTranslationMatrix;
  64408. private static _TempRotationMatrix;
  64409. private static _TempScalingMatrix;
  64410. private static _TempCompose0;
  64411. private static _TempCompose1;
  64412. private static _TempCompose2;
  64413. /**
  64414. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  64415. * @param tx defines the x coordinate of the translation
  64416. * @param ty defines the y coordinate of the translation
  64417. * @param angle defines the rotation angle
  64418. * @param scaleX defines the x coordinate of the scaling
  64419. * @param scaleY defines the y coordinate of the scaling
  64420. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  64421. * @param result defines the target matrix
  64422. */
  64423. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  64424. }
  64425. }
  64426. declare module BABYLON.GUI {
  64427. /**
  64428. * Class used to store 2D control sizes
  64429. */
  64430. export class Measure {
  64431. /** defines left coordinate */
  64432. left: number;
  64433. /** defines top coordinate */
  64434. top: number;
  64435. /** defines width dimension */
  64436. width: number;
  64437. /** defines height dimension */
  64438. height: number;
  64439. /**
  64440. * Creates a new measure
  64441. * @param left defines left coordinate
  64442. * @param top defines top coordinate
  64443. * @param width defines width dimension
  64444. * @param height defines height dimension
  64445. */
  64446. constructor(
  64447. /** defines left coordinate */
  64448. left: number,
  64449. /** defines top coordinate */
  64450. top: number,
  64451. /** defines width dimension */
  64452. width: number,
  64453. /** defines height dimension */
  64454. height: number);
  64455. /**
  64456. * Copy from another measure
  64457. * @param other defines the other measure to copy from
  64458. */
  64459. copyFrom(other: Measure): void;
  64460. /**
  64461. * Copy from a group of 4 floats
  64462. * @param left defines left coordinate
  64463. * @param top defines top coordinate
  64464. * @param width defines width dimension
  64465. * @param height defines height dimension
  64466. */
  64467. copyFromFloats(left: number, top: number, width: number, height: number): void;
  64468. /**
  64469. * Computes the axis aligned bounding box measure for two given measures
  64470. * @param a Input measure
  64471. * @param b Input measure
  64472. * @param result the resulting bounding measure
  64473. */
  64474. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  64475. /**
  64476. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  64477. * @param transform the matrix to transform the measure before computing the AABB
  64478. * @param result the resulting AABB
  64479. */
  64480. transformToRef(transform: Matrix2D, result: Measure): void;
  64481. /**
  64482. * Check equality between this measure and another one
  64483. * @param other defines the other measures
  64484. * @returns true if both measures are equals
  64485. */
  64486. isEqualsTo(other: Measure): boolean;
  64487. /**
  64488. * Creates an empty measure
  64489. * @returns a new measure
  64490. */
  64491. static Empty(): Measure;
  64492. }
  64493. }
  64494. declare module BABYLON.GUI {
  64495. /**
  64496. * Interface used to define a control that can receive focus
  64497. */
  64498. export interface IFocusableControl {
  64499. /**
  64500. * Function called when the control receives the focus
  64501. */
  64502. onFocus(): void;
  64503. /**
  64504. * Function called when the control loses the focus
  64505. */
  64506. onBlur(): void;
  64507. /**
  64508. * Function called to let the control handle keyboard events
  64509. * @param evt defines the current keyboard event
  64510. */
  64511. processKeyboard(evt: KeyboardEvent): void;
  64512. /**
  64513. * Function called to get the list of controls that should not steal the focus from this control
  64514. * @returns an array of controls
  64515. */
  64516. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64517. }
  64518. /**
  64519. * Class used to create texture to support 2D GUI elements
  64520. * @see http://doc.babylonjs.com/how_to/gui
  64521. */
  64522. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  64523. private _isDirty;
  64524. private _renderObserver;
  64525. private _resizeObserver;
  64526. private _preKeyboardObserver;
  64527. private _pointerMoveObserver;
  64528. private _pointerObserver;
  64529. private _canvasPointerOutObserver;
  64530. private _background;
  64531. /** @hidden */
  64532. _rootContainer: Container;
  64533. /** @hidden */
  64534. _lastPickedControl: Control;
  64535. /** @hidden */
  64536. _lastControlOver: {
  64537. [pointerId: number]: Control;
  64538. };
  64539. /** @hidden */
  64540. _lastControlDown: {
  64541. [pointerId: number]: Control;
  64542. };
  64543. /** @hidden */
  64544. _capturingControl: {
  64545. [pointerId: number]: Control;
  64546. };
  64547. /** @hidden */
  64548. _shouldBlockPointer: boolean;
  64549. /** @hidden */
  64550. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  64551. /** @hidden */
  64552. _linkedControls: Control[];
  64553. private _isFullscreen;
  64554. private _fullscreenViewport;
  64555. private _idealWidth;
  64556. private _idealHeight;
  64557. private _useSmallestIdeal;
  64558. private _renderAtIdealSize;
  64559. private _focusedControl;
  64560. private _blockNextFocusCheck;
  64561. private _renderScale;
  64562. private _rootCanvas;
  64563. private _cursorChanged;
  64564. /**
  64565. * Define type to string to ensure compatibility across browsers
  64566. * Safari doesn't support DataTransfer constructor
  64567. */
  64568. private _clipboardData;
  64569. /**
  64570. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  64571. */
  64572. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  64573. /**
  64574. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  64575. */
  64576. onControlPickedObservable: BABYLON.Observable<Control>;
  64577. /**
  64578. * BABYLON.Observable event triggered before layout is evaluated
  64579. */
  64580. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64581. /**
  64582. * BABYLON.Observable event triggered after the layout was evaluated
  64583. */
  64584. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64585. /**
  64586. * BABYLON.Observable event triggered before the texture is rendered
  64587. */
  64588. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64589. /**
  64590. * BABYLON.Observable event triggered after the texture was rendered
  64591. */
  64592. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64593. /**
  64594. * Gets or sets a boolean defining if alpha is stored as premultiplied
  64595. */
  64596. premulAlpha: boolean;
  64597. /**
  64598. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  64599. * Useful when you want more antialiasing
  64600. */
  64601. renderScale: number;
  64602. /** Gets or sets the background color */
  64603. background: string;
  64604. /**
  64605. * Gets or sets the ideal width used to design controls.
  64606. * The GUI will then rescale everything accordingly
  64607. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64608. */
  64609. idealWidth: number;
  64610. /**
  64611. * Gets or sets the ideal height used to design controls.
  64612. * The GUI will then rescale everything accordingly
  64613. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64614. */
  64615. idealHeight: number;
  64616. /**
  64617. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  64618. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64619. */
  64620. useSmallestIdeal: boolean;
  64621. /**
  64622. * Gets or sets a boolean indicating if adaptive scaling must be used
  64623. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64624. */
  64625. renderAtIdealSize: boolean;
  64626. /**
  64627. * Gets the underlying layer used to render the texture when in fullscreen mode
  64628. */
  64629. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  64630. /**
  64631. * Gets the root container control
  64632. */
  64633. readonly rootContainer: Container;
  64634. /**
  64635. * Returns an array containing the root container.
  64636. * This is mostly used to let the Inspector introspects the ADT
  64637. * @returns an array containing the rootContainer
  64638. */
  64639. getChildren(): Array<Container>;
  64640. /**
  64641. * Will return all controls that are inside this texture
  64642. * @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
  64643. * @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
  64644. * @return all child controls
  64645. */
  64646. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64647. /**
  64648. * Gets or sets the current focused control
  64649. */
  64650. focusedControl: BABYLON.Nullable<IFocusableControl>;
  64651. /**
  64652. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  64653. */
  64654. isForeground: boolean;
  64655. /**
  64656. * Gets or set information about clipboardData
  64657. */
  64658. clipboardData: string;
  64659. /**
  64660. * Creates a new AdvancedDynamicTexture
  64661. * @param name defines the name of the texture
  64662. * @param width defines the width of the texture
  64663. * @param height defines the height of the texture
  64664. * @param scene defines the hosting scene
  64665. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  64666. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  64667. */
  64668. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  64669. /**
  64670. * Get the current class name of the texture useful for serialization or dynamic coding.
  64671. * @returns "AdvancedDynamicTexture"
  64672. */
  64673. getClassName(): string;
  64674. /**
  64675. * Function used to execute a function on all controls
  64676. * @param func defines the function to execute
  64677. * @param container defines the container where controls belong. If null the root container will be used
  64678. */
  64679. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  64680. private _useInvalidateRectOptimization;
  64681. /**
  64682. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  64683. */
  64684. useInvalidateRectOptimization: boolean;
  64685. private _invalidatedRectangle;
  64686. /**
  64687. * Invalidates a rectangle area on the gui texture
  64688. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  64689. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  64690. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  64691. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  64692. */
  64693. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  64694. /**
  64695. * Marks the texture as dirty forcing a complete update
  64696. */
  64697. markAsDirty(): void;
  64698. /**
  64699. * Helper function used to create a new style
  64700. * @returns a new style
  64701. * @see http://doc.babylonjs.com/how_to/gui#styles
  64702. */
  64703. createStyle(): Style;
  64704. /**
  64705. * Adds a new control to the root container
  64706. * @param control defines the control to add
  64707. * @returns the current texture
  64708. */
  64709. addControl(control: Control): AdvancedDynamicTexture;
  64710. /**
  64711. * Removes a control from the root container
  64712. * @param control defines the control to remove
  64713. * @returns the current texture
  64714. */
  64715. removeControl(control: Control): AdvancedDynamicTexture;
  64716. /**
  64717. * Release all resources
  64718. */
  64719. dispose(): void;
  64720. private _onResize;
  64721. /** @hidden */
  64722. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  64723. /**
  64724. * Get screen coordinates for a vector3
  64725. * @param position defines the position to project
  64726. * @param worldMatrix defines the world matrix to use
  64727. * @returns the projected position
  64728. */
  64729. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  64730. private _checkUpdate;
  64731. private _clearMeasure;
  64732. private _render;
  64733. /** @hidden */
  64734. _changeCursor(cursor: string): void;
  64735. /** @hidden */
  64736. _registerLastControlDown(control: Control, pointerId: number): void;
  64737. private _doPicking;
  64738. /** @hidden */
  64739. _cleanControlAfterRemovalFromList(list: {
  64740. [pointerId: number]: Control;
  64741. }, control: Control): void;
  64742. /** @hidden */
  64743. _cleanControlAfterRemoval(control: Control): void;
  64744. /** Attach to all scene events required to support pointer events */
  64745. attach(): void;
  64746. /** @hidden */
  64747. private onClipboardCopy;
  64748. /** @hidden */
  64749. private onClipboardCut;
  64750. /** @hidden */
  64751. private onClipboardPaste;
  64752. /**
  64753. * Register the clipboard Events onto the canvas
  64754. */
  64755. registerClipboardEvents(): void;
  64756. /**
  64757. * Unregister the clipboard Events from the canvas
  64758. */
  64759. unRegisterClipboardEvents(): void;
  64760. /**
  64761. * Connect the texture to a hosting mesh to enable interactions
  64762. * @param mesh defines the mesh to attach to
  64763. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  64764. */
  64765. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  64766. /**
  64767. * Move the focus to a specific control
  64768. * @param control defines the control which will receive the focus
  64769. */
  64770. moveFocusToControl(control: IFocusableControl): void;
  64771. private _manageFocus;
  64772. private _attachToOnPointerOut;
  64773. /**
  64774. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  64775. * @param mesh defines the mesh which will receive the texture
  64776. * @param width defines the texture width (1024 by default)
  64777. * @param height defines the texture height (1024 by default)
  64778. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  64779. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  64780. * @returns a new AdvancedDynamicTexture
  64781. */
  64782. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  64783. /**
  64784. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  64785. * In this mode the texture will rely on a layer for its rendering.
  64786. * This allows it to be treated like any other layer.
  64787. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  64788. * LayerMask is set through advancedTexture.layer.layerMask
  64789. * @param name defines name for the texture
  64790. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  64791. * @param scene defines the hsoting scene
  64792. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  64793. * @returns a new AdvancedDynamicTexture
  64794. */
  64795. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  64796. }
  64797. }
  64798. declare module BABYLON.GUI {
  64799. /**
  64800. * Root class used for all 2D controls
  64801. * @see http://doc.babylonjs.com/how_to/gui#controls
  64802. */
  64803. export class Control {
  64804. /** defines the name of the control */
  64805. name?: string | undefined;
  64806. /**
  64807. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  64808. */
  64809. static AllowAlphaInheritance: boolean;
  64810. private _alpha;
  64811. private _alphaSet;
  64812. private _zIndex;
  64813. /** @hidden */
  64814. _host: AdvancedDynamicTexture;
  64815. /** Gets or sets the control parent */
  64816. parent: BABYLON.Nullable<Container>;
  64817. /** @hidden */
  64818. _currentMeasure: Measure;
  64819. private _fontFamily;
  64820. private _fontStyle;
  64821. private _fontWeight;
  64822. private _fontSize;
  64823. private _font;
  64824. /** @hidden */
  64825. _width: ValueAndUnit;
  64826. /** @hidden */
  64827. _height: ValueAndUnit;
  64828. /** @hidden */
  64829. protected _fontOffset: {
  64830. ascent: number;
  64831. height: number;
  64832. descent: number;
  64833. };
  64834. private _color;
  64835. private _style;
  64836. private _styleObserver;
  64837. /** @hidden */
  64838. protected _horizontalAlignment: number;
  64839. /** @hidden */
  64840. protected _verticalAlignment: number;
  64841. /** @hidden */
  64842. protected _isDirty: boolean;
  64843. /** @hidden */
  64844. protected _wasDirty: boolean;
  64845. /** @hidden */
  64846. _tempParentMeasure: Measure;
  64847. /** @hidden */
  64848. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  64849. /** @hidden */
  64850. protected _cachedParentMeasure: Measure;
  64851. private _paddingLeft;
  64852. private _paddingRight;
  64853. private _paddingTop;
  64854. private _paddingBottom;
  64855. /** @hidden */
  64856. _left: ValueAndUnit;
  64857. /** @hidden */
  64858. _top: ValueAndUnit;
  64859. private _scaleX;
  64860. private _scaleY;
  64861. private _rotation;
  64862. private _transformCenterX;
  64863. private _transformCenterY;
  64864. /** @hidden */
  64865. _transformMatrix: Matrix2D;
  64866. /** @hidden */
  64867. protected _invertTransformMatrix: Matrix2D;
  64868. /** @hidden */
  64869. protected _transformedPosition: BABYLON.Vector2;
  64870. private _isMatrixDirty;
  64871. private _cachedOffsetX;
  64872. private _cachedOffsetY;
  64873. private _isVisible;
  64874. private _isHighlighted;
  64875. /** @hidden */
  64876. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64877. private _fontSet;
  64878. private _dummyVector2;
  64879. private _downCount;
  64880. private _enterCount;
  64881. private _doNotRender;
  64882. private _downPointerIds;
  64883. protected _isEnabled: boolean;
  64884. protected _disabledColor: string;
  64885. /** @hidden */
  64886. protected _rebuildLayout: boolean;
  64887. /** @hidden */
  64888. _isClipped: boolean;
  64889. /** @hidden */
  64890. _tag: any;
  64891. /**
  64892. * 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
  64893. */
  64894. uniqueId: number;
  64895. /**
  64896. * Gets or sets an object used to store user defined information for the node
  64897. */
  64898. metadata: any;
  64899. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64900. isHitTestVisible: boolean;
  64901. /** Gets or sets a boolean indicating if the control can block pointer events */
  64902. isPointerBlocker: boolean;
  64903. /** Gets or sets a boolean indicating if the control can be focusable */
  64904. isFocusInvisible: boolean;
  64905. /**
  64906. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64907. * 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
  64908. */
  64909. clipChildren: boolean;
  64910. /**
  64911. * Gets or sets a boolean indicating that control content must be clipped
  64912. * 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
  64913. */
  64914. clipContent: boolean;
  64915. /**
  64916. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  64917. */
  64918. useBitmapCache: boolean;
  64919. private _cacheData;
  64920. private _shadowOffsetX;
  64921. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  64922. shadowOffsetX: number;
  64923. private _shadowOffsetY;
  64924. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  64925. shadowOffsetY: number;
  64926. private _shadowBlur;
  64927. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  64928. shadowBlur: number;
  64929. private _shadowColor;
  64930. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  64931. shadowColor: string;
  64932. /** Gets or sets the cursor to use when the control is hovered */
  64933. hoverCursor: string;
  64934. /** @hidden */
  64935. protected _linkOffsetX: ValueAndUnit;
  64936. /** @hidden */
  64937. protected _linkOffsetY: ValueAndUnit;
  64938. /** Gets the control type name */
  64939. readonly typeName: string;
  64940. /**
  64941. * Get the current class name of the control.
  64942. * @returns current class name
  64943. */
  64944. getClassName(): string;
  64945. /**
  64946. * An event triggered when the pointer move over the control.
  64947. */
  64948. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  64949. /**
  64950. * An event triggered when the pointer move out of the control.
  64951. */
  64952. onPointerOutObservable: BABYLON.Observable<Control>;
  64953. /**
  64954. * An event triggered when the pointer taps the control
  64955. */
  64956. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  64957. /**
  64958. * An event triggered when pointer up
  64959. */
  64960. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  64961. /**
  64962. * An event triggered when a control is clicked on
  64963. */
  64964. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  64965. /**
  64966. * An event triggered when pointer enters the control
  64967. */
  64968. onPointerEnterObservable: BABYLON.Observable<Control>;
  64969. /**
  64970. * An event triggered when the control is marked as dirty
  64971. */
  64972. onDirtyObservable: BABYLON.Observable<Control>;
  64973. /**
  64974. * An event triggered before drawing the control
  64975. */
  64976. onBeforeDrawObservable: BABYLON.Observable<Control>;
  64977. /**
  64978. * An event triggered after the control was drawn
  64979. */
  64980. onAfterDrawObservable: BABYLON.Observable<Control>;
  64981. /**
  64982. * Get the hosting AdvancedDynamicTexture
  64983. */
  64984. readonly host: AdvancedDynamicTexture;
  64985. /** Gets or set information about font offsets (used to render and align text) */
  64986. fontOffset: {
  64987. ascent: number;
  64988. height: number;
  64989. descent: number;
  64990. };
  64991. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  64992. alpha: number;
  64993. /**
  64994. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  64995. */
  64996. isHighlighted: boolean;
  64997. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  64998. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64999. */
  65000. scaleX: number;
  65001. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  65002. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65003. */
  65004. scaleY: number;
  65005. /** Gets or sets the rotation angle (0 by default)
  65006. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65007. */
  65008. rotation: number;
  65009. /** Gets or sets the transformation center on Y axis (0 by default)
  65010. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65011. */
  65012. transformCenterY: number;
  65013. /** Gets or sets the transformation center on X axis (0 by default)
  65014. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65015. */
  65016. transformCenterX: number;
  65017. /**
  65018. * Gets or sets the horizontal alignment
  65019. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65020. */
  65021. horizontalAlignment: number;
  65022. /**
  65023. * Gets or sets the vertical alignment
  65024. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65025. */
  65026. verticalAlignment: number;
  65027. /**
  65028. * Gets or sets control width
  65029. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65030. */
  65031. width: string | number;
  65032. /**
  65033. * Gets or sets the control width in pixel
  65034. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65035. */
  65036. widthInPixels: number;
  65037. /**
  65038. * Gets or sets control height
  65039. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65040. */
  65041. height: string | number;
  65042. /**
  65043. * Gets or sets control height in pixel
  65044. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65045. */
  65046. heightInPixels: number;
  65047. /** Gets or set font family */
  65048. fontFamily: string;
  65049. /** Gets or sets font style */
  65050. fontStyle: string;
  65051. /** Gets or sets font weight */
  65052. fontWeight: string;
  65053. /**
  65054. * Gets or sets style
  65055. * @see http://doc.babylonjs.com/how_to/gui#styles
  65056. */
  65057. style: BABYLON.Nullable<Style>;
  65058. /** @hidden */
  65059. readonly _isFontSizeInPercentage: boolean;
  65060. /** Gets or sets font size in pixels */
  65061. fontSizeInPixels: number;
  65062. /** Gets or sets font size */
  65063. fontSize: string | number;
  65064. /** Gets or sets foreground color */
  65065. color: string;
  65066. /** Gets or sets z index which is used to reorder controls on the z axis */
  65067. zIndex: number;
  65068. /** Gets or sets a boolean indicating if the control can be rendered */
  65069. notRenderable: boolean;
  65070. /** Gets or sets a boolean indicating if the control is visible */
  65071. isVisible: boolean;
  65072. /** Gets a boolean indicating that the control needs to update its rendering */
  65073. readonly isDirty: boolean;
  65074. /**
  65075. * Gets the current linked mesh (or null if none)
  65076. */
  65077. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65078. /**
  65079. * Gets or sets a value indicating the padding to use on the left of the control
  65080. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65081. */
  65082. paddingLeft: string | number;
  65083. /**
  65084. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  65085. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65086. */
  65087. paddingLeftInPixels: number;
  65088. /**
  65089. * Gets or sets a value indicating the padding to use on the right of the control
  65090. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65091. */
  65092. paddingRight: string | number;
  65093. /**
  65094. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  65095. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65096. */
  65097. paddingRightInPixels: number;
  65098. /**
  65099. * Gets or sets a value indicating the padding to use on the top of the control
  65100. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65101. */
  65102. paddingTop: string | number;
  65103. /**
  65104. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  65105. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65106. */
  65107. paddingTopInPixels: number;
  65108. /**
  65109. * Gets or sets a value indicating the padding to use on the bottom of the control
  65110. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65111. */
  65112. paddingBottom: string | number;
  65113. /**
  65114. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  65115. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65116. */
  65117. paddingBottomInPixels: number;
  65118. /**
  65119. * Gets or sets a value indicating the left coordinate of the control
  65120. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65121. */
  65122. left: string | number;
  65123. /**
  65124. * Gets or sets a value indicating the left coordinate in pixels of the control
  65125. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65126. */
  65127. leftInPixels: number;
  65128. /**
  65129. * Gets or sets a value indicating the top coordinate of the control
  65130. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65131. */
  65132. top: string | number;
  65133. /**
  65134. * Gets or sets a value indicating the top coordinate in pixels of the control
  65135. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65136. */
  65137. topInPixels: number;
  65138. /**
  65139. * Gets or sets a value indicating the offset on X axis to the linked mesh
  65140. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65141. */
  65142. linkOffsetX: string | number;
  65143. /**
  65144. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  65145. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65146. */
  65147. linkOffsetXInPixels: number;
  65148. /**
  65149. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  65150. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65151. */
  65152. linkOffsetY: string | number;
  65153. /**
  65154. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  65155. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65156. */
  65157. linkOffsetYInPixels: number;
  65158. /** Gets the center coordinate on X axis */
  65159. readonly centerX: number;
  65160. /** Gets the center coordinate on Y axis */
  65161. readonly centerY: number;
  65162. /** Gets or sets if control is Enabled*/
  65163. isEnabled: boolean;
  65164. /** Gets or sets background color of control if it's disabled*/
  65165. disabledColor: string;
  65166. /**
  65167. * Creates a new control
  65168. * @param name defines the name of the control
  65169. */
  65170. constructor(
  65171. /** defines the name of the control */
  65172. name?: string | undefined);
  65173. /** @hidden */
  65174. protected _getTypeName(): string;
  65175. /**
  65176. * Gets the first ascendant in the hierarchy of the given type
  65177. * @param className defines the required type
  65178. * @returns the ascendant or null if not found
  65179. */
  65180. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  65181. /** @hidden */
  65182. _resetFontCache(): void;
  65183. /**
  65184. * Determines if a container is an ascendant of the current control
  65185. * @param container defines the container to look for
  65186. * @returns true if the container is one of the ascendant of the control
  65187. */
  65188. isAscendant(container: Control): boolean;
  65189. /**
  65190. * Gets coordinates in local control space
  65191. * @param globalCoordinates defines the coordinates to transform
  65192. * @returns the new coordinates in local space
  65193. */
  65194. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65195. /**
  65196. * Gets coordinates in local control space
  65197. * @param globalCoordinates defines the coordinates to transform
  65198. * @param result defines the target vector2 where to store the result
  65199. * @returns the current control
  65200. */
  65201. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  65202. /**
  65203. * Gets coordinates in parent local control space
  65204. * @param globalCoordinates defines the coordinates to transform
  65205. * @returns the new coordinates in parent local space
  65206. */
  65207. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65208. /**
  65209. * Move the current control to a vector3 position projected onto the screen.
  65210. * @param position defines the target position
  65211. * @param scene defines the hosting scene
  65212. */
  65213. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  65214. /** @hidden */
  65215. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65216. /**
  65217. * Will return all controls that have this control as ascendant
  65218. * @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
  65219. * @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
  65220. * @return all child controls
  65221. */
  65222. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65223. /**
  65224. * Link current control with a target mesh
  65225. * @param mesh defines the mesh to link with
  65226. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65227. */
  65228. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  65229. /** @hidden */
  65230. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  65231. /** @hidden */
  65232. _offsetLeft(offset: number): void;
  65233. /** @hidden */
  65234. _offsetTop(offset: number): void;
  65235. /** @hidden */
  65236. _markMatrixAsDirty(): void;
  65237. /** @hidden */
  65238. _flagDescendantsAsMatrixDirty(): void;
  65239. /** @hidden */
  65240. _intersectsRect(rect: Measure): boolean;
  65241. /** @hidden */
  65242. protected invalidateRect(): void;
  65243. /** @hidden */
  65244. _markAsDirty(force?: boolean): void;
  65245. /** @hidden */
  65246. _markAllAsDirty(): void;
  65247. /** @hidden */
  65248. _link(host: AdvancedDynamicTexture): void;
  65249. /** @hidden */
  65250. protected _transform(context?: CanvasRenderingContext2D): void;
  65251. /** @hidden */
  65252. _renderHighlight(context: CanvasRenderingContext2D): void;
  65253. /** @hidden */
  65254. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65255. /** @hidden */
  65256. protected _applyStates(context: CanvasRenderingContext2D): void;
  65257. /** @hidden */
  65258. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65259. /** @hidden */
  65260. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65261. protected _evaluateClippingState(parentMeasure: Measure): void;
  65262. /** @hidden */
  65263. _measure(): void;
  65264. /** @hidden */
  65265. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65266. /** @hidden */
  65267. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65268. /** @hidden */
  65269. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65270. /** @hidden */
  65271. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65272. private static _ClipMeasure;
  65273. private _tmpMeasureA;
  65274. private _clip;
  65275. /** @hidden */
  65276. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  65277. /** @hidden */
  65278. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  65279. /**
  65280. * Tests if a given coordinates belong to the current control
  65281. * @param x defines x coordinate to test
  65282. * @param y defines y coordinate to test
  65283. * @returns true if the coordinates are inside the control
  65284. */
  65285. contains(x: number, y: number): boolean;
  65286. /** @hidden */
  65287. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65288. /** @hidden */
  65289. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65290. /** @hidden */
  65291. _onPointerEnter(target: Control): boolean;
  65292. /** @hidden */
  65293. _onPointerOut(target: Control, force?: boolean): void;
  65294. /** @hidden */
  65295. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65296. /** @hidden */
  65297. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65298. /** @hidden */
  65299. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65300. /** @hidden */
  65301. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  65302. private _prepareFont;
  65303. /** Releases associated resources */
  65304. dispose(): void;
  65305. private static _HORIZONTAL_ALIGNMENT_LEFT;
  65306. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  65307. private static _HORIZONTAL_ALIGNMENT_CENTER;
  65308. private static _VERTICAL_ALIGNMENT_TOP;
  65309. private static _VERTICAL_ALIGNMENT_BOTTOM;
  65310. private static _VERTICAL_ALIGNMENT_CENTER;
  65311. /** HORIZONTAL_ALIGNMENT_LEFT */
  65312. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  65313. /** HORIZONTAL_ALIGNMENT_RIGHT */
  65314. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  65315. /** HORIZONTAL_ALIGNMENT_CENTER */
  65316. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  65317. /** VERTICAL_ALIGNMENT_TOP */
  65318. static readonly VERTICAL_ALIGNMENT_TOP: number;
  65319. /** VERTICAL_ALIGNMENT_BOTTOM */
  65320. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  65321. /** VERTICAL_ALIGNMENT_CENTER */
  65322. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  65323. private static _FontHeightSizes;
  65324. /** @hidden */
  65325. static _GetFontOffset(font: string): {
  65326. ascent: number;
  65327. height: number;
  65328. descent: number;
  65329. };
  65330. /**
  65331. * Creates a stack panel that can be used to render headers
  65332. * @param control defines the control to associate with the header
  65333. * @param text defines the text of the header
  65334. * @param size defines the size of the header
  65335. * @param options defines options used to configure the header
  65336. * @returns a new StackPanel
  65337. * @ignore
  65338. * @hidden
  65339. */
  65340. static AddHeader: (control: Control, text: string, size: string | number, options: {
  65341. isHorizontal: boolean;
  65342. controlFirst: boolean;
  65343. }) => any;
  65344. /** @hidden */
  65345. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  65346. }
  65347. }
  65348. declare module BABYLON.GUI {
  65349. /**
  65350. * Root class for 2D containers
  65351. * @see http://doc.babylonjs.com/how_to/gui#containers
  65352. */
  65353. export class Container extends Control {
  65354. name?: string | undefined;
  65355. /** @hidden */
  65356. protected _children: Control[];
  65357. /** @hidden */
  65358. protected _measureForChildren: Measure;
  65359. /** @hidden */
  65360. protected _background: string;
  65361. /** @hidden */
  65362. protected _adaptWidthToChildren: boolean;
  65363. /** @hidden */
  65364. protected _adaptHeightToChildren: boolean;
  65365. /**
  65366. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  65367. */
  65368. logLayoutCycleErrors: boolean;
  65369. /**
  65370. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  65371. */
  65372. maxLayoutCycle: number;
  65373. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  65374. adaptHeightToChildren: boolean;
  65375. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  65376. adaptWidthToChildren: boolean;
  65377. /** Gets or sets background color */
  65378. background: string;
  65379. /** Gets the list of children */
  65380. readonly children: Control[];
  65381. /**
  65382. * Creates a new Container
  65383. * @param name defines the name of the container
  65384. */
  65385. constructor(name?: string | undefined);
  65386. protected _getTypeName(): string;
  65387. _flagDescendantsAsMatrixDirty(): void;
  65388. /**
  65389. * Gets a child using its name
  65390. * @param name defines the child name to look for
  65391. * @returns the child control if found
  65392. */
  65393. getChildByName(name: string): BABYLON.Nullable<Control>;
  65394. /**
  65395. * Gets a child using its type and its name
  65396. * @param name defines the child name to look for
  65397. * @param type defines the child type to look for
  65398. * @returns the child control if found
  65399. */
  65400. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  65401. /**
  65402. * Search for a specific control in children
  65403. * @param control defines the control to look for
  65404. * @returns true if the control is in child list
  65405. */
  65406. containsControl(control: Control): boolean;
  65407. /**
  65408. * Adds a new control to the current container
  65409. * @param control defines the control to add
  65410. * @returns the current container
  65411. */
  65412. addControl(control: BABYLON.Nullable<Control>): Container;
  65413. /**
  65414. * Removes all controls from the current container
  65415. * @returns the current container
  65416. */
  65417. clearControls(): Container;
  65418. /**
  65419. * Removes a control from the current container
  65420. * @param control defines the control to remove
  65421. * @returns the current container
  65422. */
  65423. removeControl(control: Control): Container;
  65424. /** @hidden */
  65425. _reOrderControl(control: Control): void;
  65426. /** @hidden */
  65427. _offsetLeft(offset: number): void;
  65428. /** @hidden */
  65429. _offsetTop(offset: number): void;
  65430. /** @hidden */
  65431. _markAllAsDirty(): void;
  65432. /** @hidden */
  65433. protected _localDraw(context: CanvasRenderingContext2D): void;
  65434. /** @hidden */
  65435. _link(host: AdvancedDynamicTexture): void;
  65436. /** @hidden */
  65437. protected _beforeLayout(): void;
  65438. /** @hidden */
  65439. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65440. /** @hidden */
  65441. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65442. protected _postMeasure(): void;
  65443. /** @hidden */
  65444. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  65445. /** @hidden */
  65446. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65447. /** @hidden */
  65448. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65449. /** @hidden */
  65450. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65451. /** Releases associated resources */
  65452. dispose(): void;
  65453. }
  65454. }
  65455. declare module BABYLON.GUI {
  65456. /** Class used to create rectangle container */
  65457. export class Rectangle extends Container {
  65458. name?: string | undefined;
  65459. private _thickness;
  65460. private _cornerRadius;
  65461. /** Gets or sets border thickness */
  65462. thickness: number;
  65463. /** Gets or sets the corner radius angle */
  65464. cornerRadius: number;
  65465. /**
  65466. * Creates a new Rectangle
  65467. * @param name defines the control name
  65468. */
  65469. constructor(name?: string | undefined);
  65470. protected _getTypeName(): string;
  65471. protected _localDraw(context: CanvasRenderingContext2D): void;
  65472. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65473. private _drawRoundedRect;
  65474. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65475. }
  65476. }
  65477. declare module BABYLON.GUI {
  65478. /**
  65479. * Enum that determines the text-wrapping mode to use.
  65480. */
  65481. export enum TextWrapping {
  65482. /**
  65483. * Clip the text when it's larger than Control.width; this is the default mode.
  65484. */
  65485. Clip = 0,
  65486. /**
  65487. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  65488. */
  65489. WordWrap = 1,
  65490. /**
  65491. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  65492. */
  65493. Ellipsis = 2
  65494. }
  65495. /**
  65496. * Class used to create text block control
  65497. */
  65498. export class TextBlock extends Control {
  65499. /**
  65500. * Defines the name of the control
  65501. */
  65502. name?: string | undefined;
  65503. private _text;
  65504. private _textWrapping;
  65505. private _textHorizontalAlignment;
  65506. private _textVerticalAlignment;
  65507. private _lines;
  65508. private _resizeToFit;
  65509. private _lineSpacing;
  65510. private _outlineWidth;
  65511. private _outlineColor;
  65512. /**
  65513. * An event triggered after the text is changed
  65514. */
  65515. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  65516. /**
  65517. * An event triggered after the text was broken up into lines
  65518. */
  65519. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  65520. /**
  65521. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  65522. */
  65523. readonly lines: any[];
  65524. /**
  65525. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65526. */
  65527. /**
  65528. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65529. */
  65530. resizeToFit: boolean;
  65531. /**
  65532. * Gets or sets a boolean indicating if text must be wrapped
  65533. */
  65534. /**
  65535. * Gets or sets a boolean indicating if text must be wrapped
  65536. */
  65537. textWrapping: TextWrapping | boolean;
  65538. /**
  65539. * Gets or sets text to display
  65540. */
  65541. /**
  65542. * Gets or sets text to display
  65543. */
  65544. text: string;
  65545. /**
  65546. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65547. */
  65548. /**
  65549. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65550. */
  65551. textHorizontalAlignment: number;
  65552. /**
  65553. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65554. */
  65555. /**
  65556. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65557. */
  65558. textVerticalAlignment: number;
  65559. /**
  65560. * Gets or sets line spacing value
  65561. */
  65562. /**
  65563. * Gets or sets line spacing value
  65564. */
  65565. lineSpacing: string | number;
  65566. /**
  65567. * Gets or sets outlineWidth of the text to display
  65568. */
  65569. /**
  65570. * Gets or sets outlineWidth of the text to display
  65571. */
  65572. outlineWidth: number;
  65573. /**
  65574. * Gets or sets outlineColor of the text to display
  65575. */
  65576. /**
  65577. * Gets or sets outlineColor of the text to display
  65578. */
  65579. outlineColor: string;
  65580. /**
  65581. * Creates a new TextBlock object
  65582. * @param name defines the name of the control
  65583. * @param text defines the text to display (emptry string by default)
  65584. */
  65585. constructor(
  65586. /**
  65587. * Defines the name of the control
  65588. */
  65589. name?: string | undefined, text?: string);
  65590. protected _getTypeName(): string;
  65591. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65592. private _drawText;
  65593. /** @hidden */
  65594. _draw(context: CanvasRenderingContext2D): void;
  65595. protected _applyStates(context: CanvasRenderingContext2D): void;
  65596. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  65597. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  65598. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  65599. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  65600. protected _renderLines(context: CanvasRenderingContext2D): void;
  65601. /**
  65602. * Given a width constraint applied on the text block, find the expected height
  65603. * @returns expected height
  65604. */
  65605. computeExpectedHeight(): number;
  65606. dispose(): void;
  65607. }
  65608. }
  65609. declare module BABYLON.GUI {
  65610. /**
  65611. * Class used to create 2D images
  65612. */
  65613. export class Image extends Control {
  65614. name?: string | undefined;
  65615. private static _WorkingCanvas;
  65616. private _domImage;
  65617. private _imageWidth;
  65618. private _imageHeight;
  65619. private _loaded;
  65620. private _stretch;
  65621. private _source;
  65622. private _autoScale;
  65623. private _sourceLeft;
  65624. private _sourceTop;
  65625. private _sourceWidth;
  65626. private _sourceHeight;
  65627. private _cellWidth;
  65628. private _cellHeight;
  65629. private _cellId;
  65630. private _populateNinePatchSlicesFromImage;
  65631. private _sliceLeft;
  65632. private _sliceRight;
  65633. private _sliceTop;
  65634. private _sliceBottom;
  65635. private _detectPointerOnOpaqueOnly;
  65636. /**
  65637. * BABYLON.Observable notified when the content is loaded
  65638. */
  65639. onImageLoadedObservable: BABYLON.Observable<Image>;
  65640. /**
  65641. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  65642. */
  65643. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  65644. /**
  65645. * Gets a boolean indicating that the content is loaded
  65646. */
  65647. readonly isLoaded: boolean;
  65648. /**
  65649. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  65650. */
  65651. populateNinePatchSlicesFromImage: boolean;
  65652. /**
  65653. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  65654. * Beware using this as this will comsume more memory as the image has to be stored twice
  65655. */
  65656. detectPointerOnOpaqueOnly: boolean;
  65657. /**
  65658. * Gets or sets the left value for slicing (9-patch)
  65659. */
  65660. sliceLeft: number;
  65661. /**
  65662. * Gets or sets the right value for slicing (9-patch)
  65663. */
  65664. sliceRight: number;
  65665. /**
  65666. * Gets or sets the top value for slicing (9-patch)
  65667. */
  65668. sliceTop: number;
  65669. /**
  65670. * Gets or sets the bottom value for slicing (9-patch)
  65671. */
  65672. sliceBottom: number;
  65673. /**
  65674. * Gets or sets the left coordinate in the source image
  65675. */
  65676. sourceLeft: number;
  65677. /**
  65678. * Gets or sets the top coordinate in the source image
  65679. */
  65680. sourceTop: number;
  65681. /**
  65682. * Gets or sets the width to capture in the source image
  65683. */
  65684. sourceWidth: number;
  65685. /**
  65686. * Gets or sets the height to capture in the source image
  65687. */
  65688. sourceHeight: number;
  65689. /**
  65690. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  65691. * @see http://doc.babylonjs.com/how_to/gui#image
  65692. */
  65693. autoScale: boolean;
  65694. /** Gets or sets the streching mode used by the image */
  65695. stretch: number;
  65696. /**
  65697. * Gets or sets the internal DOM image used to render the control
  65698. */
  65699. domImage: HTMLImageElement;
  65700. private _onImageLoaded;
  65701. private _extractNinePatchSliceDataFromImage;
  65702. /**
  65703. * Gets or sets image source url
  65704. */
  65705. source: BABYLON.Nullable<string>;
  65706. /**
  65707. * Checks for svg document with icon id present
  65708. */
  65709. private _svgCheck;
  65710. /**
  65711. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  65712. * given external svg file and icon id
  65713. */
  65714. private _getSVGAttribs;
  65715. /**
  65716. * Gets or sets the cell width to use when animation sheet is enabled
  65717. * @see http://doc.babylonjs.com/how_to/gui#image
  65718. */
  65719. cellWidth: number;
  65720. /**
  65721. * Gets or sets the cell height to use when animation sheet is enabled
  65722. * @see http://doc.babylonjs.com/how_to/gui#image
  65723. */
  65724. cellHeight: number;
  65725. /**
  65726. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  65727. * @see http://doc.babylonjs.com/how_to/gui#image
  65728. */
  65729. cellId: number;
  65730. /**
  65731. * Creates a new Image
  65732. * @param name defines the control name
  65733. * @param url defines the image url
  65734. */
  65735. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  65736. /**
  65737. * Tests if a given coordinates belong to the current control
  65738. * @param x defines x coordinate to test
  65739. * @param y defines y coordinate to test
  65740. * @returns true if the coordinates are inside the control
  65741. */
  65742. contains(x: number, y: number): boolean;
  65743. protected _getTypeName(): string;
  65744. /** Force the control to synchronize with its content */
  65745. synchronizeSizeWithContent(): void;
  65746. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65747. private _prepareWorkingCanvasForOpaqueDetection;
  65748. private _drawImage;
  65749. _draw(context: CanvasRenderingContext2D): void;
  65750. private _renderCornerPatch;
  65751. private _renderNinePatch;
  65752. dispose(): void;
  65753. /** STRETCH_NONE */
  65754. static readonly STRETCH_NONE: number;
  65755. /** STRETCH_FILL */
  65756. static readonly STRETCH_FILL: number;
  65757. /** STRETCH_UNIFORM */
  65758. static readonly STRETCH_UNIFORM: number;
  65759. /** STRETCH_EXTEND */
  65760. static readonly STRETCH_EXTEND: number;
  65761. /** NINE_PATCH */
  65762. static readonly STRETCH_NINE_PATCH: number;
  65763. }
  65764. }
  65765. declare module BABYLON.GUI {
  65766. /**
  65767. * Class used to create 2D buttons
  65768. */
  65769. export class Button extends Rectangle {
  65770. name?: string | undefined;
  65771. /**
  65772. * Function called to generate a pointer enter animation
  65773. */
  65774. pointerEnterAnimation: () => void;
  65775. /**
  65776. * Function called to generate a pointer out animation
  65777. */
  65778. pointerOutAnimation: () => void;
  65779. /**
  65780. * Function called to generate a pointer down animation
  65781. */
  65782. pointerDownAnimation: () => void;
  65783. /**
  65784. * Function called to generate a pointer up animation
  65785. */
  65786. pointerUpAnimation: () => void;
  65787. /**
  65788. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  65789. */
  65790. delegatePickingToChildren: boolean;
  65791. private _image;
  65792. /**
  65793. * Returns the image part of the button (if any)
  65794. */
  65795. readonly image: BABYLON.Nullable<Image>;
  65796. private _textBlock;
  65797. /**
  65798. * Returns the image part of the button (if any)
  65799. */
  65800. readonly textBlock: BABYLON.Nullable<TextBlock>;
  65801. /**
  65802. * Creates a new Button
  65803. * @param name defines the name of the button
  65804. */
  65805. constructor(name?: string | undefined);
  65806. protected _getTypeName(): string;
  65807. /** @hidden */
  65808. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65809. /** @hidden */
  65810. _onPointerEnter(target: Control): boolean;
  65811. /** @hidden */
  65812. _onPointerOut(target: Control, force?: boolean): void;
  65813. /** @hidden */
  65814. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65815. /** @hidden */
  65816. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65817. /**
  65818. * Creates a new button made with an image and a text
  65819. * @param name defines the name of the button
  65820. * @param text defines the text of the button
  65821. * @param imageUrl defines the url of the image
  65822. * @returns a new Button
  65823. */
  65824. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  65825. /**
  65826. * Creates a new button made with an image
  65827. * @param name defines the name of the button
  65828. * @param imageUrl defines the url of the image
  65829. * @returns a new Button
  65830. */
  65831. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  65832. /**
  65833. * Creates a new button made with a text
  65834. * @param name defines the name of the button
  65835. * @param text defines the text of the button
  65836. * @returns a new Button
  65837. */
  65838. static CreateSimpleButton(name: string, text: string): Button;
  65839. /**
  65840. * Creates a new button made with an image and a centered text
  65841. * @param name defines the name of the button
  65842. * @param text defines the text of the button
  65843. * @param imageUrl defines the url of the image
  65844. * @returns a new Button
  65845. */
  65846. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  65847. }
  65848. }
  65849. declare module BABYLON.GUI {
  65850. /**
  65851. * Class used to create a 2D stack panel container
  65852. */
  65853. export class StackPanel extends Container {
  65854. name?: string | undefined;
  65855. private _isVertical;
  65856. private _manualWidth;
  65857. private _manualHeight;
  65858. private _doNotTrackManualChanges;
  65859. /**
  65860. * Gets or sets a boolean indicating that layou warnings should be ignored
  65861. */
  65862. ignoreLayoutWarnings: boolean;
  65863. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65864. isVertical: boolean;
  65865. /**
  65866. * Gets or sets panel width.
  65867. * This value should not be set when in horizontal mode as it will be computed automatically
  65868. */
  65869. width: string | number;
  65870. /**
  65871. * Gets or sets panel height.
  65872. * This value should not be set when in vertical mode as it will be computed automatically
  65873. */
  65874. height: string | number;
  65875. /**
  65876. * Creates a new StackPanel
  65877. * @param name defines control name
  65878. */
  65879. constructor(name?: string | undefined);
  65880. protected _getTypeName(): string;
  65881. /** @hidden */
  65882. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65883. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65884. protected _postMeasure(): void;
  65885. }
  65886. }
  65887. declare module BABYLON.GUI {
  65888. /**
  65889. * Class used to represent a 2D checkbox
  65890. */
  65891. export class Checkbox extends Control {
  65892. name?: string | undefined;
  65893. private _isChecked;
  65894. private _background;
  65895. private _checkSizeRatio;
  65896. private _thickness;
  65897. /** Gets or sets border thickness */
  65898. thickness: number;
  65899. /**
  65900. * BABYLON.Observable raised when isChecked property changes
  65901. */
  65902. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65903. /** Gets or sets a value indicating the ratio between overall size and check size */
  65904. checkSizeRatio: number;
  65905. /** Gets or sets background color */
  65906. background: string;
  65907. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65908. isChecked: boolean;
  65909. /**
  65910. * Creates a new CheckBox
  65911. * @param name defines the control name
  65912. */
  65913. constructor(name?: string | undefined);
  65914. protected _getTypeName(): string;
  65915. /** @hidden */
  65916. _draw(context: CanvasRenderingContext2D): void;
  65917. /** @hidden */
  65918. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65919. /**
  65920. * Utility function to easily create a checkbox with a header
  65921. * @param title defines the label to use for the header
  65922. * @param onValueChanged defines the callback to call when value changes
  65923. * @returns a StackPanel containing the checkbox and a textBlock
  65924. */
  65925. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  65926. }
  65927. }
  65928. declare module BABYLON.GUI {
  65929. /**
  65930. * Class used to store key control properties
  65931. */
  65932. export class KeyPropertySet {
  65933. /** Width */
  65934. width?: string;
  65935. /** Height */
  65936. height?: string;
  65937. /** Left padding */
  65938. paddingLeft?: string;
  65939. /** Right padding */
  65940. paddingRight?: string;
  65941. /** Top padding */
  65942. paddingTop?: string;
  65943. /** Bottom padding */
  65944. paddingBottom?: string;
  65945. /** Foreground color */
  65946. color?: string;
  65947. /** Background color */
  65948. background?: string;
  65949. }
  65950. /**
  65951. * Class used to create virtual keyboard
  65952. */
  65953. export class VirtualKeyboard extends StackPanel {
  65954. /** BABYLON.Observable raised when a key is pressed */
  65955. onKeyPressObservable: BABYLON.Observable<string>;
  65956. /** Gets or sets default key button width */
  65957. defaultButtonWidth: string;
  65958. /** Gets or sets default key button height */
  65959. defaultButtonHeight: string;
  65960. /** Gets or sets default key button left padding */
  65961. defaultButtonPaddingLeft: string;
  65962. /** Gets or sets default key button right padding */
  65963. defaultButtonPaddingRight: string;
  65964. /** Gets or sets default key button top padding */
  65965. defaultButtonPaddingTop: string;
  65966. /** Gets or sets default key button bottom padding */
  65967. defaultButtonPaddingBottom: string;
  65968. /** Gets or sets default key button foreground color */
  65969. defaultButtonColor: string;
  65970. /** Gets or sets default key button background color */
  65971. defaultButtonBackground: string;
  65972. /** Gets or sets shift button foreground color */
  65973. shiftButtonColor: string;
  65974. /** Gets or sets shift button thickness*/
  65975. selectedShiftThickness: number;
  65976. /** Gets shift key state */
  65977. shiftState: number;
  65978. protected _getTypeName(): string;
  65979. private _createKey;
  65980. /**
  65981. * Adds a new row of keys
  65982. * @param keys defines the list of keys to add
  65983. * @param propertySets defines the associated property sets
  65984. */
  65985. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  65986. /**
  65987. * Set the shift key to a specific state
  65988. * @param shiftState defines the new shift state
  65989. */
  65990. applyShiftState(shiftState: number): void;
  65991. private _currentlyConnectedInputText;
  65992. private _connectedInputTexts;
  65993. private _onKeyPressObserver;
  65994. /** Gets the input text control currently attached to the keyboard */
  65995. readonly connectedInputText: BABYLON.Nullable<InputText>;
  65996. /**
  65997. * Connects the keyboard with an input text control
  65998. *
  65999. * @param input defines the target control
  66000. */
  66001. connect(input: InputText): void;
  66002. /**
  66003. * Disconnects the keyboard from connected InputText controls
  66004. *
  66005. * @param input optionally defines a target control, otherwise all are disconnected
  66006. */
  66007. disconnect(input?: InputText): void;
  66008. private _removeConnectedInputObservables;
  66009. /**
  66010. * Release all resources
  66011. */
  66012. dispose(): void;
  66013. /**
  66014. * Creates a new keyboard using a default layout
  66015. *
  66016. * @param name defines control name
  66017. * @returns a new VirtualKeyboard
  66018. */
  66019. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  66020. }
  66021. }
  66022. declare module BABYLON.GUI {
  66023. /**
  66024. * Class used to create input text control
  66025. */
  66026. export class InputText extends Control implements IFocusableControl {
  66027. name?: string | undefined;
  66028. private _text;
  66029. private _placeholderText;
  66030. private _background;
  66031. private _focusedBackground;
  66032. private _focusedColor;
  66033. private _placeholderColor;
  66034. private _thickness;
  66035. private _margin;
  66036. private _autoStretchWidth;
  66037. private _maxWidth;
  66038. private _isFocused;
  66039. private _blinkTimeout;
  66040. private _blinkIsEven;
  66041. private _cursorOffset;
  66042. private _scrollLeft;
  66043. private _textWidth;
  66044. private _clickedCoordinate;
  66045. private _deadKey;
  66046. private _addKey;
  66047. private _currentKey;
  66048. private _isTextHighlightOn;
  66049. private _textHighlightColor;
  66050. private _highligherOpacity;
  66051. private _highlightedText;
  66052. private _startHighlightIndex;
  66053. private _endHighlightIndex;
  66054. private _cursorIndex;
  66055. private _onFocusSelectAll;
  66056. private _isPointerDown;
  66057. private _onClipboardObserver;
  66058. private _onPointerDblTapObserver;
  66059. /** @hidden */
  66060. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  66061. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  66062. promptMessage: string;
  66063. /** Force disable prompt on mobile device */
  66064. disableMobilePrompt: boolean;
  66065. /** BABYLON.Observable raised when the text changes */
  66066. onTextChangedObservable: BABYLON.Observable<InputText>;
  66067. /** BABYLON.Observable raised just before an entered character is to be added */
  66068. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  66069. /** BABYLON.Observable raised when the control gets the focus */
  66070. onFocusObservable: BABYLON.Observable<InputText>;
  66071. /** BABYLON.Observable raised when the control loses the focus */
  66072. onBlurObservable: BABYLON.Observable<InputText>;
  66073. /**Observable raised when the text is highlighted */
  66074. onTextHighlightObservable: BABYLON.Observable<InputText>;
  66075. /**Observable raised when copy event is triggered */
  66076. onTextCopyObservable: BABYLON.Observable<InputText>;
  66077. /** BABYLON.Observable raised when cut event is triggered */
  66078. onTextCutObservable: BABYLON.Observable<InputText>;
  66079. /** BABYLON.Observable raised when paste event is triggered */
  66080. onTextPasteObservable: BABYLON.Observable<InputText>;
  66081. /** BABYLON.Observable raised when a key event was processed */
  66082. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  66083. /** Gets or sets the maximum width allowed by the control */
  66084. maxWidth: string | number;
  66085. /** Gets the maximum width allowed by the control in pixels */
  66086. readonly maxWidthInPixels: number;
  66087. /** Gets or sets the text highlighter transparency; default: 0.4 */
  66088. highligherOpacity: number;
  66089. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  66090. onFocusSelectAll: boolean;
  66091. /** Gets or sets the text hightlight color */
  66092. textHighlightColor: string;
  66093. /** Gets or sets control margin */
  66094. margin: string;
  66095. /** Gets control margin in pixels */
  66096. readonly marginInPixels: number;
  66097. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  66098. autoStretchWidth: boolean;
  66099. /** Gets or sets border thickness */
  66100. thickness: number;
  66101. /** Gets or sets the background color when focused */
  66102. focusedBackground: string;
  66103. /** Gets or sets the background color when focused */
  66104. focusedColor: string;
  66105. /** Gets or sets the background color */
  66106. background: string;
  66107. /** Gets or sets the placeholder color */
  66108. placeholderColor: string;
  66109. /** Gets or sets the text displayed when the control is empty */
  66110. placeholderText: string;
  66111. /** Gets or sets the dead key flag */
  66112. deadKey: boolean;
  66113. /** Gets or sets the highlight text */
  66114. highlightedText: string;
  66115. /** Gets or sets if the current key should be added */
  66116. addKey: boolean;
  66117. /** Gets or sets the value of the current key being entered */
  66118. currentKey: string;
  66119. /** Gets or sets the text displayed in the control */
  66120. text: string;
  66121. /** Gets or sets control width */
  66122. width: string | number;
  66123. /**
  66124. * Creates a new InputText
  66125. * @param name defines the control name
  66126. * @param text defines the text of the control
  66127. */
  66128. constructor(name?: string | undefined, text?: string);
  66129. /** @hidden */
  66130. onBlur(): void;
  66131. /** @hidden */
  66132. onFocus(): void;
  66133. protected _getTypeName(): string;
  66134. /**
  66135. * Function called to get the list of controls that should not steal the focus from this control
  66136. * @returns an array of controls
  66137. */
  66138. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66139. /** @hidden */
  66140. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  66141. /** @hidden */
  66142. private _updateValueFromCursorIndex;
  66143. /** @hidden */
  66144. private _processDblClick;
  66145. /** @hidden */
  66146. private _selectAllText;
  66147. /**
  66148. * Handles the keyboard event
  66149. * @param evt Defines the KeyboardEvent
  66150. */
  66151. processKeyboard(evt: KeyboardEvent): void;
  66152. /** @hidden */
  66153. private _onCopyText;
  66154. /** @hidden */
  66155. private _onCutText;
  66156. /** @hidden */
  66157. private _onPasteText;
  66158. _draw(context: CanvasRenderingContext2D): void;
  66159. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66160. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66161. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66162. protected _beforeRenderText(text: string): string;
  66163. dispose(): void;
  66164. }
  66165. }
  66166. declare module BABYLON.GUI {
  66167. /**
  66168. * Class used to create a 2D grid container
  66169. */
  66170. export class Grid extends Container {
  66171. name?: string | undefined;
  66172. private _rowDefinitions;
  66173. private _columnDefinitions;
  66174. private _cells;
  66175. private _childControls;
  66176. /**
  66177. * Gets the number of columns
  66178. */
  66179. readonly columnCount: number;
  66180. /**
  66181. * Gets the number of rows
  66182. */
  66183. readonly rowCount: number;
  66184. /** Gets the list of children */
  66185. readonly children: Control[];
  66186. /** Gets the list of cells (e.g. the containers) */
  66187. readonly cells: {
  66188. [key: string]: Container;
  66189. };
  66190. /**
  66191. * Gets the definition of a specific row
  66192. * @param index defines the index of the row
  66193. * @returns the row definition
  66194. */
  66195. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66196. /**
  66197. * Gets the definition of a specific column
  66198. * @param index defines the index of the column
  66199. * @returns the column definition
  66200. */
  66201. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66202. /**
  66203. * Adds a new row to the grid
  66204. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66205. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  66206. * @returns the current grid
  66207. */
  66208. addRowDefinition(height: number, isPixel?: boolean): Grid;
  66209. /**
  66210. * Adds a new column to the grid
  66211. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66212. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66213. * @returns the current grid
  66214. */
  66215. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  66216. /**
  66217. * Update a row definition
  66218. * @param index defines the index of the row to update
  66219. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66220. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  66221. * @returns the current grid
  66222. */
  66223. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  66224. /**
  66225. * Update a column definition
  66226. * @param index defines the index of the column to update
  66227. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66228. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66229. * @returns the current grid
  66230. */
  66231. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  66232. /**
  66233. * Gets the list of children stored in a specific cell
  66234. * @param row defines the row to check
  66235. * @param column defines the column to check
  66236. * @returns the list of controls
  66237. */
  66238. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  66239. /**
  66240. * Gets a string representing the child cell info (row x column)
  66241. * @param child defines the control to get info from
  66242. * @returns a string containing the child cell info (row x column)
  66243. */
  66244. getChildCellInfo(child: Control): string;
  66245. private _removeCell;
  66246. private _offsetCell;
  66247. /**
  66248. * Remove a column definition at specified index
  66249. * @param index defines the index of the column to remove
  66250. * @returns the current grid
  66251. */
  66252. removeColumnDefinition(index: number): Grid;
  66253. /**
  66254. * Remove a row definition at specified index
  66255. * @param index defines the index of the row to remove
  66256. * @returns the current grid
  66257. */
  66258. removeRowDefinition(index: number): Grid;
  66259. /**
  66260. * Adds a new control to the current grid
  66261. * @param control defines the control to add
  66262. * @param row defines the row where to add the control (0 by default)
  66263. * @param column defines the column where to add the control (0 by default)
  66264. * @returns the current grid
  66265. */
  66266. addControl(control: Control, row?: number, column?: number): Grid;
  66267. /**
  66268. * Removes a control from the current container
  66269. * @param control defines the control to remove
  66270. * @returns the current container
  66271. */
  66272. removeControl(control: Control): Container;
  66273. /**
  66274. * Creates a new Grid
  66275. * @param name defines control name
  66276. */
  66277. constructor(name?: string | undefined);
  66278. protected _getTypeName(): string;
  66279. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  66280. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66281. _flagDescendantsAsMatrixDirty(): void;
  66282. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66283. /** Releases associated resources */
  66284. dispose(): void;
  66285. }
  66286. }
  66287. declare module BABYLON.GUI {
  66288. /** Class used to create color pickers */
  66289. export class ColorPicker extends Control {
  66290. name?: string | undefined;
  66291. private static _Epsilon;
  66292. private _colorWheelCanvas;
  66293. private _value;
  66294. private _tmpColor;
  66295. private _pointerStartedOnSquare;
  66296. private _pointerStartedOnWheel;
  66297. private _squareLeft;
  66298. private _squareTop;
  66299. private _squareSize;
  66300. private _h;
  66301. private _s;
  66302. private _v;
  66303. private _lastPointerDownID;
  66304. /**
  66305. * BABYLON.Observable raised when the value changes
  66306. */
  66307. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  66308. /** Gets or sets the color of the color picker */
  66309. value: BABYLON.Color3;
  66310. /**
  66311. * Gets or sets control width
  66312. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66313. */
  66314. width: string | number;
  66315. /**
  66316. * Gets or sets control height
  66317. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66318. */
  66319. /** Gets or sets control height */
  66320. height: string | number;
  66321. /** Gets or sets control size */
  66322. size: string | number;
  66323. /**
  66324. * Creates a new ColorPicker
  66325. * @param name defines the control name
  66326. */
  66327. constructor(name?: string | undefined);
  66328. protected _getTypeName(): string;
  66329. /** @hidden */
  66330. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66331. private _updateSquareProps;
  66332. private _drawGradientSquare;
  66333. private _drawCircle;
  66334. private _createColorWheelCanvas;
  66335. /** @hidden */
  66336. _draw(context: CanvasRenderingContext2D): void;
  66337. private _pointerIsDown;
  66338. private _updateValueFromPointer;
  66339. private _isPointOnSquare;
  66340. private _isPointOnWheel;
  66341. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66342. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66343. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66344. /**
  66345. * This function expands the color picker by creating a color picker dialog with manual
  66346. * color value input and the ability to save colors into an array to be used later in
  66347. * subsequent launches of the dialogue.
  66348. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  66349. * @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.
  66350. * @returns picked color as a hex string and the saved colors array as hex strings.
  66351. */
  66352. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  66353. pickerWidth?: string;
  66354. pickerHeight?: string;
  66355. headerHeight?: string;
  66356. lastColor?: string;
  66357. swatchLimit?: number;
  66358. numSwatchesPerLine?: number;
  66359. savedColors?: Array<string>;
  66360. }): Promise<{
  66361. savedColors?: string[];
  66362. pickedColor: string;
  66363. }>;
  66364. }
  66365. }
  66366. declare module BABYLON.GUI {
  66367. /** Class used to create 2D ellipse containers */
  66368. export class Ellipse extends Container {
  66369. name?: string | undefined;
  66370. private _thickness;
  66371. /** Gets or sets border thickness */
  66372. thickness: number;
  66373. /**
  66374. * Creates a new Ellipse
  66375. * @param name defines the control name
  66376. */
  66377. constructor(name?: string | undefined);
  66378. protected _getTypeName(): string;
  66379. protected _localDraw(context: CanvasRenderingContext2D): void;
  66380. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66381. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66382. }
  66383. }
  66384. declare module BABYLON.GUI {
  66385. /**
  66386. * Class used to create a password control
  66387. */
  66388. export class InputPassword extends InputText {
  66389. protected _beforeRenderText(text: string): string;
  66390. }
  66391. }
  66392. declare module BABYLON.GUI {
  66393. /** Class used to render 2D lines */
  66394. export class Line extends Control {
  66395. name?: string | undefined;
  66396. private _lineWidth;
  66397. private _x1;
  66398. private _y1;
  66399. private _x2;
  66400. private _y2;
  66401. private _dash;
  66402. private _connectedControl;
  66403. private _connectedControlDirtyObserver;
  66404. /** Gets or sets the dash pattern */
  66405. dash: Array<number>;
  66406. /** Gets or sets the control connected with the line end */
  66407. connectedControl: Control;
  66408. /** Gets or sets start coordinates on X axis */
  66409. x1: string | number;
  66410. /** Gets or sets start coordinates on Y axis */
  66411. y1: string | number;
  66412. /** Gets or sets end coordinates on X axis */
  66413. x2: string | number;
  66414. /** Gets or sets end coordinates on Y axis */
  66415. y2: string | number;
  66416. /** Gets or sets line width */
  66417. lineWidth: number;
  66418. /** Gets or sets horizontal alignment */
  66419. horizontalAlignment: number;
  66420. /** Gets or sets vertical alignment */
  66421. verticalAlignment: number;
  66422. private readonly _effectiveX2;
  66423. private readonly _effectiveY2;
  66424. /**
  66425. * Creates a new Line
  66426. * @param name defines the control name
  66427. */
  66428. constructor(name?: string | undefined);
  66429. protected _getTypeName(): string;
  66430. _draw(context: CanvasRenderingContext2D): void;
  66431. _measure(): void;
  66432. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66433. /**
  66434. * Move one end of the line given 3D cartesian coordinates.
  66435. * @param position Targeted world position
  66436. * @param scene BABYLON.Scene
  66437. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66438. */
  66439. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  66440. /**
  66441. * Move one end of the line to a position in screen absolute space.
  66442. * @param projectedPosition Position in screen absolute space (X, Y)
  66443. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66444. */
  66445. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  66446. }
  66447. }
  66448. declare module BABYLON.GUI {
  66449. /**
  66450. * Class used to store a point for a MultiLine object.
  66451. * The point can be pure 2D coordinates, a mesh or a control
  66452. */
  66453. export class MultiLinePoint {
  66454. private _multiLine;
  66455. private _x;
  66456. private _y;
  66457. private _control;
  66458. private _mesh;
  66459. private _controlObserver;
  66460. private _meshObserver;
  66461. /** @hidden */
  66462. _point: BABYLON.Vector2;
  66463. /**
  66464. * Creates a new MultiLinePoint
  66465. * @param multiLine defines the source MultiLine object
  66466. */
  66467. constructor(multiLine: MultiLine);
  66468. /** Gets or sets x coordinate */
  66469. x: string | number;
  66470. /** Gets or sets y coordinate */
  66471. y: string | number;
  66472. /** Gets or sets the control associated with this point */
  66473. control: BABYLON.Nullable<Control>;
  66474. /** Gets or sets the mesh associated with this point */
  66475. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66476. /** Resets links */
  66477. resetLinks(): void;
  66478. /**
  66479. * Gets a translation vector
  66480. * @returns the translation vector
  66481. */
  66482. translate(): BABYLON.Vector2;
  66483. private _translatePoint;
  66484. /** Release associated resources */
  66485. dispose(): void;
  66486. }
  66487. }
  66488. declare module BABYLON.GUI {
  66489. /**
  66490. * Class used to create multi line control
  66491. */
  66492. export class MultiLine extends Control {
  66493. name?: string | undefined;
  66494. private _lineWidth;
  66495. private _dash;
  66496. private _points;
  66497. private _minX;
  66498. private _minY;
  66499. private _maxX;
  66500. private _maxY;
  66501. /**
  66502. * Creates a new MultiLine
  66503. * @param name defines the control name
  66504. */
  66505. constructor(name?: string | undefined);
  66506. /** Gets or sets dash pattern */
  66507. dash: Array<number>;
  66508. /**
  66509. * Gets point stored at specified index
  66510. * @param index defines the index to look for
  66511. * @returns the requested point if found
  66512. */
  66513. getAt(index: number): MultiLinePoint;
  66514. /** Function called when a point is updated */
  66515. onPointUpdate: () => void;
  66516. /**
  66517. * Adds new points to the point collection
  66518. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  66519. * @returns the list of created MultiLinePoint
  66520. */
  66521. add(...items: (AbstractMesh | Control | {
  66522. x: string | number;
  66523. y: string | number;
  66524. })[]): MultiLinePoint[];
  66525. /**
  66526. * Adds a new point to the point collection
  66527. * @param item defines the item (mesh, control or 2d coordiantes) to add
  66528. * @returns the created MultiLinePoint
  66529. */
  66530. push(item?: (AbstractMesh | Control | {
  66531. x: string | number;
  66532. y: string | number;
  66533. })): MultiLinePoint;
  66534. /**
  66535. * Remove a specific value or point from the active point collection
  66536. * @param value defines the value or point to remove
  66537. */
  66538. remove(value: number | MultiLinePoint): void;
  66539. /**
  66540. * Resets this object to initial state (no point)
  66541. */
  66542. reset(): void;
  66543. /**
  66544. * Resets all links
  66545. */
  66546. resetLinks(): void;
  66547. /** Gets or sets line width */
  66548. lineWidth: number;
  66549. horizontalAlignment: number;
  66550. verticalAlignment: number;
  66551. protected _getTypeName(): string;
  66552. _draw(context: CanvasRenderingContext2D): void;
  66553. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66554. _measure(): void;
  66555. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66556. dispose(): void;
  66557. }
  66558. }
  66559. declare module BABYLON.GUI {
  66560. /**
  66561. * Class used to create radio button controls
  66562. */
  66563. export class RadioButton extends Control {
  66564. name?: string | undefined;
  66565. private _isChecked;
  66566. private _background;
  66567. private _checkSizeRatio;
  66568. private _thickness;
  66569. /** Gets or sets border thickness */
  66570. thickness: number;
  66571. /** Gets or sets group name */
  66572. group: string;
  66573. /** BABYLON.Observable raised when isChecked is changed */
  66574. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66575. /** Gets or sets a value indicating the ratio between overall size and check size */
  66576. checkSizeRatio: number;
  66577. /** Gets or sets background color */
  66578. background: string;
  66579. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66580. isChecked: boolean;
  66581. /**
  66582. * Creates a new RadioButton
  66583. * @param name defines the control name
  66584. */
  66585. constructor(name?: string | undefined);
  66586. protected _getTypeName(): string;
  66587. _draw(context: CanvasRenderingContext2D): void;
  66588. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66589. /**
  66590. * Utility function to easily create a radio button with a header
  66591. * @param title defines the label to use for the header
  66592. * @param group defines the group to use for the radio button
  66593. * @param isChecked defines the initial state of the radio button
  66594. * @param onValueChanged defines the callback to call when value changes
  66595. * @returns a StackPanel containing the radio button and a textBlock
  66596. */
  66597. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  66598. }
  66599. }
  66600. declare module BABYLON.GUI {
  66601. /**
  66602. * Class used to create slider controls
  66603. */
  66604. export class BaseSlider extends Control {
  66605. name?: string | undefined;
  66606. protected _thumbWidth: ValueAndUnit;
  66607. private _minimum;
  66608. private _maximum;
  66609. private _value;
  66610. private _isVertical;
  66611. protected _barOffset: ValueAndUnit;
  66612. private _isThumbClamped;
  66613. protected _displayThumb: boolean;
  66614. private _step;
  66615. private _lastPointerDownID;
  66616. protected _effectiveBarOffset: number;
  66617. protected _renderLeft: number;
  66618. protected _renderTop: number;
  66619. protected _renderWidth: number;
  66620. protected _renderHeight: number;
  66621. protected _backgroundBoxLength: number;
  66622. protected _backgroundBoxThickness: number;
  66623. protected _effectiveThumbThickness: number;
  66624. /** BABYLON.Observable raised when the sldier value changes */
  66625. onValueChangedObservable: BABYLON.Observable<number>;
  66626. /** Gets or sets a boolean indicating if the thumb must be rendered */
  66627. displayThumb: boolean;
  66628. /** Gets or sets a step to apply to values (0 by default) */
  66629. step: number;
  66630. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  66631. barOffset: string | number;
  66632. /** Gets main bar offset in pixels*/
  66633. readonly barOffsetInPixels: number;
  66634. /** Gets or sets thumb width */
  66635. thumbWidth: string | number;
  66636. /** Gets thumb width in pixels */
  66637. readonly thumbWidthInPixels: number;
  66638. /** Gets or sets minimum value */
  66639. minimum: number;
  66640. /** Gets or sets maximum value */
  66641. maximum: number;
  66642. /** Gets or sets current value */
  66643. value: number;
  66644. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  66645. isVertical: boolean;
  66646. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  66647. isThumbClamped: boolean;
  66648. /**
  66649. * Creates a new BaseSlider
  66650. * @param name defines the control name
  66651. */
  66652. constructor(name?: string | undefined);
  66653. protected _getTypeName(): string;
  66654. protected _getThumbPosition(): number;
  66655. protected _getThumbThickness(type: string): number;
  66656. protected _prepareRenderingData(type: string): void;
  66657. private _pointerIsDown;
  66658. /** @hidden */
  66659. protected _updateValueFromPointer(x: number, y: number): void;
  66660. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66661. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66662. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66663. }
  66664. }
  66665. declare module BABYLON.GUI {
  66666. /**
  66667. * Class used to create slider controls
  66668. */
  66669. export class Slider extends BaseSlider {
  66670. name?: string | undefined;
  66671. private _background;
  66672. private _borderColor;
  66673. private _isThumbCircle;
  66674. protected _displayValueBar: boolean;
  66675. /** Gets or sets a boolean indicating if the value bar must be rendered */
  66676. displayValueBar: boolean;
  66677. /** Gets or sets border color */
  66678. borderColor: string;
  66679. /** Gets or sets background color */
  66680. background: string;
  66681. /** Gets or sets a boolean indicating if the thumb should be round or square */
  66682. isThumbCircle: boolean;
  66683. /**
  66684. * Creates a new Slider
  66685. * @param name defines the control name
  66686. */
  66687. constructor(name?: string | undefined);
  66688. protected _getTypeName(): string;
  66689. _draw(context: CanvasRenderingContext2D): void;
  66690. }
  66691. }
  66692. declare module BABYLON.GUI {
  66693. /** Class used to create a RadioGroup
  66694. * which contains groups of radio buttons
  66695. */
  66696. export class SelectorGroup {
  66697. /** name of SelectorGroup */
  66698. name: string;
  66699. private _groupPanel;
  66700. private _selectors;
  66701. private _groupHeader;
  66702. /**
  66703. * Creates a new SelectorGroup
  66704. * @param name of group, used as a group heading
  66705. */
  66706. constructor(
  66707. /** name of SelectorGroup */
  66708. name: string);
  66709. /** Gets the groupPanel of the SelectorGroup */
  66710. readonly groupPanel: StackPanel;
  66711. /** Gets the selectors array */
  66712. readonly selectors: StackPanel[];
  66713. /** Gets and sets the group header */
  66714. header: string;
  66715. /** @hidden */
  66716. private _addGroupHeader;
  66717. /** @hidden*/
  66718. _getSelector(selectorNb: number): StackPanel | undefined;
  66719. /** Removes the selector at the given position
  66720. * @param selectorNb the position of the selector within the group
  66721. */
  66722. removeSelector(selectorNb: number): void;
  66723. }
  66724. /** Class used to create a CheckboxGroup
  66725. * which contains groups of checkbox buttons
  66726. */
  66727. export class CheckboxGroup extends SelectorGroup {
  66728. /** Adds a checkbox as a control
  66729. * @param text is the label for the selector
  66730. * @param func is the function called when the Selector is checked
  66731. * @param checked is true when Selector is checked
  66732. */
  66733. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  66734. /** @hidden */
  66735. _setSelectorLabel(selectorNb: number, label: string): void;
  66736. /** @hidden */
  66737. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66738. /** @hidden */
  66739. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66740. /** @hidden */
  66741. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66742. }
  66743. /** Class used to create a RadioGroup
  66744. * which contains groups of radio buttons
  66745. */
  66746. export class RadioGroup extends SelectorGroup {
  66747. private _selectNb;
  66748. /** Adds a radio button as a control
  66749. * @param label is the label for the selector
  66750. * @param func is the function called when the Selector is checked
  66751. * @param checked is true when Selector is checked
  66752. */
  66753. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  66754. /** @hidden */
  66755. _setSelectorLabel(selectorNb: number, label: string): void;
  66756. /** @hidden */
  66757. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66758. /** @hidden */
  66759. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66760. /** @hidden */
  66761. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66762. }
  66763. /** Class used to create a SliderGroup
  66764. * which contains groups of slider buttons
  66765. */
  66766. export class SliderGroup extends SelectorGroup {
  66767. /**
  66768. * Adds a slider to the SelectorGroup
  66769. * @param label is the label for the SliderBar
  66770. * @param func is the function called when the Slider moves
  66771. * @param unit is a string describing the units used, eg degrees or metres
  66772. * @param min is the minimum value for the Slider
  66773. * @param max is the maximum value for the Slider
  66774. * @param value is the start value for the Slider between min and max
  66775. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  66776. */
  66777. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  66778. /** @hidden */
  66779. _setSelectorLabel(selectorNb: number, label: string): void;
  66780. /** @hidden */
  66781. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66782. /** @hidden */
  66783. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66784. /** @hidden */
  66785. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66786. }
  66787. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  66788. * @see http://doc.babylonjs.com/how_to/selector
  66789. */
  66790. export class SelectionPanel extends Rectangle {
  66791. /** name of SelectionPanel */
  66792. name: string;
  66793. /** an array of SelectionGroups */
  66794. groups: SelectorGroup[];
  66795. private _panel;
  66796. private _buttonColor;
  66797. private _buttonBackground;
  66798. private _headerColor;
  66799. private _barColor;
  66800. private _barHeight;
  66801. private _spacerHeight;
  66802. private _labelColor;
  66803. private _groups;
  66804. private _bars;
  66805. /**
  66806. * Creates a new SelectionPanel
  66807. * @param name of SelectionPanel
  66808. * @param groups is an array of SelectionGroups
  66809. */
  66810. constructor(
  66811. /** name of SelectionPanel */
  66812. name: string,
  66813. /** an array of SelectionGroups */
  66814. groups?: SelectorGroup[]);
  66815. protected _getTypeName(): string;
  66816. /** Gets or sets the headerColor */
  66817. headerColor: string;
  66818. private _setHeaderColor;
  66819. /** Gets or sets the button color */
  66820. buttonColor: string;
  66821. private _setbuttonColor;
  66822. /** Gets or sets the label color */
  66823. labelColor: string;
  66824. private _setLabelColor;
  66825. /** Gets or sets the button background */
  66826. buttonBackground: string;
  66827. private _setButtonBackground;
  66828. /** Gets or sets the color of separator bar */
  66829. barColor: string;
  66830. private _setBarColor;
  66831. /** Gets or sets the height of separator bar */
  66832. barHeight: string;
  66833. private _setBarHeight;
  66834. /** Gets or sets the height of spacers*/
  66835. spacerHeight: string;
  66836. private _setSpacerHeight;
  66837. /** Adds a bar between groups */
  66838. private _addSpacer;
  66839. /** Add a group to the selection panel
  66840. * @param group is the selector group to add
  66841. */
  66842. addGroup(group: SelectorGroup): void;
  66843. /** Remove the group from the given position
  66844. * @param groupNb is the position of the group in the list
  66845. */
  66846. removeGroup(groupNb: number): void;
  66847. /** Change a group header label
  66848. * @param label is the new group header label
  66849. * @param groupNb is the number of the group to relabel
  66850. * */
  66851. setHeaderName(label: string, groupNb: number): void;
  66852. /** Change selector label to the one given
  66853. * @param label is the new selector label
  66854. * @param groupNb is the number of the groupcontaining the selector
  66855. * @param selectorNb is the number of the selector within a group to relabel
  66856. * */
  66857. relabel(label: string, groupNb: number, selectorNb: number): void;
  66858. /** For a given group position remove the selector at the given position
  66859. * @param groupNb is the number of the group to remove the selector from
  66860. * @param selectorNb is the number of the selector within the group
  66861. */
  66862. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  66863. /** For a given group position of correct type add a checkbox button
  66864. * @param groupNb is the number of the group to remove the selector from
  66865. * @param label is the label for the selector
  66866. * @param func is the function called when the Selector is checked
  66867. * @param checked is true when Selector is checked
  66868. */
  66869. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66870. /** For a given group position of correct type add a radio button
  66871. * @param groupNb is the number of the group to remove the selector from
  66872. * @param label is the label for the selector
  66873. * @param func is the function called when the Selector is checked
  66874. * @param checked is true when Selector is checked
  66875. */
  66876. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66877. /**
  66878. * For a given slider group add a slider
  66879. * @param groupNb is the number of the group to add the slider to
  66880. * @param label is the label for the Slider
  66881. * @param func is the function called when the Slider moves
  66882. * @param unit is a string describing the units used, eg degrees or metres
  66883. * @param min is the minimum value for the Slider
  66884. * @param max is the maximum value for the Slider
  66885. * @param value is the start value for the Slider between min and max
  66886. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66887. */
  66888. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66889. }
  66890. }
  66891. declare module BABYLON.GUI {
  66892. /**
  66893. * Class used to hold a the container for ScrollViewer
  66894. * @hidden
  66895. */
  66896. export class _ScrollViewerWindow extends Container {
  66897. parentClientWidth: number;
  66898. parentClientHeight: number;
  66899. /**
  66900. * Creates a new ScrollViewerWindow
  66901. * @param name of ScrollViewerWindow
  66902. */
  66903. constructor(name?: string);
  66904. protected _getTypeName(): string;
  66905. /** @hidden */
  66906. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66907. protected _postMeasure(): void;
  66908. }
  66909. }
  66910. declare module BABYLON.GUI {
  66911. /**
  66912. * Class used to create slider controls
  66913. */
  66914. export class ScrollBar extends BaseSlider {
  66915. name?: string | undefined;
  66916. private _background;
  66917. private _borderColor;
  66918. private _thumbMeasure;
  66919. /** Gets or sets border color */
  66920. borderColor: string;
  66921. /** Gets or sets background color */
  66922. background: string;
  66923. /**
  66924. * Creates a new Slider
  66925. * @param name defines the control name
  66926. */
  66927. constructor(name?: string | undefined);
  66928. protected _getTypeName(): string;
  66929. protected _getThumbThickness(): number;
  66930. _draw(context: CanvasRenderingContext2D): void;
  66931. private _first;
  66932. private _originX;
  66933. private _originY;
  66934. /** @hidden */
  66935. protected _updateValueFromPointer(x: number, y: number): void;
  66936. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66937. }
  66938. }
  66939. declare module BABYLON.GUI {
  66940. /**
  66941. * Class used to hold a viewer window and sliders in a grid
  66942. */
  66943. export class ScrollViewer extends Rectangle {
  66944. private _grid;
  66945. private _horizontalBarSpace;
  66946. private _verticalBarSpace;
  66947. private _dragSpace;
  66948. private _horizontalBar;
  66949. private _verticalBar;
  66950. private _barColor;
  66951. private _barBackground;
  66952. private _barSize;
  66953. private _endLeft;
  66954. private _endTop;
  66955. private _window;
  66956. private _pointerIsOver;
  66957. private _wheelPrecision;
  66958. private _onPointerObserver;
  66959. private _clientWidth;
  66960. private _clientHeight;
  66961. /**
  66962. * Gets the horizontal scrollbar
  66963. */
  66964. readonly horizontalBar: ScrollBar;
  66965. /**
  66966. * Gets the vertical scrollbar
  66967. */
  66968. readonly verticalBar: ScrollBar;
  66969. /**
  66970. * Adds a new control to the current container
  66971. * @param control defines the control to add
  66972. * @returns the current container
  66973. */
  66974. addControl(control: BABYLON.Nullable<Control>): Container;
  66975. /**
  66976. * Removes a control from the current container
  66977. * @param control defines the control to remove
  66978. * @returns the current container
  66979. */
  66980. removeControl(control: Control): Container;
  66981. /** Gets the list of children */
  66982. readonly children: Control[];
  66983. _flagDescendantsAsMatrixDirty(): void;
  66984. /**
  66985. * Creates a new ScrollViewer
  66986. * @param name of ScrollViewer
  66987. */
  66988. constructor(name?: string);
  66989. /** Reset the scroll viewer window to initial size */
  66990. resetWindow(): void;
  66991. protected _getTypeName(): string;
  66992. private _buildClientSizes;
  66993. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66994. protected _postMeasure(): void;
  66995. /**
  66996. * Gets or sets the mouse wheel precision
  66997. * from 0 to 1 with a default value of 0.05
  66998. * */
  66999. wheelPrecision: number;
  67000. /** Gets or sets the bar color */
  67001. barColor: string;
  67002. /** Gets or sets the size of the bar */
  67003. barSize: number;
  67004. /** Gets or sets the bar background */
  67005. barBackground: string;
  67006. /** @hidden */
  67007. private _updateScroller;
  67008. _link(host: AdvancedDynamicTexture): void;
  67009. /** @hidden */
  67010. private _attachWheel;
  67011. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67012. /** Releases associated resources */
  67013. dispose(): void;
  67014. }
  67015. }
  67016. declare module BABYLON.GUI {
  67017. /** Class used to render a grid */
  67018. export class DisplayGrid extends Control {
  67019. name?: string | undefined;
  67020. private _cellWidth;
  67021. private _cellHeight;
  67022. private _minorLineTickness;
  67023. private _minorLineColor;
  67024. private _majorLineTickness;
  67025. private _majorLineColor;
  67026. private _majorLineFrequency;
  67027. private _background;
  67028. private _displayMajorLines;
  67029. private _displayMinorLines;
  67030. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  67031. displayMinorLines: boolean;
  67032. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  67033. displayMajorLines: boolean;
  67034. /** Gets or sets background color (Black by default) */
  67035. background: string;
  67036. /** Gets or sets the width of each cell (20 by default) */
  67037. cellWidth: number;
  67038. /** Gets or sets the height of each cell (20 by default) */
  67039. cellHeight: number;
  67040. /** Gets or sets the tickness of minor lines (1 by default) */
  67041. minorLineTickness: number;
  67042. /** Gets or sets the color of minor lines (DarkGray by default) */
  67043. minorLineColor: string;
  67044. /** Gets or sets the tickness of major lines (2 by default) */
  67045. majorLineTickness: number;
  67046. /** Gets or sets the color of major lines (White by default) */
  67047. majorLineColor: string;
  67048. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  67049. majorLineFrequency: number;
  67050. /**
  67051. * Creates a new GridDisplayRectangle
  67052. * @param name defines the control name
  67053. */
  67054. constructor(name?: string | undefined);
  67055. _draw(context: CanvasRenderingContext2D): void;
  67056. protected _getTypeName(): string;
  67057. }
  67058. }
  67059. declare module BABYLON.GUI {
  67060. /**
  67061. * Class used to create slider controls based on images
  67062. */
  67063. export class ImageBasedSlider extends BaseSlider {
  67064. name?: string | undefined;
  67065. private _backgroundImage;
  67066. private _thumbImage;
  67067. private _valueBarImage;
  67068. private _tempMeasure;
  67069. displayThumb: boolean;
  67070. /**
  67071. * Gets or sets the image used to render the background
  67072. */
  67073. backgroundImage: Image;
  67074. /**
  67075. * Gets or sets the image used to render the value bar
  67076. */
  67077. valueBarImage: Image;
  67078. /**
  67079. * Gets or sets the image used to render the thumb
  67080. */
  67081. thumbImage: Image;
  67082. /**
  67083. * Creates a new ImageBasedSlider
  67084. * @param name defines the control name
  67085. */
  67086. constructor(name?: string | undefined);
  67087. protected _getTypeName(): string;
  67088. _draw(context: CanvasRenderingContext2D): void;
  67089. }
  67090. }
  67091. declare module BABYLON.GUI {
  67092. /**
  67093. * Forcing an export so that this code will execute
  67094. * @hidden
  67095. */
  67096. const name = "Statics";
  67097. }
  67098. declare module BABYLON.GUI {
  67099. /**
  67100. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  67101. */
  67102. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  67103. /**
  67104. * Define the instrumented AdvancedDynamicTexture.
  67105. */
  67106. texture: AdvancedDynamicTexture;
  67107. private _captureRenderTime;
  67108. private _renderTime;
  67109. private _captureLayoutTime;
  67110. private _layoutTime;
  67111. private _onBeginRenderObserver;
  67112. private _onEndRenderObserver;
  67113. private _onBeginLayoutObserver;
  67114. private _onEndLayoutObserver;
  67115. /**
  67116. * Gets the perf counter used to capture render time
  67117. */
  67118. readonly renderTimeCounter: BABYLON.PerfCounter;
  67119. /**
  67120. * Gets the perf counter used to capture layout time
  67121. */
  67122. readonly layoutTimeCounter: BABYLON.PerfCounter;
  67123. /**
  67124. * Enable or disable the render time capture
  67125. */
  67126. captureRenderTime: boolean;
  67127. /**
  67128. * Enable or disable the layout time capture
  67129. */
  67130. captureLayoutTime: boolean;
  67131. /**
  67132. * Instantiates a new advanced dynamic texture instrumentation.
  67133. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  67134. * @param texture Defines the AdvancedDynamicTexture to instrument
  67135. */
  67136. constructor(
  67137. /**
  67138. * Define the instrumented AdvancedDynamicTexture.
  67139. */
  67140. texture: AdvancedDynamicTexture);
  67141. /**
  67142. * Dispose and release associated resources.
  67143. */
  67144. dispose(): void;
  67145. }
  67146. }
  67147. declare module BABYLON.GUI {
  67148. /**
  67149. * Class used to load GUI via XML.
  67150. */
  67151. export class XmlLoader {
  67152. private _nodes;
  67153. private _nodeTypes;
  67154. private _isLoaded;
  67155. private _objectAttributes;
  67156. private _parentClass;
  67157. /**
  67158. * Create a new xml loader
  67159. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  67160. */
  67161. constructor(parentClass?: null);
  67162. private _getChainElement;
  67163. private _getClassAttribute;
  67164. private _createGuiElement;
  67165. private _parseGrid;
  67166. private _parseElement;
  67167. private _prepareSourceElement;
  67168. private _parseElementsFromSource;
  67169. private _parseXml;
  67170. /**
  67171. * Gets if the loading has finished.
  67172. * @returns whether the loading has finished or not
  67173. */
  67174. isLoaded(): boolean;
  67175. /**
  67176. * Gets a loaded node / control by id.
  67177. * @param id the Controls id set in the xml
  67178. * @returns element of type Control
  67179. */
  67180. getNodeById(id: string): any;
  67181. /**
  67182. * Gets all loaded nodes / controls
  67183. * @returns Array of controls
  67184. */
  67185. getNodes(): any;
  67186. /**
  67187. * Initiates the xml layout loading
  67188. * @param xmlFile defines the xml layout to load
  67189. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  67190. * @param callback defines the callback called on layout load.
  67191. */
  67192. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  67193. }
  67194. }
  67195. declare module BABYLON.GUI {
  67196. /**
  67197. * Class used to create containers for controls
  67198. */
  67199. export class Container3D extends Control3D {
  67200. private _blockLayout;
  67201. /**
  67202. * Gets the list of child controls
  67203. */
  67204. protected _children: Control3D[];
  67205. /**
  67206. * Gets the list of child controls
  67207. */
  67208. readonly children: Array<Control3D>;
  67209. /**
  67210. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  67211. * This is helpful to optimize layout operation when adding multiple children in a row
  67212. */
  67213. blockLayout: boolean;
  67214. /**
  67215. * Creates a new container
  67216. * @param name defines the container name
  67217. */
  67218. constructor(name?: string);
  67219. /**
  67220. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  67221. * @returns the current container
  67222. */
  67223. updateLayout(): Container3D;
  67224. /**
  67225. * Gets a boolean indicating if the given control is in the children of this control
  67226. * @param control defines the control to check
  67227. * @returns true if the control is in the child list
  67228. */
  67229. containsControl(control: Control3D): boolean;
  67230. /**
  67231. * Adds a control to the children of this control
  67232. * @param control defines the control to add
  67233. * @returns the current container
  67234. */
  67235. addControl(control: Control3D): Container3D;
  67236. /**
  67237. * This function will be called everytime a new control is added
  67238. */
  67239. protected _arrangeChildren(): void;
  67240. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67241. /**
  67242. * Removes a control from the children of this control
  67243. * @param control defines the control to remove
  67244. * @returns the current container
  67245. */
  67246. removeControl(control: Control3D): Container3D;
  67247. protected _getTypeName(): string;
  67248. /**
  67249. * Releases all associated resources
  67250. */
  67251. dispose(): void;
  67252. /** Control rotation will remain unchanged */
  67253. static readonly UNSET_ORIENTATION: number;
  67254. /** Control will rotate to make it look at sphere central axis */
  67255. static readonly FACEORIGIN_ORIENTATION: number;
  67256. /** Control will rotate to make it look back at sphere central axis */
  67257. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  67258. /** Control will rotate to look at z axis (0, 0, 1) */
  67259. static readonly FACEFORWARD_ORIENTATION: number;
  67260. /** Control will rotate to look at negative z axis (0, 0, -1) */
  67261. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  67262. }
  67263. }
  67264. declare module BABYLON.GUI {
  67265. /**
  67266. * Class used to manage 3D user interface
  67267. * @see http://doc.babylonjs.com/how_to/gui3d
  67268. */
  67269. export class GUI3DManager implements BABYLON.IDisposable {
  67270. private _scene;
  67271. private _sceneDisposeObserver;
  67272. private _utilityLayer;
  67273. private _rootContainer;
  67274. private _pointerObserver;
  67275. private _pointerOutObserver;
  67276. /** @hidden */
  67277. _lastPickedControl: Control3D;
  67278. /** @hidden */
  67279. _lastControlOver: {
  67280. [pointerId: number]: Control3D;
  67281. };
  67282. /** @hidden */
  67283. _lastControlDown: {
  67284. [pointerId: number]: Control3D;
  67285. };
  67286. /**
  67287. * BABYLON.Observable raised when the point picked by the pointer events changed
  67288. */
  67289. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  67290. /** @hidden */
  67291. _sharedMaterials: {
  67292. [key: string]: BABYLON.Material;
  67293. };
  67294. /** Gets the hosting scene */
  67295. readonly scene: BABYLON.Scene;
  67296. /** Gets associated utility layer */
  67297. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  67298. /**
  67299. * Creates a new GUI3DManager
  67300. * @param scene
  67301. */
  67302. constructor(scene?: BABYLON.Scene);
  67303. private _handlePointerOut;
  67304. private _doPicking;
  67305. /**
  67306. * Gets the root container
  67307. */
  67308. readonly rootContainer: Container3D;
  67309. /**
  67310. * Gets a boolean indicating if the given control is in the root child list
  67311. * @param control defines the control to check
  67312. * @returns true if the control is in the root child list
  67313. */
  67314. containsControl(control: Control3D): boolean;
  67315. /**
  67316. * Adds a control to the root child list
  67317. * @param control defines the control to add
  67318. * @returns the current manager
  67319. */
  67320. addControl(control: Control3D): GUI3DManager;
  67321. /**
  67322. * Removes a control from the root child list
  67323. * @param control defines the control to remove
  67324. * @returns the current container
  67325. */
  67326. removeControl(control: Control3D): GUI3DManager;
  67327. /**
  67328. * Releases all associated resources
  67329. */
  67330. dispose(): void;
  67331. }
  67332. }
  67333. declare module BABYLON.GUI {
  67334. /**
  67335. * Class used to transport BABYLON.Vector3 information for pointer events
  67336. */
  67337. export class Vector3WithInfo extends BABYLON.Vector3 {
  67338. /** defines the current mouse button index */
  67339. buttonIndex: number;
  67340. /**
  67341. * Creates a new Vector3WithInfo
  67342. * @param source defines the vector3 data to transport
  67343. * @param buttonIndex defines the current mouse button index
  67344. */
  67345. constructor(source: BABYLON.Vector3,
  67346. /** defines the current mouse button index */
  67347. buttonIndex?: number);
  67348. }
  67349. }
  67350. declare module BABYLON.GUI {
  67351. /**
  67352. * Class used as base class for controls
  67353. */
  67354. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  67355. /** Defines the control name */
  67356. name?: string | undefined;
  67357. /** @hidden */
  67358. _host: GUI3DManager;
  67359. private _node;
  67360. private _downCount;
  67361. private _enterCount;
  67362. private _downPointerIds;
  67363. private _isVisible;
  67364. /** Gets or sets the control position in world space */
  67365. position: BABYLON.Vector3;
  67366. /** Gets or sets the control scaling in world space */
  67367. scaling: BABYLON.Vector3;
  67368. /** Callback used to start pointer enter animation */
  67369. pointerEnterAnimation: () => void;
  67370. /** Callback used to start pointer out animation */
  67371. pointerOutAnimation: () => void;
  67372. /** Callback used to start pointer down animation */
  67373. pointerDownAnimation: () => void;
  67374. /** Callback used to start pointer up animation */
  67375. pointerUpAnimation: () => void;
  67376. /**
  67377. * An event triggered when the pointer move over the control
  67378. */
  67379. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  67380. /**
  67381. * An event triggered when the pointer move out of the control
  67382. */
  67383. onPointerOutObservable: BABYLON.Observable<Control3D>;
  67384. /**
  67385. * An event triggered when the pointer taps the control
  67386. */
  67387. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  67388. /**
  67389. * An event triggered when pointer is up
  67390. */
  67391. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  67392. /**
  67393. * An event triggered when a control is clicked on (with a mouse)
  67394. */
  67395. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  67396. /**
  67397. * An event triggered when pointer enters the control
  67398. */
  67399. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  67400. /**
  67401. * Gets or sets the parent container
  67402. */
  67403. parent: BABYLON.Nullable<Container3D>;
  67404. private _behaviors;
  67405. /**
  67406. * Gets the list of attached behaviors
  67407. * @see http://doc.babylonjs.com/features/behaviour
  67408. */
  67409. readonly behaviors: BABYLON.Behavior<Control3D>[];
  67410. /**
  67411. * Attach a behavior to the control
  67412. * @see http://doc.babylonjs.com/features/behaviour
  67413. * @param behavior defines the behavior to attach
  67414. * @returns the current control
  67415. */
  67416. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67417. /**
  67418. * Remove an attached behavior
  67419. * @see http://doc.babylonjs.com/features/behaviour
  67420. * @param behavior defines the behavior to attach
  67421. * @returns the current control
  67422. */
  67423. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67424. /**
  67425. * Gets an attached behavior by name
  67426. * @param name defines the name of the behavior to look for
  67427. * @see http://doc.babylonjs.com/features/behaviour
  67428. * @returns null if behavior was not found else the requested behavior
  67429. */
  67430. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  67431. /** Gets or sets a boolean indicating if the control is visible */
  67432. isVisible: boolean;
  67433. /**
  67434. * Creates a new control
  67435. * @param name defines the control name
  67436. */
  67437. constructor(
  67438. /** Defines the control name */
  67439. name?: string | undefined);
  67440. /**
  67441. * Gets a string representing the class name
  67442. */
  67443. readonly typeName: string;
  67444. /**
  67445. * Get the current class name of the control.
  67446. * @returns current class name
  67447. */
  67448. getClassName(): string;
  67449. protected _getTypeName(): string;
  67450. /**
  67451. * Gets the transform node used by this control
  67452. */
  67453. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  67454. /**
  67455. * Gets the mesh used to render this control
  67456. */
  67457. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67458. /**
  67459. * Link the control as child of the given node
  67460. * @param node defines the node to link to. Use null to unlink the control
  67461. * @returns the current control
  67462. */
  67463. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  67464. /** @hidden **/
  67465. _prepareNode(scene: BABYLON.Scene): void;
  67466. /**
  67467. * Node creation.
  67468. * Can be overriden by children
  67469. * @param scene defines the scene where the node must be attached
  67470. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  67471. */
  67472. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67473. /**
  67474. * Affect a material to the given mesh
  67475. * @param mesh defines the mesh which will represent the control
  67476. */
  67477. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67478. /** @hidden */
  67479. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  67480. /** @hidden */
  67481. _onPointerEnter(target: Control3D): boolean;
  67482. /** @hidden */
  67483. _onPointerOut(target: Control3D): void;
  67484. /** @hidden */
  67485. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67486. /** @hidden */
  67487. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67488. /** @hidden */
  67489. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67490. /** @hidden */
  67491. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67492. /** @hidden */
  67493. _disposeNode(): void;
  67494. /**
  67495. * Releases all associated resources
  67496. */
  67497. dispose(): void;
  67498. }
  67499. }
  67500. declare module BABYLON.GUI {
  67501. /**
  67502. * Class used as a root to all buttons
  67503. */
  67504. export class AbstractButton3D extends Control3D {
  67505. /**
  67506. * Creates a new button
  67507. * @param name defines the control name
  67508. */
  67509. constructor(name?: string);
  67510. protected _getTypeName(): string;
  67511. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67512. }
  67513. }
  67514. declare module BABYLON.GUI {
  67515. /**
  67516. * Class used to create a button in 3D
  67517. */
  67518. export class Button3D extends AbstractButton3D {
  67519. /** @hidden */
  67520. protected _currentMaterial: BABYLON.Material;
  67521. private _facadeTexture;
  67522. private _content;
  67523. private _contentResolution;
  67524. private _contentScaleRatio;
  67525. /**
  67526. * Gets or sets the texture resolution used to render content (512 by default)
  67527. */
  67528. contentResolution: BABYLON.int;
  67529. /**
  67530. * Gets or sets the texture scale ratio used to render content (2 by default)
  67531. */
  67532. contentScaleRatio: number;
  67533. protected _disposeFacadeTexture(): void;
  67534. protected _resetContent(): void;
  67535. /**
  67536. * Creates a new button
  67537. * @param name defines the control name
  67538. */
  67539. constructor(name?: string);
  67540. /**
  67541. * Gets or sets the GUI 2D content used to display the button's facade
  67542. */
  67543. content: Control;
  67544. /**
  67545. * Apply the facade texture (created from the content property).
  67546. * This function can be overloaded by child classes
  67547. * @param facadeTexture defines the AdvancedDynamicTexture to use
  67548. */
  67549. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67550. protected _getTypeName(): string;
  67551. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67552. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67553. /**
  67554. * Releases all associated resources
  67555. */
  67556. dispose(): void;
  67557. }
  67558. }
  67559. declare module BABYLON.GUI {
  67560. /**
  67561. * Abstract class used to create a container panel deployed on the surface of a volume
  67562. */
  67563. export abstract class VolumeBasedPanel extends Container3D {
  67564. private _columns;
  67565. private _rows;
  67566. private _rowThenColum;
  67567. private _orientation;
  67568. protected _cellWidth: number;
  67569. protected _cellHeight: number;
  67570. /**
  67571. * Gets or sets the distance between elements
  67572. */
  67573. margin: number;
  67574. /**
  67575. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  67576. * | Value | Type | Description |
  67577. * | ----- | ----------------------------------- | ----------- |
  67578. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  67579. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  67580. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  67581. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  67582. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  67583. */
  67584. orientation: number;
  67585. /**
  67586. * Gets or sets the number of columns requested (10 by default).
  67587. * The panel will automatically compute the number of rows based on number of child controls.
  67588. */
  67589. columns: BABYLON.int;
  67590. /**
  67591. * Gets or sets a the number of rows requested.
  67592. * The panel will automatically compute the number of columns based on number of child controls.
  67593. */
  67594. rows: BABYLON.int;
  67595. /**
  67596. * Creates new VolumeBasedPanel
  67597. */
  67598. constructor();
  67599. protected _arrangeChildren(): void;
  67600. /** Child classes must implement this function to provide correct control positioning */
  67601. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67602. /** Child classes can implement this function to provide additional processing */
  67603. protected _finalProcessing(): void;
  67604. }
  67605. }
  67606. declare module BABYLON.GUI {
  67607. /**
  67608. * Class used to create a container panel deployed on the surface of a cylinder
  67609. */
  67610. export class CylinderPanel extends VolumeBasedPanel {
  67611. private _radius;
  67612. /**
  67613. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  67614. */
  67615. radius: BABYLON.float;
  67616. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67617. private _cylindricalMapping;
  67618. }
  67619. }
  67620. declare module BABYLON.GUI {
  67621. /** @hidden */
  67622. export var fluentVertexShader: {
  67623. name: string;
  67624. shader: string;
  67625. };
  67626. }
  67627. declare module BABYLON.GUI {
  67628. /** @hidden */
  67629. export var fluentPixelShader: {
  67630. name: string;
  67631. shader: string;
  67632. };
  67633. }
  67634. declare module BABYLON.GUI {
  67635. /** @hidden */
  67636. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  67637. INNERGLOW: boolean;
  67638. BORDER: boolean;
  67639. HOVERLIGHT: boolean;
  67640. TEXTURE: boolean;
  67641. constructor();
  67642. }
  67643. /**
  67644. * Class used to render controls with fluent desgin
  67645. */
  67646. export class FluentMaterial extends BABYLON.PushMaterial {
  67647. /**
  67648. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  67649. */
  67650. innerGlowColorIntensity: number;
  67651. /**
  67652. * Gets or sets the inner glow color (white by default)
  67653. */
  67654. innerGlowColor: BABYLON.Color3;
  67655. /**
  67656. * Gets or sets alpha value (default is 1.0)
  67657. */
  67658. alpha: number;
  67659. /**
  67660. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  67661. */
  67662. albedoColor: BABYLON.Color3;
  67663. /**
  67664. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  67665. */
  67666. renderBorders: boolean;
  67667. /**
  67668. * Gets or sets border width (default is 0.5)
  67669. */
  67670. borderWidth: number;
  67671. /**
  67672. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  67673. */
  67674. edgeSmoothingValue: number;
  67675. /**
  67676. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  67677. */
  67678. borderMinValue: number;
  67679. /**
  67680. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  67681. */
  67682. renderHoverLight: boolean;
  67683. /**
  67684. * Gets or sets the radius used to render the hover light (default is 1.0)
  67685. */
  67686. hoverRadius: number;
  67687. /**
  67688. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  67689. */
  67690. hoverColor: BABYLON.Color4;
  67691. /**
  67692. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  67693. */
  67694. hoverPosition: BABYLON.Vector3;
  67695. private _albedoTexture;
  67696. /** Gets or sets the texture to use for albedo color */
  67697. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67698. /**
  67699. * Creates a new Fluent material
  67700. * @param name defines the name of the material
  67701. * @param scene defines the hosting scene
  67702. */
  67703. constructor(name: string, scene: BABYLON.Scene);
  67704. needAlphaBlending(): boolean;
  67705. needAlphaTesting(): boolean;
  67706. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67707. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67708. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67709. getActiveTextures(): BABYLON.BaseTexture[];
  67710. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67711. dispose(forceDisposeEffect?: boolean): void;
  67712. clone(name: string): FluentMaterial;
  67713. serialize(): any;
  67714. getClassName(): string;
  67715. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  67716. }
  67717. }
  67718. declare module BABYLON.GUI {
  67719. /**
  67720. * Class used to create a holographic button in 3D
  67721. */
  67722. export class HolographicButton extends Button3D {
  67723. private _backPlate;
  67724. private _textPlate;
  67725. private _frontPlate;
  67726. private _text;
  67727. private _imageUrl;
  67728. private _shareMaterials;
  67729. private _frontMaterial;
  67730. private _backMaterial;
  67731. private _plateMaterial;
  67732. private _pickedPointObserver;
  67733. private _tooltipFade;
  67734. private _tooltipTextBlock;
  67735. private _tooltipTexture;
  67736. private _tooltipMesh;
  67737. private _tooltipHoverObserver;
  67738. private _tooltipOutObserver;
  67739. private _disposeTooltip;
  67740. /**
  67741. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  67742. */
  67743. tooltipText: BABYLON.Nullable<string>;
  67744. /**
  67745. * Gets or sets text for the button
  67746. */
  67747. text: string;
  67748. /**
  67749. * Gets or sets the image url for the button
  67750. */
  67751. imageUrl: string;
  67752. /**
  67753. * Gets the back material used by this button
  67754. */
  67755. readonly backMaterial: FluentMaterial;
  67756. /**
  67757. * Gets the front material used by this button
  67758. */
  67759. readonly frontMaterial: FluentMaterial;
  67760. /**
  67761. * Gets the plate material used by this button
  67762. */
  67763. readonly plateMaterial: BABYLON.StandardMaterial;
  67764. /**
  67765. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  67766. */
  67767. readonly shareMaterials: boolean;
  67768. /**
  67769. * Creates a new button
  67770. * @param name defines the control name
  67771. */
  67772. constructor(name?: string, shareMaterials?: boolean);
  67773. protected _getTypeName(): string;
  67774. private _rebuildContent;
  67775. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67776. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67777. private _createBackMaterial;
  67778. private _createFrontMaterial;
  67779. private _createPlateMaterial;
  67780. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  67781. /**
  67782. * Releases all associated resources
  67783. */
  67784. dispose(): void;
  67785. }
  67786. }
  67787. declare module BABYLON.GUI {
  67788. /**
  67789. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  67790. */
  67791. export class MeshButton3D extends Button3D {
  67792. /** @hidden */
  67793. protected _currentMesh: BABYLON.Mesh;
  67794. /**
  67795. * Creates a new 3D button based on a mesh
  67796. * @param mesh mesh to become a 3D button
  67797. * @param name defines the control name
  67798. */
  67799. constructor(mesh: BABYLON.Mesh, name?: string);
  67800. protected _getTypeName(): string;
  67801. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67802. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67803. }
  67804. }
  67805. declare module BABYLON.GUI {
  67806. /**
  67807. * Class used to create a container panel deployed on the surface of a plane
  67808. */
  67809. export class PlanePanel extends VolumeBasedPanel {
  67810. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67811. }
  67812. }
  67813. declare module BABYLON.GUI {
  67814. /**
  67815. * Class used to create a container panel where items get randomized planar mapping
  67816. */
  67817. export class ScatterPanel extends VolumeBasedPanel {
  67818. private _iteration;
  67819. /**
  67820. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  67821. */
  67822. iteration: BABYLON.float;
  67823. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67824. private _scatterMapping;
  67825. protected _finalProcessing(): void;
  67826. }
  67827. }
  67828. declare module BABYLON.GUI {
  67829. /**
  67830. * Class used to create a container panel deployed on the surface of a sphere
  67831. */
  67832. export class SpherePanel extends VolumeBasedPanel {
  67833. private _radius;
  67834. /**
  67835. * Gets or sets the radius of the sphere where to project controls (5 by default)
  67836. */
  67837. radius: BABYLON.float;
  67838. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67839. private _sphericalMapping;
  67840. }
  67841. }
  67842. declare module BABYLON.GUI {
  67843. /**
  67844. * Class used to create a stack panel in 3D on XY plane
  67845. */
  67846. export class StackPanel3D extends Container3D {
  67847. private _isVertical;
  67848. /**
  67849. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  67850. */
  67851. isVertical: boolean;
  67852. /**
  67853. * Gets or sets the distance between elements
  67854. */
  67855. margin: number;
  67856. /**
  67857. * Creates new StackPanel
  67858. * @param isVertical
  67859. */
  67860. constructor(isVertical?: boolean);
  67861. protected _arrangeChildren(): void;
  67862. }
  67863. }
  67864. declare module BABYLON {
  67865. /**
  67866. * Mode that determines the coordinate system to use.
  67867. */
  67868. export enum GLTFLoaderCoordinateSystemMode {
  67869. /**
  67870. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67871. */
  67872. AUTO = 0,
  67873. /**
  67874. * Sets the useRightHandedSystem flag on the scene.
  67875. */
  67876. FORCE_RIGHT_HANDED = 1
  67877. }
  67878. /**
  67879. * Mode that determines what animations will start.
  67880. */
  67881. export enum GLTFLoaderAnimationStartMode {
  67882. /**
  67883. * No animation will start.
  67884. */
  67885. NONE = 0,
  67886. /**
  67887. * The first animation will start.
  67888. */
  67889. FIRST = 1,
  67890. /**
  67891. * All animations will start.
  67892. */
  67893. ALL = 2
  67894. }
  67895. /**
  67896. * Interface that contains the data for the glTF asset.
  67897. */
  67898. export interface IGLTFLoaderData {
  67899. /**
  67900. * Object that represents the glTF JSON.
  67901. */
  67902. json: Object;
  67903. /**
  67904. * The BIN chunk of a binary glTF.
  67905. */
  67906. bin: Nullable<ArrayBufferView>;
  67907. }
  67908. /**
  67909. * Interface for extending the loader.
  67910. */
  67911. export interface IGLTFLoaderExtension {
  67912. /**
  67913. * The name of this extension.
  67914. */
  67915. readonly name: string;
  67916. /**
  67917. * Defines whether this extension is enabled.
  67918. */
  67919. enabled: boolean;
  67920. }
  67921. /**
  67922. * Loader state.
  67923. */
  67924. export enum GLTFLoaderState {
  67925. /**
  67926. * The asset is loading.
  67927. */
  67928. LOADING = 0,
  67929. /**
  67930. * The asset is ready for rendering.
  67931. */
  67932. READY = 1,
  67933. /**
  67934. * The asset is completely loaded.
  67935. */
  67936. COMPLETE = 2
  67937. }
  67938. /** @hidden */
  67939. export interface IGLTFLoader extends IDisposable {
  67940. readonly state: Nullable<GLTFLoaderState>;
  67941. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  67942. meshes: AbstractMesh[];
  67943. particleSystems: IParticleSystem[];
  67944. skeletons: Skeleton[];
  67945. animationGroups: AnimationGroup[];
  67946. }>;
  67947. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  67948. }
  67949. /**
  67950. * File loader for loading glTF files into a scene.
  67951. */
  67952. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67953. /** @hidden */
  67954. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67955. /** @hidden */
  67956. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67957. /**
  67958. * Raised when the asset has been parsed
  67959. */
  67960. onParsedObservable: Observable<IGLTFLoaderData>;
  67961. private _onParsedObserver;
  67962. /**
  67963. * Raised when the asset has been parsed
  67964. */
  67965. onParsed: (loaderData: IGLTFLoaderData) => void;
  67966. /**
  67967. * 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.
  67968. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  67969. * Defaults to true.
  67970. * @hidden
  67971. */
  67972. static IncrementalLoading: boolean;
  67973. /**
  67974. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  67975. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  67976. * @hidden
  67977. */
  67978. static HomogeneousCoordinates: boolean;
  67979. /**
  67980. * The coordinate system mode. Defaults to AUTO.
  67981. */
  67982. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  67983. /**
  67984. * The animation start mode. Defaults to FIRST.
  67985. */
  67986. animationStartMode: GLTFLoaderAnimationStartMode;
  67987. /**
  67988. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  67989. */
  67990. compileMaterials: boolean;
  67991. /**
  67992. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  67993. */
  67994. useClipPlane: boolean;
  67995. /**
  67996. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  67997. */
  67998. compileShadowGenerators: boolean;
  67999. /**
  68000. * Defines if the Alpha blended materials are only applied as coverage.
  68001. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  68002. * If true, no extra effects are applied to transparent pixels.
  68003. */
  68004. transparencyAsCoverage: boolean;
  68005. /**
  68006. * Function called before loading a url referenced by the asset.
  68007. */
  68008. preprocessUrlAsync: (url: string) => Promise<string>;
  68009. /**
  68010. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68011. */
  68012. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  68013. private _onMeshLoadedObserver;
  68014. /**
  68015. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68016. */
  68017. onMeshLoaded: (mesh: AbstractMesh) => void;
  68018. /**
  68019. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  68020. */
  68021. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  68022. private _onTextureLoadedObserver;
  68023. /**
  68024. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  68025. */
  68026. onTextureLoaded: (texture: BaseTexture) => void;
  68027. /**
  68028. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  68029. */
  68030. readonly onMaterialLoadedObservable: Observable<Material>;
  68031. private _onMaterialLoadedObserver;
  68032. /**
  68033. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  68034. */
  68035. onMaterialLoaded: (material: Material) => void;
  68036. /**
  68037. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  68038. */
  68039. readonly onCameraLoadedObservable: Observable<Camera>;
  68040. private _onCameraLoadedObserver;
  68041. /**
  68042. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  68043. */
  68044. onCameraLoaded: (camera: Camera) => void;
  68045. /**
  68046. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  68047. * For assets with LODs, raised when all of the LODs are complete.
  68048. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68049. */
  68050. readonly onCompleteObservable: Observable<void>;
  68051. private _onCompleteObserver;
  68052. /**
  68053. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  68054. * For assets with LODs, raised when all of the LODs are complete.
  68055. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68056. */
  68057. onComplete: () => void;
  68058. /**
  68059. * Observable raised when an error occurs.
  68060. */
  68061. readonly onErrorObservable: Observable<any>;
  68062. private _onErrorObserver;
  68063. /**
  68064. * Callback raised when an error occurs.
  68065. */
  68066. onError: (reason: any) => void;
  68067. /**
  68068. * Observable raised after the loader is disposed.
  68069. */
  68070. readonly onDisposeObservable: Observable<void>;
  68071. private _onDisposeObserver;
  68072. /**
  68073. * Callback raised after the loader is disposed.
  68074. */
  68075. onDispose: () => void;
  68076. /**
  68077. * Observable raised after a loader extension is created.
  68078. * Set additional options for a loader extension in this event.
  68079. */
  68080. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  68081. private _onExtensionLoadedObserver;
  68082. /**
  68083. * Callback raised after a loader extension is created.
  68084. */
  68085. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  68086. /**
  68087. * Defines if the loader logging is enabled.
  68088. */
  68089. loggingEnabled: boolean;
  68090. /**
  68091. * Defines if the loader should capture performance counters.
  68092. */
  68093. capturePerformanceCounters: boolean;
  68094. /**
  68095. * Defines if the loader should validate the asset.
  68096. */
  68097. validate: boolean;
  68098. /**
  68099. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  68100. */
  68101. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  68102. private _onValidatedObserver;
  68103. /**
  68104. * Callback raised after a loader extension is created.
  68105. */
  68106. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  68107. private _loader;
  68108. /**
  68109. * Name of the loader ("gltf")
  68110. */
  68111. name: string;
  68112. /**
  68113. * Supported file extensions of the loader (.gltf, .glb)
  68114. */
  68115. extensions: ISceneLoaderPluginExtensions;
  68116. /**
  68117. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  68118. */
  68119. dispose(): void;
  68120. /** @hidden */
  68121. _clear(): void;
  68122. /**
  68123. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  68124. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68125. * @param scene the scene the meshes should be added to
  68126. * @param data the glTF data to load
  68127. * @param rootUrl root url to load from
  68128. * @param onProgress event that fires when loading progress has occured
  68129. * @param fileName Defines the name of the file to load
  68130. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68131. */
  68132. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68133. meshes: AbstractMesh[];
  68134. particleSystems: IParticleSystem[];
  68135. skeletons: Skeleton[];
  68136. animationGroups: AnimationGroup[];
  68137. }>;
  68138. /**
  68139. * Imports all objects from the loaded glTF data and adds them to the scene
  68140. * @param scene the scene the objects should be added to
  68141. * @param data the glTF data to load
  68142. * @param rootUrl root url to load from
  68143. * @param onProgress event that fires when loading progress has occured
  68144. * @param fileName Defines the name of the file to load
  68145. * @returns a promise which completes when objects have been loaded to the scene
  68146. */
  68147. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68148. /**
  68149. * Load into an asset container.
  68150. * @param scene The scene to load into
  68151. * @param data The data to import
  68152. * @param rootUrl The root url for scene and resources
  68153. * @param onProgress The callback when the load progresses
  68154. * @param fileName Defines the name of the file to load
  68155. * @returns The loaded asset container
  68156. */
  68157. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68158. /**
  68159. * If the data string can be loaded directly.
  68160. * @param data string contianing the file data
  68161. * @returns if the data can be loaded directly
  68162. */
  68163. canDirectLoad(data: string): boolean;
  68164. /**
  68165. * Rewrites a url by combining a root url and response url.
  68166. */
  68167. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  68168. /**
  68169. * Instantiates a glTF file loader plugin.
  68170. * @returns the created plugin
  68171. */
  68172. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  68173. /**
  68174. * The loader state or null if the loader is not active.
  68175. */
  68176. readonly loaderState: Nullable<GLTFLoaderState>;
  68177. /**
  68178. * Returns a promise that resolves when the asset is completely loaded.
  68179. * @returns a promise that resolves when the asset is completely loaded.
  68180. */
  68181. whenCompleteAsync(): Promise<void>;
  68182. private _parseAsync;
  68183. private _validateAsync;
  68184. private _getLoader;
  68185. private _unpackBinary;
  68186. private _unpackBinaryV1;
  68187. private _unpackBinaryV2;
  68188. private static _parseVersion;
  68189. private static _compareVersion;
  68190. private static _decodeBufferToText;
  68191. private static readonly _logSpaces;
  68192. private _logIndentLevel;
  68193. private _loggingEnabled;
  68194. /** @hidden */
  68195. _log: (message: string) => void;
  68196. /** @hidden */
  68197. _logOpen(message: string): void;
  68198. /** @hidden */
  68199. _logClose(): void;
  68200. private _logEnabled;
  68201. private _logDisabled;
  68202. private _capturePerformanceCounters;
  68203. /** @hidden */
  68204. _startPerformanceCounter: (counterName: string) => void;
  68205. /** @hidden */
  68206. _endPerformanceCounter: (counterName: string) => void;
  68207. private _startPerformanceCounterEnabled;
  68208. private _startPerformanceCounterDisabled;
  68209. private _endPerformanceCounterEnabled;
  68210. private _endPerformanceCounterDisabled;
  68211. }
  68212. }
  68213. declare module BABYLON.GLTF1 {
  68214. /**
  68215. * Enums
  68216. * @hidden
  68217. */
  68218. export enum EComponentType {
  68219. BYTE = 5120,
  68220. UNSIGNED_BYTE = 5121,
  68221. SHORT = 5122,
  68222. UNSIGNED_SHORT = 5123,
  68223. FLOAT = 5126
  68224. }
  68225. /** @hidden */
  68226. export enum EShaderType {
  68227. FRAGMENT = 35632,
  68228. VERTEX = 35633
  68229. }
  68230. /** @hidden */
  68231. export enum EParameterType {
  68232. BYTE = 5120,
  68233. UNSIGNED_BYTE = 5121,
  68234. SHORT = 5122,
  68235. UNSIGNED_SHORT = 5123,
  68236. INT = 5124,
  68237. UNSIGNED_INT = 5125,
  68238. FLOAT = 5126,
  68239. FLOAT_VEC2 = 35664,
  68240. FLOAT_VEC3 = 35665,
  68241. FLOAT_VEC4 = 35666,
  68242. INT_VEC2 = 35667,
  68243. INT_VEC3 = 35668,
  68244. INT_VEC4 = 35669,
  68245. BOOL = 35670,
  68246. BOOL_VEC2 = 35671,
  68247. BOOL_VEC3 = 35672,
  68248. BOOL_VEC4 = 35673,
  68249. FLOAT_MAT2 = 35674,
  68250. FLOAT_MAT3 = 35675,
  68251. FLOAT_MAT4 = 35676,
  68252. SAMPLER_2D = 35678
  68253. }
  68254. /** @hidden */
  68255. export enum ETextureWrapMode {
  68256. CLAMP_TO_EDGE = 33071,
  68257. MIRRORED_REPEAT = 33648,
  68258. REPEAT = 10497
  68259. }
  68260. /** @hidden */
  68261. export enum ETextureFilterType {
  68262. NEAREST = 9728,
  68263. LINEAR = 9728,
  68264. NEAREST_MIPMAP_NEAREST = 9984,
  68265. LINEAR_MIPMAP_NEAREST = 9985,
  68266. NEAREST_MIPMAP_LINEAR = 9986,
  68267. LINEAR_MIPMAP_LINEAR = 9987
  68268. }
  68269. /** @hidden */
  68270. export enum ETextureFormat {
  68271. ALPHA = 6406,
  68272. RGB = 6407,
  68273. RGBA = 6408,
  68274. LUMINANCE = 6409,
  68275. LUMINANCE_ALPHA = 6410
  68276. }
  68277. /** @hidden */
  68278. export enum ECullingType {
  68279. FRONT = 1028,
  68280. BACK = 1029,
  68281. FRONT_AND_BACK = 1032
  68282. }
  68283. /** @hidden */
  68284. export enum EBlendingFunction {
  68285. ZERO = 0,
  68286. ONE = 1,
  68287. SRC_COLOR = 768,
  68288. ONE_MINUS_SRC_COLOR = 769,
  68289. DST_COLOR = 774,
  68290. ONE_MINUS_DST_COLOR = 775,
  68291. SRC_ALPHA = 770,
  68292. ONE_MINUS_SRC_ALPHA = 771,
  68293. DST_ALPHA = 772,
  68294. ONE_MINUS_DST_ALPHA = 773,
  68295. CONSTANT_COLOR = 32769,
  68296. ONE_MINUS_CONSTANT_COLOR = 32770,
  68297. CONSTANT_ALPHA = 32771,
  68298. ONE_MINUS_CONSTANT_ALPHA = 32772,
  68299. SRC_ALPHA_SATURATE = 776
  68300. }
  68301. /** @hidden */
  68302. export interface IGLTFProperty {
  68303. extensions?: {
  68304. [key: string]: any;
  68305. };
  68306. extras?: Object;
  68307. }
  68308. /** @hidden */
  68309. export interface IGLTFChildRootProperty extends IGLTFProperty {
  68310. name?: string;
  68311. }
  68312. /** @hidden */
  68313. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  68314. bufferView: string;
  68315. byteOffset: number;
  68316. byteStride: number;
  68317. count: number;
  68318. type: string;
  68319. componentType: EComponentType;
  68320. max?: number[];
  68321. min?: number[];
  68322. name?: string;
  68323. }
  68324. /** @hidden */
  68325. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  68326. buffer: string;
  68327. byteOffset: number;
  68328. byteLength: number;
  68329. byteStride: number;
  68330. target?: number;
  68331. }
  68332. /** @hidden */
  68333. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  68334. uri: string;
  68335. byteLength?: number;
  68336. type?: string;
  68337. }
  68338. /** @hidden */
  68339. export interface IGLTFShader extends IGLTFChildRootProperty {
  68340. uri: string;
  68341. type: EShaderType;
  68342. }
  68343. /** @hidden */
  68344. export interface IGLTFProgram extends IGLTFChildRootProperty {
  68345. attributes: string[];
  68346. fragmentShader: string;
  68347. vertexShader: string;
  68348. }
  68349. /** @hidden */
  68350. export interface IGLTFTechniqueParameter {
  68351. type: number;
  68352. count?: number;
  68353. semantic?: string;
  68354. node?: string;
  68355. value?: number | boolean | string | Array<any>;
  68356. source?: string;
  68357. babylonValue?: any;
  68358. }
  68359. /** @hidden */
  68360. export interface IGLTFTechniqueCommonProfile {
  68361. lightingModel: string;
  68362. texcoordBindings: Object;
  68363. parameters?: Array<any>;
  68364. }
  68365. /** @hidden */
  68366. export interface IGLTFTechniqueStatesFunctions {
  68367. blendColor?: number[];
  68368. blendEquationSeparate?: number[];
  68369. blendFuncSeparate?: number[];
  68370. colorMask: boolean[];
  68371. cullFace: number[];
  68372. }
  68373. /** @hidden */
  68374. export interface IGLTFTechniqueStates {
  68375. enable: number[];
  68376. functions: IGLTFTechniqueStatesFunctions;
  68377. }
  68378. /** @hidden */
  68379. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  68380. parameters: {
  68381. [key: string]: IGLTFTechniqueParameter;
  68382. };
  68383. program: string;
  68384. attributes: {
  68385. [key: string]: string;
  68386. };
  68387. uniforms: {
  68388. [key: string]: string;
  68389. };
  68390. states: IGLTFTechniqueStates;
  68391. }
  68392. /** @hidden */
  68393. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  68394. technique?: string;
  68395. values: string[];
  68396. }
  68397. /** @hidden */
  68398. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  68399. attributes: {
  68400. [key: string]: string;
  68401. };
  68402. indices: string;
  68403. material: string;
  68404. mode?: number;
  68405. }
  68406. /** @hidden */
  68407. export interface IGLTFMesh extends IGLTFChildRootProperty {
  68408. primitives: IGLTFMeshPrimitive[];
  68409. }
  68410. /** @hidden */
  68411. export interface IGLTFImage extends IGLTFChildRootProperty {
  68412. uri: string;
  68413. }
  68414. /** @hidden */
  68415. export interface IGLTFSampler extends IGLTFChildRootProperty {
  68416. magFilter?: number;
  68417. minFilter?: number;
  68418. wrapS?: number;
  68419. wrapT?: number;
  68420. }
  68421. /** @hidden */
  68422. export interface IGLTFTexture extends IGLTFChildRootProperty {
  68423. sampler: string;
  68424. source: string;
  68425. format?: ETextureFormat;
  68426. internalFormat?: ETextureFormat;
  68427. target?: number;
  68428. type?: number;
  68429. babylonTexture?: Texture;
  68430. }
  68431. /** @hidden */
  68432. export interface IGLTFAmbienLight {
  68433. color?: number[];
  68434. }
  68435. /** @hidden */
  68436. export interface IGLTFDirectionalLight {
  68437. color?: number[];
  68438. }
  68439. /** @hidden */
  68440. export interface IGLTFPointLight {
  68441. color?: number[];
  68442. constantAttenuation?: number;
  68443. linearAttenuation?: number;
  68444. quadraticAttenuation?: number;
  68445. }
  68446. /** @hidden */
  68447. export interface IGLTFSpotLight {
  68448. color?: number[];
  68449. constantAttenuation?: number;
  68450. fallOfAngle?: number;
  68451. fallOffExponent?: number;
  68452. linearAttenuation?: number;
  68453. quadraticAttenuation?: number;
  68454. }
  68455. /** @hidden */
  68456. export interface IGLTFLight extends IGLTFChildRootProperty {
  68457. type: string;
  68458. }
  68459. /** @hidden */
  68460. export interface IGLTFCameraOrthographic {
  68461. xmag: number;
  68462. ymag: number;
  68463. zfar: number;
  68464. znear: number;
  68465. }
  68466. /** @hidden */
  68467. export interface IGLTFCameraPerspective {
  68468. aspectRatio: number;
  68469. yfov: number;
  68470. zfar: number;
  68471. znear: number;
  68472. }
  68473. /** @hidden */
  68474. export interface IGLTFCamera extends IGLTFChildRootProperty {
  68475. type: string;
  68476. }
  68477. /** @hidden */
  68478. export interface IGLTFAnimationChannelTarget {
  68479. id: string;
  68480. path: string;
  68481. }
  68482. /** @hidden */
  68483. export interface IGLTFAnimationChannel {
  68484. sampler: string;
  68485. target: IGLTFAnimationChannelTarget;
  68486. }
  68487. /** @hidden */
  68488. export interface IGLTFAnimationSampler {
  68489. input: string;
  68490. output: string;
  68491. interpolation?: string;
  68492. }
  68493. /** @hidden */
  68494. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  68495. channels?: IGLTFAnimationChannel[];
  68496. parameters?: {
  68497. [key: string]: string;
  68498. };
  68499. samplers?: {
  68500. [key: string]: IGLTFAnimationSampler;
  68501. };
  68502. }
  68503. /** @hidden */
  68504. export interface IGLTFNodeInstanceSkin {
  68505. skeletons: string[];
  68506. skin: string;
  68507. meshes: string[];
  68508. }
  68509. /** @hidden */
  68510. export interface IGLTFSkins extends IGLTFChildRootProperty {
  68511. bindShapeMatrix: number[];
  68512. inverseBindMatrices: string;
  68513. jointNames: string[];
  68514. babylonSkeleton?: Skeleton;
  68515. }
  68516. /** @hidden */
  68517. export interface IGLTFNode extends IGLTFChildRootProperty {
  68518. camera?: string;
  68519. children: string[];
  68520. skin?: string;
  68521. jointName?: string;
  68522. light?: string;
  68523. matrix: number[];
  68524. mesh?: string;
  68525. meshes?: string[];
  68526. rotation?: number[];
  68527. scale?: number[];
  68528. translation?: number[];
  68529. babylonNode?: Node;
  68530. }
  68531. /** @hidden */
  68532. export interface IGLTFScene extends IGLTFChildRootProperty {
  68533. nodes: string[];
  68534. }
  68535. /** @hidden */
  68536. export interface IGLTFRuntime {
  68537. extensions: {
  68538. [key: string]: any;
  68539. };
  68540. accessors: {
  68541. [key: string]: IGLTFAccessor;
  68542. };
  68543. buffers: {
  68544. [key: string]: IGLTFBuffer;
  68545. };
  68546. bufferViews: {
  68547. [key: string]: IGLTFBufferView;
  68548. };
  68549. meshes: {
  68550. [key: string]: IGLTFMesh;
  68551. };
  68552. lights: {
  68553. [key: string]: IGLTFLight;
  68554. };
  68555. cameras: {
  68556. [key: string]: IGLTFCamera;
  68557. };
  68558. nodes: {
  68559. [key: string]: IGLTFNode;
  68560. };
  68561. images: {
  68562. [key: string]: IGLTFImage;
  68563. };
  68564. textures: {
  68565. [key: string]: IGLTFTexture;
  68566. };
  68567. shaders: {
  68568. [key: string]: IGLTFShader;
  68569. };
  68570. programs: {
  68571. [key: string]: IGLTFProgram;
  68572. };
  68573. samplers: {
  68574. [key: string]: IGLTFSampler;
  68575. };
  68576. techniques: {
  68577. [key: string]: IGLTFTechnique;
  68578. };
  68579. materials: {
  68580. [key: string]: IGLTFMaterial;
  68581. };
  68582. animations: {
  68583. [key: string]: IGLTFAnimation;
  68584. };
  68585. skins: {
  68586. [key: string]: IGLTFSkins;
  68587. };
  68588. currentScene?: Object;
  68589. scenes: {
  68590. [key: string]: IGLTFScene;
  68591. };
  68592. extensionsUsed: string[];
  68593. extensionsRequired?: string[];
  68594. buffersCount: number;
  68595. shaderscount: number;
  68596. scene: Scene;
  68597. rootUrl: string;
  68598. loadedBufferCount: number;
  68599. loadedBufferViews: {
  68600. [name: string]: ArrayBufferView;
  68601. };
  68602. loadedShaderCount: number;
  68603. importOnlyMeshes: boolean;
  68604. importMeshesNames?: string[];
  68605. dummyNodes: Node[];
  68606. }
  68607. /** @hidden */
  68608. export interface INodeToRoot {
  68609. bone: Bone;
  68610. node: IGLTFNode;
  68611. id: string;
  68612. }
  68613. /** @hidden */
  68614. export interface IJointNode {
  68615. node: IGLTFNode;
  68616. id: string;
  68617. }
  68618. }
  68619. declare module BABYLON.GLTF1 {
  68620. /**
  68621. * Utils functions for GLTF
  68622. * @hidden
  68623. */
  68624. export class GLTFUtils {
  68625. /**
  68626. * Sets the given "parameter" matrix
  68627. * @param scene: the Scene object
  68628. * @param source: the source node where to pick the matrix
  68629. * @param parameter: the GLTF technique parameter
  68630. * @param uniformName: the name of the shader's uniform
  68631. * @param shaderMaterial: the shader material
  68632. */
  68633. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  68634. /**
  68635. * Sets the given "parameter" matrix
  68636. * @param shaderMaterial: the shader material
  68637. * @param uniform: the name of the shader's uniform
  68638. * @param value: the value of the uniform
  68639. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  68640. */
  68641. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  68642. /**
  68643. * Returns the wrap mode of the texture
  68644. * @param mode: the mode value
  68645. */
  68646. static GetWrapMode(mode: number): number;
  68647. /**
  68648. * Returns the byte stride giving an accessor
  68649. * @param accessor: the GLTF accessor objet
  68650. */
  68651. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  68652. /**
  68653. * Returns the texture filter mode giving a mode value
  68654. * @param mode: the filter mode value
  68655. */
  68656. static GetTextureFilterMode(mode: number): ETextureFilterType;
  68657. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  68658. /**
  68659. * Returns a buffer from its accessor
  68660. * @param gltfRuntime: the GLTF runtime
  68661. * @param accessor: the GLTF accessor
  68662. */
  68663. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  68664. /**
  68665. * Decodes a buffer view into a string
  68666. * @param view: the buffer view
  68667. */
  68668. static DecodeBufferToText(view: ArrayBufferView): string;
  68669. /**
  68670. * Returns the default material of gltf. Related to
  68671. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  68672. * @param scene: the Babylon.js scene
  68673. */
  68674. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  68675. private static _DefaultMaterial;
  68676. }
  68677. }
  68678. declare module BABYLON.GLTF1 {
  68679. /**
  68680. * Implementation of the base glTF spec
  68681. * @hidden
  68682. */
  68683. export class GLTFLoaderBase {
  68684. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  68685. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68686. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  68687. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68688. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  68689. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68690. }
  68691. /**
  68692. * glTF V1 Loader
  68693. * @hidden
  68694. */
  68695. export class GLTFLoader implements IGLTFLoader {
  68696. static Extensions: {
  68697. [name: string]: GLTFLoaderExtension;
  68698. };
  68699. static RegisterExtension(extension: GLTFLoaderExtension): void;
  68700. state: Nullable<GLTFLoaderState>;
  68701. dispose(): void;
  68702. private _importMeshAsync;
  68703. /**
  68704. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  68705. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68706. * @param scene the scene the meshes should be added to
  68707. * @param data gltf data containing information of the meshes in a loaded file
  68708. * @param rootUrl root url to load from
  68709. * @param onProgress event that fires when loading progress has occured
  68710. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68711. */
  68712. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  68713. meshes: AbstractMesh[];
  68714. particleSystems: IParticleSystem[];
  68715. skeletons: Skeleton[];
  68716. animationGroups: AnimationGroup[];
  68717. }>;
  68718. private _loadAsync;
  68719. /**
  68720. * Imports all objects from a loaded gltf file and adds them to the scene
  68721. * @param scene the scene the objects should be added to
  68722. * @param data gltf data containing information of the meshes in a loaded file
  68723. * @param rootUrl root url to load from
  68724. * @param onProgress event that fires when loading progress has occured
  68725. * @returns a promise which completes when objects have been loaded to the scene
  68726. */
  68727. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  68728. private _loadShadersAsync;
  68729. private _loadBuffersAsync;
  68730. private _createNodes;
  68731. }
  68732. /** @hidden */
  68733. export abstract class GLTFLoaderExtension {
  68734. private _name;
  68735. constructor(name: string);
  68736. readonly name: string;
  68737. /**
  68738. * Defines an override for loading the runtime
  68739. * Return true to stop further extensions from loading the runtime
  68740. */
  68741. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  68742. /**
  68743. * Defines an onverride for creating gltf runtime
  68744. * Return true to stop further extensions from creating the runtime
  68745. */
  68746. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  68747. /**
  68748. * Defines an override for loading buffers
  68749. * Return true to stop further extensions from loading this buffer
  68750. */
  68751. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  68752. /**
  68753. * Defines an override for loading texture buffers
  68754. * Return true to stop further extensions from loading this texture data
  68755. */
  68756. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68757. /**
  68758. * Defines an override for creating textures
  68759. * Return true to stop further extensions from loading this texture
  68760. */
  68761. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  68762. /**
  68763. * Defines an override for loading shader strings
  68764. * Return true to stop further extensions from loading this shader data
  68765. */
  68766. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68767. /**
  68768. * Defines an override for loading materials
  68769. * Return true to stop further extensions from loading this material
  68770. */
  68771. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68772. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  68773. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  68774. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68775. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68776. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  68777. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68778. private static LoadTextureBufferAsync;
  68779. private static CreateTextureAsync;
  68780. private static ApplyExtensions;
  68781. }
  68782. }
  68783. declare module BABYLON.GLTF1 {
  68784. /** @hidden */
  68785. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  68786. private _bin;
  68787. constructor();
  68788. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  68789. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68790. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68791. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68792. }
  68793. }
  68794. declare module BABYLON.GLTF1 {
  68795. /** @hidden */
  68796. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  68797. constructor();
  68798. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  68799. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68800. private _loadTexture;
  68801. }
  68802. }
  68803. declare module BABYLON.GLTF2.Loader {
  68804. /**
  68805. * Loader interface with an index field.
  68806. */
  68807. export interface IArrayItem {
  68808. /**
  68809. * The index of this item in the array.
  68810. */
  68811. index: number;
  68812. }
  68813. /**
  68814. * Loader interface with additional members.
  68815. */
  68816. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  68817. /** @hidden */
  68818. _data?: Promise<ArrayBufferView>;
  68819. /** @hidden */
  68820. _babylonVertexBuffer?: Promise<VertexBuffer>;
  68821. }
  68822. /**
  68823. * Loader interface with additional members.
  68824. */
  68825. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  68826. }
  68827. /** @hidden */
  68828. export interface _IAnimationSamplerData {
  68829. input: Float32Array;
  68830. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  68831. output: Float32Array;
  68832. }
  68833. /**
  68834. * Loader interface with additional members.
  68835. */
  68836. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  68837. /** @hidden */
  68838. _data?: Promise<_IAnimationSamplerData>;
  68839. }
  68840. /**
  68841. * Loader interface with additional members.
  68842. */
  68843. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  68844. channels: IAnimationChannel[];
  68845. samplers: IAnimationSampler[];
  68846. /** @hidden */
  68847. _babylonAnimationGroup?: AnimationGroup;
  68848. }
  68849. /**
  68850. * Loader interface with additional members.
  68851. */
  68852. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  68853. /** @hidden */
  68854. _data?: Promise<ArrayBufferView>;
  68855. }
  68856. /**
  68857. * Loader interface with additional members.
  68858. */
  68859. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68860. /** @hidden */
  68861. _data?: Promise<ArrayBufferView>;
  68862. /** @hidden */
  68863. _babylonBuffer?: Promise<Buffer>;
  68864. }
  68865. /**
  68866. * Loader interface with additional members.
  68867. */
  68868. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68869. }
  68870. /**
  68871. * Loader interface with additional members.
  68872. */
  68873. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68874. /** @hidden */
  68875. _data?: Promise<ArrayBufferView>;
  68876. }
  68877. /**
  68878. * Loader interface with additional members.
  68879. */
  68880. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68881. }
  68882. /**
  68883. * Loader interface with additional members.
  68884. */
  68885. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68886. }
  68887. /**
  68888. * Loader interface with additional members.
  68889. */
  68890. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68891. baseColorTexture?: ITextureInfo;
  68892. metallicRoughnessTexture?: ITextureInfo;
  68893. }
  68894. /**
  68895. * Loader interface with additional members.
  68896. */
  68897. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68898. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68899. normalTexture?: IMaterialNormalTextureInfo;
  68900. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68901. emissiveTexture?: ITextureInfo;
  68902. /** @hidden */
  68903. _data?: {
  68904. [babylonDrawMode: number]: {
  68905. babylonMaterial: Material;
  68906. babylonMeshes: AbstractMesh[];
  68907. promise: Promise<void>;
  68908. };
  68909. };
  68910. }
  68911. /**
  68912. * Loader interface with additional members.
  68913. */
  68914. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  68915. primitives: IMeshPrimitive[];
  68916. }
  68917. /**
  68918. * Loader interface with additional members.
  68919. */
  68920. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  68921. /** @hidden */
  68922. _instanceData?: {
  68923. babylonSourceMesh: Mesh;
  68924. promise: Promise<any>;
  68925. };
  68926. }
  68927. /**
  68928. * Loader interface with additional members.
  68929. */
  68930. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  68931. /**
  68932. * The parent glTF node.
  68933. */
  68934. parent?: INode;
  68935. /** @hidden */
  68936. _babylonTransformNode?: TransformNode;
  68937. /** @hidden */
  68938. _primitiveBabylonMeshes?: AbstractMesh[];
  68939. /** @hidden */
  68940. _babylonBones?: Bone[];
  68941. /** @hidden */
  68942. _numMorphTargets?: number;
  68943. }
  68944. /** @hidden */
  68945. export interface _ISamplerData {
  68946. noMipMaps: boolean;
  68947. samplingMode: number;
  68948. wrapU: number;
  68949. wrapV: number;
  68950. }
  68951. /**
  68952. * Loader interface with additional members.
  68953. */
  68954. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  68955. /** @hidden */
  68956. _data?: _ISamplerData;
  68957. }
  68958. /**
  68959. * Loader interface with additional members.
  68960. */
  68961. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  68962. }
  68963. /**
  68964. * Loader interface with additional members.
  68965. */
  68966. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  68967. /** @hidden */
  68968. _data?: {
  68969. babylonSkeleton: Skeleton;
  68970. promise: Promise<void>;
  68971. };
  68972. }
  68973. /**
  68974. * Loader interface with additional members.
  68975. */
  68976. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  68977. }
  68978. /**
  68979. * Loader interface with additional members.
  68980. */
  68981. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  68982. }
  68983. /**
  68984. * Loader interface with additional members.
  68985. */
  68986. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  68987. accessors?: IAccessor[];
  68988. animations?: IAnimation[];
  68989. buffers?: IBuffer[];
  68990. bufferViews?: IBufferView[];
  68991. cameras?: ICamera[];
  68992. images?: IImage[];
  68993. materials?: IMaterial[];
  68994. meshes?: IMesh[];
  68995. nodes?: INode[];
  68996. samplers?: ISampler[];
  68997. scenes?: IScene[];
  68998. skins?: ISkin[];
  68999. textures?: ITexture[];
  69000. }
  69001. }
  69002. declare module BABYLON.GLTF2 {
  69003. /**
  69004. * Interface for a glTF loader extension.
  69005. */
  69006. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  69007. /**
  69008. * Called after the loader state changes to LOADING.
  69009. */
  69010. onLoading?(): void;
  69011. /**
  69012. * Called after the loader state changes to READY.
  69013. */
  69014. onReady?(): void;
  69015. /**
  69016. * Define this method to modify the default behavior when loading scenes.
  69017. * @param context The context when loading the asset
  69018. * @param scene The glTF scene property
  69019. * @returns A promise that resolves when the load is complete or null if not handled
  69020. */
  69021. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  69022. /**
  69023. * Define this method to modify the default behavior when loading nodes.
  69024. * @param context The context when loading the asset
  69025. * @param node The glTF node property
  69026. * @param assign A function called synchronously after parsing the glTF properties
  69027. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  69028. */
  69029. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69030. /**
  69031. * Define this method to modify the default behavior when loading cameras.
  69032. * @param context The context when loading the asset
  69033. * @param camera The glTF camera property
  69034. * @param assign A function called synchronously after parsing the glTF properties
  69035. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  69036. */
  69037. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69038. /**
  69039. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  69040. * @param context The context when loading the asset
  69041. * @param primitive The glTF mesh primitive property
  69042. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  69043. */
  69044. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69045. /**
  69046. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69047. * @param context The context when loading the asset
  69048. * @param name The mesh name when loading the asset
  69049. * @param node The glTF node when loading the asset
  69050. * @param mesh The glTF mesh when loading the asset
  69051. * @param primitive The glTF mesh primitive property
  69052. * @param assign A function called synchronously after parsing the glTF properties
  69053. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69054. */
  69055. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69056. /**
  69057. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  69058. * @param context The context when loading the asset
  69059. * @param material The glTF material property
  69060. * @param assign A function called synchronously after parsing the glTF properties
  69061. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  69062. */
  69063. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69064. /**
  69065. * Define this method to modify the default behavior when creating materials.
  69066. * @param context The context when loading the asset
  69067. * @param material The glTF material property
  69068. * @param babylonDrawMode The draw mode for the Babylon material
  69069. * @returns The Babylon material or null if not handled
  69070. */
  69071. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69072. /**
  69073. * Define this method to modify the default behavior when loading material properties.
  69074. * @param context The context when loading the asset
  69075. * @param material The glTF material property
  69076. * @param babylonMaterial The Babylon material
  69077. * @returns A promise that resolves when the load is complete or null if not handled
  69078. */
  69079. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69080. /**
  69081. * Define this method to modify the default behavior when loading texture infos.
  69082. * @param context The context when loading the asset
  69083. * @param textureInfo The glTF texture info property
  69084. * @param assign A function called synchronously after parsing the glTF properties
  69085. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  69086. */
  69087. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69088. /**
  69089. * Define this method to modify the default behavior when loading animations.
  69090. * @param context The context when loading the asset
  69091. * @param animation The glTF animation property
  69092. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  69093. */
  69094. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69095. /**
  69096. * @hidden Define this method to modify the default behavior when loading skins.
  69097. * @param context The context when loading the asset
  69098. * @param node The glTF node property
  69099. * @param skin The glTF skin property
  69100. * @returns A promise that resolves when the load is complete or null if not handled
  69101. */
  69102. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  69103. /**
  69104. * @hidden Define this method to modify the default behavior when loading uris.
  69105. * @param context The context when loading the asset
  69106. * @param property The glTF property associated with the uri
  69107. * @param uri The uri to load
  69108. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69109. */
  69110. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69111. /**
  69112. * Define this method to modify the default behavior when loading buffer views.
  69113. * @param context The context when loading the asset
  69114. * @param bufferView The glTF buffer view property
  69115. * @returns A promise that resolves with the loaded buffer view when the load is complete or null if not handled
  69116. */
  69117. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  69118. }
  69119. }
  69120. declare module BABYLON.GLTF2 {
  69121. /**
  69122. * Helper class for working with arrays when loading the glTF asset
  69123. */
  69124. export class ArrayItem {
  69125. /**
  69126. * Gets an item from the given array.
  69127. * @param context The context when loading the asset
  69128. * @param array The array to get the item from
  69129. * @param index The index to the array
  69130. * @returns The array item
  69131. */
  69132. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  69133. /**
  69134. * Assign an `index` field to each item of the given array.
  69135. * @param array The array of items
  69136. */
  69137. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  69138. }
  69139. /**
  69140. * The glTF 2.0 loader
  69141. */
  69142. export class GLTFLoader implements IGLTFLoader {
  69143. /** @hidden */
  69144. _completePromises: Promise<any>[];
  69145. private _disposed;
  69146. private _parent;
  69147. private _state;
  69148. private _extensions;
  69149. private _rootUrl;
  69150. private _fileName;
  69151. private _uniqueRootUrl;
  69152. private _gltf;
  69153. private _babylonScene;
  69154. private _rootBabylonMesh;
  69155. private _defaultBabylonMaterialData;
  69156. private _progressCallback?;
  69157. private _requests;
  69158. private static readonly _DefaultSampler;
  69159. private static _ExtensionNames;
  69160. private static _ExtensionFactories;
  69161. /**
  69162. * Registers a loader extension.
  69163. * @param name The name of the loader extension.
  69164. * @param factory The factory function that creates the loader extension.
  69165. */
  69166. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  69167. /**
  69168. * Unregisters a loader extension.
  69169. * @param name The name of the loader extenion.
  69170. * @returns A boolean indicating whether the extension has been unregistered
  69171. */
  69172. static UnregisterExtension(name: string): boolean;
  69173. /**
  69174. * Gets the loader state.
  69175. */
  69176. readonly state: Nullable<GLTFLoaderState>;
  69177. /**
  69178. * The glTF object parsed from the JSON.
  69179. */
  69180. readonly gltf: IGLTF;
  69181. /**
  69182. * The Babylon scene when loading the asset.
  69183. */
  69184. readonly babylonScene: Scene;
  69185. /**
  69186. * The root Babylon mesh when loading the asset.
  69187. */
  69188. readonly rootBabylonMesh: Mesh;
  69189. /** @hidden */
  69190. constructor(parent: GLTFFileLoader);
  69191. /** @hidden */
  69192. dispose(): void;
  69193. /** @hidden */
  69194. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69195. meshes: AbstractMesh[];
  69196. particleSystems: IParticleSystem[];
  69197. skeletons: Skeleton[];
  69198. animationGroups: AnimationGroup[];
  69199. }>;
  69200. /** @hidden */
  69201. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69202. private _loadAsync;
  69203. private _loadData;
  69204. private _setupData;
  69205. private _loadExtensions;
  69206. private _checkExtensions;
  69207. private _setState;
  69208. private _createRootNode;
  69209. /**
  69210. * Loads a glTF scene.
  69211. * @param context The context when loading the asset
  69212. * @param scene The glTF scene property
  69213. * @returns A promise that resolves when the load is complete
  69214. */
  69215. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  69216. private _forEachPrimitive;
  69217. private _getMeshes;
  69218. private _getSkeletons;
  69219. private _getAnimationGroups;
  69220. private _startAnimations;
  69221. /**
  69222. * Loads a glTF node.
  69223. * @param context The context when loading the asset
  69224. * @param node The glTF node property
  69225. * @param assign A function called synchronously after parsing the glTF properties
  69226. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  69227. */
  69228. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  69229. private _loadMeshAsync;
  69230. /**
  69231. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69232. * @param context The context when loading the asset
  69233. * @param name The mesh name when loading the asset
  69234. * @param node The glTF node when loading the asset
  69235. * @param mesh The glTF mesh when loading the asset
  69236. * @param primitive The glTF mesh primitive property
  69237. * @param assign A function called synchronously after parsing the glTF properties
  69238. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69239. */
  69240. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69241. private _loadVertexDataAsync;
  69242. private _createMorphTargets;
  69243. private _loadMorphTargetsAsync;
  69244. private _loadMorphTargetVertexDataAsync;
  69245. private static _LoadTransform;
  69246. private _loadSkinAsync;
  69247. private _loadBones;
  69248. private _loadBone;
  69249. private _loadSkinInverseBindMatricesDataAsync;
  69250. private _updateBoneMatrices;
  69251. private _getNodeMatrix;
  69252. /**
  69253. * Loads a glTF camera.
  69254. * @param context The context when loading the asset
  69255. * @param camera The glTF camera property
  69256. * @param assign A function called synchronously after parsing the glTF properties
  69257. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  69258. */
  69259. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  69260. private _loadAnimationsAsync;
  69261. /**
  69262. * Loads a glTF animation.
  69263. * @param context The context when loading the asset
  69264. * @param animation The glTF animation property
  69265. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  69266. */
  69267. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  69268. /**
  69269. * @hidden Loads a glTF animation channel.
  69270. * @param context The context when loading the asset
  69271. * @param animationContext The context of the animation when loading the asset
  69272. * @param animation The glTF animation property
  69273. * @param channel The glTF animation channel property
  69274. * @param babylonAnimationGroup The babylon animation group property
  69275. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  69276. * @returns A void promise when the channel load is complete
  69277. */
  69278. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  69279. private _loadAnimationSamplerAsync;
  69280. private _loadBufferAsync;
  69281. /**
  69282. * Loads a glTF buffer view.
  69283. * @param context The context when loading the asset
  69284. * @param bufferView The glTF buffer view property
  69285. * @returns A promise that resolves with the loaded data when the load is complete
  69286. */
  69287. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  69288. private _loadAccessorAsync;
  69289. private _loadFloatAccessorAsync;
  69290. private _loadIndicesAccessorAsync;
  69291. private _loadVertexBufferViewAsync;
  69292. private _loadVertexAccessorAsync;
  69293. private _loadMaterialMetallicRoughnessPropertiesAsync;
  69294. /** @hidden */
  69295. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  69296. private _createDefaultMaterial;
  69297. /**
  69298. * Creates a Babylon material from a glTF material.
  69299. * @param context The context when loading the asset
  69300. * @param material The glTF material property
  69301. * @param babylonDrawMode The draw mode for the Babylon material
  69302. * @returns The Babylon material
  69303. */
  69304. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  69305. /**
  69306. * Loads properties from a glTF material into a Babylon material.
  69307. * @param context The context when loading the asset
  69308. * @param material The glTF material property
  69309. * @param babylonMaterial The Babylon material
  69310. * @returns A promise that resolves when the load is complete
  69311. */
  69312. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69313. /**
  69314. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  69315. * @param context The context when loading the asset
  69316. * @param material The glTF material property
  69317. * @param babylonMaterial The Babylon material
  69318. * @returns A promise that resolves when the load is complete
  69319. */
  69320. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69321. /**
  69322. * Loads the alpha properties from a glTF material into a Babylon material.
  69323. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  69324. * @param context The context when loading the asset
  69325. * @param material The glTF material property
  69326. * @param babylonMaterial The Babylon material
  69327. */
  69328. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  69329. /**
  69330. * Loads a glTF texture info.
  69331. * @param context The context when loading the asset
  69332. * @param textureInfo The glTF texture info property
  69333. * @param assign A function called synchronously after parsing the glTF properties
  69334. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  69335. */
  69336. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  69337. private _loadTextureAsync;
  69338. private _loadSampler;
  69339. /**
  69340. * Loads a glTF image.
  69341. * @param context The context when loading the asset
  69342. * @param image The glTF image property
  69343. * @returns A promise that resolves with the loaded data when the load is complete
  69344. */
  69345. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  69346. /**
  69347. * Loads a glTF uri.
  69348. * @param context The context when loading the asset
  69349. * @param property The glTF property associated with the uri
  69350. * @param uri The base64 or relative uri
  69351. * @returns A promise that resolves with the loaded data when the load is complete
  69352. */
  69353. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  69354. private _onProgress;
  69355. /**
  69356. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  69357. * @param babylonObject the Babylon object with metadata
  69358. * @param pointer the JSON pointer
  69359. */
  69360. static AddPointerMetadata(babylonObject: {
  69361. metadata: any;
  69362. }, pointer: string): void;
  69363. private static _GetTextureWrapMode;
  69364. private static _GetTextureSamplingMode;
  69365. private static _GetTypedArrayConstructor;
  69366. private static _GetTypedArray;
  69367. private static _GetNumComponents;
  69368. private static _ValidateUri;
  69369. private static _GetDrawMode;
  69370. private _compileMaterialsAsync;
  69371. private _compileShadowGeneratorsAsync;
  69372. private _forEachExtensions;
  69373. private _applyExtensions;
  69374. private _extensionsOnLoading;
  69375. private _extensionsOnReady;
  69376. private _extensionsLoadSceneAsync;
  69377. private _extensionsLoadNodeAsync;
  69378. private _extensionsLoadCameraAsync;
  69379. private _extensionsLoadVertexDataAsync;
  69380. private _extensionsLoadMeshPrimitiveAsync;
  69381. private _extensionsLoadMaterialAsync;
  69382. private _extensionsCreateMaterial;
  69383. private _extensionsLoadMaterialPropertiesAsync;
  69384. private _extensionsLoadTextureInfoAsync;
  69385. private _extensionsLoadAnimationAsync;
  69386. private _extensionsLoadSkinAsync;
  69387. private _extensionsLoadUriAsync;
  69388. private _extensionsLoadBufferViewAsync;
  69389. /**
  69390. * Helper method called by a loader extension to load an glTF extension.
  69391. * @param context The context when loading the asset
  69392. * @param property The glTF property to load the extension from
  69393. * @param extensionName The name of the extension to load
  69394. * @param actionAsync The action to run
  69395. * @returns The promise returned by actionAsync or null if the extension does not exist
  69396. */
  69397. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69398. /**
  69399. * Helper method called by a loader extension to load a glTF extra.
  69400. * @param context The context when loading the asset
  69401. * @param property The glTF property to load the extra 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 extra does not exist
  69405. */
  69406. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69407. /**
  69408. * Increments the indentation level and logs a message.
  69409. * @param message The message to log
  69410. */
  69411. logOpen(message: string): void;
  69412. /**
  69413. * Decrements the indentation level.
  69414. */
  69415. logClose(): void;
  69416. /**
  69417. * Logs a message
  69418. * @param message The message to log
  69419. */
  69420. log(message: string): void;
  69421. /**
  69422. * Starts a performance counter.
  69423. * @param counterName The name of the performance counter
  69424. */
  69425. startPerformanceCounter(counterName: string): void;
  69426. /**
  69427. * Ends a performance counter.
  69428. * @param counterName The name of the performance counter
  69429. */
  69430. endPerformanceCounter(counterName: string): void;
  69431. }
  69432. }
  69433. declare module BABYLON.GLTF2.Loader.Extensions {
  69434. /**
  69435. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  69436. */
  69437. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  69438. /** The name of this extension. */
  69439. readonly name: string;
  69440. /** Defines whether this extension is enabled. */
  69441. enabled: boolean;
  69442. private _loader;
  69443. private _lights?;
  69444. /** @hidden */
  69445. constructor(loader: GLTFLoader);
  69446. /** @hidden */
  69447. dispose(): void;
  69448. /** @hidden */
  69449. onLoading(): void;
  69450. /** @hidden */
  69451. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69452. private _loadLightAsync;
  69453. }
  69454. }
  69455. declare module BABYLON.GLTF2.Loader.Extensions {
  69456. /**
  69457. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  69458. */
  69459. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  69460. /** The name of this extension. */
  69461. readonly name: string;
  69462. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  69463. dracoCompression?: DracoCompression;
  69464. /** Defines whether this extension is enabled. */
  69465. enabled: boolean;
  69466. private _loader;
  69467. /** @hidden */
  69468. constructor(loader: GLTFLoader);
  69469. /** @hidden */
  69470. dispose(): void;
  69471. /** @hidden */
  69472. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69473. }
  69474. }
  69475. declare module BABYLON.GLTF2.Loader.Extensions {
  69476. /**
  69477. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  69478. */
  69479. export class KHR_lights implements IGLTFLoaderExtension {
  69480. /** The name of this extension. */
  69481. readonly name: string;
  69482. /** Defines whether this extension is enabled. */
  69483. enabled: boolean;
  69484. private _loader;
  69485. private _lights?;
  69486. /** @hidden */
  69487. constructor(loader: GLTFLoader);
  69488. /** @hidden */
  69489. dispose(): void;
  69490. /** @hidden */
  69491. onLoading(): void;
  69492. /** @hidden */
  69493. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69494. }
  69495. }
  69496. declare module BABYLON.GLTF2.Loader.Extensions {
  69497. /**
  69498. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  69499. */
  69500. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  69501. /** The name of this extension. */
  69502. readonly name: string;
  69503. /** Defines whether this extension is enabled. */
  69504. enabled: boolean;
  69505. private _loader;
  69506. /** @hidden */
  69507. constructor(loader: GLTFLoader);
  69508. /** @hidden */
  69509. dispose(): void;
  69510. /** @hidden */
  69511. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69512. private _loadSpecularGlossinessPropertiesAsync;
  69513. }
  69514. }
  69515. declare module BABYLON.GLTF2.Loader.Extensions {
  69516. /**
  69517. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  69518. */
  69519. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  69520. /** The name of this extension. */
  69521. readonly name: string;
  69522. /** Defines whether this extension is enabled. */
  69523. enabled: boolean;
  69524. private _loader;
  69525. /** @hidden */
  69526. constructor(loader: GLTFLoader);
  69527. /** @hidden */
  69528. dispose(): void;
  69529. /** @hidden */
  69530. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69531. private _loadUnlitPropertiesAsync;
  69532. }
  69533. }
  69534. declare module BABYLON.GLTF2.Loader.Extensions {
  69535. /**
  69536. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  69537. */
  69538. export class KHR_texture_transform implements IGLTFLoaderExtension {
  69539. /** The name of this extension. */
  69540. readonly name: string;
  69541. /** Defines whether this extension is enabled. */
  69542. enabled: boolean;
  69543. private _loader;
  69544. /** @hidden */
  69545. constructor(loader: GLTFLoader);
  69546. /** @hidden */
  69547. dispose(): void;
  69548. /** @hidden */
  69549. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69550. }
  69551. }
  69552. declare module BABYLON.GLTF2.Loader.Extensions {
  69553. /**
  69554. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  69555. */
  69556. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  69557. /** The name of this extension. */
  69558. readonly name: string;
  69559. /** Defines whether this extension is enabled. */
  69560. enabled: boolean;
  69561. private _loader;
  69562. private _clips;
  69563. private _emitters;
  69564. /** @hidden */
  69565. constructor(loader: GLTFLoader);
  69566. /** @hidden */
  69567. dispose(): void;
  69568. /** @hidden */
  69569. onLoading(): void;
  69570. /** @hidden */
  69571. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69572. /** @hidden */
  69573. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69574. /** @hidden */
  69575. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69576. private _loadClipAsync;
  69577. private _loadEmitterAsync;
  69578. private _getEventAction;
  69579. private _loadAnimationEventAsync;
  69580. }
  69581. }
  69582. declare module BABYLON.GLTF2.Loader.Extensions {
  69583. /**
  69584. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  69585. */
  69586. export class MSFT_lod implements IGLTFLoaderExtension {
  69587. /** The name of this extension. */
  69588. readonly name: string;
  69589. /** Defines whether this extension is enabled. */
  69590. enabled: boolean;
  69591. /**
  69592. * Maximum number of LODs to load, starting from the lowest LOD.
  69593. */
  69594. maxLODsToLoad: number;
  69595. /**
  69596. * Observable raised when all node LODs of one level are loaded.
  69597. * The event data is the index of the loaded LOD starting from zero.
  69598. * Dispose the loader to cancel the loading of the next level of LODs.
  69599. */
  69600. onNodeLODsLoadedObservable: Observable<number>;
  69601. /**
  69602. * Observable raised when all material LODs of one level are loaded.
  69603. * The event data is the index of the loaded LOD starting from zero.
  69604. * Dispose the loader to cancel the loading of the next level of LODs.
  69605. */
  69606. onMaterialLODsLoadedObservable: Observable<number>;
  69607. private _loader;
  69608. private _nodeIndexLOD;
  69609. private _nodeSignalLODs;
  69610. private _nodePromiseLODs;
  69611. private _materialIndexLOD;
  69612. private _materialSignalLODs;
  69613. private _materialPromiseLODs;
  69614. /** @hidden */
  69615. constructor(loader: GLTFLoader);
  69616. /** @hidden */
  69617. dispose(): void;
  69618. /** @hidden */
  69619. onReady(): void;
  69620. /** @hidden */
  69621. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69622. /** @hidden */
  69623. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69624. /** @hidden */
  69625. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69626. /**
  69627. * Gets an array of LOD properties from lowest to highest.
  69628. */
  69629. private _getLODs;
  69630. private _disposeUnusedMaterials;
  69631. }
  69632. }
  69633. declare module BABYLON.GLTF2.Loader.Extensions {
  69634. /** @hidden */
  69635. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  69636. readonly name: string;
  69637. enabled: boolean;
  69638. private _loader;
  69639. constructor(loader: GLTFLoader);
  69640. dispose(): void;
  69641. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69642. }
  69643. }
  69644. declare module BABYLON.GLTF2.Loader.Extensions {
  69645. /** @hidden */
  69646. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  69647. readonly name: string;
  69648. enabled: boolean;
  69649. private _loader;
  69650. constructor(loader: GLTFLoader);
  69651. dispose(): void;
  69652. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69653. }
  69654. }
  69655. declare module BABYLON.GLTF2.Loader.Extensions {
  69656. /**
  69657. * Store glTF extras (if present) in BJS objects' metadata
  69658. */
  69659. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  69660. /** The name of this extension. */
  69661. readonly name: string;
  69662. /** Defines whether this extension is enabled. */
  69663. enabled: boolean;
  69664. private _loader;
  69665. private _assignExtras;
  69666. /** @hidden */
  69667. constructor(loader: GLTFLoader);
  69668. /** @hidden */
  69669. dispose(): void;
  69670. /** @hidden */
  69671. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69672. /** @hidden */
  69673. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69674. /** @hidden */
  69675. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69676. }
  69677. }
  69678. declare module BABYLON {
  69679. /**
  69680. * Class reading and parsing the MTL file bundled with the obj file.
  69681. */
  69682. export class MTLFileLoader {
  69683. /**
  69684. * All material loaded from the mtl will be set here
  69685. */
  69686. materials: StandardMaterial[];
  69687. /**
  69688. * This function will read the mtl file and create each material described inside
  69689. * This function could be improve by adding :
  69690. * -some component missing (Ni, Tf...)
  69691. * -including the specific options available
  69692. *
  69693. * @param scene defines the scene the material will be created in
  69694. * @param data defines the mtl data to parse
  69695. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  69696. */
  69697. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  69698. /**
  69699. * Gets the texture for the material.
  69700. *
  69701. * If the material is imported from input file,
  69702. * We sanitize the url to ensure it takes the textre from aside the material.
  69703. *
  69704. * @param rootUrl The root url to load from
  69705. * @param value The value stored in the mtl
  69706. * @return The Texture
  69707. */
  69708. private static _getTexture;
  69709. }
  69710. /**
  69711. * Options for loading OBJ/MTL files
  69712. */
  69713. type MeshLoadOptions = {
  69714. /**
  69715. * Defines if UVs are optimized by default during load.
  69716. */
  69717. OptimizeWithUV: boolean;
  69718. /**
  69719. * Defines custom scaling of UV coordinates of loaded meshes.
  69720. */
  69721. UVScaling: Vector2;
  69722. /**
  69723. * Invert model on y-axis (does a model scaling inversion)
  69724. */
  69725. InvertY: boolean;
  69726. /**
  69727. * Invert Y-Axis of referenced textures on load
  69728. */
  69729. InvertTextureY: boolean;
  69730. /**
  69731. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69732. */
  69733. ImportVertexColors: boolean;
  69734. /**
  69735. * Compute the normals for the model, even if normals are present in the file.
  69736. */
  69737. ComputeNormals: boolean;
  69738. /**
  69739. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69740. */
  69741. SkipMaterials: boolean;
  69742. /**
  69743. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69744. */
  69745. MaterialLoadingFailsSilently: boolean;
  69746. };
  69747. /**
  69748. * OBJ file type loader.
  69749. * This is a babylon scene loader plugin.
  69750. */
  69751. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  69752. /**
  69753. * Defines if UVs are optimized by default during load.
  69754. */
  69755. static OPTIMIZE_WITH_UV: boolean;
  69756. /**
  69757. * Invert model on y-axis (does a model scaling inversion)
  69758. */
  69759. static INVERT_Y: boolean;
  69760. /**
  69761. * Invert Y-Axis of referenced textures on load
  69762. */
  69763. static INVERT_TEXTURE_Y: boolean;
  69764. /**
  69765. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69766. */
  69767. static IMPORT_VERTEX_COLORS: boolean;
  69768. /**
  69769. * Compute the normals for the model, even if normals are present in the file.
  69770. */
  69771. static COMPUTE_NORMALS: boolean;
  69772. /**
  69773. * Defines custom scaling of UV coordinates of loaded meshes.
  69774. */
  69775. static UV_SCALING: Vector2;
  69776. /**
  69777. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69778. */
  69779. static SKIP_MATERIALS: boolean;
  69780. /**
  69781. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69782. *
  69783. * Defaults to true for backwards compatibility.
  69784. */
  69785. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  69786. /**
  69787. * Defines the name of the plugin.
  69788. */
  69789. name: string;
  69790. /**
  69791. * Defines the extension the plugin is able to load.
  69792. */
  69793. extensions: string;
  69794. /** @hidden */
  69795. obj: RegExp;
  69796. /** @hidden */
  69797. group: RegExp;
  69798. /** @hidden */
  69799. mtllib: RegExp;
  69800. /** @hidden */
  69801. usemtl: RegExp;
  69802. /** @hidden */
  69803. smooth: RegExp;
  69804. /** @hidden */
  69805. vertexPattern: RegExp;
  69806. /** @hidden */
  69807. normalPattern: RegExp;
  69808. /** @hidden */
  69809. uvPattern: RegExp;
  69810. /** @hidden */
  69811. facePattern1: RegExp;
  69812. /** @hidden */
  69813. facePattern2: RegExp;
  69814. /** @hidden */
  69815. facePattern3: RegExp;
  69816. /** @hidden */
  69817. facePattern4: RegExp;
  69818. /** @hidden */
  69819. facePattern5: RegExp;
  69820. private _meshLoadOptions;
  69821. /**
  69822. * Creates loader for .OBJ files
  69823. *
  69824. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  69825. */
  69826. constructor(meshLoadOptions?: MeshLoadOptions);
  69827. private static readonly currentMeshLoadOptions;
  69828. /**
  69829. * Calls synchronously the MTL file attached to this obj.
  69830. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  69831. * Without this function materials are not displayed in the first frame (but displayed after).
  69832. * In consequence it is impossible to get material information in your HTML file
  69833. *
  69834. * @param url The URL of the MTL file
  69835. * @param rootUrl
  69836. * @param onSuccess Callback function to be called when the MTL file is loaded
  69837. * @private
  69838. */
  69839. private _loadMTL;
  69840. /**
  69841. * Instantiates a OBJ file loader plugin.
  69842. * @returns the created plugin
  69843. */
  69844. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  69845. /**
  69846. * If the data string can be loaded directly.
  69847. *
  69848. * @param data string containing the file data
  69849. * @returns if the data can be loaded directly
  69850. */
  69851. canDirectLoad(data: string): boolean;
  69852. /**
  69853. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  69854. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69855. * @param scene the scene the meshes should be added to
  69856. * @param data the OBJ data to load
  69857. * @param rootUrl root url to load from
  69858. * @param onProgress event that fires when loading progress has occured
  69859. * @param fileName Defines the name of the file to load
  69860. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69861. */
  69862. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69863. meshes: AbstractMesh[];
  69864. particleSystems: IParticleSystem[];
  69865. skeletons: Skeleton[];
  69866. animationGroups: AnimationGroup[];
  69867. }>;
  69868. /**
  69869. * Imports all objects from the loaded OBJ data and adds them to the scene
  69870. * @param scene the scene the objects should be added to
  69871. * @param data the OBJ data to load
  69872. * @param rootUrl root url to load from
  69873. * @param onProgress event that fires when loading progress has occured
  69874. * @param fileName Defines the name of the file to load
  69875. * @returns a promise which completes when objects have been loaded to the scene
  69876. */
  69877. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69878. /**
  69879. * Load into an asset container.
  69880. * @param scene The scene to load into
  69881. * @param data The data to import
  69882. * @param rootUrl The root url for scene and resources
  69883. * @param onProgress The callback when the load progresses
  69884. * @param fileName Defines the name of the file to load
  69885. * @returns The loaded asset container
  69886. */
  69887. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69888. /**
  69889. * Read the OBJ file and create an Array of meshes.
  69890. * Each mesh contains all information given by the OBJ and the MTL file.
  69891. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69892. *
  69893. * @param meshesNames
  69894. * @param scene Scene The scene where are displayed the data
  69895. * @param data String The content of the obj file
  69896. * @param rootUrl String The path to the folder
  69897. * @returns Array<AbstractMesh>
  69898. * @private
  69899. */
  69900. private _parseSolid;
  69901. }
  69902. }
  69903. declare module BABYLON {
  69904. /**
  69905. * STL file type loader.
  69906. * This is a babylon scene loader plugin.
  69907. */
  69908. export class STLFileLoader implements ISceneLoaderPlugin {
  69909. /** @hidden */
  69910. solidPattern: RegExp;
  69911. /** @hidden */
  69912. facetsPattern: RegExp;
  69913. /** @hidden */
  69914. normalPattern: RegExp;
  69915. /** @hidden */
  69916. vertexPattern: RegExp;
  69917. /**
  69918. * Defines the name of the plugin.
  69919. */
  69920. name: string;
  69921. /**
  69922. * Defines the extensions the stl loader is able to load.
  69923. * force data to come in as an ArrayBuffer
  69924. * we'll convert to string if it looks like it's an ASCII .stl
  69925. */
  69926. extensions: ISceneLoaderPluginExtensions;
  69927. /**
  69928. * Import meshes into a scene.
  69929. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  69930. * @param scene The scene to import into
  69931. * @param data The data to import
  69932. * @param rootUrl The root url for scene and resources
  69933. * @param meshes The meshes array to import into
  69934. * @param particleSystems The particle systems array to import into
  69935. * @param skeletons The skeletons array to import into
  69936. * @param onError The callback when import fails
  69937. * @returns True if successful or false otherwise
  69938. */
  69939. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  69940. /**
  69941. * Load into a scene.
  69942. * @param scene The scene to load into
  69943. * @param data The data to import
  69944. * @param rootUrl The root url for scene and resources
  69945. * @param onError The callback when import fails
  69946. * @returns true if successful or false otherwise
  69947. */
  69948. load(scene: Scene, data: any, rootUrl: string): boolean;
  69949. /**
  69950. * Load into an asset container.
  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 The loaded asset container
  69956. */
  69957. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  69958. private _isBinary;
  69959. private _parseBinary;
  69960. private _parseASCII;
  69961. }
  69962. }
  69963. declare module BABYLON {
  69964. /**
  69965. * Class for generating OBJ data from a Babylon scene.
  69966. */
  69967. export class OBJExport {
  69968. /**
  69969. * Exports the geometry of a Mesh array in .OBJ file format (text)
  69970. * @param mesh defines the list of meshes to serialize
  69971. * @param materials defines if materials should be exported
  69972. * @param matlibname defines the name of the associated mtl file
  69973. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  69974. * @returns the OBJ content
  69975. */
  69976. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  69977. /**
  69978. * Exports the material(s) of a mesh in .MTL file format (text)
  69979. * @param mesh defines the mesh to extract the material from
  69980. * @returns the mtl content
  69981. */
  69982. static MTL(mesh: Mesh): string;
  69983. }
  69984. }
  69985. declare module BABYLON {
  69986. /** @hidden */
  69987. export var __IGLTFExporterExtension: number;
  69988. /**
  69989. * Interface for extending the exporter
  69990. * @hidden
  69991. */
  69992. export interface IGLTFExporterExtension {
  69993. /**
  69994. * The name of this extension
  69995. */
  69996. readonly name: string;
  69997. /**
  69998. * Defines whether this extension is enabled
  69999. */
  70000. enabled: boolean;
  70001. /**
  70002. * Defines whether this extension is required
  70003. */
  70004. required: boolean;
  70005. }
  70006. }
  70007. declare module BABYLON.GLTF2.Exporter {
  70008. /** @hidden */
  70009. export var __IGLTFExporterExtensionV2: number;
  70010. /**
  70011. * Interface for a glTF exporter extension
  70012. * @hidden
  70013. */
  70014. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  70015. /**
  70016. * Define this method to modify the default behavior before exporting a texture
  70017. * @param context The context when loading the asset
  70018. * @param babylonTexture The glTF texture info property
  70019. * @param mimeType The mime-type of the generated image
  70020. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  70021. */
  70022. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70023. /**
  70024. * Define this method to modify the default behavior when exporting texture info
  70025. * @param context The context when loading the asset
  70026. * @param meshPrimitive glTF mesh primitive
  70027. * @param babylonSubMesh Babylon submesh
  70028. * @param binaryWriter glTF serializer binary writer instance
  70029. * @returns nullable IMeshPrimitive promise
  70030. */
  70031. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70032. /**
  70033. * Define this method to modify the default behavior when exporting a node
  70034. * @param context The context when exporting the node
  70035. * @param node glTF node
  70036. * @param babylonNode BabylonJS node
  70037. * @returns nullable INode promise
  70038. */
  70039. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70040. /**
  70041. * Called after the exporter state changes to EXPORTING
  70042. */
  70043. onExporting?(): void;
  70044. }
  70045. }
  70046. declare module BABYLON.GLTF2.Exporter {
  70047. /**
  70048. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  70049. * @hidden
  70050. */
  70051. export class _GLTFMaterialExporter {
  70052. /**
  70053. * Represents the dielectric specular values for R, G and B
  70054. */
  70055. private static readonly _DielectricSpecular;
  70056. /**
  70057. * Allows the maximum specular power to be defined for material calculations
  70058. */
  70059. private static readonly _MaxSpecularPower;
  70060. /**
  70061. * Mapping to store textures
  70062. */
  70063. private _textureMap;
  70064. /**
  70065. * Numeric tolerance value
  70066. */
  70067. private static readonly _Epsilon;
  70068. /**
  70069. * Reference to the glTF Exporter
  70070. */
  70071. private _exporter;
  70072. constructor(exporter: _Exporter);
  70073. /**
  70074. * Specifies if two colors are approximately equal in value
  70075. * @param color1 first color to compare to
  70076. * @param color2 second color to compare to
  70077. * @param epsilon threshold value
  70078. */
  70079. private static FuzzyEquals;
  70080. /**
  70081. * Gets the materials from a Babylon scene and converts them to glTF materials
  70082. * @param scene babylonjs scene
  70083. * @param mimeType texture mime type
  70084. * @param images array of images
  70085. * @param textures array of textures
  70086. * @param materials array of materials
  70087. * @param imageData mapping of texture names to base64 textures
  70088. * @param hasTextureCoords specifies if texture coordinates are present on the material
  70089. */
  70090. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70091. /**
  70092. * Makes a copy of the glTF material without the texture parameters
  70093. * @param originalMaterial original glTF material
  70094. * @returns glTF material without texture parameters
  70095. */
  70096. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  70097. /**
  70098. * Specifies if the material has any texture parameters present
  70099. * @param material glTF Material
  70100. * @returns boolean specifying if texture parameters are present
  70101. */
  70102. _hasTexturesPresent(material: IMaterial): boolean;
  70103. /**
  70104. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  70105. * @param babylonStandardMaterial
  70106. * @returns glTF Metallic Roughness Material representation
  70107. */
  70108. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  70109. /**
  70110. * Computes the metallic factor
  70111. * @param diffuse diffused value
  70112. * @param specular specular value
  70113. * @param oneMinusSpecularStrength one minus the specular strength
  70114. * @returns metallic value
  70115. */
  70116. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  70117. /**
  70118. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  70119. * @param glTFMaterial glTF material
  70120. * @param babylonMaterial Babylon material
  70121. */
  70122. private static _SetAlphaMode;
  70123. /**
  70124. * Converts a Babylon Standard Material to a glTF Material
  70125. * @param babylonStandardMaterial BJS Standard Material
  70126. * @param mimeType mime type to use for the textures
  70127. * @param images array of glTF image interfaces
  70128. * @param textures array of glTF texture interfaces
  70129. * @param materials array of glTF material interfaces
  70130. * @param imageData map of image file name to data
  70131. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70132. */
  70133. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70134. /**
  70135. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70136. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  70137. * @param mimeType mime type to use for the textures
  70138. * @param images array of glTF image interfaces
  70139. * @param textures array of glTF texture interfaces
  70140. * @param materials array of glTF material interfaces
  70141. * @param imageData map of image file name to data
  70142. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70143. */
  70144. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70145. /**
  70146. * Converts an image typed array buffer to a base64 image
  70147. * @param buffer typed array buffer
  70148. * @param width width of the image
  70149. * @param height height of the image
  70150. * @param mimeType mimetype of the image
  70151. * @returns base64 image string
  70152. */
  70153. private _createBase64FromCanvasAsync;
  70154. /**
  70155. * Generates a white texture based on the specified width and height
  70156. * @param width width of the texture in pixels
  70157. * @param height height of the texture in pixels
  70158. * @param scene babylonjs scene
  70159. * @returns white texture
  70160. */
  70161. private _createWhiteTexture;
  70162. /**
  70163. * 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
  70164. * @param texture1 first texture to resize
  70165. * @param texture2 second texture to resize
  70166. * @param scene babylonjs scene
  70167. * @returns resized textures or null
  70168. */
  70169. private _resizeTexturesToSameDimensions;
  70170. /**
  70171. * Converts an array of pixels to a Float32Array
  70172. * Throws an error if the pixel format is not supported
  70173. * @param pixels - array buffer containing pixel values
  70174. * @returns Float32 of pixels
  70175. */
  70176. private _convertPixelArrayToFloat32;
  70177. /**
  70178. * Convert Specular Glossiness Textures to Metallic Roughness
  70179. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  70180. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  70181. * @param diffuseTexture texture used to store diffuse information
  70182. * @param specularGlossinessTexture texture used to store specular and glossiness information
  70183. * @param factors specular glossiness material factors
  70184. * @param mimeType the mime type to use for the texture
  70185. * @returns pbr metallic roughness interface or null
  70186. */
  70187. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  70188. /**
  70189. * Converts specular glossiness material properties to metallic roughness
  70190. * @param specularGlossiness interface with specular glossiness material properties
  70191. * @returns interface with metallic roughness material properties
  70192. */
  70193. private _convertSpecularGlossinessToMetallicRoughness;
  70194. /**
  70195. * Calculates the surface reflectance, independent of lighting conditions
  70196. * @param color Color source to calculate brightness from
  70197. * @returns number representing the perceived brightness, or zero if color is undefined
  70198. */
  70199. private _getPerceivedBrightness;
  70200. /**
  70201. * Returns the maximum color component value
  70202. * @param color
  70203. * @returns maximum color component value, or zero if color is null or undefined
  70204. */
  70205. private _getMaxComponent;
  70206. /**
  70207. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  70208. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70209. * @param mimeType mime type to use for the textures
  70210. * @param images array of glTF image interfaces
  70211. * @param textures array of glTF texture interfaces
  70212. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70213. * @param imageData map of image file name to data
  70214. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70215. * @returns glTF PBR Metallic Roughness factors
  70216. */
  70217. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  70218. private _getGLTFTextureSampler;
  70219. private _getGLTFTextureWrapMode;
  70220. private _getGLTFTextureWrapModesSampler;
  70221. /**
  70222. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  70223. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70224. * @param mimeType mime type to use for the textures
  70225. * @param images array of glTF image interfaces
  70226. * @param textures array of glTF texture interfaces
  70227. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70228. * @param imageData map of image file name to data
  70229. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70230. * @returns glTF PBR Metallic Roughness factors
  70231. */
  70232. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  70233. /**
  70234. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70235. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70236. * @param mimeType mime type to use for the textures
  70237. * @param images array of glTF image interfaces
  70238. * @param textures array of glTF texture interfaces
  70239. * @param materials array of glTF material interfaces
  70240. * @param imageData map of image file name to data
  70241. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70242. */
  70243. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70244. private setMetallicRoughnessPbrMaterial;
  70245. private getPixelsFromTexture;
  70246. /**
  70247. * Extracts a texture from a Babylon texture into file data and glTF data
  70248. * @param babylonTexture Babylon texture to extract
  70249. * @param mimeType Mime Type of the babylonTexture
  70250. * @return glTF texture info, or null if the texture format is not supported
  70251. */
  70252. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  70253. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  70254. /**
  70255. * Builds a texture from base64 string
  70256. * @param base64Texture base64 texture string
  70257. * @param baseTextureName Name to use for the texture
  70258. * @param mimeType image mime type for the texture
  70259. * @param images array of images
  70260. * @param textures array of textures
  70261. * @param imageData map of image data
  70262. * @returns glTF texture info, or null if the texture format is not supported
  70263. */
  70264. private _getTextureInfoFromBase64;
  70265. }
  70266. }
  70267. declare module BABYLON {
  70268. /**
  70269. * Class for holding and downloading glTF file data
  70270. */
  70271. export class GLTFData {
  70272. /**
  70273. * Object which contains the file name as the key and its data as the value
  70274. */
  70275. glTFFiles: {
  70276. [fileName: string]: string | Blob;
  70277. };
  70278. /**
  70279. * Initializes the glTF file object
  70280. */
  70281. constructor();
  70282. /**
  70283. * Downloads the glTF data as files based on their names and data
  70284. */
  70285. downloadFiles(): void;
  70286. }
  70287. }
  70288. declare module BABYLON {
  70289. /**
  70290. * Holds a collection of exporter options and parameters
  70291. */
  70292. export interface IExportOptions {
  70293. /**
  70294. * Function which indicates whether a babylon node should be exported or not
  70295. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  70296. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  70297. */
  70298. shouldExportNode?(node: Node): boolean;
  70299. /**
  70300. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  70301. * @param metadata source metadata to read from
  70302. * @returns the data to store to glTF node extras
  70303. */
  70304. metadataSelector?(metadata: any): any;
  70305. /**
  70306. * The sample rate to bake animation curves
  70307. */
  70308. animationSampleRate?: number;
  70309. /**
  70310. * Begin serialization without waiting for the scene to be ready
  70311. */
  70312. exportWithoutWaitingForScene?: boolean;
  70313. }
  70314. /**
  70315. * Class for generating glTF data from a Babylon scene.
  70316. */
  70317. export class GLTF2Export {
  70318. /**
  70319. * Exports the geometry of the scene to .gltf file format asynchronously
  70320. * @param scene Babylon scene with scene hierarchy information
  70321. * @param filePrefix File prefix to use when generating the glTF file
  70322. * @param options Exporter options
  70323. * @returns Returns an object with a .gltf file and associates texture names
  70324. * as keys and their data and paths as values
  70325. */
  70326. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70327. private static _PreExportAsync;
  70328. private static _PostExportAsync;
  70329. /**
  70330. * Exports the geometry of the scene to .glb file format asychronously
  70331. * @param scene Babylon scene with scene hierarchy information
  70332. * @param filePrefix File prefix to use when generating glb file
  70333. * @param options Exporter options
  70334. * @returns Returns an object with a .glb filename as key and data as value
  70335. */
  70336. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70337. }
  70338. }
  70339. declare module BABYLON.GLTF2.Exporter {
  70340. /**
  70341. * @hidden
  70342. */
  70343. export class _GLTFUtilities {
  70344. /**
  70345. * Creates a buffer view based on the supplied arguments
  70346. * @param bufferIndex index value of the specified buffer
  70347. * @param byteOffset byte offset value
  70348. * @param byteLength byte length of the bufferView
  70349. * @param byteStride byte distance between conequential elements
  70350. * @param name name of the buffer view
  70351. * @returns bufferView for glTF
  70352. */
  70353. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  70354. /**
  70355. * Creates an accessor based on the supplied arguments
  70356. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  70357. * @param name The name of the accessor
  70358. * @param type The type of the accessor
  70359. * @param componentType The datatype of components in the attribute
  70360. * @param count The number of attributes referenced by this accessor
  70361. * @param byteOffset The offset relative to the start of the bufferView in bytes
  70362. * @param min Minimum value of each component in this attribute
  70363. * @param max Maximum value of each component in this attribute
  70364. * @returns accessor for glTF
  70365. */
  70366. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  70367. /**
  70368. * Calculates the minimum and maximum values of an array of position floats
  70369. * @param positions Positions array of a mesh
  70370. * @param vertexStart Starting vertex offset to calculate min and max values
  70371. * @param vertexCount Number of vertices to check for min and max values
  70372. * @returns min number array and max number array
  70373. */
  70374. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  70375. min: number[];
  70376. max: number[];
  70377. };
  70378. /**
  70379. * Converts a new right-handed Vector3
  70380. * @param vector vector3 array
  70381. * @returns right-handed Vector3
  70382. */
  70383. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  70384. /**
  70385. * Converts a Vector3 to right-handed
  70386. * @param vector Vector3 to convert to right-handed
  70387. */
  70388. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  70389. /**
  70390. * Converts a three element number array to right-handed
  70391. * @param vector number array to convert to right-handed
  70392. */
  70393. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  70394. /**
  70395. * Converts a new right-handed Vector3
  70396. * @param vector vector3 array
  70397. * @returns right-handed Vector3
  70398. */
  70399. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  70400. /**
  70401. * Converts a Vector3 to right-handed
  70402. * @param vector Vector3 to convert to right-handed
  70403. */
  70404. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  70405. /**
  70406. * Converts a three element number array to right-handed
  70407. * @param vector number array to convert to right-handed
  70408. */
  70409. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  70410. /**
  70411. * Converts a Vector4 to right-handed
  70412. * @param vector Vector4 to convert to right-handed
  70413. */
  70414. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  70415. /**
  70416. * Converts a Vector4 to right-handed
  70417. * @param vector Vector4 to convert to right-handed
  70418. */
  70419. static _GetRightHandedArray4FromRef(vector: number[]): void;
  70420. /**
  70421. * Converts a Quaternion to right-handed
  70422. * @param quaternion Source quaternion to convert to right-handed
  70423. */
  70424. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  70425. /**
  70426. * Converts a Quaternion to right-handed
  70427. * @param quaternion Source quaternion to convert to right-handed
  70428. */
  70429. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  70430. static _NormalizeTangentFromRef(tangent: Vector4): void;
  70431. }
  70432. }
  70433. declare module BABYLON.GLTF2.Exporter {
  70434. /**
  70435. * Converts Babylon Scene into glTF 2.0.
  70436. * @hidden
  70437. */
  70438. export class _Exporter {
  70439. /**
  70440. * Stores the glTF to export
  70441. */
  70442. _glTF: IGLTF;
  70443. /**
  70444. * Stores all generated buffer views, which represents views into the main glTF buffer data
  70445. */
  70446. _bufferViews: IBufferView[];
  70447. /**
  70448. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  70449. */
  70450. _accessors: IAccessor[];
  70451. /**
  70452. * Stores all the generated nodes, which contains transform and/or mesh information per node
  70453. */
  70454. private _nodes;
  70455. /**
  70456. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  70457. */
  70458. private _scenes;
  70459. /**
  70460. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  70461. */
  70462. private _meshes;
  70463. /**
  70464. * Stores all the generated material information, which represents the appearance of each primitive
  70465. */
  70466. _materials: IMaterial[];
  70467. _materialMap: {
  70468. [materialID: number]: number;
  70469. };
  70470. /**
  70471. * Stores all the generated texture information, which is referenced by glTF materials
  70472. */
  70473. _textures: ITexture[];
  70474. /**
  70475. * Stores all the generated image information, which is referenced by glTF textures
  70476. */
  70477. _images: IImage[];
  70478. /**
  70479. * Stores all the texture samplers
  70480. */
  70481. _samplers: ISampler[];
  70482. /**
  70483. * Stores all the generated animation samplers, which is referenced by glTF animations
  70484. */
  70485. /**
  70486. * Stores the animations for glTF models
  70487. */
  70488. private _animations;
  70489. /**
  70490. * Stores the total amount of bytes stored in the glTF buffer
  70491. */
  70492. private _totalByteLength;
  70493. /**
  70494. * Stores a reference to the Babylon scene containing the source geometry and material information
  70495. */
  70496. _babylonScene: Scene;
  70497. /**
  70498. * Stores a map of the image data, where the key is the file name and the value
  70499. * is the image data
  70500. */
  70501. _imageData: {
  70502. [fileName: string]: {
  70503. data: Uint8Array;
  70504. mimeType: ImageMimeType;
  70505. };
  70506. };
  70507. /**
  70508. * Stores a map of the unique id of a node to its index in the node array
  70509. */
  70510. private _nodeMap;
  70511. /**
  70512. * Specifies if the Babylon scene should be converted to right-handed on export
  70513. */
  70514. _convertToRightHandedSystem: boolean;
  70515. /**
  70516. * Baked animation sample rate
  70517. */
  70518. private _animationSampleRate;
  70519. private _options;
  70520. private _localEngine;
  70521. _glTFMaterialExporter: _GLTFMaterialExporter;
  70522. private _extensions;
  70523. private static _ExtensionNames;
  70524. private static _ExtensionFactories;
  70525. private _applyExtensions;
  70526. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  70527. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70528. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70529. private _forEachExtensions;
  70530. private _extensionsOnExporting;
  70531. /**
  70532. * Load glTF serializer extensions
  70533. */
  70534. private _loadExtensions;
  70535. /**
  70536. * Creates a glTF Exporter instance, which can accept optional exporter options
  70537. * @param babylonScene Babylon scene object
  70538. * @param options Options to modify the behavior of the exporter
  70539. */
  70540. constructor(babylonScene: Scene, options?: IExportOptions);
  70541. /**
  70542. * Registers a glTF exporter extension
  70543. * @param name Name of the extension to export
  70544. * @param factory The factory function that creates the exporter extension
  70545. */
  70546. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  70547. /**
  70548. * Un-registers an exporter extension
  70549. * @param name The name fo the exporter extension
  70550. * @returns A boolean indicating whether the extension has been un-registered
  70551. */
  70552. static UnregisterExtension(name: string): boolean;
  70553. /**
  70554. * Lazy load a local engine with premultiplied alpha set to false
  70555. */
  70556. _getLocalEngine(): Engine;
  70557. private reorderIndicesBasedOnPrimitiveMode;
  70558. /**
  70559. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  70560. * clock-wise during export to glTF
  70561. * @param submesh BabylonJS submesh
  70562. * @param primitiveMode Primitive mode of the mesh
  70563. * @param sideOrientation the winding order of the submesh
  70564. * @param vertexBufferKind The type of vertex attribute
  70565. * @param meshAttributeArray The vertex attribute data
  70566. * @param byteOffset The offset to the binary data
  70567. * @param binaryWriter The binary data for the glTF file
  70568. */
  70569. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  70570. /**
  70571. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  70572. * clock-wise during export to glTF
  70573. * @param submesh BabylonJS submesh
  70574. * @param primitiveMode Primitive mode of the mesh
  70575. * @param sideOrientation the winding order of the submesh
  70576. * @param vertexBufferKind The type of vertex attribute
  70577. * @param meshAttributeArray The vertex attribute data
  70578. * @param byteOffset The offset to the binary data
  70579. * @param binaryWriter The binary data for the glTF file
  70580. */
  70581. private reorderTriangleFillMode;
  70582. /**
  70583. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  70584. * clock-wise during export to glTF
  70585. * @param submesh BabylonJS submesh
  70586. * @param primitiveMode Primitive mode of the mesh
  70587. * @param sideOrientation the winding order of the submesh
  70588. * @param vertexBufferKind The type of vertex attribute
  70589. * @param meshAttributeArray The vertex attribute data
  70590. * @param byteOffset The offset to the binary data
  70591. * @param binaryWriter The binary data for the glTF file
  70592. */
  70593. private reorderTriangleStripDrawMode;
  70594. /**
  70595. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  70596. * clock-wise during export to glTF
  70597. * @param submesh BabylonJS submesh
  70598. * @param primitiveMode Primitive mode of the mesh
  70599. * @param sideOrientation the winding order of the submesh
  70600. * @param vertexBufferKind The type of vertex attribute
  70601. * @param meshAttributeArray The vertex attribute data
  70602. * @param byteOffset The offset to the binary data
  70603. * @param binaryWriter The binary data for the glTF file
  70604. */
  70605. private reorderTriangleFanMode;
  70606. /**
  70607. * Writes the vertex attribute data to binary
  70608. * @param vertices The vertices to write to the binary writer
  70609. * @param byteOffset The offset into the binary writer to overwrite binary data
  70610. * @param vertexAttributeKind The vertex attribute type
  70611. * @param meshAttributeArray The vertex attribute data
  70612. * @param binaryWriter The writer containing the binary data
  70613. */
  70614. private writeVertexAttributeData;
  70615. /**
  70616. * Writes mesh attribute data to a data buffer
  70617. * Returns the bytelength of the data
  70618. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  70619. * @param meshAttributeArray Array containing the attribute data
  70620. * @param binaryWriter The buffer to write the binary data to
  70621. * @param indices Used to specify the order of the vertex data
  70622. */
  70623. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  70624. /**
  70625. * Generates glTF json data
  70626. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  70627. * @param glTFPrefix Text to use when prefixing a glTF file
  70628. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  70629. * @returns json data as string
  70630. */
  70631. private generateJSON;
  70632. /**
  70633. * Generates data for .gltf and .bin files based on the glTF prefix string
  70634. * @param glTFPrefix Text to use when prefixing a glTF file
  70635. * @returns GLTFData with glTF file data
  70636. */
  70637. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  70638. /**
  70639. * Creates a binary buffer for glTF
  70640. * @returns array buffer for binary data
  70641. */
  70642. private _generateBinaryAsync;
  70643. /**
  70644. * Pads the number to a multiple of 4
  70645. * @param num number to pad
  70646. * @returns padded number
  70647. */
  70648. private _getPadding;
  70649. /**
  70650. * Generates a glb file from the json and binary data
  70651. * Returns an object with the glb file name as the key and data as the value
  70652. * @param glTFPrefix
  70653. * @returns object with glb filename as key and data as value
  70654. */
  70655. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  70656. /**
  70657. * Sets the TRS for each node
  70658. * @param node glTF Node for storing the transformation data
  70659. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  70660. */
  70661. private setNodeTransformation;
  70662. private getVertexBufferFromMesh;
  70663. /**
  70664. * Creates a bufferview based on the vertices type for the Babylon mesh
  70665. * @param kind Indicates the type of vertices data
  70666. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  70667. * @param binaryWriter The buffer to write the bufferview data to
  70668. */
  70669. private createBufferViewKind;
  70670. /**
  70671. * The primitive mode of the Babylon mesh
  70672. * @param babylonMesh The BabylonJS mesh
  70673. */
  70674. private getMeshPrimitiveMode;
  70675. /**
  70676. * Sets the primitive mode of the glTF mesh primitive
  70677. * @param meshPrimitive glTF mesh primitive
  70678. * @param primitiveMode The primitive mode
  70679. */
  70680. private setPrimitiveMode;
  70681. /**
  70682. * Sets the vertex attribute accessor based of the glTF mesh primitive
  70683. * @param meshPrimitive glTF mesh primitive
  70684. * @param attributeKind vertex attribute
  70685. * @returns boolean specifying if uv coordinates are present
  70686. */
  70687. private setAttributeKind;
  70688. /**
  70689. * Sets data for the primitive attributes of each submesh
  70690. * @param mesh glTF Mesh object to store the primitive attribute information
  70691. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  70692. * @param binaryWriter Buffer to write the attribute data to
  70693. */
  70694. private setPrimitiveAttributesAsync;
  70695. /**
  70696. * Creates a glTF scene based on the array of meshes
  70697. * Returns the the total byte offset
  70698. * @param babylonScene Babylon scene to get the mesh data from
  70699. * @param binaryWriter Buffer to write binary data to
  70700. */
  70701. private createSceneAsync;
  70702. /**
  70703. * Creates a mapping of Node unique id to node index and handles animations
  70704. * @param babylonScene Babylon Scene
  70705. * @param nodes Babylon transform nodes
  70706. * @param binaryWriter Buffer to write binary data to
  70707. * @returns Node mapping of unique id to index
  70708. */
  70709. private createNodeMapAndAnimationsAsync;
  70710. /**
  70711. * Creates a glTF node from a Babylon mesh
  70712. * @param babylonMesh Source Babylon mesh
  70713. * @param binaryWriter Buffer for storing geometry data
  70714. * @returns glTF node
  70715. */
  70716. private createNodeAsync;
  70717. }
  70718. /**
  70719. * @hidden
  70720. *
  70721. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  70722. */
  70723. export class _BinaryWriter {
  70724. /**
  70725. * Array buffer which stores all binary data
  70726. */
  70727. private _arrayBuffer;
  70728. /**
  70729. * View of the array buffer
  70730. */
  70731. private _dataView;
  70732. /**
  70733. * byte offset of data in array buffer
  70734. */
  70735. private _byteOffset;
  70736. /**
  70737. * Initialize binary writer with an initial byte length
  70738. * @param byteLength Initial byte length of the array buffer
  70739. */
  70740. constructor(byteLength: number);
  70741. /**
  70742. * Resize the array buffer to the specified byte length
  70743. * @param byteLength
  70744. */
  70745. private resizeBuffer;
  70746. /**
  70747. * Get an array buffer with the length of the byte offset
  70748. * @returns ArrayBuffer resized to the byte offset
  70749. */
  70750. getArrayBuffer(): ArrayBuffer;
  70751. /**
  70752. * Get the byte offset of the array buffer
  70753. * @returns byte offset
  70754. */
  70755. getByteOffset(): number;
  70756. /**
  70757. * Stores an UInt8 in the array buffer
  70758. * @param entry
  70759. * @param byteOffset If defined, specifies where to set the value as an offset.
  70760. */
  70761. setUInt8(entry: number, byteOffset?: number): void;
  70762. /**
  70763. * Gets an UInt32 in the array buffer
  70764. * @param entry
  70765. * @param byteOffset If defined, specifies where to set the value as an offset.
  70766. */
  70767. getUInt32(byteOffset: number): number;
  70768. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70769. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70770. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70771. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70772. /**
  70773. * Stores a Float32 in the array buffer
  70774. * @param entry
  70775. */
  70776. setFloat32(entry: number, byteOffset?: number): void;
  70777. /**
  70778. * Stores an UInt32 in the array buffer
  70779. * @param entry
  70780. * @param byteOffset If defined, specifies where to set the value as an offset.
  70781. */
  70782. setUInt32(entry: number, byteOffset?: number): void;
  70783. }
  70784. }
  70785. declare module BABYLON.GLTF2.Exporter {
  70786. /**
  70787. * @hidden
  70788. * Interface to store animation data.
  70789. */
  70790. export interface _IAnimationData {
  70791. /**
  70792. * Keyframe data.
  70793. */
  70794. inputs: number[];
  70795. /**
  70796. * Value data.
  70797. */
  70798. outputs: number[][];
  70799. /**
  70800. * Animation interpolation data.
  70801. */
  70802. samplerInterpolation: AnimationSamplerInterpolation;
  70803. /**
  70804. * Minimum keyframe value.
  70805. */
  70806. inputsMin: number;
  70807. /**
  70808. * Maximum keyframe value.
  70809. */
  70810. inputsMax: number;
  70811. }
  70812. /**
  70813. * @hidden
  70814. */
  70815. export interface _IAnimationInfo {
  70816. /**
  70817. * The target channel for the animation
  70818. */
  70819. animationChannelTargetPath: AnimationChannelTargetPath;
  70820. /**
  70821. * The glTF accessor type for the data.
  70822. */
  70823. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  70824. /**
  70825. * Specifies if quaternions should be used.
  70826. */
  70827. useQuaternion: boolean;
  70828. }
  70829. /**
  70830. * @hidden
  70831. * Utility class for generating glTF animation data from BabylonJS.
  70832. */
  70833. export class _GLTFAnimation {
  70834. /**
  70835. * @ignore
  70836. *
  70837. * Creates glTF channel animation from BabylonJS animation.
  70838. * @param babylonTransformNode - BabylonJS mesh.
  70839. * @param animation - animation.
  70840. * @param animationChannelTargetPath - The target animation channel.
  70841. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  70842. * @param useQuaternion - Specifies if quaternions are used.
  70843. * @returns nullable IAnimationData
  70844. */
  70845. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  70846. private static _DeduceAnimationInfo;
  70847. /**
  70848. * @ignore
  70849. * Create node animations from the transform node animations
  70850. * @param babylonNode
  70851. * @param runtimeGLTFAnimation
  70852. * @param idleGLTFAnimations
  70853. * @param nodeMap
  70854. * @param nodes
  70855. * @param binaryWriter
  70856. * @param bufferViews
  70857. * @param accessors
  70858. * @param convertToRightHandedSystem
  70859. */
  70860. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  70861. [key: number]: number;
  70862. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70863. /**
  70864. * @ignore
  70865. * Create node animations from the animation groups
  70866. * @param babylonScene
  70867. * @param glTFAnimations
  70868. * @param nodeMap
  70869. * @param nodes
  70870. * @param binaryWriter
  70871. * @param bufferViews
  70872. * @param accessors
  70873. * @param convertToRightHandedSystem
  70874. */
  70875. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70876. [key: number]: number;
  70877. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70878. private static AddAnimation;
  70879. /**
  70880. * Create a baked animation
  70881. * @param babylonTransformNode BabylonJS mesh
  70882. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70883. * @param animationChannelTargetPath animation target channel
  70884. * @param minFrame minimum animation frame
  70885. * @param maxFrame maximum animation frame
  70886. * @param fps frames per second of the animation
  70887. * @param inputs input key frames of the animation
  70888. * @param outputs output key frame data of the animation
  70889. * @param convertToRightHandedSystem converts the values to right-handed
  70890. * @param useQuaternion specifies if quaternions should be used
  70891. */
  70892. private static _CreateBakedAnimation;
  70893. private static _ConvertFactorToVector3OrQuaternion;
  70894. private static _SetInterpolatedValue;
  70895. /**
  70896. * Creates linear animation from the animation key frames
  70897. * @param babylonTransformNode BabylonJS mesh
  70898. * @param animation BabylonJS animation
  70899. * @param animationChannelTargetPath The target animation channel
  70900. * @param frameDelta The difference between the last and first frame of the animation
  70901. * @param inputs Array to store the key frame times
  70902. * @param outputs Array to store the key frame data
  70903. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70904. * @param useQuaternion Specifies if quaternions are used in the animation
  70905. */
  70906. private static _CreateLinearOrStepAnimation;
  70907. /**
  70908. * Creates cubic spline animation from the animation key frames
  70909. * @param babylonTransformNode BabylonJS mesh
  70910. * @param animation BabylonJS animation
  70911. * @param animationChannelTargetPath The target animation channel
  70912. * @param frameDelta The difference between the last and first frame of the animation
  70913. * @param inputs Array to store the key frame times
  70914. * @param outputs Array to store the key frame data
  70915. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70916. * @param useQuaternion Specifies if quaternions are used in the animation
  70917. */
  70918. private static _CreateCubicSplineAnimation;
  70919. private static _GetBasePositionRotationOrScale;
  70920. /**
  70921. * Adds a key frame value
  70922. * @param keyFrame
  70923. * @param animation
  70924. * @param outputs
  70925. * @param animationChannelTargetPath
  70926. * @param basePositionRotationOrScale
  70927. * @param convertToRightHandedSystem
  70928. * @param useQuaternion
  70929. */
  70930. private static _AddKeyframeValue;
  70931. /**
  70932. * Determine the interpolation based on the key frames
  70933. * @param keyFrames
  70934. * @param animationChannelTargetPath
  70935. * @param useQuaternion
  70936. */
  70937. private static _DeduceInterpolation;
  70938. /**
  70939. * Adds an input tangent or output tangent to the output data
  70940. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  70941. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  70942. * @param outputs The animation data by keyframe
  70943. * @param animationChannelTargetPath The target animation channel
  70944. * @param interpolation The interpolation type
  70945. * @param keyFrame The key frame with the animation data
  70946. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  70947. * @param useQuaternion Specifies if quaternions are used
  70948. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  70949. */
  70950. private static AddSplineTangent;
  70951. /**
  70952. * Get the minimum and maximum key frames' frame values
  70953. * @param keyFrames animation key frames
  70954. * @returns the minimum and maximum key frame value
  70955. */
  70956. private static calculateMinMaxKeyFrames;
  70957. }
  70958. }
  70959. declare module BABYLON.GLTF2.Exporter {
  70960. /** @hidden */
  70961. export var textureTransformPixelShader: {
  70962. name: string;
  70963. shader: string;
  70964. };
  70965. }
  70966. declare module BABYLON.GLTF2.Exporter.Extensions {
  70967. /**
  70968. * @hidden
  70969. */
  70970. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  70971. /** Name of this extension */
  70972. readonly name: string;
  70973. /** Defines whether this extension is enabled */
  70974. enabled: boolean;
  70975. /** Defines whether this extension is required */
  70976. required: boolean;
  70977. /** Reference to the glTF exporter */
  70978. private _exporter;
  70979. constructor(exporter: _Exporter);
  70980. dispose(): void;
  70981. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70982. /**
  70983. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  70984. * @param babylonTexture
  70985. * @param offset
  70986. * @param rotation
  70987. * @param scale
  70988. * @param scene
  70989. */
  70990. private _textureTransformTextureAsync;
  70991. }
  70992. }
  70993. declare module BABYLON.GLTF2.Exporter.Extensions {
  70994. /**
  70995. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70996. */
  70997. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  70998. /** The name of this extension. */
  70999. readonly name: string;
  71000. /** Defines whether this extension is enabled. */
  71001. enabled: boolean;
  71002. /** Defines whether this extension is required */
  71003. required: boolean;
  71004. /** Reference to the glTF exporter */
  71005. private _exporter;
  71006. private _lights;
  71007. /** @hidden */
  71008. constructor(exporter: _Exporter);
  71009. /** @hidden */
  71010. dispose(): void;
  71011. /** @hidden */
  71012. onExporting(): void;
  71013. /**
  71014. * Define this method to modify the default behavior when exporting a node
  71015. * @param context The context when exporting the node
  71016. * @param node glTF node
  71017. * @param babylonNode BabylonJS node
  71018. * @returns nullable INode promise
  71019. */
  71020. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71021. }
  71022. }
  71023. declare module BABYLON {
  71024. /**
  71025. * Class for generating STL data from a Babylon scene.
  71026. */
  71027. export class STLExport {
  71028. /**
  71029. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  71030. * @param meshes list defines the mesh to serialize
  71031. * @param download triggers the automatic download of the file.
  71032. * @param fileName changes the downloads fileName.
  71033. * @param binary changes the STL to a binary type.
  71034. * @param isLittleEndian toggle for binary type exporter.
  71035. * @returns the STL as UTF8 string
  71036. */
  71037. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  71038. }
  71039. }
  71040. declare module "babylonjs-gltf2interface" {
  71041. export = BABYLON.GLTF2;
  71042. }
  71043. /**
  71044. * Module for glTF 2.0 Interface
  71045. */
  71046. declare module BABYLON.GLTF2 {
  71047. /**
  71048. * The datatype of the components in the attribute
  71049. */
  71050. const enum AccessorComponentType {
  71051. /**
  71052. * Byte
  71053. */
  71054. BYTE = 5120,
  71055. /**
  71056. * Unsigned Byte
  71057. */
  71058. UNSIGNED_BYTE = 5121,
  71059. /**
  71060. * Short
  71061. */
  71062. SHORT = 5122,
  71063. /**
  71064. * Unsigned Short
  71065. */
  71066. UNSIGNED_SHORT = 5123,
  71067. /**
  71068. * Unsigned Int
  71069. */
  71070. UNSIGNED_INT = 5125,
  71071. /**
  71072. * Float
  71073. */
  71074. FLOAT = 5126,
  71075. }
  71076. /**
  71077. * Specifies if the attirbute is a scalar, vector, or matrix
  71078. */
  71079. const enum AccessorType {
  71080. /**
  71081. * Scalar
  71082. */
  71083. SCALAR = "SCALAR",
  71084. /**
  71085. * Vector2
  71086. */
  71087. VEC2 = "VEC2",
  71088. /**
  71089. * Vector3
  71090. */
  71091. VEC3 = "VEC3",
  71092. /**
  71093. * Vector4
  71094. */
  71095. VEC4 = "VEC4",
  71096. /**
  71097. * Matrix2x2
  71098. */
  71099. MAT2 = "MAT2",
  71100. /**
  71101. * Matrix3x3
  71102. */
  71103. MAT3 = "MAT3",
  71104. /**
  71105. * Matrix4x4
  71106. */
  71107. MAT4 = "MAT4",
  71108. }
  71109. /**
  71110. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  71111. */
  71112. const enum AnimationChannelTargetPath {
  71113. /**
  71114. * Translation
  71115. */
  71116. TRANSLATION = "translation",
  71117. /**
  71118. * Rotation
  71119. */
  71120. ROTATION = "rotation",
  71121. /**
  71122. * Scale
  71123. */
  71124. SCALE = "scale",
  71125. /**
  71126. * Weights
  71127. */
  71128. WEIGHTS = "weights",
  71129. }
  71130. /**
  71131. * Interpolation algorithm
  71132. */
  71133. const enum AnimationSamplerInterpolation {
  71134. /**
  71135. * The animated values are linearly interpolated between keyframes
  71136. */
  71137. LINEAR = "LINEAR",
  71138. /**
  71139. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  71140. */
  71141. STEP = "STEP",
  71142. /**
  71143. * The animation's interpolation is computed using a cubic spline with specified tangents
  71144. */
  71145. CUBICSPLINE = "CUBICSPLINE",
  71146. }
  71147. /**
  71148. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71149. */
  71150. const enum CameraType {
  71151. /**
  71152. * A perspective camera containing properties to create a perspective projection matrix
  71153. */
  71154. PERSPECTIVE = "perspective",
  71155. /**
  71156. * An orthographic camera containing properties to create an orthographic projection matrix
  71157. */
  71158. ORTHOGRAPHIC = "orthographic",
  71159. }
  71160. /**
  71161. * The mime-type of the image
  71162. */
  71163. const enum ImageMimeType {
  71164. /**
  71165. * JPEG Mime-type
  71166. */
  71167. JPEG = "image/jpeg",
  71168. /**
  71169. * PNG Mime-type
  71170. */
  71171. PNG = "image/png",
  71172. }
  71173. /**
  71174. * The alpha rendering mode of the material
  71175. */
  71176. const enum MaterialAlphaMode {
  71177. /**
  71178. * The alpha value is ignored and the rendered output is fully opaque
  71179. */
  71180. OPAQUE = "OPAQUE",
  71181. /**
  71182. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  71183. */
  71184. MASK = "MASK",
  71185. /**
  71186. * 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)
  71187. */
  71188. BLEND = "BLEND",
  71189. }
  71190. /**
  71191. * The type of the primitives to render
  71192. */
  71193. const enum MeshPrimitiveMode {
  71194. /**
  71195. * Points
  71196. */
  71197. POINTS = 0,
  71198. /**
  71199. * Lines
  71200. */
  71201. LINES = 1,
  71202. /**
  71203. * Line Loop
  71204. */
  71205. LINE_LOOP = 2,
  71206. /**
  71207. * Line Strip
  71208. */
  71209. LINE_STRIP = 3,
  71210. /**
  71211. * Triangles
  71212. */
  71213. TRIANGLES = 4,
  71214. /**
  71215. * Triangle Strip
  71216. */
  71217. TRIANGLE_STRIP = 5,
  71218. /**
  71219. * Triangle Fan
  71220. */
  71221. TRIANGLE_FAN = 6,
  71222. }
  71223. /**
  71224. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71225. */
  71226. const enum TextureMagFilter {
  71227. /**
  71228. * Nearest
  71229. */
  71230. NEAREST = 9728,
  71231. /**
  71232. * Linear
  71233. */
  71234. LINEAR = 9729,
  71235. }
  71236. /**
  71237. * Minification filter. All valid values correspond to WebGL enums
  71238. */
  71239. const enum TextureMinFilter {
  71240. /**
  71241. * Nearest
  71242. */
  71243. NEAREST = 9728,
  71244. /**
  71245. * Linear
  71246. */
  71247. LINEAR = 9729,
  71248. /**
  71249. * Nearest Mip-Map Nearest
  71250. */
  71251. NEAREST_MIPMAP_NEAREST = 9984,
  71252. /**
  71253. * Linear Mipmap Nearest
  71254. */
  71255. LINEAR_MIPMAP_NEAREST = 9985,
  71256. /**
  71257. * Nearest Mipmap Linear
  71258. */
  71259. NEAREST_MIPMAP_LINEAR = 9986,
  71260. /**
  71261. * Linear Mipmap Linear
  71262. */
  71263. LINEAR_MIPMAP_LINEAR = 9987,
  71264. }
  71265. /**
  71266. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71267. */
  71268. const enum TextureWrapMode {
  71269. /**
  71270. * Clamp to Edge
  71271. */
  71272. CLAMP_TO_EDGE = 33071,
  71273. /**
  71274. * Mirrored Repeat
  71275. */
  71276. MIRRORED_REPEAT = 33648,
  71277. /**
  71278. * Repeat
  71279. */
  71280. REPEAT = 10497,
  71281. }
  71282. /**
  71283. * glTF Property
  71284. */
  71285. interface IProperty {
  71286. /**
  71287. * Dictionary object with extension-specific objects
  71288. */
  71289. extensions?: {
  71290. [key: string]: any;
  71291. };
  71292. /**
  71293. * Application-Specific data
  71294. */
  71295. extras?: any;
  71296. }
  71297. /**
  71298. * glTF Child of Root Property
  71299. */
  71300. interface IChildRootProperty extends IProperty {
  71301. /**
  71302. * The user-defined name of this object
  71303. */
  71304. name?: string;
  71305. }
  71306. /**
  71307. * Indices of those attributes that deviate from their initialization value
  71308. */
  71309. interface IAccessorSparseIndices extends IProperty {
  71310. /**
  71311. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71312. */
  71313. bufferView: number;
  71314. /**
  71315. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71316. */
  71317. byteOffset?: number;
  71318. /**
  71319. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  71320. */
  71321. componentType: AccessorComponentType;
  71322. }
  71323. /**
  71324. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  71325. */
  71326. interface IAccessorSparseValues extends IProperty {
  71327. /**
  71328. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71329. */
  71330. bufferView: number;
  71331. /**
  71332. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71333. */
  71334. byteOffset?: number;
  71335. }
  71336. /**
  71337. * Sparse storage of attributes that deviate from their initialization value
  71338. */
  71339. interface IAccessorSparse extends IProperty {
  71340. /**
  71341. * The number of attributes encoded in this sparse accessor
  71342. */
  71343. count: number;
  71344. /**
  71345. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  71346. */
  71347. indices: IAccessorSparseIndices;
  71348. /**
  71349. * 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
  71350. */
  71351. values: IAccessorSparseValues;
  71352. }
  71353. /**
  71354. * 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
  71355. */
  71356. interface IAccessor extends IChildRootProperty {
  71357. /**
  71358. * The index of the bufferview
  71359. */
  71360. bufferView?: number;
  71361. /**
  71362. * The offset relative to the start of the bufferView in bytes
  71363. */
  71364. byteOffset?: number;
  71365. /**
  71366. * The datatype of components in the attribute
  71367. */
  71368. componentType: AccessorComponentType;
  71369. /**
  71370. * Specifies whether integer data values should be normalized
  71371. */
  71372. normalized?: boolean;
  71373. /**
  71374. * The number of attributes referenced by this accessor
  71375. */
  71376. count: number;
  71377. /**
  71378. * Specifies if the attribute is a scalar, vector, or matrix
  71379. */
  71380. type: AccessorType;
  71381. /**
  71382. * Maximum value of each component in this attribute
  71383. */
  71384. max?: number[];
  71385. /**
  71386. * Minimum value of each component in this attribute
  71387. */
  71388. min?: number[];
  71389. /**
  71390. * Sparse storage of attributes that deviate from their initialization value
  71391. */
  71392. sparse?: IAccessorSparse;
  71393. }
  71394. /**
  71395. * Targets an animation's sampler at a node's property
  71396. */
  71397. interface IAnimationChannel extends IProperty {
  71398. /**
  71399. * The index of a sampler in this animation used to compute the value for the target
  71400. */
  71401. sampler: number;
  71402. /**
  71403. * The index of the node and TRS property to target
  71404. */
  71405. target: IAnimationChannelTarget;
  71406. }
  71407. /**
  71408. * The index of the node and TRS property that an animation channel targets
  71409. */
  71410. interface IAnimationChannelTarget extends IProperty {
  71411. /**
  71412. * The index of the node to target
  71413. */
  71414. node: number;
  71415. /**
  71416. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  71417. */
  71418. path: AnimationChannelTargetPath;
  71419. }
  71420. /**
  71421. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  71422. */
  71423. interface IAnimationSampler extends IProperty {
  71424. /**
  71425. * The index of an accessor containing keyframe input values, e.g., time
  71426. */
  71427. input: number;
  71428. /**
  71429. * Interpolation algorithm
  71430. */
  71431. interpolation?: AnimationSamplerInterpolation;
  71432. /**
  71433. * The index of an accessor, containing keyframe output values
  71434. */
  71435. output: number;
  71436. }
  71437. /**
  71438. * A keyframe animation
  71439. */
  71440. interface IAnimation extends IChildRootProperty {
  71441. /**
  71442. * An array of channels, each of which targets an animation's sampler at a node's property
  71443. */
  71444. channels: IAnimationChannel[];
  71445. /**
  71446. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  71447. */
  71448. samplers: IAnimationSampler[];
  71449. }
  71450. /**
  71451. * Metadata about the glTF asset
  71452. */
  71453. interface IAsset extends IChildRootProperty {
  71454. /**
  71455. * A copyright message suitable for display to credit the content creator
  71456. */
  71457. copyright?: string;
  71458. /**
  71459. * Tool that generated this glTF model. Useful for debugging
  71460. */
  71461. generator?: string;
  71462. /**
  71463. * The glTF version that this asset targets
  71464. */
  71465. version: string;
  71466. /**
  71467. * The minimum glTF version that this asset targets
  71468. */
  71469. minVersion?: string;
  71470. }
  71471. /**
  71472. * A buffer points to binary geometry, animation, or skins
  71473. */
  71474. interface IBuffer extends IChildRootProperty {
  71475. /**
  71476. * 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
  71477. */
  71478. uri?: string;
  71479. /**
  71480. * The length of the buffer in bytes
  71481. */
  71482. byteLength: number;
  71483. }
  71484. /**
  71485. * A view into a buffer generally representing a subset of the buffer
  71486. */
  71487. interface IBufferView extends IChildRootProperty {
  71488. /**
  71489. * The index of the buffer
  71490. */
  71491. buffer: number;
  71492. /**
  71493. * The offset into the buffer in bytes
  71494. */
  71495. byteOffset?: number;
  71496. /**
  71497. * The lenth of the bufferView in bytes
  71498. */
  71499. byteLength: number;
  71500. /**
  71501. * The stride, in bytes
  71502. */
  71503. byteStride?: number;
  71504. }
  71505. /**
  71506. * An orthographic camera containing properties to create an orthographic projection matrix
  71507. */
  71508. interface ICameraOrthographic extends IProperty {
  71509. /**
  71510. * The floating-point horizontal magnification of the view. Must not be zero
  71511. */
  71512. xmag: number;
  71513. /**
  71514. * The floating-point vertical magnification of the view. Must not be zero
  71515. */
  71516. ymag: number;
  71517. /**
  71518. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  71519. */
  71520. zfar: number;
  71521. /**
  71522. * The floating-point distance to the near clipping plane
  71523. */
  71524. znear: number;
  71525. }
  71526. /**
  71527. * A perspective camera containing properties to create a perspective projection matrix
  71528. */
  71529. interface ICameraPerspective extends IProperty {
  71530. /**
  71531. * The floating-point aspect ratio of the field of view
  71532. */
  71533. aspectRatio?: number;
  71534. /**
  71535. * The floating-point vertical field of view in radians
  71536. */
  71537. yfov: number;
  71538. /**
  71539. * The floating-point distance to the far clipping plane
  71540. */
  71541. zfar?: number;
  71542. /**
  71543. * The floating-point distance to the near clipping plane
  71544. */
  71545. znear: number;
  71546. }
  71547. /**
  71548. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71549. */
  71550. interface ICamera extends IChildRootProperty {
  71551. /**
  71552. * An orthographic camera containing properties to create an orthographic projection matrix
  71553. */
  71554. orthographic?: ICameraOrthographic;
  71555. /**
  71556. * A perspective camera containing properties to create a perspective projection matrix
  71557. */
  71558. perspective?: ICameraPerspective;
  71559. /**
  71560. * Specifies if the camera uses a perspective or orthographic projection
  71561. */
  71562. type: CameraType;
  71563. }
  71564. /**
  71565. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  71566. */
  71567. interface IImage extends IChildRootProperty {
  71568. /**
  71569. * 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
  71570. */
  71571. uri?: string;
  71572. /**
  71573. * The image's MIME type
  71574. */
  71575. mimeType?: ImageMimeType;
  71576. /**
  71577. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  71578. */
  71579. bufferView?: number;
  71580. }
  71581. /**
  71582. * Material Normal Texture Info
  71583. */
  71584. interface IMaterialNormalTextureInfo extends ITextureInfo {
  71585. /**
  71586. * The scalar multiplier applied to each normal vector of the normal texture
  71587. */
  71588. scale?: number;
  71589. }
  71590. /**
  71591. * Material Occlusion Texture Info
  71592. */
  71593. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  71594. /**
  71595. * A scalar multiplier controlling the amount of occlusion applied
  71596. */
  71597. strength?: number;
  71598. }
  71599. /**
  71600. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  71601. */
  71602. interface IMaterialPbrMetallicRoughness {
  71603. /**
  71604. * The material's base color factor
  71605. */
  71606. baseColorFactor?: number[];
  71607. /**
  71608. * The base color texture
  71609. */
  71610. baseColorTexture?: ITextureInfo;
  71611. /**
  71612. * The metalness of the material
  71613. */
  71614. metallicFactor?: number;
  71615. /**
  71616. * The roughness of the material
  71617. */
  71618. roughnessFactor?: number;
  71619. /**
  71620. * The metallic-roughness texture
  71621. */
  71622. metallicRoughnessTexture?: ITextureInfo;
  71623. }
  71624. /**
  71625. * The material appearance of a primitive
  71626. */
  71627. interface IMaterial extends IChildRootProperty {
  71628. /**
  71629. * 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
  71630. */
  71631. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71632. /**
  71633. * The normal map texture
  71634. */
  71635. normalTexture?: IMaterialNormalTextureInfo;
  71636. /**
  71637. * The occlusion map texture
  71638. */
  71639. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71640. /**
  71641. * The emissive map texture
  71642. */
  71643. emissiveTexture?: ITextureInfo;
  71644. /**
  71645. * 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
  71646. */
  71647. emissiveFactor?: number[];
  71648. /**
  71649. * The alpha rendering mode of the material
  71650. */
  71651. alphaMode?: MaterialAlphaMode;
  71652. /**
  71653. * The alpha cutoff value of the material
  71654. */
  71655. alphaCutoff?: number;
  71656. /**
  71657. * Specifies whether the material is double sided
  71658. */
  71659. doubleSided?: boolean;
  71660. }
  71661. /**
  71662. * Geometry to be rendered with the given material
  71663. */
  71664. interface IMeshPrimitive extends IProperty {
  71665. /**
  71666. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  71667. */
  71668. attributes: {
  71669. [name: string]: number;
  71670. };
  71671. /**
  71672. * The index of the accessor that contains the indices
  71673. */
  71674. indices?: number;
  71675. /**
  71676. * The index of the material to apply to this primitive when rendering
  71677. */
  71678. material?: number;
  71679. /**
  71680. * The type of primitives to render. All valid values correspond to WebGL enums
  71681. */
  71682. mode?: MeshPrimitiveMode;
  71683. /**
  71684. * 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
  71685. */
  71686. targets?: {
  71687. [name: string]: number;
  71688. }[];
  71689. }
  71690. /**
  71691. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  71692. */
  71693. interface IMesh extends IChildRootProperty {
  71694. /**
  71695. * An array of primitives, each defining geometry to be rendered with a material
  71696. */
  71697. primitives: IMeshPrimitive[];
  71698. /**
  71699. * Array of weights to be applied to the Morph Targets
  71700. */
  71701. weights?: number[];
  71702. }
  71703. /**
  71704. * A node in the node hierarchy
  71705. */
  71706. interface INode extends IChildRootProperty {
  71707. /**
  71708. * The index of the camera referenced by this node
  71709. */
  71710. camera?: number;
  71711. /**
  71712. * The indices of this node's children
  71713. */
  71714. children?: number[];
  71715. /**
  71716. * The index of the skin referenced by this node
  71717. */
  71718. skin?: number;
  71719. /**
  71720. * A floating-point 4x4 transformation matrix stored in column-major order
  71721. */
  71722. matrix?: number[];
  71723. /**
  71724. * The index of the mesh in this node
  71725. */
  71726. mesh?: number;
  71727. /**
  71728. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  71729. */
  71730. rotation?: number[];
  71731. /**
  71732. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  71733. */
  71734. scale?: number[];
  71735. /**
  71736. * The node's translation along the x, y, and z axes
  71737. */
  71738. translation?: number[];
  71739. /**
  71740. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  71741. */
  71742. weights?: number[];
  71743. }
  71744. /**
  71745. * Texture sampler properties for filtering and wrapping modes
  71746. */
  71747. interface ISampler extends IChildRootProperty {
  71748. /**
  71749. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71750. */
  71751. magFilter?: TextureMagFilter;
  71752. /**
  71753. * Minification filter. All valid values correspond to WebGL enums
  71754. */
  71755. minFilter?: TextureMinFilter;
  71756. /**
  71757. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71758. */
  71759. wrapS?: TextureWrapMode;
  71760. /**
  71761. * T (V) wrapping mode. All valid values correspond to WebGL enums
  71762. */
  71763. wrapT?: TextureWrapMode;
  71764. }
  71765. /**
  71766. * The root nodes of a scene
  71767. */
  71768. interface IScene extends IChildRootProperty {
  71769. /**
  71770. * The indices of each root node
  71771. */
  71772. nodes: number[];
  71773. }
  71774. /**
  71775. * Joints and matrices defining a skin
  71776. */
  71777. interface ISkin extends IChildRootProperty {
  71778. /**
  71779. * 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
  71780. */
  71781. inverseBindMatrices?: number;
  71782. /**
  71783. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  71784. */
  71785. skeleton?: number;
  71786. /**
  71787. * 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)
  71788. */
  71789. joints: number[];
  71790. }
  71791. /**
  71792. * A texture and its sampler
  71793. */
  71794. interface ITexture extends IChildRootProperty {
  71795. /**
  71796. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  71797. */
  71798. sampler?: number;
  71799. /**
  71800. * The index of the image used by this texture
  71801. */
  71802. source: number;
  71803. }
  71804. /**
  71805. * Reference to a texture
  71806. */
  71807. interface ITextureInfo extends IProperty {
  71808. /**
  71809. * The index of the texture
  71810. */
  71811. index: number;
  71812. /**
  71813. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  71814. */
  71815. texCoord?: number;
  71816. }
  71817. /**
  71818. * The root object for a glTF asset
  71819. */
  71820. interface IGLTF extends IProperty {
  71821. /**
  71822. * An array of accessors. An accessor is a typed view into a bufferView
  71823. */
  71824. accessors?: IAccessor[];
  71825. /**
  71826. * An array of keyframe animations
  71827. */
  71828. animations?: IAnimation[];
  71829. /**
  71830. * Metadata about the glTF asset
  71831. */
  71832. asset: IAsset;
  71833. /**
  71834. * An array of buffers. A buffer points to binary geometry, animation, or skins
  71835. */
  71836. buffers?: IBuffer[];
  71837. /**
  71838. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  71839. */
  71840. bufferViews?: IBufferView[];
  71841. /**
  71842. * An array of cameras
  71843. */
  71844. cameras?: ICamera[];
  71845. /**
  71846. * Names of glTF extensions used somewhere in this asset
  71847. */
  71848. extensionsUsed?: string[];
  71849. /**
  71850. * Names of glTF extensions required to properly load this asset
  71851. */
  71852. extensionsRequired?: string[];
  71853. /**
  71854. * An array of images. An image defines data used to create a texture
  71855. */
  71856. images?: IImage[];
  71857. /**
  71858. * An array of materials. A material defines the appearance of a primitive
  71859. */
  71860. materials?: IMaterial[];
  71861. /**
  71862. * An array of meshes. A mesh is a set of primitives to be rendered
  71863. */
  71864. meshes?: IMesh[];
  71865. /**
  71866. * An array of nodes
  71867. */
  71868. nodes?: INode[];
  71869. /**
  71870. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71871. */
  71872. samplers?: ISampler[];
  71873. /**
  71874. * The index of the default scene
  71875. */
  71876. scene?: number;
  71877. /**
  71878. * An array of scenes
  71879. */
  71880. scenes?: IScene[];
  71881. /**
  71882. * An array of skins. A skin is defined by joints and matrices
  71883. */
  71884. skins?: ISkin[];
  71885. /**
  71886. * An array of textures
  71887. */
  71888. textures?: ITexture[];
  71889. }
  71890. /**
  71891. * The glTF validation results
  71892. * @ignore
  71893. */
  71894. interface IGLTFValidationResults {
  71895. info: {
  71896. generator: string;
  71897. hasAnimations: boolean;
  71898. hasDefaultScene: boolean;
  71899. hasMaterials: boolean;
  71900. hasMorphTargets: boolean;
  71901. hasSkins: boolean;
  71902. hasTextures: boolean;
  71903. maxAttributesUsed: number;
  71904. primitivesCount: number
  71905. };
  71906. issues: {
  71907. messages: Array<string>;
  71908. numErrors: number;
  71909. numHints: number;
  71910. numInfos: number;
  71911. numWarnings: number;
  71912. truncated: boolean
  71913. };
  71914. mimeType: string;
  71915. uri: string;
  71916. validatedAt: string;
  71917. validatorVersion: string;
  71918. }
  71919. /**
  71920. * The glTF validation options
  71921. */
  71922. interface IGLTFValidationOptions {
  71923. /** Uri to use */
  71924. uri?: string;
  71925. /** Function used to load external resources */
  71926. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  71927. /** Boolean indicating that we need to validate accessor data */
  71928. validateAccessorData?: boolean;
  71929. /** max number of issues allowed */
  71930. maxIssues?: number;
  71931. /** Ignored issues */
  71932. ignoredIssues?: Array<string>;
  71933. /** Value to override severy settings */
  71934. severityOverrides?: Object;
  71935. }
  71936. /**
  71937. * The glTF validator object
  71938. * @ignore
  71939. */
  71940. interface IGLTFValidator {
  71941. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71942. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71943. }
  71944. }
  71945. declare module BABYLON {
  71946. /** @hidden */
  71947. export var cellPixelShader: {
  71948. name: string;
  71949. shader: string;
  71950. };
  71951. }
  71952. declare module BABYLON {
  71953. /** @hidden */
  71954. export var cellVertexShader: {
  71955. name: string;
  71956. shader: string;
  71957. };
  71958. }
  71959. declare module BABYLON {
  71960. export class CellMaterial extends BABYLON.PushMaterial {
  71961. private _diffuseTexture;
  71962. diffuseTexture: BABYLON.BaseTexture;
  71963. diffuseColor: BABYLON.Color3;
  71964. _computeHighLevel: boolean;
  71965. computeHighLevel: boolean;
  71966. private _disableLighting;
  71967. disableLighting: boolean;
  71968. private _maxSimultaneousLights;
  71969. maxSimultaneousLights: number;
  71970. private _renderId;
  71971. constructor(name: string, scene: BABYLON.Scene);
  71972. needAlphaBlending(): boolean;
  71973. needAlphaTesting(): boolean;
  71974. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71975. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71976. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71977. getAnimatables(): BABYLON.IAnimatable[];
  71978. getActiveTextures(): BABYLON.BaseTexture[];
  71979. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71980. dispose(forceDisposeEffect?: boolean): void;
  71981. getClassName(): string;
  71982. clone(name: string): CellMaterial;
  71983. serialize(): any;
  71984. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  71985. }
  71986. }
  71987. declare module BABYLON {
  71988. export class CustomShaderStructure {
  71989. FragmentStore: string;
  71990. VertexStore: string;
  71991. constructor();
  71992. }
  71993. export class ShaderSpecialParts {
  71994. constructor();
  71995. Fragment_Begin: string;
  71996. Fragment_Definitions: string;
  71997. Fragment_MainBegin: string;
  71998. Fragment_Custom_Diffuse: string;
  71999. Fragment_Before_Lights: string;
  72000. Fragment_Before_Fog: string;
  72001. Fragment_Custom_Alpha: string;
  72002. Fragment_Before_FragColor: string;
  72003. Vertex_Begin: string;
  72004. Vertex_Definitions: string;
  72005. Vertex_MainBegin: string;
  72006. Vertex_Before_PositionUpdated: string;
  72007. Vertex_Before_NormalUpdated: string;
  72008. Vertex_MainEnd: string;
  72009. }
  72010. export class CustomMaterial extends BABYLON.StandardMaterial {
  72011. static ShaderIndexer: number;
  72012. CustomParts: ShaderSpecialParts;
  72013. _isCreatedShader: boolean;
  72014. _createdShaderName: string;
  72015. _customUniform: string[];
  72016. _newUniforms: string[];
  72017. _newUniformInstances: any[];
  72018. _newSamplerInstances: BABYLON.Texture[];
  72019. FragmentShader: string;
  72020. VertexShader: string;
  72021. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72022. ReviewUniform(name: string, arr: string[]): string[];
  72023. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  72024. constructor(name: string, scene: BABYLON.Scene);
  72025. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  72026. Fragment_Begin(shaderPart: string): CustomMaterial;
  72027. Fragment_Definitions(shaderPart: string): CustomMaterial;
  72028. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  72029. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  72030. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  72031. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  72032. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  72033. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  72034. Vertex_Begin(shaderPart: string): CustomMaterial;
  72035. Vertex_Definitions(shaderPart: string): CustomMaterial;
  72036. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  72037. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  72038. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  72039. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  72040. }
  72041. }
  72042. declare module BABYLON {
  72043. export class ShaderAlebdoParts {
  72044. constructor();
  72045. Fragment_Begin: string;
  72046. Fragment_Definitions: string;
  72047. Fragment_MainBegin: string;
  72048. Fragment_Custom_Albedo: string;
  72049. Fragment_Before_Lights: string;
  72050. Fragment_Custom_MetallicRoughness: string;
  72051. Fragment_Custom_MicroSurface: string;
  72052. Fragment_Before_Fog: string;
  72053. Fragment_Custom_Alpha: string;
  72054. Fragment_Before_FragColor: string;
  72055. Vertex_Begin: string;
  72056. Vertex_Definitions: string;
  72057. Vertex_MainBegin: string;
  72058. Vertex_Before_PositionUpdated: string;
  72059. Vertex_Before_NormalUpdated: string;
  72060. Vertex_MainEnd: string;
  72061. }
  72062. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  72063. static ShaderIndexer: number;
  72064. CustomParts: ShaderAlebdoParts;
  72065. _isCreatedShader: boolean;
  72066. _createdShaderName: string;
  72067. _customUniform: string[];
  72068. _newUniforms: string[];
  72069. _newUniformInstances: any[];
  72070. _newSamplerInstances: BABYLON.Texture[];
  72071. FragmentShader: string;
  72072. VertexShader: string;
  72073. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72074. ReviewUniform(name: string, arr: string[]): string[];
  72075. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  72076. constructor(name: string, scene: BABYLON.Scene);
  72077. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  72078. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  72079. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  72080. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  72081. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  72082. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  72083. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  72084. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  72085. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  72086. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  72087. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  72088. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  72089. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  72090. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  72091. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  72092. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  72093. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  72094. }
  72095. }
  72096. declare module BABYLON {
  72097. /** @hidden */
  72098. export var firePixelShader: {
  72099. name: string;
  72100. shader: string;
  72101. };
  72102. }
  72103. declare module BABYLON {
  72104. /** @hidden */
  72105. export var fireVertexShader: {
  72106. name: string;
  72107. shader: string;
  72108. };
  72109. }
  72110. declare module BABYLON {
  72111. export class FireMaterial extends BABYLON.PushMaterial {
  72112. private _diffuseTexture;
  72113. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72114. private _distortionTexture;
  72115. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72116. private _opacityTexture;
  72117. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72118. diffuseColor: BABYLON.Color3;
  72119. speed: number;
  72120. private _scaledDiffuse;
  72121. private _renderId;
  72122. private _lastTime;
  72123. constructor(name: string, scene: BABYLON.Scene);
  72124. needAlphaBlending(): boolean;
  72125. needAlphaTesting(): boolean;
  72126. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72127. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72128. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72129. getAnimatables(): BABYLON.IAnimatable[];
  72130. getActiveTextures(): BABYLON.BaseTexture[];
  72131. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72132. getClassName(): string;
  72133. dispose(forceDisposeEffect?: boolean): void;
  72134. clone(name: string): FireMaterial;
  72135. serialize(): any;
  72136. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  72137. }
  72138. }
  72139. declare module BABYLON {
  72140. /** @hidden */
  72141. export var furPixelShader: {
  72142. name: string;
  72143. shader: string;
  72144. };
  72145. }
  72146. declare module BABYLON {
  72147. /** @hidden */
  72148. export var furVertexShader: {
  72149. name: string;
  72150. shader: string;
  72151. };
  72152. }
  72153. declare module BABYLON {
  72154. export class FurMaterial extends BABYLON.PushMaterial {
  72155. private _diffuseTexture;
  72156. diffuseTexture: BABYLON.BaseTexture;
  72157. private _heightTexture;
  72158. heightTexture: BABYLON.BaseTexture;
  72159. diffuseColor: BABYLON.Color3;
  72160. furLength: number;
  72161. furAngle: number;
  72162. furColor: BABYLON.Color3;
  72163. furOffset: number;
  72164. furSpacing: number;
  72165. furGravity: BABYLON.Vector3;
  72166. furSpeed: number;
  72167. furDensity: number;
  72168. furOcclusion: number;
  72169. furTexture: BABYLON.DynamicTexture;
  72170. private _disableLighting;
  72171. disableLighting: boolean;
  72172. private _maxSimultaneousLights;
  72173. maxSimultaneousLights: number;
  72174. highLevelFur: boolean;
  72175. _meshes: BABYLON.AbstractMesh[];
  72176. private _renderId;
  72177. private _furTime;
  72178. constructor(name: string, scene: BABYLON.Scene);
  72179. furTime: number;
  72180. needAlphaBlending(): boolean;
  72181. needAlphaTesting(): boolean;
  72182. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72183. updateFur(): void;
  72184. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72185. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72186. getAnimatables(): BABYLON.IAnimatable[];
  72187. getActiveTextures(): BABYLON.BaseTexture[];
  72188. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72189. dispose(forceDisposeEffect?: boolean): void;
  72190. clone(name: string): FurMaterial;
  72191. serialize(): any;
  72192. getClassName(): string;
  72193. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  72194. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  72195. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  72196. }
  72197. }
  72198. declare module BABYLON {
  72199. /** @hidden */
  72200. export var gradientPixelShader: {
  72201. name: string;
  72202. shader: string;
  72203. };
  72204. }
  72205. declare module BABYLON {
  72206. /** @hidden */
  72207. export var gradientVertexShader: {
  72208. name: string;
  72209. shader: string;
  72210. };
  72211. }
  72212. declare module BABYLON {
  72213. export class GradientMaterial extends BABYLON.PushMaterial {
  72214. private _maxSimultaneousLights;
  72215. maxSimultaneousLights: number;
  72216. topColor: BABYLON.Color3;
  72217. topColorAlpha: number;
  72218. bottomColor: BABYLON.Color3;
  72219. bottomColorAlpha: number;
  72220. offset: number;
  72221. scale: number;
  72222. smoothness: number;
  72223. private _disableLighting;
  72224. disableLighting: boolean;
  72225. private _renderId;
  72226. constructor(name: string, scene: BABYLON.Scene);
  72227. needAlphaBlending(): boolean;
  72228. needAlphaTesting(): boolean;
  72229. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72230. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72231. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72232. getAnimatables(): BABYLON.IAnimatable[];
  72233. dispose(forceDisposeEffect?: boolean): void;
  72234. clone(name: string): GradientMaterial;
  72235. serialize(): any;
  72236. getClassName(): string;
  72237. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  72238. }
  72239. }
  72240. declare module BABYLON {
  72241. /** @hidden */
  72242. export var gridPixelShader: {
  72243. name: string;
  72244. shader: string;
  72245. };
  72246. }
  72247. declare module BABYLON {
  72248. /** @hidden */
  72249. export var gridVertexShader: {
  72250. name: string;
  72251. shader: string;
  72252. };
  72253. }
  72254. declare module BABYLON {
  72255. /**
  72256. * The grid materials allows you to wrap any shape with a grid.
  72257. * Colors are customizable.
  72258. */
  72259. export class GridMaterial extends BABYLON.PushMaterial {
  72260. /**
  72261. * Main color of the grid (e.g. between lines)
  72262. */
  72263. mainColor: BABYLON.Color3;
  72264. /**
  72265. * Color of the grid lines.
  72266. */
  72267. lineColor: BABYLON.Color3;
  72268. /**
  72269. * The scale of the grid compared to unit.
  72270. */
  72271. gridRatio: number;
  72272. /**
  72273. * Allows setting an offset for the grid lines.
  72274. */
  72275. gridOffset: BABYLON.Vector3;
  72276. /**
  72277. * The frequency of thicker lines.
  72278. */
  72279. majorUnitFrequency: number;
  72280. /**
  72281. * The visibility of minor units in the grid.
  72282. */
  72283. minorUnitVisibility: number;
  72284. /**
  72285. * The grid opacity outside of the lines.
  72286. */
  72287. opacity: number;
  72288. /**
  72289. * Determine RBG output is premultiplied by alpha value.
  72290. */
  72291. preMultiplyAlpha: boolean;
  72292. private _opacityTexture;
  72293. opacityTexture: BABYLON.BaseTexture;
  72294. private _gridControl;
  72295. private _renderId;
  72296. /**
  72297. * constructor
  72298. * @param name The name given to the material in order to identify it afterwards.
  72299. * @param scene The scene the material is used in.
  72300. */
  72301. constructor(name: string, scene: BABYLON.Scene);
  72302. /**
  72303. * Returns wehter or not the grid requires alpha blending.
  72304. */
  72305. needAlphaBlending(): boolean;
  72306. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72307. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72308. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72309. /**
  72310. * Dispose the material and its associated resources.
  72311. * @param forceDisposeEffect will also dispose the used effect when true
  72312. */
  72313. dispose(forceDisposeEffect?: boolean): void;
  72314. clone(name: string): GridMaterial;
  72315. serialize(): any;
  72316. getClassName(): string;
  72317. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  72318. }
  72319. }
  72320. declare module BABYLON {
  72321. /** @hidden */
  72322. export var lavaPixelShader: {
  72323. name: string;
  72324. shader: string;
  72325. };
  72326. }
  72327. declare module BABYLON {
  72328. /** @hidden */
  72329. export var lavaVertexShader: {
  72330. name: string;
  72331. shader: string;
  72332. };
  72333. }
  72334. declare module BABYLON {
  72335. export class LavaMaterial extends BABYLON.PushMaterial {
  72336. private _diffuseTexture;
  72337. diffuseTexture: BABYLON.BaseTexture;
  72338. noiseTexture: BABYLON.BaseTexture;
  72339. fogColor: BABYLON.Color3;
  72340. speed: number;
  72341. movingSpeed: number;
  72342. lowFrequencySpeed: number;
  72343. fogDensity: number;
  72344. private _lastTime;
  72345. diffuseColor: BABYLON.Color3;
  72346. private _disableLighting;
  72347. disableLighting: boolean;
  72348. private _unlit;
  72349. unlit: boolean;
  72350. private _maxSimultaneousLights;
  72351. maxSimultaneousLights: number;
  72352. private _scaledDiffuse;
  72353. private _renderId;
  72354. constructor(name: string, scene: BABYLON.Scene);
  72355. needAlphaBlending(): boolean;
  72356. needAlphaTesting(): boolean;
  72357. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72358. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72359. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72360. getAnimatables(): BABYLON.IAnimatable[];
  72361. getActiveTextures(): BABYLON.BaseTexture[];
  72362. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72363. dispose(forceDisposeEffect?: boolean): void;
  72364. clone(name: string): LavaMaterial;
  72365. serialize(): any;
  72366. getClassName(): string;
  72367. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  72368. }
  72369. }
  72370. declare module BABYLON {
  72371. /** @hidden */
  72372. export var mixPixelShader: {
  72373. name: string;
  72374. shader: string;
  72375. };
  72376. }
  72377. declare module BABYLON {
  72378. /** @hidden */
  72379. export var mixVertexShader: {
  72380. name: string;
  72381. shader: string;
  72382. };
  72383. }
  72384. declare module BABYLON {
  72385. export class MixMaterial extends BABYLON.PushMaterial {
  72386. /**
  72387. * Mix textures
  72388. */
  72389. private _mixTexture1;
  72390. mixTexture1: BABYLON.BaseTexture;
  72391. private _mixTexture2;
  72392. mixTexture2: BABYLON.BaseTexture;
  72393. /**
  72394. * Diffuse textures
  72395. */
  72396. private _diffuseTexture1;
  72397. diffuseTexture1: BABYLON.Texture;
  72398. private _diffuseTexture2;
  72399. diffuseTexture2: BABYLON.Texture;
  72400. private _diffuseTexture3;
  72401. diffuseTexture3: BABYLON.Texture;
  72402. private _diffuseTexture4;
  72403. diffuseTexture4: BABYLON.Texture;
  72404. private _diffuseTexture5;
  72405. diffuseTexture5: BABYLON.Texture;
  72406. private _diffuseTexture6;
  72407. diffuseTexture6: BABYLON.Texture;
  72408. private _diffuseTexture7;
  72409. diffuseTexture7: BABYLON.Texture;
  72410. private _diffuseTexture8;
  72411. diffuseTexture8: BABYLON.Texture;
  72412. /**
  72413. * Uniforms
  72414. */
  72415. diffuseColor: BABYLON.Color3;
  72416. specularColor: BABYLON.Color3;
  72417. specularPower: number;
  72418. private _disableLighting;
  72419. disableLighting: boolean;
  72420. private _maxSimultaneousLights;
  72421. maxSimultaneousLights: number;
  72422. private _renderId;
  72423. constructor(name: string, scene: BABYLON.Scene);
  72424. needAlphaBlending(): boolean;
  72425. needAlphaTesting(): boolean;
  72426. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72427. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72428. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72429. getAnimatables(): BABYLON.IAnimatable[];
  72430. getActiveTextures(): BABYLON.BaseTexture[];
  72431. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72432. dispose(forceDisposeEffect?: boolean): void;
  72433. clone(name: string): MixMaterial;
  72434. serialize(): any;
  72435. getClassName(): string;
  72436. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  72437. }
  72438. }
  72439. declare module BABYLON {
  72440. /** @hidden */
  72441. export var normalPixelShader: {
  72442. name: string;
  72443. shader: string;
  72444. };
  72445. }
  72446. declare module BABYLON {
  72447. /** @hidden */
  72448. export var normalVertexShader: {
  72449. name: string;
  72450. shader: string;
  72451. };
  72452. }
  72453. declare module BABYLON {
  72454. export class NormalMaterial extends BABYLON.PushMaterial {
  72455. private _diffuseTexture;
  72456. diffuseTexture: BABYLON.BaseTexture;
  72457. diffuseColor: BABYLON.Color3;
  72458. private _disableLighting;
  72459. disableLighting: boolean;
  72460. private _maxSimultaneousLights;
  72461. maxSimultaneousLights: number;
  72462. private _renderId;
  72463. constructor(name: string, scene: BABYLON.Scene);
  72464. needAlphaBlending(): boolean;
  72465. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72466. needAlphaTesting(): boolean;
  72467. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72468. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72469. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72470. getAnimatables(): BABYLON.IAnimatable[];
  72471. getActiveTextures(): BABYLON.BaseTexture[];
  72472. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72473. dispose(forceDisposeEffect?: boolean): void;
  72474. clone(name: string): NormalMaterial;
  72475. serialize(): any;
  72476. getClassName(): string;
  72477. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  72478. }
  72479. }
  72480. declare module BABYLON {
  72481. /** @hidden */
  72482. export var shadowOnlyPixelShader: {
  72483. name: string;
  72484. shader: string;
  72485. };
  72486. }
  72487. declare module BABYLON {
  72488. /** @hidden */
  72489. export var shadowOnlyVertexShader: {
  72490. name: string;
  72491. shader: string;
  72492. };
  72493. }
  72494. declare module BABYLON {
  72495. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  72496. private _renderId;
  72497. private _activeLight;
  72498. constructor(name: string, scene: BABYLON.Scene);
  72499. shadowColor: BABYLON.Color3;
  72500. needAlphaBlending(): boolean;
  72501. needAlphaTesting(): boolean;
  72502. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72503. activeLight: BABYLON.IShadowLight;
  72504. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72505. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72506. clone(name: string): ShadowOnlyMaterial;
  72507. serialize(): any;
  72508. getClassName(): string;
  72509. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  72510. }
  72511. }
  72512. declare module BABYLON {
  72513. /** @hidden */
  72514. export var simplePixelShader: {
  72515. name: string;
  72516. shader: string;
  72517. };
  72518. }
  72519. declare module BABYLON {
  72520. /** @hidden */
  72521. export var simpleVertexShader: {
  72522. name: string;
  72523. shader: string;
  72524. };
  72525. }
  72526. declare module BABYLON {
  72527. export class SimpleMaterial extends BABYLON.PushMaterial {
  72528. private _diffuseTexture;
  72529. diffuseTexture: BABYLON.BaseTexture;
  72530. diffuseColor: BABYLON.Color3;
  72531. private _disableLighting;
  72532. disableLighting: boolean;
  72533. private _maxSimultaneousLights;
  72534. maxSimultaneousLights: number;
  72535. private _renderId;
  72536. constructor(name: string, scene: BABYLON.Scene);
  72537. needAlphaBlending(): boolean;
  72538. needAlphaTesting(): boolean;
  72539. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72540. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72541. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72542. getAnimatables(): BABYLON.IAnimatable[];
  72543. getActiveTextures(): BABYLON.BaseTexture[];
  72544. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72545. dispose(forceDisposeEffect?: boolean): void;
  72546. clone(name: string): SimpleMaterial;
  72547. serialize(): any;
  72548. getClassName(): string;
  72549. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  72550. }
  72551. }
  72552. declare module BABYLON {
  72553. /** @hidden */
  72554. export var skyPixelShader: {
  72555. name: string;
  72556. shader: string;
  72557. };
  72558. }
  72559. declare module BABYLON {
  72560. /** @hidden */
  72561. export var skyVertexShader: {
  72562. name: string;
  72563. shader: string;
  72564. };
  72565. }
  72566. declare module BABYLON {
  72567. /**
  72568. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  72569. * @see https://doc.babylonjs.com/extensions/sky
  72570. */
  72571. export class SkyMaterial extends BABYLON.PushMaterial {
  72572. /**
  72573. * Defines the overall luminance of sky in interval ]0, 1[.
  72574. */
  72575. luminance: number;
  72576. /**
  72577. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  72578. */
  72579. turbidity: number;
  72580. /**
  72581. * Defines the sky appearance (light intensity).
  72582. */
  72583. rayleigh: number;
  72584. /**
  72585. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  72586. */
  72587. mieCoefficient: number;
  72588. /**
  72589. * Defines the amount of haze particles following the Mie scattering theory.
  72590. */
  72591. mieDirectionalG: number;
  72592. /**
  72593. * Defines the distance of the sun according to the active scene camera.
  72594. */
  72595. distance: number;
  72596. /**
  72597. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  72598. * "inclined".
  72599. */
  72600. inclination: number;
  72601. /**
  72602. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  72603. * an object direction and a reference direction.
  72604. */
  72605. azimuth: number;
  72606. /**
  72607. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  72608. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  72609. */
  72610. sunPosition: BABYLON.Vector3;
  72611. /**
  72612. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  72613. * .sunPosition property.
  72614. */
  72615. useSunPosition: boolean;
  72616. /**
  72617. * Defines an offset vector used to get a horizon offset.
  72618. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  72619. */
  72620. cameraOffset: BABYLON.Vector3;
  72621. private _cameraPosition;
  72622. private _renderId;
  72623. /**
  72624. * Instantiates a new sky material.
  72625. * This material allows to create dynamic and texture free
  72626. * effects for skyboxes by taking care of the atmosphere state.
  72627. * @see https://doc.babylonjs.com/extensions/sky
  72628. * @param name Define the name of the material in the scene
  72629. * @param scene Define the scene the material belong to
  72630. */
  72631. constructor(name: string, scene: BABYLON.Scene);
  72632. /**
  72633. * Specifies if the material will require alpha blending
  72634. * @returns a boolean specifying if alpha blending is needed
  72635. */
  72636. needAlphaBlending(): boolean;
  72637. /**
  72638. * Specifies if this material should be rendered in alpha test mode
  72639. * @returns false as the sky material doesn't need alpha testing.
  72640. */
  72641. needAlphaTesting(): boolean;
  72642. /**
  72643. * Get the texture used for alpha test purpose.
  72644. * @returns null as the sky material has no texture.
  72645. */
  72646. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72647. /**
  72648. * Get if the submesh is ready to be used and all its information available.
  72649. * Child classes can use it to update shaders
  72650. * @param mesh defines the mesh to check
  72651. * @param subMesh defines which submesh to check
  72652. * @param useInstances specifies that instances should be used
  72653. * @returns a boolean indicating that the submesh is ready or not
  72654. */
  72655. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72656. /**
  72657. * Binds the submesh to this material by preparing the effect and shader to draw
  72658. * @param world defines the world transformation matrix
  72659. * @param mesh defines the mesh containing the submesh
  72660. * @param subMesh defines the submesh to bind the material to
  72661. */
  72662. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72663. /**
  72664. * Get the list of animatables in the material.
  72665. * @returns the list of animatables object used in the material
  72666. */
  72667. getAnimatables(): BABYLON.IAnimatable[];
  72668. /**
  72669. * Disposes the material
  72670. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  72671. */
  72672. dispose(forceDisposeEffect?: boolean): void;
  72673. /**
  72674. * Makes a duplicate of the material, and gives it a new name
  72675. * @param name defines the new name for the duplicated material
  72676. * @returns the cloned material
  72677. */
  72678. clone(name: string): SkyMaterial;
  72679. /**
  72680. * Serializes this material in a JSON representation
  72681. * @returns the serialized material object
  72682. */
  72683. serialize(): any;
  72684. /**
  72685. * Gets the current class name of the material e.g. "SkyMaterial"
  72686. * Mainly use in serialization.
  72687. * @returns the class name
  72688. */
  72689. getClassName(): string;
  72690. /**
  72691. * Creates a sky material from parsed material data
  72692. * @param source defines the JSON representation of the material
  72693. * @param scene defines the hosting scene
  72694. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72695. * @returns a new sky material
  72696. */
  72697. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  72698. }
  72699. }
  72700. declare module BABYLON {
  72701. /** @hidden */
  72702. export var terrainPixelShader: {
  72703. name: string;
  72704. shader: string;
  72705. };
  72706. }
  72707. declare module BABYLON {
  72708. /** @hidden */
  72709. export var terrainVertexShader: {
  72710. name: string;
  72711. shader: string;
  72712. };
  72713. }
  72714. declare module BABYLON {
  72715. export class TerrainMaterial extends BABYLON.PushMaterial {
  72716. private _mixTexture;
  72717. mixTexture: BABYLON.BaseTexture;
  72718. private _diffuseTexture1;
  72719. diffuseTexture1: BABYLON.Texture;
  72720. private _diffuseTexture2;
  72721. diffuseTexture2: BABYLON.Texture;
  72722. private _diffuseTexture3;
  72723. diffuseTexture3: BABYLON.Texture;
  72724. private _bumpTexture1;
  72725. bumpTexture1: BABYLON.Texture;
  72726. private _bumpTexture2;
  72727. bumpTexture2: BABYLON.Texture;
  72728. private _bumpTexture3;
  72729. bumpTexture3: BABYLON.Texture;
  72730. diffuseColor: BABYLON.Color3;
  72731. specularColor: BABYLON.Color3;
  72732. specularPower: number;
  72733. private _disableLighting;
  72734. disableLighting: boolean;
  72735. private _maxSimultaneousLights;
  72736. maxSimultaneousLights: number;
  72737. private _renderId;
  72738. constructor(name: string, scene: BABYLON.Scene);
  72739. needAlphaBlending(): boolean;
  72740. needAlphaTesting(): boolean;
  72741. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72742. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72743. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72744. getAnimatables(): BABYLON.IAnimatable[];
  72745. getActiveTextures(): BABYLON.BaseTexture[];
  72746. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72747. dispose(forceDisposeEffect?: boolean): void;
  72748. clone(name: string): TerrainMaterial;
  72749. serialize(): any;
  72750. getClassName(): string;
  72751. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  72752. }
  72753. }
  72754. declare module BABYLON {
  72755. /** @hidden */
  72756. export var triplanarPixelShader: {
  72757. name: string;
  72758. shader: string;
  72759. };
  72760. }
  72761. declare module BABYLON {
  72762. /** @hidden */
  72763. export var triplanarVertexShader: {
  72764. name: string;
  72765. shader: string;
  72766. };
  72767. }
  72768. declare module BABYLON {
  72769. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  72770. mixTexture: BABYLON.BaseTexture;
  72771. private _diffuseTextureX;
  72772. diffuseTextureX: BABYLON.BaseTexture;
  72773. private _diffuseTextureY;
  72774. diffuseTextureY: BABYLON.BaseTexture;
  72775. private _diffuseTextureZ;
  72776. diffuseTextureZ: BABYLON.BaseTexture;
  72777. private _normalTextureX;
  72778. normalTextureX: BABYLON.BaseTexture;
  72779. private _normalTextureY;
  72780. normalTextureY: BABYLON.BaseTexture;
  72781. private _normalTextureZ;
  72782. normalTextureZ: BABYLON.BaseTexture;
  72783. tileSize: number;
  72784. diffuseColor: BABYLON.Color3;
  72785. specularColor: BABYLON.Color3;
  72786. specularPower: number;
  72787. private _disableLighting;
  72788. disableLighting: boolean;
  72789. private _maxSimultaneousLights;
  72790. maxSimultaneousLights: number;
  72791. private _renderId;
  72792. constructor(name: string, scene: BABYLON.Scene);
  72793. needAlphaBlending(): boolean;
  72794. needAlphaTesting(): boolean;
  72795. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72796. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72797. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72798. getAnimatables(): BABYLON.IAnimatable[];
  72799. getActiveTextures(): BABYLON.BaseTexture[];
  72800. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72801. dispose(forceDisposeEffect?: boolean): void;
  72802. clone(name: string): TriPlanarMaterial;
  72803. serialize(): any;
  72804. getClassName(): string;
  72805. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  72806. }
  72807. }
  72808. declare module BABYLON {
  72809. /** @hidden */
  72810. export var waterPixelShader: {
  72811. name: string;
  72812. shader: string;
  72813. };
  72814. }
  72815. declare module BABYLON {
  72816. /** @hidden */
  72817. export var waterVertexShader: {
  72818. name: string;
  72819. shader: string;
  72820. };
  72821. }
  72822. declare module BABYLON {
  72823. export class WaterMaterial extends BABYLON.PushMaterial {
  72824. renderTargetSize: BABYLON.Vector2;
  72825. private _bumpTexture;
  72826. bumpTexture: BABYLON.BaseTexture;
  72827. diffuseColor: BABYLON.Color3;
  72828. specularColor: BABYLON.Color3;
  72829. specularPower: number;
  72830. private _disableLighting;
  72831. disableLighting: boolean;
  72832. private _maxSimultaneousLights;
  72833. maxSimultaneousLights: number;
  72834. /**
  72835. * @param {number}: Represents the wind force
  72836. */
  72837. windForce: number;
  72838. /**
  72839. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  72840. */
  72841. windDirection: BABYLON.Vector2;
  72842. /**
  72843. * @param {number}: Wave height, represents the height of the waves
  72844. */
  72845. waveHeight: number;
  72846. /**
  72847. * @param {number}: Bump height, represents the bump height related to the bump map
  72848. */
  72849. bumpHeight: number;
  72850. /**
  72851. * @param {boolean}: Add a smaller moving bump to less steady waves.
  72852. */
  72853. private _bumpSuperimpose;
  72854. bumpSuperimpose: boolean;
  72855. /**
  72856. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  72857. */
  72858. private _fresnelSeparate;
  72859. fresnelSeparate: boolean;
  72860. /**
  72861. * @param {boolean}: bump Waves modify the reflection.
  72862. */
  72863. private _bumpAffectsReflection;
  72864. bumpAffectsReflection: boolean;
  72865. /**
  72866. * @param {number}: The water color blended with the refraction (near)
  72867. */
  72868. waterColor: BABYLON.Color3;
  72869. /**
  72870. * @param {number}: The blend factor related to the water color
  72871. */
  72872. colorBlendFactor: number;
  72873. /**
  72874. * @param {number}: The water color blended with the reflection (far)
  72875. */
  72876. waterColor2: BABYLON.Color3;
  72877. /**
  72878. * @param {number}: The blend factor related to the water color (reflection, far)
  72879. */
  72880. colorBlendFactor2: number;
  72881. /**
  72882. * @param {number}: Represents the maximum length of a wave
  72883. */
  72884. waveLength: number;
  72885. /**
  72886. * @param {number}: Defines the waves speed
  72887. */
  72888. waveSpeed: number;
  72889. /**
  72890. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72891. * will avoid calculating useless pixels in the pixel shader of the water material.
  72892. */
  72893. disableClipPlane: boolean;
  72894. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72895. private _mesh;
  72896. private _refractionRTT;
  72897. private _reflectionRTT;
  72898. private _reflectionTransform;
  72899. private _lastTime;
  72900. private _lastDeltaTime;
  72901. private _renderId;
  72902. private _useLogarithmicDepth;
  72903. private _waitingRenderList;
  72904. private _imageProcessingConfiguration;
  72905. private _imageProcessingObserver;
  72906. /**
  72907. * Gets a boolean indicating that current material needs to register RTT
  72908. */
  72909. readonly hasRenderTargetTextures: boolean;
  72910. /**
  72911. * Constructor
  72912. */
  72913. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72914. useLogarithmicDepth: boolean;
  72915. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72916. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72917. addToRenderList(node: any): void;
  72918. enableRenderTargets(enable: boolean): void;
  72919. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  72920. readonly renderTargetsEnabled: boolean;
  72921. needAlphaBlending(): boolean;
  72922. needAlphaTesting(): boolean;
  72923. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72924. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72925. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72926. private _createRenderTargets;
  72927. getAnimatables(): BABYLON.IAnimatable[];
  72928. getActiveTextures(): BABYLON.BaseTexture[];
  72929. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72930. dispose(forceDisposeEffect?: boolean): void;
  72931. clone(name: string): WaterMaterial;
  72932. serialize(): any;
  72933. getClassName(): string;
  72934. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  72935. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  72936. }
  72937. }
  72938. declare module BABYLON {
  72939. /** @hidden */
  72940. export var asciiartPixelShader: {
  72941. name: string;
  72942. shader: string;
  72943. };
  72944. }
  72945. declare module BABYLON {
  72946. /**
  72947. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  72948. *
  72949. * It basically takes care rendering the font front the given font size to a texture.
  72950. * This is used later on in the postprocess.
  72951. */
  72952. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  72953. private _font;
  72954. private _text;
  72955. private _charSize;
  72956. /**
  72957. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72958. */
  72959. readonly charSize: number;
  72960. /**
  72961. * Create a new instance of the Ascii Art FontTexture class
  72962. * @param name the name of the texture
  72963. * @param font the font to use, use the W3C CSS notation
  72964. * @param text the caracter set to use in the rendering.
  72965. * @param scene the scene that owns the texture
  72966. */
  72967. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72968. /**
  72969. * Gets the max char width of a font.
  72970. * @param font the font to use, use the W3C CSS notation
  72971. * @return the max char width
  72972. */
  72973. private getFontWidth;
  72974. /**
  72975. * Gets the max char height of a font.
  72976. * @param font the font to use, use the W3C CSS notation
  72977. * @return the max char height
  72978. */
  72979. private getFontHeight;
  72980. /**
  72981. * Clones the current AsciiArtTexture.
  72982. * @return the clone of the texture.
  72983. */
  72984. clone(): AsciiArtFontTexture;
  72985. /**
  72986. * Parses a json object representing the texture and returns an instance of it.
  72987. * @param source the source JSON representation
  72988. * @param scene the scene to create the texture for
  72989. * @return the parsed texture
  72990. */
  72991. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  72992. }
  72993. /**
  72994. * Option available in the Ascii Art Post Process.
  72995. */
  72996. export interface IAsciiArtPostProcessOptions {
  72997. /**
  72998. * The font to use following the w3c font definition.
  72999. */
  73000. font?: string;
  73001. /**
  73002. * The character set to use in the postprocess.
  73003. */
  73004. characterSet?: string;
  73005. /**
  73006. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73007. * This number is defined between 0 and 1;
  73008. */
  73009. mixToTile?: number;
  73010. /**
  73011. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73012. * This number is defined between 0 and 1;
  73013. */
  73014. mixToNormal?: number;
  73015. }
  73016. /**
  73017. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  73018. *
  73019. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73020. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  73021. */
  73022. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  73023. /**
  73024. * The font texture used to render the char in the post process.
  73025. */
  73026. private _asciiArtFontTexture;
  73027. /**
  73028. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73029. * This number is defined between 0 and 1;
  73030. */
  73031. mixToTile: number;
  73032. /**
  73033. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73034. * This number is defined between 0 and 1;
  73035. */
  73036. mixToNormal: number;
  73037. /**
  73038. * Instantiates a new Ascii Art Post Process.
  73039. * @param name the name to give to the postprocess
  73040. * @camera the camera to apply the post process to.
  73041. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  73042. */
  73043. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  73044. }
  73045. }
  73046. declare module BABYLON {
  73047. /** @hidden */
  73048. export var digitalrainPixelShader: {
  73049. name: string;
  73050. shader: string;
  73051. };
  73052. }
  73053. declare module BABYLON {
  73054. /**
  73055. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  73056. *
  73057. * It basically takes care rendering the font front the given font size to a texture.
  73058. * This is used later on in the postprocess.
  73059. */
  73060. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  73061. private _font;
  73062. private _text;
  73063. private _charSize;
  73064. /**
  73065. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73066. */
  73067. readonly charSize: number;
  73068. /**
  73069. * Create a new instance of the Digital Rain FontTexture class
  73070. * @param name the name of the texture
  73071. * @param font the font to use, use the W3C CSS notation
  73072. * @param text the caracter set to use in the rendering.
  73073. * @param scene the scene that owns the texture
  73074. */
  73075. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73076. /**
  73077. * Gets the max char width of a font.
  73078. * @param font the font to use, use the W3C CSS notation
  73079. * @return the max char width
  73080. */
  73081. private getFontWidth;
  73082. /**
  73083. * Gets the max char height of a font.
  73084. * @param font the font to use, use the W3C CSS notation
  73085. * @return the max char height
  73086. */
  73087. private getFontHeight;
  73088. /**
  73089. * Clones the current DigitalRainFontTexture.
  73090. * @return the clone of the texture.
  73091. */
  73092. clone(): DigitalRainFontTexture;
  73093. /**
  73094. * Parses a json object representing the texture and returns an instance of it.
  73095. * @param source the source JSON representation
  73096. * @param scene the scene to create the texture for
  73097. * @return the parsed texture
  73098. */
  73099. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  73100. }
  73101. /**
  73102. * Option available in the Digital Rain Post Process.
  73103. */
  73104. export interface IDigitalRainPostProcessOptions {
  73105. /**
  73106. * The font to use following the w3c font definition.
  73107. */
  73108. font?: string;
  73109. /**
  73110. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73111. * This number is defined between 0 and 1;
  73112. */
  73113. mixToTile?: number;
  73114. /**
  73115. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73116. * This number is defined between 0 and 1;
  73117. */
  73118. mixToNormal?: number;
  73119. }
  73120. /**
  73121. * DigitalRainPostProcess helps rendering everithing in digital rain.
  73122. *
  73123. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73124. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  73125. */
  73126. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  73127. /**
  73128. * The font texture used to render the char in the post process.
  73129. */
  73130. private _digitalRainFontTexture;
  73131. /**
  73132. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73133. * This number is defined between 0 and 1;
  73134. */
  73135. mixToTile: number;
  73136. /**
  73137. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73138. * This number is defined between 0 and 1;
  73139. */
  73140. mixToNormal: number;
  73141. /**
  73142. * Instantiates a new Digital Rain Post Process.
  73143. * @param name the name to give to the postprocess
  73144. * @camera the camera to apply the post process to.
  73145. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  73146. */
  73147. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  73148. }
  73149. }
  73150. declare module BABYLON {
  73151. /** @hidden */
  73152. export var oceanPostProcessPixelShader: {
  73153. name: string;
  73154. shader: string;
  73155. };
  73156. }
  73157. declare module BABYLON {
  73158. /**
  73159. * Option available in the Ocean Post Process.
  73160. */
  73161. export interface IOceanPostProcessOptions {
  73162. /**
  73163. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73164. */
  73165. reflectionSize?: number | {
  73166. width: number;
  73167. height: number;
  73168. } | {
  73169. ratio: number;
  73170. };
  73171. /**
  73172. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73173. */
  73174. refractionSize?: number | {
  73175. width: number;
  73176. height: number;
  73177. } | {
  73178. ratio: number;
  73179. };
  73180. }
  73181. /**
  73182. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  73183. *
  73184. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73185. * Example usage:
  73186. * var pp = new OceanPostProcess("myOcean", camera);
  73187. * pp.reflectionEnabled = true;
  73188. * pp.refractionEnabled = true;
  73189. */
  73190. export class OceanPostProcess extends BABYLON.PostProcess {
  73191. /**
  73192. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  73193. */
  73194. /**
  73195. * Sets weither or not the real-time reflection is enabled on the ocean.
  73196. * Is set to true, the reflection mirror texture will be used as reflection texture.
  73197. */
  73198. reflectionEnabled: boolean;
  73199. /**
  73200. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  73201. */
  73202. /**
  73203. * Sets weither or not the real-time refraction is enabled on the ocean.
  73204. * Is set to true, the refraction render target texture will be used as refraction texture.
  73205. */
  73206. refractionEnabled: boolean;
  73207. /**
  73208. * Gets wether or not the post-processes is supported by the running hardware.
  73209. * This requires draw buffer supports.
  73210. */
  73211. readonly isSupported: boolean;
  73212. /**
  73213. * This is the reflection mirror texture used to display reflections on the ocean.
  73214. * By default, render list is empty.
  73215. */
  73216. reflectionTexture: BABYLON.MirrorTexture;
  73217. /**
  73218. * This is the refraction render target texture used to display refraction on the ocean.
  73219. * By default, render list is empty.
  73220. */
  73221. refractionTexture: BABYLON.RenderTargetTexture;
  73222. private _time;
  73223. private _cameraRotation;
  73224. private _cameraViewMatrix;
  73225. private _reflectionEnabled;
  73226. private _refractionEnabled;
  73227. private _geometryRenderer;
  73228. /**
  73229. * Instantiates a new Ocean Post Process.
  73230. * @param name the name to give to the postprocess.
  73231. * @camera the camera to apply the post process to.
  73232. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  73233. */
  73234. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  73235. /**
  73236. * Returns the appropriate defines according to the current configuration.
  73237. */
  73238. private _getDefines;
  73239. /**
  73240. * Computes the current camera rotation as the shader requires a camera rotation.
  73241. */
  73242. private _computeCameraRotation;
  73243. }
  73244. }
  73245. declare module BABYLON {
  73246. /** @hidden */
  73247. export var brickProceduralTexturePixelShader: {
  73248. name: string;
  73249. shader: string;
  73250. };
  73251. }
  73252. declare module BABYLON {
  73253. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  73254. private _numberOfBricksHeight;
  73255. private _numberOfBricksWidth;
  73256. private _jointColor;
  73257. private _brickColor;
  73258. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73259. updateShaderUniforms(): void;
  73260. numberOfBricksHeight: number;
  73261. numberOfBricksWidth: number;
  73262. jointColor: BABYLON.Color3;
  73263. brickColor: BABYLON.Color3;
  73264. /**
  73265. * Serializes this brick procedural texture
  73266. * @returns a serialized brick procedural texture object
  73267. */
  73268. serialize(): any;
  73269. /**
  73270. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  73271. * @param parsedTexture defines parsed texture data
  73272. * @param scene defines the current scene
  73273. * @param rootUrl defines the root URL containing brick procedural texture information
  73274. * @returns a parsed Brick Procedural BABYLON.Texture
  73275. */
  73276. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  73277. }
  73278. }
  73279. declare module BABYLON {
  73280. /** @hidden */
  73281. export var cloudProceduralTexturePixelShader: {
  73282. name: string;
  73283. shader: string;
  73284. };
  73285. }
  73286. declare module BABYLON {
  73287. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  73288. private _skyColor;
  73289. private _cloudColor;
  73290. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73291. updateShaderUniforms(): void;
  73292. skyColor: BABYLON.Color4;
  73293. cloudColor: BABYLON.Color4;
  73294. /**
  73295. * Serializes this cloud procedural texture
  73296. * @returns a serialized cloud procedural texture object
  73297. */
  73298. serialize(): any;
  73299. /**
  73300. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  73301. * @param parsedTexture defines parsed texture data
  73302. * @param scene defines the current scene
  73303. * @param rootUrl defines the root URL containing cloud procedural texture information
  73304. * @returns a parsed Cloud Procedural BABYLON.Texture
  73305. */
  73306. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  73307. }
  73308. }
  73309. declare module BABYLON {
  73310. /** @hidden */
  73311. export var fireProceduralTexturePixelShader: {
  73312. name: string;
  73313. shader: string;
  73314. };
  73315. }
  73316. declare module BABYLON {
  73317. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  73318. private _time;
  73319. private _speed;
  73320. private _autoGenerateTime;
  73321. private _fireColors;
  73322. private _alphaThreshold;
  73323. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73324. updateShaderUniforms(): void;
  73325. render(useCameraPostProcess?: boolean): void;
  73326. static readonly PurpleFireColors: BABYLON.Color3[];
  73327. static readonly GreenFireColors: BABYLON.Color3[];
  73328. static readonly RedFireColors: BABYLON.Color3[];
  73329. static readonly BlueFireColors: BABYLON.Color3[];
  73330. autoGenerateTime: boolean;
  73331. fireColors: BABYLON.Color3[];
  73332. time: number;
  73333. speed: BABYLON.Vector2;
  73334. alphaThreshold: number;
  73335. /**
  73336. * Serializes this fire procedural texture
  73337. * @returns a serialized fire procedural texture object
  73338. */
  73339. serialize(): any;
  73340. /**
  73341. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  73342. * @param parsedTexture defines parsed texture data
  73343. * @param scene defines the current scene
  73344. * @param rootUrl defines the root URL containing fire procedural texture information
  73345. * @returns a parsed Fire Procedural BABYLON.Texture
  73346. */
  73347. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  73348. }
  73349. }
  73350. declare module BABYLON {
  73351. /** @hidden */
  73352. export var grassProceduralTexturePixelShader: {
  73353. name: string;
  73354. shader: string;
  73355. };
  73356. }
  73357. declare module BABYLON {
  73358. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  73359. private _grassColors;
  73360. private _groundColor;
  73361. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73362. updateShaderUniforms(): void;
  73363. grassColors: BABYLON.Color3[];
  73364. groundColor: BABYLON.Color3;
  73365. /**
  73366. * Serializes this grass procedural texture
  73367. * @returns a serialized grass procedural texture object
  73368. */
  73369. serialize(): any;
  73370. /**
  73371. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  73372. * @param parsedTexture defines parsed texture data
  73373. * @param scene defines the current scene
  73374. * @param rootUrl defines the root URL containing grass procedural texture information
  73375. * @returns a parsed Grass Procedural BABYLON.Texture
  73376. */
  73377. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  73378. }
  73379. }
  73380. declare module BABYLON {
  73381. /** @hidden */
  73382. export var marbleProceduralTexturePixelShader: {
  73383. name: string;
  73384. shader: string;
  73385. };
  73386. }
  73387. declare module BABYLON {
  73388. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  73389. private _numberOfTilesHeight;
  73390. private _numberOfTilesWidth;
  73391. private _amplitude;
  73392. private _jointColor;
  73393. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73394. updateShaderUniforms(): void;
  73395. numberOfTilesHeight: number;
  73396. amplitude: number;
  73397. numberOfTilesWidth: number;
  73398. jointColor: BABYLON.Color3;
  73399. /**
  73400. * Serializes this marble procedural texture
  73401. * @returns a serialized marble procedural texture object
  73402. */
  73403. serialize(): any;
  73404. /**
  73405. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  73406. * @param parsedTexture defines parsed texture data
  73407. * @param scene defines the current scene
  73408. * @param rootUrl defines the root URL containing marble procedural texture information
  73409. * @returns a parsed Marble Procedural BABYLON.Texture
  73410. */
  73411. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  73412. }
  73413. }
  73414. declare module BABYLON {
  73415. /** @hidden */
  73416. export var normalMapProceduralTexturePixelShader: {
  73417. name: string;
  73418. shader: string;
  73419. };
  73420. }
  73421. declare module BABYLON {
  73422. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  73423. private _baseTexture;
  73424. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73425. updateShaderUniforms(): void;
  73426. render(useCameraPostProcess?: boolean): void;
  73427. resize(size: any, generateMipMaps: any): void;
  73428. baseTexture: BABYLON.Texture;
  73429. /**
  73430. * Serializes this normal map procedural texture
  73431. * @returns a serialized normal map procedural texture object
  73432. */
  73433. serialize(): any;
  73434. /**
  73435. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  73436. * @param parsedTexture defines parsed texture data
  73437. * @param scene defines the current scene
  73438. * @param rootUrl defines the root URL containing normal map procedural texture information
  73439. * @returns a parsed Normal Map Procedural BABYLON.Texture
  73440. */
  73441. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  73442. }
  73443. }
  73444. declare module BABYLON {
  73445. /** @hidden */
  73446. export var perlinNoiseProceduralTexturePixelShader: {
  73447. name: string;
  73448. shader: string;
  73449. };
  73450. }
  73451. declare module BABYLON {
  73452. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  73453. time: number;
  73454. timeScale: number;
  73455. translationSpeed: number;
  73456. private _currentTranslation;
  73457. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73458. updateShaderUniforms(): void;
  73459. render(useCameraPostProcess?: boolean): void;
  73460. resize(size: any, generateMipMaps: any): void;
  73461. /**
  73462. * Serializes this perlin noise procedural texture
  73463. * @returns a serialized perlin noise procedural texture object
  73464. */
  73465. serialize(): any;
  73466. /**
  73467. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  73468. * @param parsedTexture defines parsed texture data
  73469. * @param scene defines the current scene
  73470. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  73471. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  73472. */
  73473. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  73474. }
  73475. }
  73476. declare module BABYLON {
  73477. /** @hidden */
  73478. export var roadProceduralTexturePixelShader: {
  73479. name: string;
  73480. shader: string;
  73481. };
  73482. }
  73483. declare module BABYLON {
  73484. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  73485. private _roadColor;
  73486. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73487. updateShaderUniforms(): void;
  73488. roadColor: BABYLON.Color3;
  73489. /**
  73490. * Serializes this road procedural texture
  73491. * @returns a serialized road procedural texture object
  73492. */
  73493. serialize(): any;
  73494. /**
  73495. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  73496. * @param parsedTexture defines parsed texture data
  73497. * @param scene defines the current scene
  73498. * @param rootUrl defines the root URL containing road procedural texture information
  73499. * @returns a parsed Road Procedural BABYLON.Texture
  73500. */
  73501. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  73502. }
  73503. }
  73504. declare module BABYLON {
  73505. /** @hidden */
  73506. export var starfieldProceduralTexturePixelShader: {
  73507. name: string;
  73508. shader: string;
  73509. };
  73510. }
  73511. declare module BABYLON {
  73512. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  73513. private _time;
  73514. private _alpha;
  73515. private _beta;
  73516. private _zoom;
  73517. private _formuparam;
  73518. private _stepsize;
  73519. private _tile;
  73520. private _brightness;
  73521. private _darkmatter;
  73522. private _distfading;
  73523. private _saturation;
  73524. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73525. updateShaderUniforms(): void;
  73526. time: number;
  73527. alpha: number;
  73528. beta: number;
  73529. formuparam: number;
  73530. stepsize: number;
  73531. zoom: number;
  73532. tile: number;
  73533. brightness: number;
  73534. darkmatter: number;
  73535. distfading: number;
  73536. saturation: number;
  73537. /**
  73538. * Serializes this starfield procedural texture
  73539. * @returns a serialized starfield procedural texture object
  73540. */
  73541. serialize(): any;
  73542. /**
  73543. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  73544. * @param parsedTexture defines parsed texture data
  73545. * @param scene defines the current scene
  73546. * @param rootUrl defines the root URL containing startfield procedural texture information
  73547. * @returns a parsed Starfield Procedural BABYLON.Texture
  73548. */
  73549. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  73550. }
  73551. }
  73552. declare module BABYLON {
  73553. /** @hidden */
  73554. export var woodProceduralTexturePixelShader: {
  73555. name: string;
  73556. shader: string;
  73557. };
  73558. }
  73559. declare module BABYLON {
  73560. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  73561. private _ampScale;
  73562. private _woodColor;
  73563. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73564. updateShaderUniforms(): void;
  73565. ampScale: number;
  73566. woodColor: BABYLON.Color3;
  73567. /**
  73568. * Serializes this wood procedural texture
  73569. * @returns a serialized wood procedural texture object
  73570. */
  73571. serialize(): any;
  73572. /**
  73573. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  73574. * @param parsedTexture defines parsed texture data
  73575. * @param scene defines the current scene
  73576. * @param rootUrl defines the root URL containing wood procedural texture information
  73577. * @returns a parsed Wood Procedural BABYLON.Texture
  73578. */
  73579. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  73580. }
  73581. }