documentation.d.ts 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182
  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. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module BABYLON {
  480. /**
  481. * File request interface
  482. */
  483. export interface IFileRequest {
  484. /**
  485. * Raised when the request is complete (success or error).
  486. */
  487. onCompleteObservable: Observable<IFileRequest>;
  488. /**
  489. * Aborts the request for a file.
  490. */
  491. abort: () => void;
  492. }
  493. }
  494. declare module BABYLON {
  495. /**
  496. * Scalar computation library
  497. */
  498. export class Scalar {
  499. /**
  500. * Two pi constants convenient for computation.
  501. */
  502. static TwoPi: number;
  503. /**
  504. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  505. * @param a number
  506. * @param b number
  507. * @param epsilon (default = 1.401298E-45)
  508. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  509. */
  510. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  511. /**
  512. * Returns a string : the upper case translation of the number i to hexadecimal.
  513. * @param i number
  514. * @returns the upper case translation of the number i to hexadecimal.
  515. */
  516. static ToHex(i: number): string;
  517. /**
  518. * Returns -1 if value is negative and +1 is value is positive.
  519. * @param value the value
  520. * @returns the value itself if it's equal to zero.
  521. */
  522. static Sign(value: number): number;
  523. /**
  524. * Returns the value itself if it's between min and max.
  525. * Returns min if the value is lower than min.
  526. * Returns max if the value is greater than max.
  527. * @param value the value to clmap
  528. * @param min the min value to clamp to (default: 0)
  529. * @param max the max value to clamp to (default: 1)
  530. * @returns the clamped value
  531. */
  532. static Clamp(value: number, min?: number, max?: number): number;
  533. /**
  534. * the log2 of value.
  535. * @param value the value to compute log2 of
  536. * @returns the log2 of value.
  537. */
  538. static Log2(value: number): number;
  539. /**
  540. * Loops the value, so that it is never larger than length and never smaller than 0.
  541. *
  542. * This is similar to the modulo operator but it works with floating point numbers.
  543. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  544. * With t = 5 and length = 2.5, the result would be 0.0.
  545. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  546. * @param value the value
  547. * @param length the length
  548. * @returns the looped value
  549. */
  550. static Repeat(value: number, length: number): number;
  551. /**
  552. * Normalize the value between 0.0 and 1.0 using min and max values
  553. * @param value value to normalize
  554. * @param min max to normalize between
  555. * @param max min to normalize between
  556. * @returns the normalized value
  557. */
  558. static Normalize(value: number, min: number, max: number): number;
  559. /**
  560. * Denormalize the value from 0.0 and 1.0 using min and max values
  561. * @param normalized value to denormalize
  562. * @param min max to denormalize between
  563. * @param max min to denormalize between
  564. * @returns the denormalized value
  565. */
  566. static Denormalize(normalized: number, min: number, max: number): number;
  567. /**
  568. * Calculates the shortest difference between two given angles given in degrees.
  569. * @param current current angle in degrees
  570. * @param target target angle in degrees
  571. * @returns the delta
  572. */
  573. static DeltaAngle(current: number, target: number): number;
  574. /**
  575. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  576. * @param tx value
  577. * @param length length
  578. * @returns The returned value will move back and forth between 0 and length
  579. */
  580. static PingPong(tx: number, length: number): number;
  581. /**
  582. * Interpolates between min and max with smoothing at the limits.
  583. *
  584. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  585. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  586. * @param from from
  587. * @param to to
  588. * @param tx value
  589. * @returns the smooth stepped value
  590. */
  591. static SmoothStep(from: number, to: number, tx: number): number;
  592. /**
  593. * Moves a value current towards target.
  594. *
  595. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  596. * Negative values of maxDelta pushes the value away from target.
  597. * @param current current value
  598. * @param target target value
  599. * @param maxDelta max distance to move
  600. * @returns resulting value
  601. */
  602. static MoveTowards(current: number, target: number, maxDelta: number): number;
  603. /**
  604. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  605. *
  606. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  607. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  608. * @param current current value
  609. * @param target target value
  610. * @param maxDelta max distance to move
  611. * @returns resulting angle
  612. */
  613. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  614. /**
  615. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  616. * @param start start value
  617. * @param end target value
  618. * @param amount amount to lerp between
  619. * @returns the lerped value
  620. */
  621. static Lerp(start: number, end: number, amount: number): number;
  622. /**
  623. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  624. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  625. * @param start start value
  626. * @param end target value
  627. * @param amount amount to lerp between
  628. * @returns the lerped value
  629. */
  630. static LerpAngle(start: number, end: number, amount: number): number;
  631. /**
  632. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  633. * @param a start value
  634. * @param b target value
  635. * @param value value between a and b
  636. * @returns the inverseLerp value
  637. */
  638. static InverseLerp(a: number, b: number, value: number): number;
  639. /**
  640. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  641. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  642. * @param value1 spline value
  643. * @param tangent1 spline value
  644. * @param value2 spline value
  645. * @param tangent2 spline value
  646. * @param amount input value
  647. * @returns hermite result
  648. */
  649. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  650. /**
  651. * Returns a random float number between and min and max values
  652. * @param min min value of random
  653. * @param max max value of random
  654. * @returns random value
  655. */
  656. static RandomRange(min: number, max: number): number;
  657. /**
  658. * This function returns percentage of a number in a given range.
  659. *
  660. * RangeToPercent(40,20,60) will return 0.5 (50%)
  661. * RangeToPercent(34,0,100) will return 0.34 (34%)
  662. * @param number to convert to percentage
  663. * @param min min range
  664. * @param max max range
  665. * @returns the percentage
  666. */
  667. static RangeToPercent(number: number, min: number, max: number): number;
  668. /**
  669. * This function returns number that corresponds to the percentage in a given range.
  670. *
  671. * PercentToRange(0.34,0,100) will return 34.
  672. * @param percent to convert to number
  673. * @param min min range
  674. * @param max max range
  675. * @returns the number
  676. */
  677. static PercentToRange(percent: number, min: number, max: number): number;
  678. /**
  679. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  680. * @param angle The angle to normalize in radian.
  681. * @return The converted angle.
  682. */
  683. static NormalizeRadians(angle: number): number;
  684. }
  685. }
  686. declare module BABYLON {
  687. /**
  688. * Constant used to convert a value to gamma space
  689. * @ignorenaming
  690. */
  691. export const ToGammaSpace: number;
  692. /**
  693. * Constant used to convert a value to linear space
  694. * @ignorenaming
  695. */
  696. export const ToLinearSpace = 2.2;
  697. /**
  698. * Constant used to define the minimal number value in Babylon.js
  699. * @ignorenaming
  700. */
  701. let Epsilon: number;
  702. }
  703. declare module BABYLON {
  704. /**
  705. * Class used to represent a viewport on screen
  706. */
  707. export class Viewport {
  708. /** viewport left coordinate */
  709. x: number;
  710. /** viewport top coordinate */
  711. y: number;
  712. /**viewport width */
  713. width: number;
  714. /** viewport height */
  715. height: number;
  716. /**
  717. * Creates a Viewport object located at (x, y) and sized (width, height)
  718. * @param x defines viewport left coordinate
  719. * @param y defines viewport top coordinate
  720. * @param width defines the viewport width
  721. * @param height defines the viewport height
  722. */
  723. constructor(
  724. /** viewport left coordinate */
  725. x: number,
  726. /** viewport top coordinate */
  727. y: number,
  728. /**viewport width */
  729. width: number,
  730. /** viewport height */
  731. height: number);
  732. /**
  733. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  734. * @param renderWidth defines the rendering width
  735. * @param renderHeight defines the rendering height
  736. * @returns a new Viewport
  737. */
  738. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  739. /**
  740. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  741. * @param renderWidth defines the rendering width
  742. * @param renderHeight defines the rendering height
  743. * @param ref defines the target viewport
  744. * @returns the current viewport
  745. */
  746. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  747. /**
  748. * Returns a new Viewport copied from the current one
  749. * @returns a new Viewport
  750. */
  751. clone(): Viewport;
  752. }
  753. }
  754. declare module BABYLON {
  755. /**
  756. * Class containing a set of static utilities functions for arrays.
  757. */
  758. export class ArrayTools {
  759. /**
  760. * Returns an array of the given size filled with element built from the given constructor and the paramters
  761. * @param size the number of element to construct and put in the array
  762. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  763. * @returns a new array filled with new objects
  764. */
  765. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  766. }
  767. }
  768. declare module BABYLON {
  769. /**
  770. * @hidden
  771. */
  772. export interface IColor4Like {
  773. r: float;
  774. g: float;
  775. b: float;
  776. a: float;
  777. }
  778. /**
  779. * @hidden
  780. */
  781. export interface IColor3Like {
  782. r: float;
  783. g: float;
  784. b: float;
  785. }
  786. /**
  787. * @hidden
  788. */
  789. export interface IVector4Like {
  790. x: float;
  791. y: float;
  792. z: float;
  793. w: float;
  794. }
  795. /**
  796. * @hidden
  797. */
  798. export interface IVector3Like {
  799. x: float;
  800. y: float;
  801. z: float;
  802. }
  803. /**
  804. * @hidden
  805. */
  806. export interface IVector2Like {
  807. x: float;
  808. y: float;
  809. }
  810. /**
  811. * @hidden
  812. */
  813. export interface IMatrixLike {
  814. toArray(): DeepImmutable<Float32Array>;
  815. updateFlag: int;
  816. }
  817. /**
  818. * @hidden
  819. */
  820. export interface IViewportLike {
  821. x: float;
  822. y: float;
  823. width: float;
  824. height: float;
  825. }
  826. /**
  827. * @hidden
  828. */
  829. export interface IPlaneLike {
  830. normal: IVector3Like;
  831. d: float;
  832. normalize(): void;
  833. }
  834. }
  835. declare module BABYLON {
  836. /**
  837. * Class representing a vector containing 2 coordinates
  838. */
  839. export class Vector2 {
  840. /** defines the first coordinate */
  841. x: number;
  842. /** defines the second coordinate */
  843. y: number;
  844. /**
  845. * Creates a new Vector2 from the given x and y coordinates
  846. * @param x defines the first coordinate
  847. * @param y defines the second coordinate
  848. */
  849. constructor(
  850. /** defines the first coordinate */
  851. x?: number,
  852. /** defines the second coordinate */
  853. y?: number);
  854. /**
  855. * Gets a string with the Vector2 coordinates
  856. * @returns a string with the Vector2 coordinates
  857. */
  858. toString(): string;
  859. /**
  860. * Gets class name
  861. * @returns the string "Vector2"
  862. */
  863. getClassName(): string;
  864. /**
  865. * Gets current vector hash code
  866. * @returns the Vector2 hash code as a number
  867. */
  868. getHashCode(): number;
  869. /**
  870. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  871. * @param array defines the source array
  872. * @param index defines the offset in source array
  873. * @returns the current Vector2
  874. */
  875. toArray(array: FloatArray, index?: number): Vector2;
  876. /**
  877. * Copy the current vector to an array
  878. * @returns a new array with 2 elements: the Vector2 coordinates.
  879. */
  880. asArray(): number[];
  881. /**
  882. * Sets the Vector2 coordinates with the given Vector2 coordinates
  883. * @param source defines the source Vector2
  884. * @returns the current updated Vector2
  885. */
  886. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  887. /**
  888. * Sets the Vector2 coordinates with the given floats
  889. * @param x defines the first coordinate
  890. * @param y defines the second coordinate
  891. * @returns the current updated Vector2
  892. */
  893. copyFromFloats(x: number, y: number): Vector2;
  894. /**
  895. * Sets the Vector2 coordinates with the given floats
  896. * @param x defines the first coordinate
  897. * @param y defines the second coordinate
  898. * @returns the current updated Vector2
  899. */
  900. set(x: number, y: number): Vector2;
  901. /**
  902. * Add another vector with the current one
  903. * @param otherVector defines the other vector
  904. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  905. */
  906. add(otherVector: DeepImmutable<Vector2>): Vector2;
  907. /**
  908. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  909. * @param otherVector defines the other vector
  910. * @param result defines the target vector
  911. * @returns the unmodified current Vector2
  912. */
  913. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  914. /**
  915. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  916. * @param otherVector defines the other vector
  917. * @returns the current updated Vector2
  918. */
  919. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  920. /**
  921. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. addVector3(otherVector: Vector3): Vector2;
  926. /**
  927. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  928. * @param otherVector defines the other vector
  929. * @returns a new Vector2
  930. */
  931. subtract(otherVector: Vector2): Vector2;
  932. /**
  933. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  934. * @param otherVector defines the other vector
  935. * @param result defines the target vector
  936. * @returns the unmodified current Vector2
  937. */
  938. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  939. /**
  940. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Multiplies in place the current Vector2 coordinates by the given ones
  947. * @param otherVector defines the other vector
  948. * @returns the current updated Vector2
  949. */
  950. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns a new Vector2
  955. */
  956. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  959. * @param otherVector defines the other vector
  960. * @param result defines the target vector
  961. * @returns the unmodified current Vector2
  962. */
  963. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  964. /**
  965. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  966. * @param x defines the first coordinate
  967. * @param y defines the second coordinate
  968. * @returns a new Vector2
  969. */
  970. multiplyByFloats(x: number, y: number): Vector2;
  971. /**
  972. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @returns a new Vector2
  975. */
  976. divide(otherVector: Vector2): Vector2;
  977. /**
  978. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  979. * @param otherVector defines the other vector
  980. * @param result defines the target vector
  981. * @returns the unmodified current Vector2
  982. */
  983. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  984. /**
  985. * Divides the current Vector2 coordinates by the given ones
  986. * @param otherVector defines the other vector
  987. * @returns the current updated Vector2
  988. */
  989. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  990. /**
  991. * Gets a new Vector2 with current Vector2 negated coordinates
  992. * @returns a new Vector2
  993. */
  994. negate(): Vector2;
  995. /**
  996. * Multiply the Vector2 coordinates by scale
  997. * @param scale defines the scaling factor
  998. * @returns the current updated Vector2
  999. */
  1000. scaleInPlace(scale: number): Vector2;
  1001. /**
  1002. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1003. * @param scale defines the scaling factor
  1004. * @returns a new Vector2
  1005. */
  1006. scale(scale: number): Vector2;
  1007. /**
  1008. * Scale the current Vector2 values by a factor to a given Vector2
  1009. * @param scale defines the scale factor
  1010. * @param result defines the Vector2 object where to store the result
  1011. * @returns the unmodified current Vector2
  1012. */
  1013. scaleToRef(scale: number, result: Vector2): Vector2;
  1014. /**
  1015. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1016. * @param scale defines the scale factor
  1017. * @param result defines the Vector2 object where to store the result
  1018. * @returns the unmodified current Vector2
  1019. */
  1020. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1021. /**
  1022. * Gets a boolean if two vectors are equals
  1023. * @param otherVector defines the other vector
  1024. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1025. */
  1026. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1027. /**
  1028. * Gets a boolean if two vectors are equals (using an epsilon value)
  1029. * @param otherVector defines the other vector
  1030. * @param epsilon defines the minimal distance to consider equality
  1031. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1032. */
  1033. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. floor(): Vector2;
  1039. /**
  1040. * Gets a new Vector2 from current Vector2 floored values
  1041. * @returns a new Vector2
  1042. */
  1043. fract(): Vector2;
  1044. /**
  1045. * Gets the length of the vector
  1046. * @returns the vector length (float)
  1047. */
  1048. length(): number;
  1049. /**
  1050. * Gets the vector squared length
  1051. * @returns the vector squared length (float)
  1052. */
  1053. lengthSquared(): number;
  1054. /**
  1055. * Normalize the vector
  1056. * @returns the current updated Vector2
  1057. */
  1058. normalize(): Vector2;
  1059. /**
  1060. * Gets a new Vector2 copied from the Vector2
  1061. * @returns a new Vector2
  1062. */
  1063. clone(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(0, 0)
  1066. * @returns a new Vector2
  1067. */
  1068. static Zero(): Vector2;
  1069. /**
  1070. * Gets a new Vector2(1, 1)
  1071. * @returns a new Vector2
  1072. */
  1073. static One(): Vector2;
  1074. /**
  1075. * Gets a new Vector2 set from the given index element of the given array
  1076. * @param array defines the data source
  1077. * @param offset defines the offset in the data source
  1078. * @returns a new Vector2
  1079. */
  1080. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1081. /**
  1082. * Sets "result" from the given index element of the given array
  1083. * @param array defines the data source
  1084. * @param offset defines the offset in the data source
  1085. * @param result defines the target vector
  1086. */
  1087. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1088. /**
  1089. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1090. * @param value1 defines 1st point of control
  1091. * @param value2 defines 2nd point of control
  1092. * @param value3 defines 3rd point of control
  1093. * @param value4 defines 4th point of control
  1094. * @param amount defines the interpolation factor
  1095. * @returns a new Vector2
  1096. */
  1097. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1098. /**
  1099. * 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".
  1100. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1101. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1102. * @param value defines the value to clamp
  1103. * @param min defines the lower limit
  1104. * @param max defines the upper limit
  1105. * @returns a new Vector2
  1106. */
  1107. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1108. /**
  1109. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1110. * @param value1 defines the 1st control point
  1111. * @param tangent1 defines the outgoing tangent
  1112. * @param value2 defines the 2nd control point
  1113. * @param tangent2 defines the incoming tangent
  1114. * @param amount defines the interpolation factor
  1115. * @returns a new Vector2
  1116. */
  1117. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1118. /**
  1119. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1120. * @param start defines the start vector
  1121. * @param end defines the end vector
  1122. * @param amount defines the interpolation factor
  1123. * @returns a new Vector2
  1124. */
  1125. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1126. /**
  1127. * Gets the dot product of the vector "left" and the vector "right"
  1128. * @param left defines first vector
  1129. * @param right defines second vector
  1130. * @returns the dot product (float)
  1131. */
  1132. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1133. /**
  1134. * Returns a new Vector2 equal to the normalized given vector
  1135. * @param vector defines the vector to normalize
  1136. * @returns a new Vector2
  1137. */
  1138. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1139. /**
  1140. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1141. * @param left defines 1st vector
  1142. * @param right defines 2nd vector
  1143. * @returns a new Vector2
  1144. */
  1145. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1146. /**
  1147. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1148. * @param left defines 1st vector
  1149. * @param right defines 2nd vector
  1150. * @returns a new Vector2
  1151. */
  1152. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1155. * @param vector defines the vector to transform
  1156. * @param transformation defines the matrix to apply
  1157. * @returns a new Vector2
  1158. */
  1159. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1160. /**
  1161. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1162. * @param vector defines the vector to transform
  1163. * @param transformation defines the matrix to apply
  1164. * @param result defines the target vector
  1165. */
  1166. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1167. /**
  1168. * Determines if a given vector is included in a triangle
  1169. * @param p defines the vector to test
  1170. * @param p0 defines 1st triangle point
  1171. * @param p1 defines 2nd triangle point
  1172. * @param p2 defines 3rd triangle point
  1173. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1174. */
  1175. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1176. /**
  1177. * Gets the distance between the vectors "value1" and "value2"
  1178. * @param value1 defines first vector
  1179. * @param value2 defines second vector
  1180. * @returns the distance between vectors
  1181. */
  1182. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1183. /**
  1184. * Returns the squared distance between the vectors "value1" and "value2"
  1185. * @param value1 defines first vector
  1186. * @param value2 defines second vector
  1187. * @returns the squared distance between vectors
  1188. */
  1189. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1190. /**
  1191. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns a new Vector2
  1195. */
  1196. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1197. /**
  1198. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1199. * @param p defines the middle point
  1200. * @param segA defines one point of the segment
  1201. * @param segB defines the other point of the segment
  1202. * @returns the shortest distance
  1203. */
  1204. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1205. }
  1206. /**
  1207. * Classed used to store (x,y,z) vector representation
  1208. * A Vector3 is the main object used in 3D geometry
  1209. * It can represent etiher the coordinates of a point the space, either a direction
  1210. * Reminder: js uses a left handed forward facing system
  1211. */
  1212. export class Vector3 {
  1213. /**
  1214. * Defines the first coordinates (on X axis)
  1215. */
  1216. x: number;
  1217. /**
  1218. * Defines the second coordinates (on Y axis)
  1219. */
  1220. y: number;
  1221. /**
  1222. * Defines the third coordinates (on Z axis)
  1223. */
  1224. z: number;
  1225. private static _UpReadOnly;
  1226. private static _ZeroReadOnly;
  1227. /**
  1228. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1229. * @param x defines the first coordinates (on X axis)
  1230. * @param y defines the second coordinates (on Y axis)
  1231. * @param z defines the third coordinates (on Z axis)
  1232. */
  1233. constructor(
  1234. /**
  1235. * Defines the first coordinates (on X axis)
  1236. */
  1237. x?: number,
  1238. /**
  1239. * Defines the second coordinates (on Y axis)
  1240. */
  1241. y?: number,
  1242. /**
  1243. * Defines the third coordinates (on Z axis)
  1244. */
  1245. z?: number);
  1246. /**
  1247. * Creates a string representation of the Vector3
  1248. * @returns a string with the Vector3 coordinates.
  1249. */
  1250. toString(): string;
  1251. /**
  1252. * Gets the class name
  1253. * @returns the string "Vector3"
  1254. */
  1255. getClassName(): string;
  1256. /**
  1257. * Creates the Vector3 hash code
  1258. * @returns a number which tends to be unique between Vector3 instances
  1259. */
  1260. getHashCode(): number;
  1261. /**
  1262. * Creates an array containing three elements : the coordinates of the Vector3
  1263. * @returns a new array of numbers
  1264. */
  1265. asArray(): number[];
  1266. /**
  1267. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1268. * @param array defines the destination array
  1269. * @param index defines the offset in the destination array
  1270. * @returns the current Vector3
  1271. */
  1272. toArray(array: FloatArray, index?: number): Vector3;
  1273. /**
  1274. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1275. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1276. */
  1277. toQuaternion(): Quaternion;
  1278. /**
  1279. * Adds the given vector to the current Vector3
  1280. * @param otherVector defines the second operand
  1281. * @returns the current updated Vector3
  1282. */
  1283. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1284. /**
  1285. * Adds the given coordinates to the current Vector3
  1286. * @param x defines the x coordinate of the operand
  1287. * @param y defines the y coordinate of the operand
  1288. * @param z defines the z coordinate of the operand
  1289. * @returns the current updated Vector3
  1290. */
  1291. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1292. /**
  1293. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1294. * @param otherVector defines the second operand
  1295. * @returns the resulting Vector3
  1296. */
  1297. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1300. * @param otherVector defines the second operand
  1301. * @param result defines the Vector3 object where to store the result
  1302. * @returns the current Vector3
  1303. */
  1304. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1305. /**
  1306. * Subtract the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the current updated Vector3
  1309. */
  1310. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1313. * @param otherVector defines the second operand
  1314. * @returns the resulting Vector3
  1315. */
  1316. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1317. /**
  1318. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1319. * @param otherVector defines the second operand
  1320. * @param result defines the Vector3 object where to store the result
  1321. * @returns the current Vector3
  1322. */
  1323. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1324. /**
  1325. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1326. * @param x defines the x coordinate of the operand
  1327. * @param y defines the y coordinate of the operand
  1328. * @param z defines the z coordinate of the operand
  1329. * @returns the resulting Vector3
  1330. */
  1331. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1332. /**
  1333. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1334. * @param x defines the x coordinate of the operand
  1335. * @param y defines the y coordinate of the operand
  1336. * @param z defines the z coordinate of the operand
  1337. * @param result defines the Vector3 object where to store the result
  1338. * @returns the current Vector3
  1339. */
  1340. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1341. /**
  1342. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1343. * @returns a new Vector3
  1344. */
  1345. negate(): Vector3;
  1346. /**
  1347. * Multiplies the Vector3 coordinates by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns the current updated Vector3
  1350. */
  1351. scaleInPlace(scale: number): Vector3;
  1352. /**
  1353. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1354. * @param scale defines the multiplier factor
  1355. * @returns a new Vector3
  1356. */
  1357. scale(scale: number): Vector3;
  1358. /**
  1359. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1360. * @param scale defines the multiplier factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the current Vector3
  1363. */
  1364. scaleToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1367. * @param scale defines the scale factor
  1368. * @param result defines the Vector3 object where to store the result
  1369. * @returns the unmodified current Vector3
  1370. */
  1371. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1374. * @param otherVector defines the second operand
  1375. * @returns true if both vectors are equals
  1376. */
  1377. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1380. * @param otherVector defines the second operand
  1381. * @param epsilon defines the minimal distance to define values as equals
  1382. * @returns true if both vectors are distant less than epsilon
  1383. */
  1384. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1385. /**
  1386. * Returns true if the current Vector3 coordinates equals the given floats
  1387. * @param x defines the x coordinate of the operand
  1388. * @param y defines the y coordinate of the operand
  1389. * @param z defines the z coordinate of the operand
  1390. * @returns true if both vectors are equals
  1391. */
  1392. equalsToFloats(x: number, y: number, z: number): boolean;
  1393. /**
  1394. * Multiplies the current Vector3 coordinates by the given ones
  1395. * @param otherVector defines the second operand
  1396. * @returns the current updated Vector3
  1397. */
  1398. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1401. * @param otherVector defines the second operand
  1402. * @returns the new Vector3
  1403. */
  1404. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1405. /**
  1406. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1407. * @param otherVector defines the second operand
  1408. * @param result defines the Vector3 object where to store the result
  1409. * @returns the current Vector3
  1410. */
  1411. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1412. /**
  1413. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1414. * @param x defines the x coordinate of the operand
  1415. * @param y defines the y coordinate of the operand
  1416. * @param z defines the z coordinate of the operand
  1417. * @returns the new Vector3
  1418. */
  1419. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1420. /**
  1421. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1422. * @param otherVector defines the second operand
  1423. * @returns the new Vector3
  1424. */
  1425. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1428. * @param otherVector defines the second operand
  1429. * @param result defines the Vector3 object where to store the result
  1430. * @returns the current Vector3
  1431. */
  1432. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1433. /**
  1434. * Divides the current Vector3 coordinates by the given ones.
  1435. * @param otherVector defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. divideInPlace(otherVector: Vector3): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1447. * @param other defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1453. * @param x defines the x coordinate of the operand
  1454. * @param y defines the y coordinate of the operand
  1455. * @param z defines the z coordinate of the operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1461. * @param x defines the x coordinate of the operand
  1462. * @param y defines the y coordinate of the operand
  1463. * @param z defines the z coordinate of the operand
  1464. * @returns the current updated Vector3
  1465. */
  1466. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1467. /**
  1468. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1469. * Check if is non uniform within a certain amount of decimal places to account for this
  1470. * @param epsilon the amount the values can differ
  1471. * @returns if the the vector is non uniform to a certain number of decimal places
  1472. */
  1473. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1474. /**
  1475. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1476. */
  1477. readonly isNonUniform: boolean;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. floor(): Vector3;
  1483. /**
  1484. * Gets a new Vector3 from current Vector3 floored values
  1485. * @returns a new Vector3
  1486. */
  1487. fract(): Vector3;
  1488. /**
  1489. * Gets the length of the Vector3
  1490. * @returns the length of the Vector3
  1491. */
  1492. length(): number;
  1493. /**
  1494. * Gets the squared length of the Vector3
  1495. * @returns squared length of the Vector3
  1496. */
  1497. lengthSquared(): number;
  1498. /**
  1499. * Normalize the current Vector3.
  1500. * Please note that this is an in place operation.
  1501. * @returns the current updated Vector3
  1502. */
  1503. normalize(): Vector3;
  1504. /**
  1505. * Reorders the x y z properties of the vector in place
  1506. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1507. * @returns the current updated vector
  1508. */
  1509. reorderInPlace(order: string): this;
  1510. /**
  1511. * Rotates the vector around 0,0,0 by a quaternion
  1512. * @param quaternion the rotation quaternion
  1513. * @param result vector to store the result
  1514. * @returns the resulting vector
  1515. */
  1516. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1517. /**
  1518. * Rotates a vector around a given point
  1519. * @param quaternion the rotation quaternion
  1520. * @param point the point to rotate around
  1521. * @param result vector to store the result
  1522. * @returns the resulting vector
  1523. */
  1524. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1525. /**
  1526. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1527. * The cross product is then orthogonal to both current and "other"
  1528. * @param other defines the right operand
  1529. * @returns the cross product
  1530. */
  1531. cross(other: Vector3): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 with the given input length.
  1534. * Please note that this is an in place operation.
  1535. * @param len the length of the vector
  1536. * @returns the current updated Vector3
  1537. */
  1538. normalizeFromLength(len: number): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 to a new vector
  1541. * @returns the new Vector3
  1542. */
  1543. normalizeToNew(): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to the reference
  1546. * @param reference define the Vector3 to update
  1547. * @returns the updated Vector3
  1548. */
  1549. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1550. /**
  1551. * Creates a new Vector3 copied from the current Vector3
  1552. * @returns the new Vector3
  1553. */
  1554. clone(): Vector3;
  1555. /**
  1556. * Copies the given vector coordinates to the current Vector3 ones
  1557. * @param source defines the source Vector3
  1558. * @returns the current updated Vector3
  1559. */
  1560. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1561. /**
  1562. * Copies the given floats to the current Vector3 coordinates
  1563. * @param x defines the x coordinate of the operand
  1564. * @param y defines the y coordinate of the operand
  1565. * @param z defines the z coordinate of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. copyFromFloats(x: number, y: number, z: number): Vector3;
  1569. /**
  1570. * Copies the given floats to the current Vector3 coordinates
  1571. * @param x defines the x coordinate of the operand
  1572. * @param y defines the y coordinate of the operand
  1573. * @param z defines the z coordinate of the operand
  1574. * @returns the current updated Vector3
  1575. */
  1576. set(x: number, y: number, z: number): Vector3;
  1577. /**
  1578. * Copies the given float to the current Vector3 coordinates
  1579. * @param v defines the x, y and z coordinates of the operand
  1580. * @returns the current updated Vector3
  1581. */
  1582. setAll(v: number): Vector3;
  1583. /**
  1584. * Get the clip factor between two vectors
  1585. * @param vector0 defines the first operand
  1586. * @param vector1 defines the second operand
  1587. * @param axis defines the axis to use
  1588. * @param size defines the size along the axis
  1589. * @returns the clip factor
  1590. */
  1591. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1592. /**
  1593. * Get angle between two vectors
  1594. * @param vector0 angle between vector0 and vector1
  1595. * @param vector1 angle between vector0 and vector1
  1596. * @param normal direction of the normal
  1597. * @return the angle between vector0 and vector1
  1598. */
  1599. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1600. /**
  1601. * Returns a new Vector3 set from the index "offset" of the given array
  1602. * @param array defines the source array
  1603. * @param offset defines the offset in the source array
  1604. * @returns the new Vector3
  1605. */
  1606. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1609. * This function is deprecated. Use FromArray instead
  1610. * @param array defines the source array
  1611. * @param offset defines the offset in the source array
  1612. * @returns the new Vector3
  1613. */
  1614. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1615. /**
  1616. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @param result defines the Vector3 where to store the result
  1620. */
  1621. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1624. * This function is deprecated. Use FromArrayToRef instead.
  1625. * @param array defines the source array
  1626. * @param offset defines the offset in the source array
  1627. * @param result defines the Vector3 where to store the result
  1628. */
  1629. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1630. /**
  1631. * Sets the given vector "result" with the given floats.
  1632. * @param x defines the x coordinate of the source
  1633. * @param y defines the y coordinate of the source
  1634. * @param z defines the z coordinate of the source
  1635. * @param result defines the Vector3 where to store the result
  1636. */
  1637. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1638. /**
  1639. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1640. * @returns a new empty Vector3
  1641. */
  1642. static Zero(): Vector3;
  1643. /**
  1644. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1645. * @returns a new unit Vector3
  1646. */
  1647. static One(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1650. * @returns a new up Vector3
  1651. */
  1652. static Up(): Vector3;
  1653. /**
  1654. * Gets a up Vector3 that must not be updated
  1655. */
  1656. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1657. /**
  1658. * Gets a zero Vector3 that must not be updated
  1659. */
  1660. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1661. /**
  1662. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1663. * @returns a new down Vector3
  1664. */
  1665. static Down(): Vector3;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1668. * @returns a new forward Vector3
  1669. */
  1670. static Forward(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Backward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1678. * @returns a new right Vector3
  1679. */
  1680. static Right(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1683. * @returns a new left Vector3
  1684. */
  1685. static Left(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1688. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1689. * @param vector defines the Vector3 to transform
  1690. * @param transformation defines the transformation matrix
  1691. * @returns the transformed Vector3
  1692. */
  1693. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1694. /**
  1695. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1696. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @param result defines the Vector3 where to store the result
  1700. */
  1701. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1702. /**
  1703. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1704. * This method computes tranformed coordinates only, not transformed direction vectors
  1705. * @param x define the x coordinate of the source vector
  1706. * @param y define the y coordinate of the source vector
  1707. * @param z define the z coordinate of the source vector
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param vector defines the Vector3 to transform
  1716. * @param transformation defines the transformation matrix
  1717. * @returns the new Vector3
  1718. */
  1719. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1720. /**
  1721. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1722. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1723. * @param vector defines the Vector3 to transform
  1724. * @param transformation defines the transformation matrix
  1725. * @param result defines the Vector3 where to store the result
  1726. */
  1727. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1728. /**
  1729. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1730. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1731. * @param x define the x coordinate of the source vector
  1732. * @param y define the y coordinate of the source vector
  1733. * @param z define the z coordinate of the source vector
  1734. * @param transformation defines the transformation matrix
  1735. * @param result defines the Vector3 where to store the result
  1736. */
  1737. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1738. /**
  1739. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1740. * @param value1 defines the first control point
  1741. * @param value2 defines the second control point
  1742. * @param value3 defines the third control point
  1743. * @param value4 defines the fourth control point
  1744. * @param amount defines the amount on the spline to use
  1745. * @returns the new Vector3
  1746. */
  1747. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1748. /**
  1749. * 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"
  1750. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1751. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1752. * @param value defines the current value
  1753. * @param min defines the lower range value
  1754. * @param max defines the upper range value
  1755. * @returns the new Vector3
  1756. */
  1757. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1758. /**
  1759. * 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"
  1760. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1761. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1762. * @param value defines the current value
  1763. * @param min defines the lower range value
  1764. * @param max defines the upper range value
  1765. * @param result defines the Vector3 where to store the result
  1766. */
  1767. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1768. /**
  1769. * Checks if a given vector is inside a specific range
  1770. * @param v defines the vector to test
  1771. * @param min defines the minimum range
  1772. * @param max defines the maximum range
  1773. */
  1774. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Class used to store quaternion data
  2363. * @see https://en.wikipedia.org/wiki/Quaternion
  2364. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2365. */
  2366. export class Quaternion {
  2367. /** defines the first component (0 by default) */
  2368. x: number;
  2369. /** defines the second component (0 by default) */
  2370. y: number;
  2371. /** defines the third component (0 by default) */
  2372. z: number;
  2373. /** defines the fourth component (1.0 by default) */
  2374. w: number;
  2375. /**
  2376. * Creates a new Quaternion from the given floats
  2377. * @param x defines the first component (0 by default)
  2378. * @param y defines the second component (0 by default)
  2379. * @param z defines the third component (0 by default)
  2380. * @param w defines the fourth component (1.0 by default)
  2381. */
  2382. constructor(
  2383. /** defines the first component (0 by default) */
  2384. x?: number,
  2385. /** defines the second component (0 by default) */
  2386. y?: number,
  2387. /** defines the third component (0 by default) */
  2388. z?: number,
  2389. /** defines the fourth component (1.0 by default) */
  2390. w?: number);
  2391. /**
  2392. * Gets a string representation for the current quaternion
  2393. * @returns a string with the Quaternion coordinates
  2394. */
  2395. toString(): string;
  2396. /**
  2397. * Gets the class name of the quaternion
  2398. * @returns the string "Quaternion"
  2399. */
  2400. getClassName(): string;
  2401. /**
  2402. * Gets a hash code for this quaternion
  2403. * @returns the quaternion hash code
  2404. */
  2405. getHashCode(): number;
  2406. /**
  2407. * Copy the quaternion to an array
  2408. * @returns a new array populated with 4 elements from the quaternion coordinates
  2409. */
  2410. asArray(): number[];
  2411. /**
  2412. * Check if two quaternions are equals
  2413. * @param otherQuaternion defines the second operand
  2414. * @return true if the current quaternion and the given one coordinates are strictly equals
  2415. */
  2416. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2417. /**
  2418. * Clone the current quaternion
  2419. * @returns a new quaternion copied from the current one
  2420. */
  2421. clone(): Quaternion;
  2422. /**
  2423. * Copy a quaternion to the current one
  2424. * @param other defines the other quaternion
  2425. * @returns the updated current quaternion
  2426. */
  2427. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2428. /**
  2429. * Updates the current quaternion with the given float coordinates
  2430. * @param x defines the x coordinate
  2431. * @param y defines the y coordinate
  2432. * @param z defines the z coordinate
  2433. * @param w defines the w coordinate
  2434. * @returns the updated current quaternion
  2435. */
  2436. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2437. /**
  2438. * Updates the current quaternion from the given float coordinates
  2439. * @param x defines the x coordinate
  2440. * @param y defines the y coordinate
  2441. * @param z defines the z coordinate
  2442. * @param w defines the w coordinate
  2443. * @returns the updated current quaternion
  2444. */
  2445. set(x: number, y: number, z: number, w: number): Quaternion;
  2446. /**
  2447. * Adds two quaternions
  2448. * @param other defines the second operand
  2449. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2450. */
  2451. add(other: DeepImmutable<Quaternion>): Quaternion;
  2452. /**
  2453. * Add a quaternion to the current one
  2454. * @param other defines the quaternion to add
  2455. * @returns the current quaternion
  2456. */
  2457. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2458. /**
  2459. * Subtract two quaternions
  2460. * @param other defines the second operand
  2461. * @returns a new quaternion as the subtraction result of the given one from the current one
  2462. */
  2463. subtract(other: Quaternion): Quaternion;
  2464. /**
  2465. * Multiplies the current quaternion by a scale factor
  2466. * @param value defines the scale factor
  2467. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2468. */
  2469. scale(value: number): Quaternion;
  2470. /**
  2471. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2472. * @param scale defines the scale factor
  2473. * @param result defines the Quaternion object where to store the result
  2474. * @returns the unmodified current quaternion
  2475. */
  2476. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2477. /**
  2478. * Multiplies in place the current quaternion by a scale factor
  2479. * @param value defines the scale factor
  2480. * @returns the current modified quaternion
  2481. */
  2482. scaleInPlace(value: number): Quaternion;
  2483. /**
  2484. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2485. * @param scale defines the scale factor
  2486. * @param result defines the Quaternion object where to store the result
  2487. * @returns the unmodified current quaternion
  2488. */
  2489. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2490. /**
  2491. * Multiplies two quaternions
  2492. * @param q1 defines the second operand
  2493. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2494. */
  2495. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2496. /**
  2497. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2498. * @param q1 defines the second operand
  2499. * @param result defines the target quaternion
  2500. * @returns the current quaternion
  2501. */
  2502. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2503. /**
  2504. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2505. * @param q1 defines the second operand
  2506. * @returns the currentupdated quaternion
  2507. */
  2508. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2509. /**
  2510. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2511. * @param ref defines the target quaternion
  2512. * @returns the current quaternion
  2513. */
  2514. conjugateToRef(ref: Quaternion): Quaternion;
  2515. /**
  2516. * Conjugates in place (1-q) the current quaternion
  2517. * @returns the current updated quaternion
  2518. */
  2519. conjugateInPlace(): Quaternion;
  2520. /**
  2521. * Conjugates in place (1-q) the current quaternion
  2522. * @returns a new quaternion
  2523. */
  2524. conjugate(): Quaternion;
  2525. /**
  2526. * Gets length of current quaternion
  2527. * @returns the quaternion length (float)
  2528. */
  2529. length(): number;
  2530. /**
  2531. * Normalize in place the current quaternion
  2532. * @returns the current updated quaternion
  2533. */
  2534. normalize(): Quaternion;
  2535. /**
  2536. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2537. * @param order is a reserved parameter and is ignore for now
  2538. * @returns a new Vector3 containing the Euler angles
  2539. */
  2540. toEulerAngles(order?: string): Vector3;
  2541. /**
  2542. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2543. * @param result defines the vector which will be filled with the Euler angles
  2544. * @param order is a reserved parameter and is ignore for now
  2545. * @returns the current unchanged quaternion
  2546. */
  2547. toEulerAnglesToRef(result: Vector3): Quaternion;
  2548. /**
  2549. * Updates the given rotation matrix with the current quaternion values
  2550. * @param result defines the target matrix
  2551. * @returns the current unchanged quaternion
  2552. */
  2553. toRotationMatrix(result: Matrix): Quaternion;
  2554. /**
  2555. * Updates the current quaternion from the given rotation matrix values
  2556. * @param matrix defines the source matrix
  2557. * @returns the current updated quaternion
  2558. */
  2559. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2560. /**
  2561. * Creates a new quaternion from a rotation matrix
  2562. * @param matrix defines the source matrix
  2563. * @returns a new quaternion created from the given rotation matrix values
  2564. */
  2565. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2566. /**
  2567. * Updates the given quaternion with the given rotation matrix values
  2568. * @param matrix defines the source matrix
  2569. * @param result defines the target quaternion
  2570. */
  2571. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2572. /**
  2573. * Returns the dot product (float) between the quaternions "left" and "right"
  2574. * @param left defines the left operand
  2575. * @param right defines the right operand
  2576. * @returns the dot product
  2577. */
  2578. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2579. /**
  2580. * Checks if the two quaternions are close to each other
  2581. * @param quat0 defines the first quaternion to check
  2582. * @param quat1 defines the second quaternion to check
  2583. * @returns true if the two quaternions are close to each other
  2584. */
  2585. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2586. /**
  2587. * Creates an empty quaternion
  2588. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2589. */
  2590. static Zero(): Quaternion;
  2591. /**
  2592. * Inverse a given quaternion
  2593. * @param q defines the source quaternion
  2594. * @returns a new quaternion as the inverted current quaternion
  2595. */
  2596. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Inverse a given quaternion
  2599. * @param q defines the source quaternion
  2600. * @param result the quaternion the result will be stored in
  2601. * @returns the result quaternion
  2602. */
  2603. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2604. /**
  2605. * Creates an identity quaternion
  2606. * @returns the identity quaternion
  2607. */
  2608. static Identity(): Quaternion;
  2609. /**
  2610. * Gets a boolean indicating if the given quaternion is identity
  2611. * @param quaternion defines the quaternion to check
  2612. * @returns true if the quaternion is identity
  2613. */
  2614. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2615. /**
  2616. * Creates a quaternion from a rotation around an axis
  2617. * @param axis defines the axis to use
  2618. * @param angle defines the angle to use
  2619. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2620. */
  2621. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2622. /**
  2623. * Creates a rotation around an axis and stores it into the given quaternion
  2624. * @param axis defines the axis to use
  2625. * @param angle defines the angle to use
  2626. * @param result defines the target quaternion
  2627. * @returns the target quaternion
  2628. */
  2629. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2630. /**
  2631. * Creates a new quaternion from data stored into an array
  2632. * @param array defines the data source
  2633. * @param offset defines the offset in the source array where the data starts
  2634. * @returns a new quaternion
  2635. */
  2636. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2637. /**
  2638. * Create a quaternion from Euler rotation angles
  2639. * @param x Pitch
  2640. * @param y Yaw
  2641. * @param z Roll
  2642. * @returns the new Quaternion
  2643. */
  2644. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2645. /**
  2646. * Updates a quaternion from Euler rotation angles
  2647. * @param x Pitch
  2648. * @param y Yaw
  2649. * @param z Roll
  2650. * @param result the quaternion to store the result
  2651. * @returns the updated quaternion
  2652. */
  2653. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2654. /**
  2655. * Create a quaternion from Euler rotation vector
  2656. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2657. * @returns the new Quaternion
  2658. */
  2659. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2660. /**
  2661. * Updates a quaternion from Euler rotation vector
  2662. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2663. * @param result the quaternion to store the result
  2664. * @returns the updated quaternion
  2665. */
  2666. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2667. /**
  2668. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2669. * @param yaw defines the rotation around Y axis
  2670. * @param pitch defines the rotation around X axis
  2671. * @param roll defines the rotation around Z axis
  2672. * @returns the new quaternion
  2673. */
  2674. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2675. /**
  2676. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2677. * @param yaw defines the rotation around Y axis
  2678. * @param pitch defines the rotation around X axis
  2679. * @param roll defines the rotation around Z axis
  2680. * @param result defines the target quaternion
  2681. */
  2682. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2683. /**
  2684. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2685. * @param alpha defines the rotation around first axis
  2686. * @param beta defines the rotation around second axis
  2687. * @param gamma defines the rotation around third axis
  2688. * @returns the new quaternion
  2689. */
  2690. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2691. /**
  2692. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2693. * @param alpha defines the rotation around first axis
  2694. * @param beta defines the rotation around second axis
  2695. * @param gamma defines the rotation around third axis
  2696. * @param result defines the target quaternion
  2697. */
  2698. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2699. /**
  2700. * 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)
  2701. * @param axis1 defines the first axis
  2702. * @param axis2 defines the second axis
  2703. * @param axis3 defines the third axis
  2704. * @returns the new quaternion
  2705. */
  2706. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2707. /**
  2708. * 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
  2709. * @param axis1 defines the first axis
  2710. * @param axis2 defines the second axis
  2711. * @param axis3 defines the third axis
  2712. * @param ref defines the target quaternion
  2713. */
  2714. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2715. /**
  2716. * Interpolates between two quaternions
  2717. * @param left defines first quaternion
  2718. * @param right defines second quaternion
  2719. * @param amount defines the gradient to use
  2720. * @returns the new interpolated quaternion
  2721. */
  2722. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2723. /**
  2724. * Interpolates between two quaternions and stores it into a target quaternion
  2725. * @param left defines first quaternion
  2726. * @param right defines second quaternion
  2727. * @param amount defines the gradient to use
  2728. * @param result defines the target quaternion
  2729. */
  2730. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2731. /**
  2732. * Interpolate between two quaternions using Hermite interpolation
  2733. * @param value1 defines first quaternion
  2734. * @param tangent1 defines the incoming tangent
  2735. * @param value2 defines second quaternion
  2736. * @param tangent2 defines the outgoing tangent
  2737. * @param amount defines the target quaternion
  2738. * @returns the new interpolated quaternion
  2739. */
  2740. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2741. }
  2742. /**
  2743. * Class used to store matrix data (4x4)
  2744. */
  2745. export class Matrix {
  2746. private static _updateFlagSeed;
  2747. private static _identityReadOnly;
  2748. private _isIdentity;
  2749. private _isIdentityDirty;
  2750. private _isIdentity3x2;
  2751. private _isIdentity3x2Dirty;
  2752. /**
  2753. * Gets the update flag of the matrix which is an unique number for the matrix.
  2754. * It will be incremented every time the matrix data change.
  2755. * You can use it to speed the comparison between two versions of the same matrix.
  2756. */
  2757. updateFlag: number;
  2758. private readonly _m;
  2759. /**
  2760. * Gets the internal data of the matrix
  2761. */
  2762. readonly m: DeepImmutable<Float32Array>;
  2763. /** @hidden */
  2764. _markAsUpdated(): void;
  2765. /** @hidden */
  2766. private _updateIdentityStatus;
  2767. /**
  2768. * Creates an empty matrix (filled with zeros)
  2769. */
  2770. constructor();
  2771. /**
  2772. * Check if the current matrix is identity
  2773. * @returns true is the matrix is the identity matrix
  2774. */
  2775. isIdentity(): boolean;
  2776. /**
  2777. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2778. * @returns true is the matrix is the identity matrix
  2779. */
  2780. isIdentityAs3x2(): boolean;
  2781. /**
  2782. * Gets the determinant of the matrix
  2783. * @returns the matrix determinant
  2784. */
  2785. determinant(): number;
  2786. /**
  2787. * Returns the matrix as a Float32Array
  2788. * @returns the matrix underlying array
  2789. */
  2790. toArray(): DeepImmutable<Float32Array>;
  2791. /**
  2792. * Returns the matrix as a Float32Array
  2793. * @returns the matrix underlying array.
  2794. */
  2795. asArray(): DeepImmutable<Float32Array>;
  2796. /**
  2797. * Inverts the current matrix in place
  2798. * @returns the current inverted matrix
  2799. */
  2800. invert(): Matrix;
  2801. /**
  2802. * Sets all the matrix elements to zero
  2803. * @returns the current matrix
  2804. */
  2805. reset(): Matrix;
  2806. /**
  2807. * Adds the current matrix with a second one
  2808. * @param other defines the matrix to add
  2809. * @returns a new matrix as the addition of the current matrix and the given one
  2810. */
  2811. add(other: DeepImmutable<Matrix>): Matrix;
  2812. /**
  2813. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2814. * @param other defines the matrix to add
  2815. * @param result defines the target matrix
  2816. * @returns the current matrix
  2817. */
  2818. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2819. /**
  2820. * Adds in place the given matrix to the current matrix
  2821. * @param other defines the second operand
  2822. * @returns the current updated matrix
  2823. */
  2824. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2825. /**
  2826. * Sets the given matrix to the current inverted Matrix
  2827. * @param other defines the target matrix
  2828. * @returns the unmodified current matrix
  2829. */
  2830. invertToRef(other: Matrix): Matrix;
  2831. /**
  2832. * add a value at the specified position in the current Matrix
  2833. * @param index the index of the value within the matrix. between 0 and 15.
  2834. * @param value the value to be added
  2835. * @returns the current updated matrix
  2836. */
  2837. addAtIndex(index: number, value: number): Matrix;
  2838. /**
  2839. * mutiply the specified position in the current Matrix by a value
  2840. * @param index the index of the value within the matrix. between 0 and 15.
  2841. * @param value the value to be added
  2842. * @returns the current updated matrix
  2843. */
  2844. multiplyAtIndex(index: number, value: number): Matrix;
  2845. /**
  2846. * Inserts the translation vector (using 3 floats) in the current matrix
  2847. * @param x defines the 1st component of the translation
  2848. * @param y defines the 2nd component of the translation
  2849. * @param z defines the 3rd component of the translation
  2850. * @returns the current updated matrix
  2851. */
  2852. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2853. /**
  2854. * Adds the translation vector (using 3 floats) in the current matrix
  2855. * @param x defines the 1st component of the translation
  2856. * @param y defines the 2nd component of the translation
  2857. * @param z defines the 3rd component of the translation
  2858. * @returns the current updated matrix
  2859. */
  2860. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2861. /**
  2862. * Inserts the translation vector in the current matrix
  2863. * @param vector3 defines the translation to insert
  2864. * @returns the current updated matrix
  2865. */
  2866. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2867. /**
  2868. * Gets the translation value of the current matrix
  2869. * @returns a new Vector3 as the extracted translation from the matrix
  2870. */
  2871. getTranslation(): Vector3;
  2872. /**
  2873. * Fill a Vector3 with the extracted translation from the matrix
  2874. * @param result defines the Vector3 where to store the translation
  2875. * @returns the current matrix
  2876. */
  2877. getTranslationToRef(result: Vector3): Matrix;
  2878. /**
  2879. * Remove rotation and scaling part from the matrix
  2880. * @returns the updated matrix
  2881. */
  2882. removeRotationAndScaling(): Matrix;
  2883. /**
  2884. * Multiply two matrices
  2885. * @param other defines the second operand
  2886. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2887. */
  2888. multiply(other: DeepImmutable<Matrix>): Matrix;
  2889. /**
  2890. * Copy the current matrix from the given one
  2891. * @param other defines the source matrix
  2892. * @returns the current updated matrix
  2893. */
  2894. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2895. /**
  2896. * Populates the given array from the starting index with the current matrix values
  2897. * @param array defines the target array
  2898. * @param offset defines the offset in the target array where to start storing values
  2899. * @returns the current matrix
  2900. */
  2901. copyToArray(array: Float32Array, offset?: number): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2904. * @param other defines the second operand
  2905. * @param result defines the matrix where to store the multiplication
  2906. * @returns the current matrix
  2907. */
  2908. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2911. * @param other defines the second operand
  2912. * @param result defines the array where to store the multiplication
  2913. * @param offset defines the offset in the target array where to start storing values
  2914. * @returns the current matrix
  2915. */
  2916. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2917. /**
  2918. * Check equality between this matrix and a second one
  2919. * @param value defines the second matrix to compare
  2920. * @returns true is the current matrix and the given one values are strictly equal
  2921. */
  2922. equals(value: DeepImmutable<Matrix>): boolean;
  2923. /**
  2924. * Clone the current matrix
  2925. * @returns a new matrix from the current matrix
  2926. */
  2927. clone(): Matrix;
  2928. /**
  2929. * Returns the name of the current matrix class
  2930. * @returns the string "Matrix"
  2931. */
  2932. getClassName(): string;
  2933. /**
  2934. * Gets the hash code of the current matrix
  2935. * @returns the hash code
  2936. */
  2937. getHashCode(): number;
  2938. /**
  2939. * Decomposes the current Matrix into a translation, rotation and scaling components
  2940. * @param scale defines the scale vector3 given as a reference to update
  2941. * @param rotation defines the rotation quaternion given as a reference to update
  2942. * @param translation defines the translation vector3 given as a reference to update
  2943. * @returns true if operation was successful
  2944. */
  2945. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2946. /**
  2947. * Gets specific row of the matrix
  2948. * @param index defines the number of the row to get
  2949. * @returns the index-th row of the current matrix as a new Vector4
  2950. */
  2951. getRow(index: number): Nullable<Vector4>;
  2952. /**
  2953. * Sets the index-th row of the current matrix to the vector4 values
  2954. * @param index defines the number of the row to set
  2955. * @param row defines the target vector4
  2956. * @returns the updated current matrix
  2957. */
  2958. setRow(index: number, row: Vector4): Matrix;
  2959. /**
  2960. * Compute the transpose of the matrix
  2961. * @returns the new transposed matrix
  2962. */
  2963. transpose(): Matrix;
  2964. /**
  2965. * Compute the transpose of the matrix and store it in a given matrix
  2966. * @param result defines the target matrix
  2967. * @returns the current matrix
  2968. */
  2969. transposeToRef(result: Matrix): Matrix;
  2970. /**
  2971. * Sets the index-th row of the current matrix with the given 4 x float values
  2972. * @param index defines the row index
  2973. * @param x defines the x component to set
  2974. * @param y defines the y component to set
  2975. * @param z defines the z component to set
  2976. * @param w defines the w component to set
  2977. * @returns the updated current matrix
  2978. */
  2979. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2980. /**
  2981. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2982. * @param scale defines the scale factor
  2983. * @returns a new matrix
  2984. */
  2985. scale(scale: number): Matrix;
  2986. /**
  2987. * Scale the current matrix values by a factor to a given result matrix
  2988. * @param scale defines the scale factor
  2989. * @param result defines the matrix to store the result
  2990. * @returns the current matrix
  2991. */
  2992. scaleToRef(scale: number, result: Matrix): Matrix;
  2993. /**
  2994. * Scale the current matrix values by a factor and add the result to a given matrix
  2995. * @param scale defines the scale factor
  2996. * @param result defines the Matrix to store the result
  2997. * @returns the current matrix
  2998. */
  2999. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3000. /**
  3001. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3002. * @param ref matrix to store the result
  3003. */
  3004. toNormalMatrix(ref: Matrix): void;
  3005. /**
  3006. * Gets only rotation part of the current matrix
  3007. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3008. */
  3009. getRotationMatrix(): Matrix;
  3010. /**
  3011. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3012. * @param result defines the target matrix to store data to
  3013. * @returns the current matrix
  3014. */
  3015. getRotationMatrixToRef(result: Matrix): Matrix;
  3016. /**
  3017. * Toggles model matrix from being right handed to left handed in place and vice versa
  3018. */
  3019. toggleModelMatrixHandInPlace(): void;
  3020. /**
  3021. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3022. */
  3023. toggleProjectionMatrixHandInPlace(): void;
  3024. /**
  3025. * Creates a matrix from an array
  3026. * @param array defines the source array
  3027. * @param offset defines an offset in the source array
  3028. * @returns a new Matrix set from the starting index of the given array
  3029. */
  3030. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3031. /**
  3032. * Copy the content of an array into a given matrix
  3033. * @param array defines the source array
  3034. * @param offset defines an offset in the source array
  3035. * @param result defines the target matrix
  3036. */
  3037. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3038. /**
  3039. * Stores an array into a matrix after having multiplied each component by a given factor
  3040. * @param array defines the source array
  3041. * @param offset defines the offset in the source array
  3042. * @param scale defines the scaling factor
  3043. * @param result defines the target matrix
  3044. */
  3045. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3046. /**
  3047. * Gets an identity matrix that must not be updated
  3048. */
  3049. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3050. /**
  3051. * Stores a list of values (16) inside a given matrix
  3052. * @param initialM11 defines 1st value of 1st row
  3053. * @param initialM12 defines 2nd value of 1st row
  3054. * @param initialM13 defines 3rd value of 1st row
  3055. * @param initialM14 defines 4th value of 1st row
  3056. * @param initialM21 defines 1st value of 2nd row
  3057. * @param initialM22 defines 2nd value of 2nd row
  3058. * @param initialM23 defines 3rd value of 2nd row
  3059. * @param initialM24 defines 4th value of 2nd row
  3060. * @param initialM31 defines 1st value of 3rd row
  3061. * @param initialM32 defines 2nd value of 3rd row
  3062. * @param initialM33 defines 3rd value of 3rd row
  3063. * @param initialM34 defines 4th value of 3rd row
  3064. * @param initialM41 defines 1st value of 4th row
  3065. * @param initialM42 defines 2nd value of 4th row
  3066. * @param initialM43 defines 3rd value of 4th row
  3067. * @param initialM44 defines 4th value of 4th row
  3068. * @param result defines the target matrix
  3069. */
  3070. 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;
  3071. /**
  3072. * Creates new matrix from a list of values (16)
  3073. * @param initialM11 defines 1st value of 1st row
  3074. * @param initialM12 defines 2nd value of 1st row
  3075. * @param initialM13 defines 3rd value of 1st row
  3076. * @param initialM14 defines 4th value of 1st row
  3077. * @param initialM21 defines 1st value of 2nd row
  3078. * @param initialM22 defines 2nd value of 2nd row
  3079. * @param initialM23 defines 3rd value of 2nd row
  3080. * @param initialM24 defines 4th value of 2nd row
  3081. * @param initialM31 defines 1st value of 3rd row
  3082. * @param initialM32 defines 2nd value of 3rd row
  3083. * @param initialM33 defines 3rd value of 3rd row
  3084. * @param initialM34 defines 4th value of 3rd row
  3085. * @param initialM41 defines 1st value of 4th row
  3086. * @param initialM42 defines 2nd value of 4th row
  3087. * @param initialM43 defines 3rd value of 4th row
  3088. * @param initialM44 defines 4th value of 4th row
  3089. * @returns the new matrix
  3090. */
  3091. 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;
  3092. /**
  3093. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3094. * @param scale defines the scale vector3
  3095. * @param rotation defines the rotation quaternion
  3096. * @param translation defines the translation vector3
  3097. * @returns a new matrix
  3098. */
  3099. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3100. /**
  3101. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3102. * @param scale defines the scale vector3
  3103. * @param rotation defines the rotation quaternion
  3104. * @param translation defines the translation vector3
  3105. * @param result defines the target matrix
  3106. */
  3107. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3108. /**
  3109. * Creates a new identity matrix
  3110. * @returns a new identity matrix
  3111. */
  3112. static Identity(): Matrix;
  3113. /**
  3114. * Creates a new identity matrix and stores the result in a given matrix
  3115. * @param result defines the target matrix
  3116. */
  3117. static IdentityToRef(result: Matrix): void;
  3118. /**
  3119. * Creates a new zero matrix
  3120. * @returns a new zero matrix
  3121. */
  3122. static Zero(): Matrix;
  3123. /**
  3124. * Creates a new rotation matrix for "angle" radians around the X axis
  3125. * @param angle defines the angle (in radians) to use
  3126. * @return the new matrix
  3127. */
  3128. static RotationX(angle: number): Matrix;
  3129. /**
  3130. * Creates a new matrix as the invert of a given matrix
  3131. * @param source defines the source matrix
  3132. * @returns the new matrix
  3133. */
  3134. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3135. /**
  3136. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3137. * @param angle defines the angle (in radians) to use
  3138. * @param result defines the target matrix
  3139. */
  3140. static RotationXToRef(angle: number, result: Matrix): void;
  3141. /**
  3142. * Creates a new rotation matrix for "angle" radians around the Y axis
  3143. * @param angle defines the angle (in radians) to use
  3144. * @return the new matrix
  3145. */
  3146. static RotationY(angle: number): Matrix;
  3147. /**
  3148. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3149. * @param angle defines the angle (in radians) to use
  3150. * @param result defines the target matrix
  3151. */
  3152. static RotationYToRef(angle: number, result: Matrix): void;
  3153. /**
  3154. * Creates a new rotation matrix for "angle" radians around the Z axis
  3155. * @param angle defines the angle (in radians) to use
  3156. * @return the new matrix
  3157. */
  3158. static RotationZ(angle: number): Matrix;
  3159. /**
  3160. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3161. * @param angle defines the angle (in radians) to use
  3162. * @param result defines the target matrix
  3163. */
  3164. static RotationZToRef(angle: number, result: Matrix): void;
  3165. /**
  3166. * Creates a new rotation matrix for "angle" radians around the given axis
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle (in radians) to use
  3169. * @return the new matrix
  3170. */
  3171. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3172. /**
  3173. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3174. * @param axis defines the axis to use
  3175. * @param angle defines the angle (in radians) to use
  3176. * @param result defines the target matrix
  3177. */
  3178. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3179. /**
  3180. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3181. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3182. * @param from defines the vector to align
  3183. * @param to defines the vector to align to
  3184. * @param result defines the target matrix
  3185. */
  3186. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3187. /**
  3188. * Creates a rotation matrix
  3189. * @param yaw defines the yaw angle in radians (Y axis)
  3190. * @param pitch defines the pitch angle in radians (X axis)
  3191. * @param roll defines the roll angle in radians (X axis)
  3192. * @returns the new rotation matrix
  3193. */
  3194. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3195. /**
  3196. * Creates a rotation matrix and stores it in a given matrix
  3197. * @param yaw defines the yaw angle in radians (Y axis)
  3198. * @param pitch defines the pitch angle in radians (X axis)
  3199. * @param roll defines the roll angle in radians (X axis)
  3200. * @param result defines the target matrix
  3201. */
  3202. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3203. /**
  3204. * Creates a scaling matrix
  3205. * @param x defines the scale factor on X axis
  3206. * @param y defines the scale factor on Y axis
  3207. * @param z defines the scale factor on Z axis
  3208. * @returns the new matrix
  3209. */
  3210. static Scaling(x: number, y: number, z: number): Matrix;
  3211. /**
  3212. * Creates a scaling matrix and stores it in a given matrix
  3213. * @param x defines the scale factor on X axis
  3214. * @param y defines the scale factor on Y axis
  3215. * @param z defines the scale factor on Z axis
  3216. * @param result defines the target matrix
  3217. */
  3218. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3219. /**
  3220. * Creates a translation matrix
  3221. * @param x defines the translation on X axis
  3222. * @param y defines the translation on Y axis
  3223. * @param z defines the translationon Z axis
  3224. * @returns the new matrix
  3225. */
  3226. static Translation(x: number, y: number, z: number): Matrix;
  3227. /**
  3228. * Creates a translation matrix and stores it in a given matrix
  3229. * @param x defines the translation on X axis
  3230. * @param y defines the translation on Y axis
  3231. * @param z defines the translationon Z axis
  3232. * @param result defines the target matrix
  3233. */
  3234. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3235. /**
  3236. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3237. * @param startValue defines the start value
  3238. * @param endValue defines the end value
  3239. * @param gradient defines the gradient factor
  3240. * @returns the new matrix
  3241. */
  3242. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3243. /**
  3244. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3245. * @param startValue defines the start value
  3246. * @param endValue defines the end value
  3247. * @param gradient defines the gradient factor
  3248. * @param result defines the Matrix object where to store data
  3249. */
  3250. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3251. /**
  3252. * Builds a new matrix whose values are computed by:
  3253. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3254. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3255. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3256. * @param startValue defines the first matrix
  3257. * @param endValue defines the second matrix
  3258. * @param gradient defines the gradient between the two matrices
  3259. * @returns the new matrix
  3260. */
  3261. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3262. /**
  3263. * Update a matrix to values which are computed by:
  3264. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3265. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3266. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3267. * @param startValue defines the first matrix
  3268. * @param endValue defines the second matrix
  3269. * @param gradient defines the gradient between the two matrices
  3270. * @param result defines the target matrix
  3271. */
  3272. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3273. /**
  3274. * 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"
  3275. * This function works in left handed mode
  3276. * @param eye defines the final position of the entity
  3277. * @param target defines where the entity should look at
  3278. * @param up defines the up vector for the entity
  3279. * @returns the new matrix
  3280. */
  3281. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3282. /**
  3283. * 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".
  3284. * This function works in left handed mode
  3285. * @param eye defines the final position of the entity
  3286. * @param target defines where the entity should look at
  3287. * @param up defines the up vector for the entity
  3288. * @param result defines the target matrix
  3289. */
  3290. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3291. /**
  3292. * 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"
  3293. * This function works in right handed mode
  3294. * @param eye defines the final position of the entity
  3295. * @param target defines where the entity should look at
  3296. * @param up defines the up vector for the entity
  3297. * @returns the new matrix
  3298. */
  3299. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3300. /**
  3301. * 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".
  3302. * This function works in right handed mode
  3303. * @param eye defines the final position of the entity
  3304. * @param target defines where the entity should look at
  3305. * @param up defines the up vector for the entity
  3306. * @param result defines the target matrix
  3307. */
  3308. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3309. /**
  3310. * Create a left-handed orthographic projection matrix
  3311. * @param width defines the viewport width
  3312. * @param height defines the viewport height
  3313. * @param znear defines the near clip plane
  3314. * @param zfar defines the far clip plane
  3315. * @returns a new matrix as a left-handed orthographic projection matrix
  3316. */
  3317. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3318. /**
  3319. * Store a left-handed orthographic projection to a given matrix
  3320. * @param width defines the viewport width
  3321. * @param height defines the viewport height
  3322. * @param znear defines the near clip plane
  3323. * @param zfar defines the far clip plane
  3324. * @param result defines the target matrix
  3325. */
  3326. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3327. /**
  3328. * Create a left-handed orthographic projection matrix
  3329. * @param left defines the viewport left coordinate
  3330. * @param right defines the viewport right coordinate
  3331. * @param bottom defines the viewport bottom coordinate
  3332. * @param top defines the viewport top coordinate
  3333. * @param znear defines the near clip plane
  3334. * @param zfar defines the far clip plane
  3335. * @returns a new matrix as a left-handed orthographic projection matrix
  3336. */
  3337. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3338. /**
  3339. * Stores a left-handed orthographic projection into a given matrix
  3340. * @param left defines the viewport left coordinate
  3341. * @param right defines the viewport right coordinate
  3342. * @param bottom defines the viewport bottom coordinate
  3343. * @param top defines the viewport top coordinate
  3344. * @param znear defines the near clip plane
  3345. * @param zfar defines the far clip plane
  3346. * @param result defines the target matrix
  3347. */
  3348. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3349. /**
  3350. * Creates a right-handed orthographic projection matrix
  3351. * @param left defines the viewport left coordinate
  3352. * @param right defines the viewport right coordinate
  3353. * @param bottom defines the viewport bottom coordinate
  3354. * @param top defines the viewport top coordinate
  3355. * @param znear defines the near clip plane
  3356. * @param zfar defines the far clip plane
  3357. * @returns a new matrix as a right-handed orthographic projection matrix
  3358. */
  3359. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3360. /**
  3361. * Stores a right-handed orthographic projection into a given matrix
  3362. * @param left defines the viewport left coordinate
  3363. * @param right defines the viewport right coordinate
  3364. * @param bottom defines the viewport bottom coordinate
  3365. * @param top defines the viewport top coordinate
  3366. * @param znear defines the near clip plane
  3367. * @param zfar defines the far clip plane
  3368. * @param result defines the target matrix
  3369. */
  3370. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3371. /**
  3372. * Creates a left-handed perspective projection matrix
  3373. * @param width defines the viewport width
  3374. * @param height defines the viewport height
  3375. * @param znear defines the near clip plane
  3376. * @param zfar defines the far clip plane
  3377. * @returns a new matrix as a left-handed perspective projection matrix
  3378. */
  3379. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3380. /**
  3381. * Creates a left-handed perspective projection matrix
  3382. * @param fov defines the horizontal field of view
  3383. * @param aspect defines the aspect ratio
  3384. * @param znear defines the near clip plane
  3385. * @param zfar defines the far clip plane
  3386. * @returns a new matrix as a left-handed perspective projection matrix
  3387. */
  3388. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3389. /**
  3390. * Stores a left-handed perspective projection into a given matrix
  3391. * @param fov defines the horizontal field of view
  3392. * @param aspect defines the aspect ratio
  3393. * @param znear defines the near clip plane
  3394. * @param zfar defines the far clip plane
  3395. * @param result defines the target matrix
  3396. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3397. */
  3398. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3399. /**
  3400. * Creates a right-handed perspective projection matrix
  3401. * @param fov defines the horizontal field of view
  3402. * @param aspect defines the aspect ratio
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a right-handed perspective projection matrix
  3406. */
  3407. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Stores a right-handed perspective projection into a given matrix
  3410. * @param fov defines the horizontal field of view
  3411. * @param aspect defines the aspect ratio
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3416. */
  3417. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3418. /**
  3419. * Stores a perspective projection for WebVR info a given matrix
  3420. * @param fov defines the field of view
  3421. * @param znear defines the near clip plane
  3422. * @param zfar defines the far clip plane
  3423. * @param result defines the target matrix
  3424. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3425. */
  3426. static PerspectiveFovWebVRToRef(fov: {
  3427. upDegrees: number;
  3428. downDegrees: number;
  3429. leftDegrees: number;
  3430. rightDegrees: number;
  3431. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3432. /**
  3433. * Computes a complete transformation matrix
  3434. * @param viewport defines the viewport to use
  3435. * @param world defines the world matrix
  3436. * @param view defines the view matrix
  3437. * @param projection defines the projection matrix
  3438. * @param zmin defines the near clip plane
  3439. * @param zmax defines the far clip plane
  3440. * @returns the transformation matrix
  3441. */
  3442. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3443. /**
  3444. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3445. * @param matrix defines the matrix to use
  3446. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3447. */
  3448. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3449. /**
  3450. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3451. * @param matrix defines the matrix to use
  3452. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3453. */
  3454. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3455. /**
  3456. * Compute the transpose of a given matrix
  3457. * @param matrix defines the matrix to transpose
  3458. * @returns the new matrix
  3459. */
  3460. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3461. /**
  3462. * Compute the transpose of a matrix and store it in a target matrix
  3463. * @param matrix defines the matrix to transpose
  3464. * @param result defines the target matrix
  3465. */
  3466. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3467. /**
  3468. * Computes a reflection matrix from a plane
  3469. * @param plane defines the reflection plane
  3470. * @returns a new matrix
  3471. */
  3472. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3473. /**
  3474. * Computes a reflection matrix from a plane
  3475. * @param plane defines the reflection plane
  3476. * @param result defines the target matrix
  3477. */
  3478. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3479. /**
  3480. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3481. * @param xaxis defines the value of the 1st axis
  3482. * @param yaxis defines the value of the 2nd axis
  3483. * @param zaxis defines the value of the 3rd axis
  3484. * @param result defines the target matrix
  3485. */
  3486. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3487. /**
  3488. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3489. * @param quat defines the quaternion to use
  3490. * @param result defines the target matrix
  3491. */
  3492. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3493. }
  3494. /**
  3495. * @hidden
  3496. */
  3497. export class TmpVectors {
  3498. static Vector2: Vector2[];
  3499. static Vector3: Vector3[];
  3500. static Vector4: Vector4[];
  3501. static Quaternion: Quaternion[];
  3502. static Matrix: Matrix[];
  3503. }
  3504. }
  3505. declare module BABYLON {
  3506. /**
  3507. * Class used to hold a RBG color
  3508. */
  3509. export class Color3 {
  3510. /**
  3511. * Defines the red component (between 0 and 1, default is 0)
  3512. */
  3513. r: number;
  3514. /**
  3515. * Defines the green component (between 0 and 1, default is 0)
  3516. */
  3517. g: number;
  3518. /**
  3519. * Defines the blue component (between 0 and 1, default is 0)
  3520. */
  3521. b: number;
  3522. /**
  3523. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3524. * @param r defines the red component (between 0 and 1, default is 0)
  3525. * @param g defines the green component (between 0 and 1, default is 0)
  3526. * @param b defines the blue component (between 0 and 1, default is 0)
  3527. */
  3528. constructor(
  3529. /**
  3530. * Defines the red component (between 0 and 1, default is 0)
  3531. */
  3532. r?: number,
  3533. /**
  3534. * Defines the green component (between 0 and 1, default is 0)
  3535. */
  3536. g?: number,
  3537. /**
  3538. * Defines the blue component (between 0 and 1, default is 0)
  3539. */
  3540. b?: number);
  3541. /**
  3542. * Creates a string with the Color3 current values
  3543. * @returns the string representation of the Color3 object
  3544. */
  3545. toString(): string;
  3546. /**
  3547. * Returns the string "Color3"
  3548. * @returns "Color3"
  3549. */
  3550. getClassName(): string;
  3551. /**
  3552. * Compute the Color3 hash code
  3553. * @returns an unique number that can be used to hash Color3 objects
  3554. */
  3555. getHashCode(): number;
  3556. /**
  3557. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3558. * @param array defines the array where to store the r,g,b components
  3559. * @param index defines an optional index in the target array to define where to start storing values
  3560. * @returns the current Color3 object
  3561. */
  3562. toArray(array: FloatArray, index?: number): Color3;
  3563. /**
  3564. * Returns a new Color4 object from the current Color3 and the given alpha
  3565. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3566. * @returns a new Color4 object
  3567. */
  3568. toColor4(alpha?: number): Color4;
  3569. /**
  3570. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3571. * @returns the new array
  3572. */
  3573. asArray(): number[];
  3574. /**
  3575. * Returns the luminance value
  3576. * @returns a float value
  3577. */
  3578. toLuminance(): number;
  3579. /**
  3580. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3581. * @param otherColor defines the second operand
  3582. * @returns the new Color3 object
  3583. */
  3584. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3585. /**
  3586. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3587. * @param otherColor defines the second operand
  3588. * @param result defines the Color3 object where to store the result
  3589. * @returns the current Color3
  3590. */
  3591. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3592. /**
  3593. * Determines equality between Color3 objects
  3594. * @param otherColor defines the second operand
  3595. * @returns true if the rgb values are equal to the given ones
  3596. */
  3597. equals(otherColor: DeepImmutable<Color3>): boolean;
  3598. /**
  3599. * Determines equality between the current Color3 object and a set of r,b,g values
  3600. * @param r defines the red component to check
  3601. * @param g defines the green component to check
  3602. * @param b defines the blue component to check
  3603. * @returns true if the rgb values are equal to the given ones
  3604. */
  3605. equalsFloats(r: number, g: number, b: number): boolean;
  3606. /**
  3607. * Multiplies in place each rgb value by scale
  3608. * @param scale defines the scaling factor
  3609. * @returns the updated Color3
  3610. */
  3611. scale(scale: number): Color3;
  3612. /**
  3613. * Multiplies the rgb values by scale and stores the result into "result"
  3614. * @param scale defines the scaling factor
  3615. * @param result defines the Color3 object where to store the result
  3616. * @returns the unmodified current Color3
  3617. */
  3618. scaleToRef(scale: number, result: Color3): Color3;
  3619. /**
  3620. * Scale the current Color3 values by a factor and add the result to a given Color3
  3621. * @param scale defines the scale factor
  3622. * @param result defines color to store the result into
  3623. * @returns the unmodified current Color3
  3624. */
  3625. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3626. /**
  3627. * Clamps the rgb values by the min and max values and stores the result into "result"
  3628. * @param min defines minimum clamping value (default is 0)
  3629. * @param max defines maximum clamping value (default is 1)
  3630. * @param result defines color to store the result into
  3631. * @returns the original Color3
  3632. */
  3633. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3634. /**
  3635. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3636. * @param otherColor defines the second operand
  3637. * @returns the new Color3
  3638. */
  3639. add(otherColor: DeepImmutable<Color3>): Color3;
  3640. /**
  3641. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3642. * @param otherColor defines the second operand
  3643. * @param result defines Color3 object to store the result into
  3644. * @returns the unmodified current Color3
  3645. */
  3646. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3647. /**
  3648. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3649. * @param otherColor defines the second operand
  3650. * @returns the new Color3
  3651. */
  3652. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3653. /**
  3654. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3655. * @param otherColor defines the second operand
  3656. * @param result defines Color3 object to store the result into
  3657. * @returns the unmodified current Color3
  3658. */
  3659. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3660. /**
  3661. * Copy the current object
  3662. * @returns a new Color3 copied the current one
  3663. */
  3664. clone(): Color3;
  3665. /**
  3666. * Copies the rgb values from the source in the current Color3
  3667. * @param source defines the source Color3 object
  3668. * @returns the updated Color3 object
  3669. */
  3670. copyFrom(source: DeepImmutable<Color3>): Color3;
  3671. /**
  3672. * Updates the Color3 rgb values from the given floats
  3673. * @param r defines the red component to read from
  3674. * @param g defines the green component to read from
  3675. * @param b defines the blue component to read from
  3676. * @returns the current Color3 object
  3677. */
  3678. copyFromFloats(r: number, g: number, b: number): Color3;
  3679. /**
  3680. * Updates the Color3 rgb values from the given floats
  3681. * @param r defines the red component to read from
  3682. * @param g defines the green component to read from
  3683. * @param b defines the blue component to read from
  3684. * @returns the current Color3 object
  3685. */
  3686. set(r: number, g: number, b: number): Color3;
  3687. /**
  3688. * Compute the Color3 hexadecimal code as a string
  3689. * @returns a string containing the hexadecimal representation of the Color3 object
  3690. */
  3691. toHexString(): string;
  3692. /**
  3693. * Computes a new Color3 converted from the current one to linear space
  3694. * @returns a new Color3 object
  3695. */
  3696. toLinearSpace(): Color3;
  3697. /**
  3698. * Converts current color in rgb space to HSV values
  3699. * @returns a new color3 representing the HSV values
  3700. */
  3701. toHSV(): Color3;
  3702. /**
  3703. * Converts current color in rgb space to HSV values
  3704. * @param result defines the Color3 where to store the HSV values
  3705. */
  3706. toHSVToRef(result: Color3): void;
  3707. /**
  3708. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3709. * @param convertedColor defines the Color3 object where to store the linear space version
  3710. * @returns the unmodified Color3
  3711. */
  3712. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3713. /**
  3714. * Computes a new Color3 converted from the current one to gamma space
  3715. * @returns a new Color3 object
  3716. */
  3717. toGammaSpace(): Color3;
  3718. /**
  3719. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3720. * @param convertedColor defines the Color3 object where to store the gamma space version
  3721. * @returns the unmodified Color3
  3722. */
  3723. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3724. private static _BlackReadOnly;
  3725. /**
  3726. * Convert Hue, saturation and value to a Color3 (RGB)
  3727. * @param hue defines the hue
  3728. * @param saturation defines the saturation
  3729. * @param value defines the value
  3730. * @param result defines the Color3 where to store the RGB values
  3731. */
  3732. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3733. /**
  3734. * Creates a new Color3 from the string containing valid hexadecimal values
  3735. * @param hex defines a string containing valid hexadecimal values
  3736. * @returns a new Color3 object
  3737. */
  3738. static FromHexString(hex: string): Color3;
  3739. /**
  3740. * Creates a new Color3 from the starting index of the given array
  3741. * @param array defines the source array
  3742. * @param offset defines an offset in the source array
  3743. * @returns a new Color3 object
  3744. */
  3745. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3746. /**
  3747. * Creates a new Color3 from integer values (< 256)
  3748. * @param r defines the red component to read from (value between 0 and 255)
  3749. * @param g defines the green component to read from (value between 0 and 255)
  3750. * @param b defines the blue component to read from (value between 0 and 255)
  3751. * @returns a new Color3 object
  3752. */
  3753. static FromInts(r: number, g: number, b: number): Color3;
  3754. /**
  3755. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3756. * @param start defines the start Color3 value
  3757. * @param end defines the end Color3 value
  3758. * @param amount defines the gradient value between start and end
  3759. * @returns a new Color3 object
  3760. */
  3761. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3762. /**
  3763. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3764. * @param left defines the start value
  3765. * @param right defines the end value
  3766. * @param amount defines the gradient factor
  3767. * @param result defines the Color3 object where to store the result
  3768. */
  3769. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3770. /**
  3771. * Returns a Color3 value containing a red color
  3772. * @returns a new Color3 object
  3773. */
  3774. static Red(): Color3;
  3775. /**
  3776. * Returns a Color3 value containing a green color
  3777. * @returns a new Color3 object
  3778. */
  3779. static Green(): Color3;
  3780. /**
  3781. * Returns a Color3 value containing a blue color
  3782. * @returns a new Color3 object
  3783. */
  3784. static Blue(): Color3;
  3785. /**
  3786. * Returns a Color3 value containing a black color
  3787. * @returns a new Color3 object
  3788. */
  3789. static Black(): Color3;
  3790. /**
  3791. * Gets a Color3 value containing a black color that must not be updated
  3792. */
  3793. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3794. /**
  3795. * Returns a Color3 value containing a white color
  3796. * @returns a new Color3 object
  3797. */
  3798. static White(): Color3;
  3799. /**
  3800. * Returns a Color3 value containing a purple color
  3801. * @returns a new Color3 object
  3802. */
  3803. static Purple(): Color3;
  3804. /**
  3805. * Returns a Color3 value containing a magenta color
  3806. * @returns a new Color3 object
  3807. */
  3808. static Magenta(): Color3;
  3809. /**
  3810. * Returns a Color3 value containing a yellow color
  3811. * @returns a new Color3 object
  3812. */
  3813. static Yellow(): Color3;
  3814. /**
  3815. * Returns a Color3 value containing a gray color
  3816. * @returns a new Color3 object
  3817. */
  3818. static Gray(): Color3;
  3819. /**
  3820. * Returns a Color3 value containing a teal color
  3821. * @returns a new Color3 object
  3822. */
  3823. static Teal(): Color3;
  3824. /**
  3825. * Returns a Color3 value containing a random color
  3826. * @returns a new Color3 object
  3827. */
  3828. static Random(): Color3;
  3829. }
  3830. /**
  3831. * Class used to hold a RBGA color
  3832. */
  3833. export class Color4 {
  3834. /**
  3835. * Defines the red component (between 0 and 1, default is 0)
  3836. */
  3837. r: number;
  3838. /**
  3839. * Defines the green component (between 0 and 1, default is 0)
  3840. */
  3841. g: number;
  3842. /**
  3843. * Defines the blue component (between 0 and 1, default is 0)
  3844. */
  3845. b: number;
  3846. /**
  3847. * Defines the alpha component (between 0 and 1, default is 1)
  3848. */
  3849. a: number;
  3850. /**
  3851. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3852. * @param r defines the red component (between 0 and 1, default is 0)
  3853. * @param g defines the green component (between 0 and 1, default is 0)
  3854. * @param b defines the blue component (between 0 and 1, default is 0)
  3855. * @param a defines the alpha component (between 0 and 1, default is 1)
  3856. */
  3857. constructor(
  3858. /**
  3859. * Defines the red component (between 0 and 1, default is 0)
  3860. */
  3861. r?: number,
  3862. /**
  3863. * Defines the green component (between 0 and 1, default is 0)
  3864. */
  3865. g?: number,
  3866. /**
  3867. * Defines the blue component (between 0 and 1, default is 0)
  3868. */
  3869. b?: number,
  3870. /**
  3871. * Defines the alpha component (between 0 and 1, default is 1)
  3872. */
  3873. a?: number);
  3874. /**
  3875. * Adds in place the given Color4 values to the current Color4 object
  3876. * @param right defines the second operand
  3877. * @returns the current updated Color4 object
  3878. */
  3879. addInPlace(right: DeepImmutable<Color4>): Color4;
  3880. /**
  3881. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3882. * @returns the new array
  3883. */
  3884. asArray(): number[];
  3885. /**
  3886. * Stores from the starting index in the given array the Color4 successive values
  3887. * @param array defines the array where to store the r,g,b components
  3888. * @param index defines an optional index in the target array to define where to start storing values
  3889. * @returns the current Color4 object
  3890. */
  3891. toArray(array: number[], index?: number): Color4;
  3892. /**
  3893. * Determines equality between Color4 objects
  3894. * @param otherColor defines the second operand
  3895. * @returns true if the rgba values are equal to the given ones
  3896. */
  3897. equals(otherColor: DeepImmutable<Color4>): boolean;
  3898. /**
  3899. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3900. * @param right defines the second operand
  3901. * @returns a new Color4 object
  3902. */
  3903. add(right: DeepImmutable<Color4>): Color4;
  3904. /**
  3905. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3906. * @param right defines the second operand
  3907. * @returns a new Color4 object
  3908. */
  3909. subtract(right: DeepImmutable<Color4>): Color4;
  3910. /**
  3911. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3912. * @param right defines the second operand
  3913. * @param result defines the Color4 object where to store the result
  3914. * @returns the current Color4 object
  3915. */
  3916. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3917. /**
  3918. * Creates a new Color4 with the current Color4 values multiplied by scale
  3919. * @param scale defines the scaling factor to apply
  3920. * @returns a new Color4 object
  3921. */
  3922. scale(scale: number): Color4;
  3923. /**
  3924. * Multiplies the current Color4 values by scale and stores the result in "result"
  3925. * @param scale defines the scaling factor to apply
  3926. * @param result defines the Color4 object where to store the result
  3927. * @returns the current unmodified Color4
  3928. */
  3929. scaleToRef(scale: number, result: Color4): Color4;
  3930. /**
  3931. * Scale the current Color4 values by a factor and add the result to a given Color4
  3932. * @param scale defines the scale factor
  3933. * @param result defines the Color4 object where to store the result
  3934. * @returns the unmodified current Color4
  3935. */
  3936. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3937. /**
  3938. * Clamps the rgb values by the min and max values and stores the result into "result"
  3939. * @param min defines minimum clamping value (default is 0)
  3940. * @param max defines maximum clamping value (default is 1)
  3941. * @param result defines color to store the result into.
  3942. * @returns the cuurent Color4
  3943. */
  3944. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3945. /**
  3946. * Multipy an Color4 value by another and return a new Color4 object
  3947. * @param color defines the Color4 value to multiply by
  3948. * @returns a new Color4 object
  3949. */
  3950. multiply(color: Color4): Color4;
  3951. /**
  3952. * Multipy a Color4 value by another and push the result in a reference value
  3953. * @param color defines the Color4 value to multiply by
  3954. * @param result defines the Color4 to fill the result in
  3955. * @returns the result Color4
  3956. */
  3957. multiplyToRef(color: Color4, result: Color4): Color4;
  3958. /**
  3959. * Creates a string with the Color4 current values
  3960. * @returns the string representation of the Color4 object
  3961. */
  3962. toString(): string;
  3963. /**
  3964. * Returns the string "Color4"
  3965. * @returns "Color4"
  3966. */
  3967. getClassName(): string;
  3968. /**
  3969. * Compute the Color4 hash code
  3970. * @returns an unique number that can be used to hash Color4 objects
  3971. */
  3972. getHashCode(): number;
  3973. /**
  3974. * Creates a new Color4 copied from the current one
  3975. * @returns a new Color4 object
  3976. */
  3977. clone(): Color4;
  3978. /**
  3979. * Copies the given Color4 values into the current one
  3980. * @param source defines the source Color4 object
  3981. * @returns the current updated Color4 object
  3982. */
  3983. copyFrom(source: Color4): Color4;
  3984. /**
  3985. * Copies the given float values into the current one
  3986. * @param r defines the red component to read from
  3987. * @param g defines the green component to read from
  3988. * @param b defines the blue component to read from
  3989. * @param a defines the alpha component to read from
  3990. * @returns the current updated Color4 object
  3991. */
  3992. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  3993. /**
  3994. * Copies the given float values into the current one
  3995. * @param r defines the red component to read from
  3996. * @param g defines the green component to read from
  3997. * @param b defines the blue component to read from
  3998. * @param a defines the alpha component to read from
  3999. * @returns the current updated Color4 object
  4000. */
  4001. set(r: number, g: number, b: number, a: number): Color4;
  4002. /**
  4003. * Compute the Color4 hexadecimal code as a string
  4004. * @returns a string containing the hexadecimal representation of the Color4 object
  4005. */
  4006. toHexString(): string;
  4007. /**
  4008. * Computes a new Color4 converted from the current one to linear space
  4009. * @returns a new Color4 object
  4010. */
  4011. toLinearSpace(): Color4;
  4012. /**
  4013. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4014. * @param convertedColor defines the Color4 object where to store the linear space version
  4015. * @returns the unmodified Color4
  4016. */
  4017. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4018. /**
  4019. * Computes a new Color4 converted from the current one to gamma space
  4020. * @returns a new Color4 object
  4021. */
  4022. toGammaSpace(): Color4;
  4023. /**
  4024. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4025. * @param convertedColor defines the Color4 object where to store the gamma space version
  4026. * @returns the unmodified Color4
  4027. */
  4028. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4029. /**
  4030. * Creates a new Color4 from the string containing valid hexadecimal values
  4031. * @param hex defines a string containing valid hexadecimal values
  4032. * @returns a new Color4 object
  4033. */
  4034. static FromHexString(hex: string): Color4;
  4035. /**
  4036. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4037. * @param left defines the start value
  4038. * @param right defines the end value
  4039. * @param amount defines the gradient factor
  4040. * @returns a new Color4 object
  4041. */
  4042. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4043. /**
  4044. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4045. * @param left defines the start value
  4046. * @param right defines the end value
  4047. * @param amount defines the gradient factor
  4048. * @param result defines the Color4 object where to store data
  4049. */
  4050. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4051. /**
  4052. * Creates a new Color4 from a Color3 and an alpha value
  4053. * @param color3 defines the source Color3 to read from
  4054. * @param alpha defines the alpha component (1.0 by default)
  4055. * @returns a new Color4 object
  4056. */
  4057. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4058. /**
  4059. * Creates a new Color4 from the starting index element of the given array
  4060. * @param array defines the source array to read from
  4061. * @param offset defines the offset in the source array
  4062. * @returns a new Color4 object
  4063. */
  4064. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4065. /**
  4066. * Creates a new Color3 from integer values (< 256)
  4067. * @param r defines the red component to read from (value between 0 and 255)
  4068. * @param g defines the green component to read from (value between 0 and 255)
  4069. * @param b defines the blue component to read from (value between 0 and 255)
  4070. * @param a defines the alpha component to read from (value between 0 and 255)
  4071. * @returns a new Color3 object
  4072. */
  4073. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4074. /**
  4075. * Check the content of a given array and convert it to an array containing RGBA data
  4076. * If the original array was already containing count * 4 values then it is returned directly
  4077. * @param colors defines the array to check
  4078. * @param count defines the number of RGBA data to expect
  4079. * @returns an array containing count * 4 values (RGBA)
  4080. */
  4081. static CheckColors4(colors: number[], count: number): number[];
  4082. }
  4083. /**
  4084. * @hidden
  4085. */
  4086. export class TmpColors {
  4087. static Color3: Color3[];
  4088. static Color4: Color4[];
  4089. }
  4090. }
  4091. declare module BABYLON {
  4092. /**
  4093. * Class representing spherical harmonics coefficients to the 3rd degree
  4094. */
  4095. export class SphericalHarmonics {
  4096. /**
  4097. * Defines whether or not the harmonics have been prescaled for rendering.
  4098. */
  4099. preScaled: boolean;
  4100. /**
  4101. * The l0,0 coefficients of the spherical harmonics
  4102. */
  4103. l00: Vector3;
  4104. /**
  4105. * The l1,-1 coefficients of the spherical harmonics
  4106. */
  4107. l1_1: Vector3;
  4108. /**
  4109. * The l1,0 coefficients of the spherical harmonics
  4110. */
  4111. l10: Vector3;
  4112. /**
  4113. * The l1,1 coefficients of the spherical harmonics
  4114. */
  4115. l11: Vector3;
  4116. /**
  4117. * The l2,-2 coefficients of the spherical harmonics
  4118. */
  4119. l2_2: Vector3;
  4120. /**
  4121. * The l2,-1 coefficients of the spherical harmonics
  4122. */
  4123. l2_1: Vector3;
  4124. /**
  4125. * The l2,0 coefficients of the spherical harmonics
  4126. */
  4127. l20: Vector3;
  4128. /**
  4129. * The l2,1 coefficients of the spherical harmonics
  4130. */
  4131. l21: Vector3;
  4132. /**
  4133. * The l2,2 coefficients of the spherical harmonics
  4134. */
  4135. l22: Vector3;
  4136. /**
  4137. * Adds a light to the spherical harmonics
  4138. * @param direction the direction of the light
  4139. * @param color the color of the light
  4140. * @param deltaSolidAngle the delta solid angle of the light
  4141. */
  4142. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4143. /**
  4144. * Scales the spherical harmonics by the given amount
  4145. * @param scale the amount to scale
  4146. */
  4147. scaleInPlace(scale: number): void;
  4148. /**
  4149. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4150. *
  4151. * ```
  4152. * E_lm = A_l * L_lm
  4153. * ```
  4154. *
  4155. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4156. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4157. * the scaling factors are given in equation 9.
  4158. */
  4159. convertIncidentRadianceToIrradiance(): void;
  4160. /**
  4161. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4162. *
  4163. * ```
  4164. * L = (1/pi) * E * rho
  4165. * ```
  4166. *
  4167. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4168. */
  4169. convertIrradianceToLambertianRadiance(): void;
  4170. /**
  4171. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4172. * required operations at run time.
  4173. *
  4174. * This is simply done by scaling back the SH with Ylm constants parameter.
  4175. * The trigonometric part being applied by the shader at run time.
  4176. */
  4177. preScaleForRendering(): void;
  4178. /**
  4179. * Constructs a spherical harmonics from an array.
  4180. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4181. * @returns the spherical harmonics
  4182. */
  4183. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4184. /**
  4185. * Gets the spherical harmonics from polynomial
  4186. * @param polynomial the spherical polynomial
  4187. * @returns the spherical harmonics
  4188. */
  4189. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4190. }
  4191. /**
  4192. * Class representing spherical polynomial coefficients to the 3rd degree
  4193. */
  4194. export class SphericalPolynomial {
  4195. private _harmonics;
  4196. /**
  4197. * The spherical harmonics used to create the polynomials.
  4198. */
  4199. readonly preScaledHarmonics: SphericalHarmonics;
  4200. /**
  4201. * The x coefficients of the spherical polynomial
  4202. */
  4203. x: Vector3;
  4204. /**
  4205. * The y coefficients of the spherical polynomial
  4206. */
  4207. y: Vector3;
  4208. /**
  4209. * The z coefficients of the spherical polynomial
  4210. */
  4211. z: Vector3;
  4212. /**
  4213. * The xx coefficients of the spherical polynomial
  4214. */
  4215. xx: Vector3;
  4216. /**
  4217. * The yy coefficients of the spherical polynomial
  4218. */
  4219. yy: Vector3;
  4220. /**
  4221. * The zz coefficients of the spherical polynomial
  4222. */
  4223. zz: Vector3;
  4224. /**
  4225. * The xy coefficients of the spherical polynomial
  4226. */
  4227. xy: Vector3;
  4228. /**
  4229. * The yz coefficients of the spherical polynomial
  4230. */
  4231. yz: Vector3;
  4232. /**
  4233. * The zx coefficients of the spherical polynomial
  4234. */
  4235. zx: Vector3;
  4236. /**
  4237. * Adds an ambient color to the spherical polynomial
  4238. * @param color the color to add
  4239. */
  4240. addAmbient(color: Color3): void;
  4241. /**
  4242. * Scales the spherical polynomial by the given amount
  4243. * @param scale the amount to scale
  4244. */
  4245. scaleInPlace(scale: number): void;
  4246. /**
  4247. * Gets the spherical polynomial from harmonics
  4248. * @param harmonics the spherical harmonics
  4249. * @returns the spherical polynomial
  4250. */
  4251. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4252. /**
  4253. * Constructs a spherical polynomial from an array.
  4254. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4255. * @returns the spherical polynomial
  4256. */
  4257. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4258. }
  4259. }
  4260. declare module BABYLON {
  4261. /**
  4262. * Define options used to create a render target texture
  4263. */
  4264. export class RenderTargetCreationOptions {
  4265. /**
  4266. * Specifies is mipmaps must be generated
  4267. */
  4268. generateMipMaps?: boolean;
  4269. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4270. generateDepthBuffer?: boolean;
  4271. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4272. generateStencilBuffer?: boolean;
  4273. /** Defines texture type (int by default) */
  4274. type?: number;
  4275. /** Defines sampling mode (trilinear by default) */
  4276. samplingMode?: number;
  4277. /** Defines format (RGBA by default) */
  4278. format?: number;
  4279. }
  4280. }
  4281. declare module BABYLON {
  4282. /**
  4283. * @hidden
  4284. **/
  4285. export class _TimeToken {
  4286. _startTimeQuery: Nullable<WebGLQuery>;
  4287. _endTimeQuery: Nullable<WebGLQuery>;
  4288. _timeElapsedQuery: Nullable<WebGLQuery>;
  4289. _timeElapsedQueryEnded: boolean;
  4290. }
  4291. }
  4292. declare module BABYLON {
  4293. /** Defines the cross module used constants to avoid circular dependncies */
  4294. export class Constants {
  4295. /** Defines that alpha blending is disabled */
  4296. static readonly ALPHA_DISABLE: number;
  4297. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4298. static readonly ALPHA_ADD: number;
  4299. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4300. static readonly ALPHA_COMBINE: number;
  4301. /** Defines that alpha blending to DEST - SRC * DEST */
  4302. static readonly ALPHA_SUBTRACT: number;
  4303. /** Defines that alpha blending to SRC * DEST */
  4304. static readonly ALPHA_MULTIPLY: number;
  4305. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4306. static readonly ALPHA_MAXIMIZED: number;
  4307. /** Defines that alpha blending to SRC + DEST */
  4308. static readonly ALPHA_ONEONE: number;
  4309. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4310. static readonly ALPHA_PREMULTIPLIED: number;
  4311. /**
  4312. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4313. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4314. */
  4315. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4316. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4317. static readonly ALPHA_INTERPOLATE: number;
  4318. /**
  4319. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4320. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4321. */
  4322. static readonly ALPHA_SCREENMODE: number;
  4323. /**
  4324. * Defines that alpha blending to SRC + DST
  4325. * Alpha will be set to SRC ALPHA + DST ALPHA
  4326. */
  4327. static readonly ALPHA_ONEONE_ONEONE: number;
  4328. /**
  4329. * Defines that alpha blending to SRC * DST ALPHA + DST
  4330. * Alpha will be set to 0
  4331. */
  4332. static readonly ALPHA_ALPHATOCOLOR: number;
  4333. /**
  4334. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4335. */
  4336. static readonly ALPHA_REVERSEONEMINUS: number;
  4337. /**
  4338. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4339. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4340. */
  4341. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4342. /**
  4343. * Defines that alpha blending to SRC + DST
  4344. * Alpha will be set to SRC ALPHA
  4345. */
  4346. static readonly ALPHA_ONEONE_ONEZERO: number;
  4347. /** Defines that alpha blending equation a SUM */
  4348. static readonly ALPHA_EQUATION_ADD: number;
  4349. /** Defines that alpha blending equation a SUBSTRACTION */
  4350. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4351. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4352. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4353. /** Defines that alpha blending equation a MAX operation */
  4354. static readonly ALPHA_EQUATION_MAX: number;
  4355. /** Defines that alpha blending equation a MIN operation */
  4356. static readonly ALPHA_EQUATION_MIN: number;
  4357. /**
  4358. * Defines that alpha blending equation a DARKEN operation:
  4359. * It takes the min of the src and sums the alpha channels.
  4360. */
  4361. static readonly ALPHA_EQUATION_DARKEN: number;
  4362. /** Defines that the ressource is not delayed*/
  4363. static readonly DELAYLOADSTATE_NONE: number;
  4364. /** Defines that the ressource was successfully delay loaded */
  4365. static readonly DELAYLOADSTATE_LOADED: number;
  4366. /** Defines that the ressource is currently delay loading */
  4367. static readonly DELAYLOADSTATE_LOADING: number;
  4368. /** Defines that the ressource is delayed and has not started loading */
  4369. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4370. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4371. static readonly NEVER: number;
  4372. /** 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 */
  4373. static readonly ALWAYS: number;
  4374. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4375. static readonly LESS: number;
  4376. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4377. static readonly EQUAL: number;
  4378. /** 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 */
  4379. static readonly LEQUAL: number;
  4380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4381. static readonly GREATER: number;
  4382. /** 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 */
  4383. static readonly GEQUAL: number;
  4384. /** 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 */
  4385. static readonly NOTEQUAL: number;
  4386. /** Passed to stencilOperation to specify that stencil value must be kept */
  4387. static readonly KEEP: number;
  4388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4389. static readonly REPLACE: number;
  4390. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4391. static readonly INCR: number;
  4392. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4393. static readonly DECR: number;
  4394. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4395. static readonly INVERT: number;
  4396. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4397. static readonly INCR_WRAP: number;
  4398. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4399. static readonly DECR_WRAP: number;
  4400. /** Texture is not repeating outside of 0..1 UVs */
  4401. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4402. /** Texture is repeating outside of 0..1 UVs */
  4403. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4404. /** Texture is repeating and mirrored */
  4405. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4406. /** ALPHA */
  4407. static readonly TEXTUREFORMAT_ALPHA: number;
  4408. /** LUMINANCE */
  4409. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4410. /** LUMINANCE_ALPHA */
  4411. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4412. /** RGB */
  4413. static readonly TEXTUREFORMAT_RGB: number;
  4414. /** RGBA */
  4415. static readonly TEXTUREFORMAT_RGBA: number;
  4416. /** RED */
  4417. static readonly TEXTUREFORMAT_RED: number;
  4418. /** RED (2nd reference) */
  4419. static readonly TEXTUREFORMAT_R: number;
  4420. /** RG */
  4421. static readonly TEXTUREFORMAT_RG: number;
  4422. /** RED_INTEGER */
  4423. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4424. /** RED_INTEGER (2nd reference) */
  4425. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4426. /** RG_INTEGER */
  4427. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4428. /** RGB_INTEGER */
  4429. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4430. /** RGBA_INTEGER */
  4431. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4432. /** UNSIGNED_BYTE */
  4433. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4434. /** UNSIGNED_BYTE (2nd reference) */
  4435. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4436. /** FLOAT */
  4437. static readonly TEXTURETYPE_FLOAT: number;
  4438. /** HALF_FLOAT */
  4439. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4440. /** BYTE */
  4441. static readonly TEXTURETYPE_BYTE: number;
  4442. /** SHORT */
  4443. static readonly TEXTURETYPE_SHORT: number;
  4444. /** UNSIGNED_SHORT */
  4445. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4446. /** INT */
  4447. static readonly TEXTURETYPE_INT: number;
  4448. /** UNSIGNED_INT */
  4449. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4450. /** UNSIGNED_SHORT_4_4_4_4 */
  4451. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4452. /** UNSIGNED_SHORT_5_5_5_1 */
  4453. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4454. /** UNSIGNED_SHORT_5_6_5 */
  4455. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4456. /** UNSIGNED_INT_2_10_10_10_REV */
  4457. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4458. /** UNSIGNED_INT_24_8 */
  4459. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4460. /** UNSIGNED_INT_10F_11F_11F_REV */
  4461. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4462. /** UNSIGNED_INT_5_9_9_9_REV */
  4463. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4464. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4465. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4466. /** nearest is mag = nearest and min = nearest and mip = linear */
  4467. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4468. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4469. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4470. /** Trilinear is mag = linear and min = linear and mip = linear */
  4471. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4472. /** nearest is mag = nearest and min = nearest and mip = linear */
  4473. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4474. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4475. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4476. /** Trilinear is mag = linear and min = linear and mip = linear */
  4477. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4478. /** mag = nearest and min = nearest and mip = nearest */
  4479. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4480. /** mag = nearest and min = linear and mip = nearest */
  4481. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4482. /** mag = nearest and min = linear and mip = linear */
  4483. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4484. /** mag = nearest and min = linear and mip = none */
  4485. static readonly TEXTURE_NEAREST_LINEAR: number;
  4486. /** mag = nearest and min = nearest and mip = none */
  4487. static readonly TEXTURE_NEAREST_NEAREST: number;
  4488. /** mag = linear and min = nearest and mip = nearest */
  4489. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4490. /** mag = linear and min = nearest and mip = linear */
  4491. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4492. /** mag = linear and min = linear and mip = none */
  4493. static readonly TEXTURE_LINEAR_LINEAR: number;
  4494. /** mag = linear and min = nearest and mip = none */
  4495. static readonly TEXTURE_LINEAR_NEAREST: number;
  4496. /** Explicit coordinates mode */
  4497. static readonly TEXTURE_EXPLICIT_MODE: number;
  4498. /** Spherical coordinates mode */
  4499. static readonly TEXTURE_SPHERICAL_MODE: number;
  4500. /** Planar coordinates mode */
  4501. static readonly TEXTURE_PLANAR_MODE: number;
  4502. /** Cubic coordinates mode */
  4503. static readonly TEXTURE_CUBIC_MODE: number;
  4504. /** Projection coordinates mode */
  4505. static readonly TEXTURE_PROJECTION_MODE: number;
  4506. /** Skybox coordinates mode */
  4507. static readonly TEXTURE_SKYBOX_MODE: number;
  4508. /** Inverse Cubic coordinates mode */
  4509. static readonly TEXTURE_INVCUBIC_MODE: number;
  4510. /** Equirectangular coordinates mode */
  4511. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4512. /** Equirectangular Fixed coordinates mode */
  4513. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4514. /** Equirectangular Fixed Mirrored coordinates mode */
  4515. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4516. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4517. static readonly SCALEMODE_FLOOR: number;
  4518. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4519. static readonly SCALEMODE_NEAREST: number;
  4520. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4521. static readonly SCALEMODE_CEILING: number;
  4522. /**
  4523. * The dirty texture flag value
  4524. */
  4525. static readonly MATERIAL_TextureDirtyFlag: number;
  4526. /**
  4527. * The dirty light flag value
  4528. */
  4529. static readonly MATERIAL_LightDirtyFlag: number;
  4530. /**
  4531. * The dirty fresnel flag value
  4532. */
  4533. static readonly MATERIAL_FresnelDirtyFlag: number;
  4534. /**
  4535. * The dirty attribute flag value
  4536. */
  4537. static readonly MATERIAL_AttributesDirtyFlag: number;
  4538. /**
  4539. * The dirty misc flag value
  4540. */
  4541. static readonly MATERIAL_MiscDirtyFlag: number;
  4542. /**
  4543. * The all dirty flag value
  4544. */
  4545. static readonly MATERIAL_AllDirtyFlag: number;
  4546. /**
  4547. * Returns the triangle fill mode
  4548. */
  4549. static readonly MATERIAL_TriangleFillMode: number;
  4550. /**
  4551. * Returns the wireframe mode
  4552. */
  4553. static readonly MATERIAL_WireFrameFillMode: number;
  4554. /**
  4555. * Returns the point fill mode
  4556. */
  4557. static readonly MATERIAL_PointFillMode: number;
  4558. /**
  4559. * Returns the point list draw mode
  4560. */
  4561. static readonly MATERIAL_PointListDrawMode: number;
  4562. /**
  4563. * Returns the line list draw mode
  4564. */
  4565. static readonly MATERIAL_LineListDrawMode: number;
  4566. /**
  4567. * Returns the line loop draw mode
  4568. */
  4569. static readonly MATERIAL_LineLoopDrawMode: number;
  4570. /**
  4571. * Returns the line strip draw mode
  4572. */
  4573. static readonly MATERIAL_LineStripDrawMode: number;
  4574. /**
  4575. * Returns the triangle strip draw mode
  4576. */
  4577. static readonly MATERIAL_TriangleStripDrawMode: number;
  4578. /**
  4579. * Returns the triangle fan draw mode
  4580. */
  4581. static readonly MATERIAL_TriangleFanDrawMode: number;
  4582. /**
  4583. * Stores the clock-wise side orientation
  4584. */
  4585. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4586. /**
  4587. * Stores the counter clock-wise side orientation
  4588. */
  4589. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4590. /**
  4591. * Nothing
  4592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4593. */
  4594. static readonly ACTION_NothingTrigger: number;
  4595. /**
  4596. * On pick
  4597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4598. */
  4599. static readonly ACTION_OnPickTrigger: number;
  4600. /**
  4601. * On left pick
  4602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4603. */
  4604. static readonly ACTION_OnLeftPickTrigger: number;
  4605. /**
  4606. * On right pick
  4607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4608. */
  4609. static readonly ACTION_OnRightPickTrigger: number;
  4610. /**
  4611. * On center pick
  4612. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4613. */
  4614. static readonly ACTION_OnCenterPickTrigger: number;
  4615. /**
  4616. * On pick down
  4617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4618. */
  4619. static readonly ACTION_OnPickDownTrigger: number;
  4620. /**
  4621. * On double pick
  4622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4623. */
  4624. static readonly ACTION_OnDoublePickTrigger: number;
  4625. /**
  4626. * On pick up
  4627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4628. */
  4629. static readonly ACTION_OnPickUpTrigger: number;
  4630. /**
  4631. * On pick out.
  4632. * This trigger will only be raised if you also declared a OnPickDown
  4633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4634. */
  4635. static readonly ACTION_OnPickOutTrigger: number;
  4636. /**
  4637. * On long press
  4638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4639. */
  4640. static readonly ACTION_OnLongPressTrigger: number;
  4641. /**
  4642. * On pointer over
  4643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4644. */
  4645. static readonly ACTION_OnPointerOverTrigger: number;
  4646. /**
  4647. * On pointer out
  4648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4649. */
  4650. static readonly ACTION_OnPointerOutTrigger: number;
  4651. /**
  4652. * On every frame
  4653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4654. */
  4655. static readonly ACTION_OnEveryFrameTrigger: number;
  4656. /**
  4657. * On intersection enter
  4658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4659. */
  4660. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4661. /**
  4662. * On intersection exit
  4663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4664. */
  4665. static readonly ACTION_OnIntersectionExitTrigger: number;
  4666. /**
  4667. * On key down
  4668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4669. */
  4670. static readonly ACTION_OnKeyDownTrigger: number;
  4671. /**
  4672. * On key up
  4673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4674. */
  4675. static readonly ACTION_OnKeyUpTrigger: number;
  4676. /**
  4677. * Billboard mode will only apply to Y axis
  4678. */
  4679. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4680. /**
  4681. * Billboard mode will apply to all axes
  4682. */
  4683. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4684. /**
  4685. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4686. */
  4687. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4688. /**
  4689. * Gets or sets base Assets URL
  4690. */
  4691. static PARTICLES_BaseAssetsUrl: string;
  4692. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4693. * Test order :
  4694. * Is the bounding sphere outside the frustum ?
  4695. * If not, are the bounding box vertices outside the frustum ?
  4696. * It not, then the cullable object is in the frustum.
  4697. */
  4698. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4699. /** Culling strategy : Bounding Sphere Only.
  4700. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4701. * It's also less accurate than the standard because some not visible objects can still be selected.
  4702. * Test : is the bounding sphere outside the frustum ?
  4703. * If not, then the cullable object is in the frustum.
  4704. */
  4705. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4706. /** Culling strategy : Optimistic Inclusion.
  4707. * This in an inclusion test first, then the standard exclusion test.
  4708. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4709. * 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.
  4710. * Anyway, it's as accurate as the standard strategy.
  4711. * Test :
  4712. * Is the cullable object bounding sphere center in the frustum ?
  4713. * If not, apply the default culling strategy.
  4714. */
  4715. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4716. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4717. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4718. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4719. * 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.
  4720. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4721. * Test :
  4722. * Is the cullable object bounding sphere center in the frustum ?
  4723. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4724. */
  4725. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4726. /**
  4727. * No logging while loading
  4728. */
  4729. static readonly SCENELOADER_NO_LOGGING: number;
  4730. /**
  4731. * Minimal logging while loading
  4732. */
  4733. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4734. /**
  4735. * Summary logging while loading
  4736. */
  4737. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4738. /**
  4739. * Detailled logging while loading
  4740. */
  4741. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4742. }
  4743. }
  4744. declare module BABYLON {
  4745. /**
  4746. * This represents the required contract to create a new type of texture loader.
  4747. */
  4748. export interface IInternalTextureLoader {
  4749. /**
  4750. * Defines wether the loader supports cascade loading the different faces.
  4751. */
  4752. supportCascades: boolean;
  4753. /**
  4754. * This returns if the loader support the current file information.
  4755. * @param extension defines the file extension of the file being loaded
  4756. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4757. * @param fallback defines the fallback internal texture if any
  4758. * @param isBase64 defines whether the texture is encoded as a base64
  4759. * @param isBuffer defines whether the texture data are stored as a buffer
  4760. * @returns true if the loader can load the specified file
  4761. */
  4762. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4763. /**
  4764. * Transform the url before loading if required.
  4765. * @param rootUrl the url of the texture
  4766. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4767. * @returns the transformed texture
  4768. */
  4769. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4770. /**
  4771. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4772. * @param rootUrl the url of the texture
  4773. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4774. * @returns the fallback texture
  4775. */
  4776. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4777. /**
  4778. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4779. * @param data contains the texture data
  4780. * @param texture defines the BabylonJS internal texture
  4781. * @param createPolynomials will be true if polynomials have been requested
  4782. * @param onLoad defines the callback to trigger once the texture is ready
  4783. * @param onError defines the callback to trigger in case of error
  4784. */
  4785. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4786. /**
  4787. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4788. * @param data contains the texture data
  4789. * @param texture defines the BabylonJS internal texture
  4790. * @param callback defines the method to call once ready to upload
  4791. */
  4792. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4793. }
  4794. }
  4795. declare module BABYLON {
  4796. /**
  4797. * Class used to store and describe the pipeline context associated with an effect
  4798. */
  4799. export interface IPipelineContext {
  4800. /**
  4801. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4802. */
  4803. isAsync: boolean;
  4804. /**
  4805. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4806. */
  4807. isReady: boolean;
  4808. /** @hidden */
  4809. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4810. }
  4811. }
  4812. declare module BABYLON {
  4813. /**
  4814. * Class used to store gfx data (like WebGLBuffer)
  4815. */
  4816. export class DataBuffer {
  4817. /**
  4818. * Gets or sets the number of objects referencing this buffer
  4819. */
  4820. references: number;
  4821. /** Gets or sets the size of the underlying buffer */
  4822. capacity: number;
  4823. /**
  4824. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4825. */
  4826. is32Bits: boolean;
  4827. /**
  4828. * Gets the underlying buffer
  4829. */
  4830. readonly underlyingResource: any;
  4831. }
  4832. }
  4833. declare module BABYLON {
  4834. /** @hidden */
  4835. export interface IShaderProcessor {
  4836. attributeProcessor?: (attribute: string) => string;
  4837. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4838. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4839. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4840. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4841. lineProcessor?: (line: string, isFragment: boolean) => string;
  4842. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4843. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4844. }
  4845. }
  4846. declare module BABYLON {
  4847. /** @hidden */
  4848. export interface ProcessingOptions {
  4849. defines: string[];
  4850. indexParameters: any;
  4851. isFragment: boolean;
  4852. shouldUseHighPrecisionShader: boolean;
  4853. supportsUniformBuffers: boolean;
  4854. shadersRepository: string;
  4855. includesShadersStore: {
  4856. [key: string]: string;
  4857. };
  4858. processor?: IShaderProcessor;
  4859. version: string;
  4860. platformName: string;
  4861. lookForClosingBracketForUniformBuffer?: boolean;
  4862. }
  4863. }
  4864. declare module BABYLON {
  4865. /**
  4866. * Helper to manipulate strings
  4867. */
  4868. export class StringTools {
  4869. /**
  4870. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4871. * @param str Source string
  4872. * @param suffix Suffix to search for in the source string
  4873. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4874. */
  4875. static EndsWith(str: string, suffix: string): boolean;
  4876. /**
  4877. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4878. * @param str Source string
  4879. * @param suffix Suffix to search for in the source string
  4880. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4881. */
  4882. static StartsWith(str: string, suffix: string): boolean;
  4883. }
  4884. }
  4885. declare module BABYLON {
  4886. /** @hidden */
  4887. export class ShaderCodeNode {
  4888. line: string;
  4889. children: ShaderCodeNode[];
  4890. additionalDefineKey?: string;
  4891. additionalDefineValue?: string;
  4892. isValid(preprocessors: {
  4893. [key: string]: string;
  4894. }): boolean;
  4895. process(preprocessors: {
  4896. [key: string]: string;
  4897. }, options: ProcessingOptions): string;
  4898. }
  4899. }
  4900. declare module BABYLON {
  4901. /** @hidden */
  4902. export class ShaderCodeCursor {
  4903. private _lines;
  4904. lineIndex: number;
  4905. readonly currentLine: string;
  4906. readonly canRead: boolean;
  4907. lines: string[];
  4908. }
  4909. }
  4910. declare module BABYLON {
  4911. /** @hidden */
  4912. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4913. process(preprocessors: {
  4914. [key: string]: string;
  4915. }, options: ProcessingOptions): string;
  4916. }
  4917. }
  4918. declare module BABYLON {
  4919. /** @hidden */
  4920. export class ShaderDefineExpression {
  4921. isTrue(preprocessors: {
  4922. [key: string]: string;
  4923. }): boolean;
  4924. }
  4925. }
  4926. declare module BABYLON {
  4927. /** @hidden */
  4928. export class ShaderCodeTestNode extends ShaderCodeNode {
  4929. testExpression: ShaderDefineExpression;
  4930. isValid(preprocessors: {
  4931. [key: string]: string;
  4932. }): boolean;
  4933. }
  4934. }
  4935. declare module BABYLON {
  4936. /** @hidden */
  4937. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4938. define: string;
  4939. not: boolean;
  4940. constructor(define: string, not?: boolean);
  4941. isTrue(preprocessors: {
  4942. [key: string]: string;
  4943. }): boolean;
  4944. }
  4945. }
  4946. declare module BABYLON {
  4947. /** @hidden */
  4948. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4949. leftOperand: ShaderDefineExpression;
  4950. rightOperand: ShaderDefineExpression;
  4951. isTrue(preprocessors: {
  4952. [key: string]: string;
  4953. }): boolean;
  4954. }
  4955. }
  4956. declare module BABYLON {
  4957. /** @hidden */
  4958. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4959. leftOperand: ShaderDefineExpression;
  4960. rightOperand: ShaderDefineExpression;
  4961. isTrue(preprocessors: {
  4962. [key: string]: string;
  4963. }): boolean;
  4964. }
  4965. }
  4966. declare module BABYLON {
  4967. /** @hidden */
  4968. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4969. define: string;
  4970. operand: string;
  4971. testValue: string;
  4972. constructor(define: string, operand: string, testValue: string);
  4973. isTrue(preprocessors: {
  4974. [key: string]: string;
  4975. }): boolean;
  4976. }
  4977. }
  4978. declare module BABYLON {
  4979. /**
  4980. * @ignore
  4981. * Application error to support additional information when loading a file
  4982. */
  4983. export class LoadFileError extends Error {
  4984. /** defines the optional web request */
  4985. request?: WebRequest | undefined;
  4986. private static _setPrototypeOf;
  4987. /**
  4988. * Creates a new LoadFileError
  4989. * @param message defines the message of the error
  4990. * @param request defines the optional web request
  4991. */
  4992. constructor(message: string,
  4993. /** defines the optional web request */
  4994. request?: WebRequest | undefined);
  4995. }
  4996. }
  4997. declare module BABYLON {
  4998. /**
  4999. * Class used to enable access to offline support
  5000. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5001. */
  5002. export interface IOfflineProvider {
  5003. /**
  5004. * Gets a boolean indicating if scene must be saved in the database
  5005. */
  5006. enableSceneOffline: boolean;
  5007. /**
  5008. * Gets a boolean indicating if textures must be saved in the database
  5009. */
  5010. enableTexturesOffline: boolean;
  5011. /**
  5012. * Open the offline support and make it available
  5013. * @param successCallback defines the callback to call on success
  5014. * @param errorCallback defines the callback to call on error
  5015. */
  5016. open(successCallback: () => void, errorCallback: () => void): void;
  5017. /**
  5018. * Loads an image from the offline support
  5019. * @param url defines the url to load from
  5020. * @param image defines the target DOM image
  5021. */
  5022. loadImage(url: string, image: HTMLImageElement): void;
  5023. /**
  5024. * Loads a file from offline support
  5025. * @param url defines the URL to load from
  5026. * @param sceneLoaded defines a callback to call on success
  5027. * @param progressCallBack defines a callback to call when progress changed
  5028. * @param errorCallback defines a callback to call on error
  5029. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5030. */
  5031. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5032. }
  5033. }
  5034. declare module BABYLON {
  5035. /**
  5036. * Class used to help managing file picking and drag'n'drop
  5037. * File Storage
  5038. */
  5039. export class FilesInputStore {
  5040. /**
  5041. * List of files ready to be loaded
  5042. */
  5043. static FilesToLoad: {
  5044. [key: string]: File;
  5045. };
  5046. }
  5047. }
  5048. declare module BABYLON {
  5049. /**
  5050. * Class used to define a retry strategy when error happens while loading assets
  5051. */
  5052. export class RetryStrategy {
  5053. /**
  5054. * Function used to defines an exponential back off strategy
  5055. * @param maxRetries defines the maximum number of retries (3 by default)
  5056. * @param baseInterval defines the interval between retries
  5057. * @returns the strategy function to use
  5058. */
  5059. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5060. }
  5061. }
  5062. declare module BABYLON {
  5063. /**
  5064. * @hidden
  5065. */
  5066. export class FileTools {
  5067. /**
  5068. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5069. */
  5070. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5071. /**
  5072. * Gets or sets the base URL to use to load assets
  5073. */
  5074. static BaseUrl: string;
  5075. /**
  5076. * Default behaviour for cors in the application.
  5077. * It can be a string if the expected behavior is identical in the entire app.
  5078. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5079. */
  5080. static CorsBehavior: string | ((url: string | string[]) => string);
  5081. /**
  5082. * Gets or sets a function used to pre-process url before using them to load assets
  5083. */
  5084. static PreprocessUrl: (url: string) => string;
  5085. /**
  5086. * Removes unwanted characters from an url
  5087. * @param url defines the url to clean
  5088. * @returns the cleaned url
  5089. */
  5090. private static _CleanUrl;
  5091. /**
  5092. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5093. * @param url define the url we are trying
  5094. * @param element define the dom element where to configure the cors policy
  5095. */
  5096. static SetCorsBehavior(url: string | string[], element: {
  5097. crossOrigin: string | null;
  5098. }): void;
  5099. /**
  5100. * Loads an image as an HTMLImageElement.
  5101. * @param input url string, ArrayBuffer, or Blob to load
  5102. * @param onLoad callback called when the image successfully loads
  5103. * @param onError callback called when the image fails to load
  5104. * @param offlineProvider offline provider for caching
  5105. * @returns the HTMLImageElement of the loaded image
  5106. */
  5107. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5108. /**
  5109. * Loads a file
  5110. * @param fileToLoad defines the file to load
  5111. * @param callback defines the callback to call when data is loaded
  5112. * @param progressCallBack defines the callback to call during loading process
  5113. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5114. * @returns a file request object
  5115. */
  5116. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5117. /**
  5118. * Loads a file
  5119. * @param url url string, ArrayBuffer, or Blob to load
  5120. * @param onSuccess callback called when the file successfully loads
  5121. * @param onProgress callback called while file is loading (if the server supports this mode)
  5122. * @param offlineProvider defines the offline provider for caching
  5123. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5124. * @param onError callback called when the file fails to load
  5125. * @returns a file request object
  5126. */
  5127. 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;
  5128. /**
  5129. * Checks if the loaded document was accessed via `file:`-Protocol.
  5130. * @returns boolean
  5131. */
  5132. static IsFileURL(): boolean;
  5133. }
  5134. }
  5135. declare module BABYLON {
  5136. /** @hidden */
  5137. export class ShaderProcessor {
  5138. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5139. private static _ProcessPrecision;
  5140. private static _ExtractOperation;
  5141. private static _BuildSubExpression;
  5142. private static _BuildExpression;
  5143. private static _MoveCursorWithinIf;
  5144. private static _MoveCursor;
  5145. private static _EvaluatePreProcessors;
  5146. private static _PreparePreProcessors;
  5147. private static _ProcessShaderConversion;
  5148. private static _ProcessIncludes;
  5149. }
  5150. }
  5151. declare module BABYLON {
  5152. /**
  5153. * Interface used to define common properties for effect fallbacks
  5154. */
  5155. export interface IEffectFallbacks {
  5156. /**
  5157. * Removes the defines that should be removed when falling back.
  5158. * @param currentDefines defines the current define statements for the shader.
  5159. * @param effect defines the current effect we try to compile
  5160. * @returns The resulting defines with defines of the current rank removed.
  5161. */
  5162. reduce(currentDefines: string, effect: Effect): string;
  5163. /**
  5164. * Removes the fallback from the bound mesh.
  5165. */
  5166. unBindMesh(): void;
  5167. /**
  5168. * Checks to see if more fallbacks are still availible.
  5169. */
  5170. hasMoreFallbacks: boolean;
  5171. }
  5172. }
  5173. declare module BABYLON {
  5174. /**
  5175. * Class used to evalaute queries containing `and` and `or` operators
  5176. */
  5177. export class AndOrNotEvaluator {
  5178. /**
  5179. * Evaluate a query
  5180. * @param query defines the query to evaluate
  5181. * @param evaluateCallback defines the callback used to filter result
  5182. * @returns true if the query matches
  5183. */
  5184. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5185. private static _HandleParenthesisContent;
  5186. private static _SimplifyNegation;
  5187. }
  5188. }
  5189. declare module BABYLON {
  5190. /**
  5191. * Class used to store custom tags
  5192. */
  5193. export class Tags {
  5194. /**
  5195. * Adds support for tags on the given object
  5196. * @param obj defines the object to use
  5197. */
  5198. static EnableFor(obj: any): void;
  5199. /**
  5200. * Removes tags support
  5201. * @param obj defines the object to use
  5202. */
  5203. static DisableFor(obj: any): void;
  5204. /**
  5205. * Gets a boolean indicating if the given object has tags
  5206. * @param obj defines the object to use
  5207. * @returns a boolean
  5208. */
  5209. static HasTags(obj: any): boolean;
  5210. /**
  5211. * Gets the tags available on a given object
  5212. * @param obj defines the object to use
  5213. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5214. * @returns the tags
  5215. */
  5216. static GetTags(obj: any, asString?: boolean): any;
  5217. /**
  5218. * Adds tags to an object
  5219. * @param obj defines the object to use
  5220. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5221. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5222. */
  5223. static AddTagsTo(obj: any, tagsString: string): void;
  5224. /**
  5225. * @hidden
  5226. */
  5227. static _AddTagTo(obj: any, tag: string): void;
  5228. /**
  5229. * Removes specific tags from a specific object
  5230. * @param obj defines the object to use
  5231. * @param tagsString defines the tags to remove
  5232. */
  5233. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5234. /**
  5235. * @hidden
  5236. */
  5237. static _RemoveTagFrom(obj: any, tag: string): void;
  5238. /**
  5239. * Defines if tags hosted on an object match a given query
  5240. * @param obj defines the object to use
  5241. * @param tagsQuery defines the tag query
  5242. * @returns a boolean
  5243. */
  5244. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5245. }
  5246. }
  5247. declare module BABYLON {
  5248. /**
  5249. * Defines potential orientation for back face culling
  5250. */
  5251. export enum Orientation {
  5252. /**
  5253. * Clockwise
  5254. */
  5255. CW = 0,
  5256. /** Counter clockwise */
  5257. CCW = 1
  5258. }
  5259. /** Class used to represent a Bezier curve */
  5260. export class BezierCurve {
  5261. /**
  5262. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5263. * @param t defines the time
  5264. * @param x1 defines the left coordinate on X axis
  5265. * @param y1 defines the left coordinate on Y axis
  5266. * @param x2 defines the right coordinate on X axis
  5267. * @param y2 defines the right coordinate on Y axis
  5268. * @returns the interpolated value
  5269. */
  5270. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5271. }
  5272. /**
  5273. * Defines angle representation
  5274. */
  5275. export class Angle {
  5276. private _radians;
  5277. /**
  5278. * Creates an Angle object of "radians" radians (float).
  5279. * @param radians the angle in radians
  5280. */
  5281. constructor(radians: number);
  5282. /**
  5283. * Get value in degrees
  5284. * @returns the Angle value in degrees (float)
  5285. */
  5286. degrees(): number;
  5287. /**
  5288. * Get value in radians
  5289. * @returns the Angle value in radians (float)
  5290. */
  5291. radians(): number;
  5292. /**
  5293. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5294. * @param a defines first vector
  5295. * @param b defines second vector
  5296. * @returns a new Angle
  5297. */
  5298. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5299. /**
  5300. * Gets a new Angle object from the given float in radians
  5301. * @param radians defines the angle value in radians
  5302. * @returns a new Angle
  5303. */
  5304. static FromRadians(radians: number): Angle;
  5305. /**
  5306. * Gets a new Angle object from the given float in degrees
  5307. * @param degrees defines the angle value in degrees
  5308. * @returns a new Angle
  5309. */
  5310. static FromDegrees(degrees: number): Angle;
  5311. }
  5312. /**
  5313. * This represents an arc in a 2d space.
  5314. */
  5315. export class Arc2 {
  5316. /** Defines the start point of the arc */
  5317. startPoint: Vector2;
  5318. /** Defines the mid point of the arc */
  5319. midPoint: Vector2;
  5320. /** Defines the end point of the arc */
  5321. endPoint: Vector2;
  5322. /**
  5323. * Defines the center point of the arc.
  5324. */
  5325. centerPoint: Vector2;
  5326. /**
  5327. * Defines the radius of the arc.
  5328. */
  5329. radius: number;
  5330. /**
  5331. * Defines the angle of the arc (from mid point to end point).
  5332. */
  5333. angle: Angle;
  5334. /**
  5335. * Defines the start angle of the arc (from start point to middle point).
  5336. */
  5337. startAngle: Angle;
  5338. /**
  5339. * Defines the orientation of the arc (clock wise/counter clock wise).
  5340. */
  5341. orientation: Orientation;
  5342. /**
  5343. * Creates an Arc object from the three given points : start, middle and end.
  5344. * @param startPoint Defines the start point of the arc
  5345. * @param midPoint Defines the midlle point of the arc
  5346. * @param endPoint Defines the end point of the arc
  5347. */
  5348. constructor(
  5349. /** Defines the start point of the arc */
  5350. startPoint: Vector2,
  5351. /** Defines the mid point of the arc */
  5352. midPoint: Vector2,
  5353. /** Defines the end point of the arc */
  5354. endPoint: Vector2);
  5355. }
  5356. /**
  5357. * Represents a 2D path made up of multiple 2D points
  5358. */
  5359. export class Path2 {
  5360. private _points;
  5361. private _length;
  5362. /**
  5363. * If the path start and end point are the same
  5364. */
  5365. closed: boolean;
  5366. /**
  5367. * Creates a Path2 object from the starting 2D coordinates x and y.
  5368. * @param x the starting points x value
  5369. * @param y the starting points y value
  5370. */
  5371. constructor(x: number, y: number);
  5372. /**
  5373. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5374. * @param x the added points x value
  5375. * @param y the added points y value
  5376. * @returns the updated Path2.
  5377. */
  5378. addLineTo(x: number, y: number): Path2;
  5379. /**
  5380. * 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.
  5381. * @param midX middle point x value
  5382. * @param midY middle point y value
  5383. * @param endX end point x value
  5384. * @param endY end point y value
  5385. * @param numberOfSegments (default: 36)
  5386. * @returns the updated Path2.
  5387. */
  5388. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5389. /**
  5390. * Closes the Path2.
  5391. * @returns the Path2.
  5392. */
  5393. close(): Path2;
  5394. /**
  5395. * Gets the sum of the distance between each sequential point in the path
  5396. * @returns the Path2 total length (float).
  5397. */
  5398. length(): number;
  5399. /**
  5400. * Gets the points which construct the path
  5401. * @returns the Path2 internal array of points.
  5402. */
  5403. getPoints(): Vector2[];
  5404. /**
  5405. * Retreives the point at the distance aways from the starting point
  5406. * @param normalizedLengthPosition the length along the path to retreive the point from
  5407. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5408. */
  5409. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5410. /**
  5411. * Creates a new path starting from an x and y position
  5412. * @param x starting x value
  5413. * @param y starting y value
  5414. * @returns a new Path2 starting at the coordinates (x, y).
  5415. */
  5416. static StartingAt(x: number, y: number): Path2;
  5417. }
  5418. /**
  5419. * Represents a 3D path made up of multiple 3D points
  5420. */
  5421. export class Path3D {
  5422. /**
  5423. * an array of Vector3, the curve axis of the Path3D
  5424. */
  5425. path: Vector3[];
  5426. private _curve;
  5427. private _distances;
  5428. private _tangents;
  5429. private _normals;
  5430. private _binormals;
  5431. private _raw;
  5432. /**
  5433. * new Path3D(path, normal, raw)
  5434. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5435. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5436. * @param path an array of Vector3, the curve axis of the Path3D
  5437. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5438. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5439. */
  5440. constructor(
  5441. /**
  5442. * an array of Vector3, the curve axis of the Path3D
  5443. */
  5444. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5445. /**
  5446. * Returns the Path3D array of successive Vector3 designing its curve.
  5447. * @returns the Path3D array of successive Vector3 designing its curve.
  5448. */
  5449. getCurve(): Vector3[];
  5450. /**
  5451. * Returns an array populated with tangent vectors on each Path3D curve point.
  5452. * @returns an array populated with tangent vectors on each Path3D curve point.
  5453. */
  5454. getTangents(): Vector3[];
  5455. /**
  5456. * Returns an array populated with normal vectors on each Path3D curve point.
  5457. * @returns an array populated with normal vectors on each Path3D curve point.
  5458. */
  5459. getNormals(): Vector3[];
  5460. /**
  5461. * Returns an array populated with binormal vectors on each Path3D curve point.
  5462. * @returns an array populated with binormal vectors on each Path3D curve point.
  5463. */
  5464. getBinormals(): Vector3[];
  5465. /**
  5466. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5467. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5468. */
  5469. getDistances(): number[];
  5470. /**
  5471. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5472. * @param path path which all values are copied into the curves points
  5473. * @param firstNormal which should be projected onto the curve
  5474. * @returns the same object updated.
  5475. */
  5476. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5477. private _compute;
  5478. private _getFirstNonNullVector;
  5479. private _getLastNonNullVector;
  5480. private _normalVector;
  5481. }
  5482. /**
  5483. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5484. * A Curve3 is designed from a series of successive Vector3.
  5485. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5486. */
  5487. export class Curve3 {
  5488. private _points;
  5489. private _length;
  5490. /**
  5491. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5492. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5493. * @param v1 (Vector3) the control point
  5494. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5495. * @param nbPoints (integer) the wanted number of points in the curve
  5496. * @returns the created Curve3
  5497. */
  5498. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5499. /**
  5500. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5501. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5502. * @param v1 (Vector3) the first control point
  5503. * @param v2 (Vector3) the second control point
  5504. * @param v3 (Vector3) the end point of the Cubic Bezier
  5505. * @param nbPoints (integer) the wanted number of points in the curve
  5506. * @returns the created Curve3
  5507. */
  5508. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5509. /**
  5510. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5511. * @param p1 (Vector3) the origin point of the Hermite Spline
  5512. * @param t1 (Vector3) the tangent vector at the origin point
  5513. * @param p2 (Vector3) the end point of the Hermite Spline
  5514. * @param t2 (Vector3) the tangent vector at the end point
  5515. * @param nbPoints (integer) the wanted number of points in the curve
  5516. * @returns the created Curve3
  5517. */
  5518. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5519. /**
  5520. * Returns a Curve3 object along a CatmullRom Spline curve :
  5521. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5522. * @param nbPoints (integer) the wanted number of points between each curve control points
  5523. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5524. * @returns the created Curve3
  5525. */
  5526. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5527. /**
  5528. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5529. * A Curve3 is designed from a series of successive Vector3.
  5530. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5531. * @param points points which make up the curve
  5532. */
  5533. constructor(points: Vector3[]);
  5534. /**
  5535. * @returns the Curve3 stored array of successive Vector3
  5536. */
  5537. getPoints(): Vector3[];
  5538. /**
  5539. * @returns the computed length (float) of the curve.
  5540. */
  5541. length(): number;
  5542. /**
  5543. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5544. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5545. * curveA and curveB keep unchanged.
  5546. * @param curve the curve to continue from this curve
  5547. * @returns the newly constructed curve
  5548. */
  5549. continue(curve: DeepImmutable<Curve3>): Curve3;
  5550. private _computeLength;
  5551. }
  5552. }
  5553. declare module BABYLON {
  5554. /**
  5555. * This represents the main contract an easing function should follow.
  5556. * Easing functions are used throughout the animation system.
  5557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5558. */
  5559. export interface IEasingFunction {
  5560. /**
  5561. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5562. * of the easing function.
  5563. * The link below provides some of the most common examples of easing functions.
  5564. * @see https://easings.net/
  5565. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5566. * @returns the corresponding value on the curve defined by the easing function
  5567. */
  5568. ease(gradient: number): number;
  5569. }
  5570. /**
  5571. * Base class used for every default easing function.
  5572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5573. */
  5574. export class EasingFunction implements IEasingFunction {
  5575. /**
  5576. * Interpolation follows the mathematical formula associated with the easing function.
  5577. */
  5578. static readonly EASINGMODE_EASEIN: number;
  5579. /**
  5580. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5581. */
  5582. static readonly EASINGMODE_EASEOUT: number;
  5583. /**
  5584. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5585. */
  5586. static readonly EASINGMODE_EASEINOUT: number;
  5587. private _easingMode;
  5588. /**
  5589. * Sets the easing mode of the current function.
  5590. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5591. */
  5592. setEasingMode(easingMode: number): void;
  5593. /**
  5594. * Gets the current easing mode.
  5595. * @returns the easing mode
  5596. */
  5597. getEasingMode(): number;
  5598. /**
  5599. * @hidden
  5600. */
  5601. easeInCore(gradient: number): number;
  5602. /**
  5603. * Given an input gradient between 0 and 1, this returns the corresponding value
  5604. * of the easing function.
  5605. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5606. * @returns the corresponding value on the curve defined by the easing function
  5607. */
  5608. ease(gradient: number): number;
  5609. }
  5610. /**
  5611. * Easing function with a circle shape (see link below).
  5612. * @see https://easings.net/#easeInCirc
  5613. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5614. */
  5615. export class CircleEase extends EasingFunction implements IEasingFunction {
  5616. /** @hidden */
  5617. easeInCore(gradient: number): number;
  5618. }
  5619. /**
  5620. * Easing function with a ease back shape (see link below).
  5621. * @see https://easings.net/#easeInBack
  5622. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5623. */
  5624. export class BackEase extends EasingFunction implements IEasingFunction {
  5625. /** Defines the amplitude of the function */
  5626. amplitude: number;
  5627. /**
  5628. * Instantiates a back ease easing
  5629. * @see https://easings.net/#easeInBack
  5630. * @param amplitude Defines the amplitude of the function
  5631. */
  5632. constructor(
  5633. /** Defines the amplitude of the function */
  5634. amplitude?: number);
  5635. /** @hidden */
  5636. easeInCore(gradient: number): number;
  5637. }
  5638. /**
  5639. * Easing function with a bouncing shape (see link below).
  5640. * @see https://easings.net/#easeInBounce
  5641. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5642. */
  5643. export class BounceEase extends EasingFunction implements IEasingFunction {
  5644. /** Defines the number of bounces */
  5645. bounces: number;
  5646. /** Defines the amplitude of the bounce */
  5647. bounciness: number;
  5648. /**
  5649. * Instantiates a bounce easing
  5650. * @see https://easings.net/#easeInBounce
  5651. * @param bounces Defines the number of bounces
  5652. * @param bounciness Defines the amplitude of the bounce
  5653. */
  5654. constructor(
  5655. /** Defines the number of bounces */
  5656. bounces?: number,
  5657. /** Defines the amplitude of the bounce */
  5658. bounciness?: number);
  5659. /** @hidden */
  5660. easeInCore(gradient: number): number;
  5661. }
  5662. /**
  5663. * Easing function with a power of 3 shape (see link below).
  5664. * @see https://easings.net/#easeInCubic
  5665. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5666. */
  5667. export class CubicEase extends EasingFunction implements IEasingFunction {
  5668. /** @hidden */
  5669. easeInCore(gradient: number): number;
  5670. }
  5671. /**
  5672. * Easing function with an elastic shape (see link below).
  5673. * @see https://easings.net/#easeInElastic
  5674. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5675. */
  5676. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5677. /** Defines the number of oscillations*/
  5678. oscillations: number;
  5679. /** Defines the amplitude of the oscillations*/
  5680. springiness: number;
  5681. /**
  5682. * Instantiates an elastic easing function
  5683. * @see https://easings.net/#easeInElastic
  5684. * @param oscillations Defines the number of oscillations
  5685. * @param springiness Defines the amplitude of the oscillations
  5686. */
  5687. constructor(
  5688. /** Defines the number of oscillations*/
  5689. oscillations?: number,
  5690. /** Defines the amplitude of the oscillations*/
  5691. springiness?: number);
  5692. /** @hidden */
  5693. easeInCore(gradient: number): number;
  5694. }
  5695. /**
  5696. * Easing function with an exponential shape (see link below).
  5697. * @see https://easings.net/#easeInExpo
  5698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5699. */
  5700. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5701. /** Defines the exponent of the function */
  5702. exponent: number;
  5703. /**
  5704. * Instantiates an exponential easing function
  5705. * @see https://easings.net/#easeInExpo
  5706. * @param exponent Defines the exponent of the function
  5707. */
  5708. constructor(
  5709. /** Defines the exponent of the function */
  5710. exponent?: number);
  5711. /** @hidden */
  5712. easeInCore(gradient: number): number;
  5713. }
  5714. /**
  5715. * Easing function with a power shape (see link below).
  5716. * @see https://easings.net/#easeInQuad
  5717. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5718. */
  5719. export class PowerEase extends EasingFunction implements IEasingFunction {
  5720. /** Defines the power of the function */
  5721. power: number;
  5722. /**
  5723. * Instantiates an power base easing function
  5724. * @see https://easings.net/#easeInQuad
  5725. * @param power Defines the power of the function
  5726. */
  5727. constructor(
  5728. /** Defines the power of the function */
  5729. power?: number);
  5730. /** @hidden */
  5731. easeInCore(gradient: number): number;
  5732. }
  5733. /**
  5734. * Easing function with a power of 2 shape (see link below).
  5735. * @see https://easings.net/#easeInQuad
  5736. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5737. */
  5738. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5739. /** @hidden */
  5740. easeInCore(gradient: number): number;
  5741. }
  5742. /**
  5743. * Easing function with a power of 4 shape (see link below).
  5744. * @see https://easings.net/#easeInQuart
  5745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5746. */
  5747. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5748. /** @hidden */
  5749. easeInCore(gradient: number): number;
  5750. }
  5751. /**
  5752. * Easing function with a power of 5 shape (see link below).
  5753. * @see https://easings.net/#easeInQuint
  5754. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5755. */
  5756. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5757. /** @hidden */
  5758. easeInCore(gradient: number): number;
  5759. }
  5760. /**
  5761. * Easing function with a sin shape (see link below).
  5762. * @see https://easings.net/#easeInSine
  5763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5764. */
  5765. export class SineEase extends EasingFunction implements IEasingFunction {
  5766. /** @hidden */
  5767. easeInCore(gradient: number): number;
  5768. }
  5769. /**
  5770. * Easing function with a bezier shape (see link below).
  5771. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5773. */
  5774. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5775. /** Defines the x component of the start tangent in the bezier curve */
  5776. x1: number;
  5777. /** Defines the y component of the start tangent in the bezier curve */
  5778. y1: number;
  5779. /** Defines the x component of the end tangent in the bezier curve */
  5780. x2: number;
  5781. /** Defines the y component of the end tangent in the bezier curve */
  5782. y2: number;
  5783. /**
  5784. * Instantiates a bezier function
  5785. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5786. * @param x1 Defines the x component of the start tangent in the bezier curve
  5787. * @param y1 Defines the y component of the start tangent in the bezier curve
  5788. * @param x2 Defines the x component of the end tangent in the bezier curve
  5789. * @param y2 Defines the y component of the end tangent in the bezier curve
  5790. */
  5791. constructor(
  5792. /** Defines the x component of the start tangent in the bezier curve */
  5793. x1?: number,
  5794. /** Defines the y component of the start tangent in the bezier curve */
  5795. y1?: number,
  5796. /** Defines the x component of the end tangent in the bezier curve */
  5797. x2?: number,
  5798. /** Defines the y component of the end tangent in the bezier curve */
  5799. y2?: number);
  5800. /** @hidden */
  5801. easeInCore(gradient: number): number;
  5802. }
  5803. }
  5804. declare module BABYLON {
  5805. /**
  5806. * Defines an interface which represents an animation key frame
  5807. */
  5808. export interface IAnimationKey {
  5809. /**
  5810. * Frame of the key frame
  5811. */
  5812. frame: number;
  5813. /**
  5814. * Value at the specifies key frame
  5815. */
  5816. value: any;
  5817. /**
  5818. * The input tangent for the cubic hermite spline
  5819. */
  5820. inTangent?: any;
  5821. /**
  5822. * The output tangent for the cubic hermite spline
  5823. */
  5824. outTangent?: any;
  5825. /**
  5826. * The animation interpolation type
  5827. */
  5828. interpolation?: AnimationKeyInterpolation;
  5829. }
  5830. /**
  5831. * Enum for the animation key frame interpolation type
  5832. */
  5833. export enum AnimationKeyInterpolation {
  5834. /**
  5835. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5836. */
  5837. STEP = 1
  5838. }
  5839. }
  5840. declare module BABYLON {
  5841. /**
  5842. * Represents the range of an animation
  5843. */
  5844. export class AnimationRange {
  5845. /**The name of the animation range**/
  5846. name: string;
  5847. /**The starting frame of the animation */
  5848. from: number;
  5849. /**The ending frame of the animation*/
  5850. to: number;
  5851. /**
  5852. * Initializes the range of an animation
  5853. * @param name The name of the animation range
  5854. * @param from The starting frame of the animation
  5855. * @param to The ending frame of the animation
  5856. */
  5857. constructor(
  5858. /**The name of the animation range**/
  5859. name: string,
  5860. /**The starting frame of the animation */
  5861. from: number,
  5862. /**The ending frame of the animation*/
  5863. to: number);
  5864. /**
  5865. * Makes a copy of the animation range
  5866. * @returns A copy of the animation range
  5867. */
  5868. clone(): AnimationRange;
  5869. }
  5870. }
  5871. declare module BABYLON {
  5872. /**
  5873. * Composed of a frame, and an action function
  5874. */
  5875. export class AnimationEvent {
  5876. /** The frame for which the event is triggered **/
  5877. frame: number;
  5878. /** The event to perform when triggered **/
  5879. action: (currentFrame: number) => void;
  5880. /** Specifies if the event should be triggered only once**/
  5881. onlyOnce?: boolean | undefined;
  5882. /**
  5883. * Specifies if the animation event is done
  5884. */
  5885. isDone: boolean;
  5886. /**
  5887. * Initializes the animation event
  5888. * @param frame The frame for which the event is triggered
  5889. * @param action The event to perform when triggered
  5890. * @param onlyOnce Specifies if the event should be triggered only once
  5891. */
  5892. constructor(
  5893. /** The frame for which the event is triggered **/
  5894. frame: number,
  5895. /** The event to perform when triggered **/
  5896. action: (currentFrame: number) => void,
  5897. /** Specifies if the event should be triggered only once**/
  5898. onlyOnce?: boolean | undefined);
  5899. /** @hidden */
  5900. _clone(): AnimationEvent;
  5901. }
  5902. }
  5903. declare module BABYLON {
  5904. /**
  5905. * Interface used to define a behavior
  5906. */
  5907. export interface Behavior<T> {
  5908. /** gets or sets behavior's name */
  5909. name: string;
  5910. /**
  5911. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5912. */
  5913. init(): void;
  5914. /**
  5915. * Called when the behavior is attached to a target
  5916. * @param target defines the target where the behavior is attached to
  5917. */
  5918. attach(target: T): void;
  5919. /**
  5920. * Called when the behavior is detached from its target
  5921. */
  5922. detach(): void;
  5923. }
  5924. /**
  5925. * Interface implemented by classes supporting behaviors
  5926. */
  5927. export interface IBehaviorAware<T> {
  5928. /**
  5929. * Attach a behavior
  5930. * @param behavior defines the behavior to attach
  5931. * @returns the current host
  5932. */
  5933. addBehavior(behavior: Behavior<T>): T;
  5934. /**
  5935. * Remove a behavior from the current object
  5936. * @param behavior defines the behavior to detach
  5937. * @returns the current host
  5938. */
  5939. removeBehavior(behavior: Behavior<T>): T;
  5940. /**
  5941. * Gets a behavior using its name to search
  5942. * @param name defines the name to search
  5943. * @returns the behavior or null if not found
  5944. */
  5945. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * Defines an array and its length.
  5951. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5952. */
  5953. export interface ISmartArrayLike<T> {
  5954. /**
  5955. * The data of the array.
  5956. */
  5957. data: Array<T>;
  5958. /**
  5959. * The active length of the array.
  5960. */
  5961. length: number;
  5962. }
  5963. /**
  5964. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5965. */
  5966. export class SmartArray<T> implements ISmartArrayLike<T> {
  5967. /**
  5968. * The full set of data from the array.
  5969. */
  5970. data: Array<T>;
  5971. /**
  5972. * The active length of the array.
  5973. */
  5974. length: number;
  5975. protected _id: number;
  5976. /**
  5977. * Instantiates a Smart Array.
  5978. * @param capacity defines the default capacity of the array.
  5979. */
  5980. constructor(capacity: number);
  5981. /**
  5982. * Pushes a value at the end of the active data.
  5983. * @param value defines the object to push in the array.
  5984. */
  5985. push(value: T): void;
  5986. /**
  5987. * Iterates over the active data and apply the lambda to them.
  5988. * @param func defines the action to apply on each value.
  5989. */
  5990. forEach(func: (content: T) => void): void;
  5991. /**
  5992. * Sorts the full sets of data.
  5993. * @param compareFn defines the comparison function to apply.
  5994. */
  5995. sort(compareFn: (a: T, b: T) => number): void;
  5996. /**
  5997. * Resets the active data to an empty array.
  5998. */
  5999. reset(): void;
  6000. /**
  6001. * Releases all the data from the array as well as the array.
  6002. */
  6003. dispose(): void;
  6004. /**
  6005. * Concats the active data with a given array.
  6006. * @param array defines the data to concatenate with.
  6007. */
  6008. concat(array: any): void;
  6009. /**
  6010. * Returns the position of a value in the active data.
  6011. * @param value defines the value to find the index for
  6012. * @returns the index if found in the active data otherwise -1
  6013. */
  6014. indexOf(value: T): number;
  6015. /**
  6016. * Returns whether an element is part of the active data.
  6017. * @param value defines the value to look for
  6018. * @returns true if found in the active data otherwise false
  6019. */
  6020. contains(value: T): boolean;
  6021. private static _GlobalId;
  6022. }
  6023. /**
  6024. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6025. * The data in this array can only be present once
  6026. */
  6027. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6028. private _duplicateId;
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6032. * @param value defines the object to push in the array.
  6033. */
  6034. push(value: T): void;
  6035. /**
  6036. * Pushes a value at the end of the active data.
  6037. * If the data is already present, it won t be added again
  6038. * @param value defines the object to push in the array.
  6039. * @returns true if added false if it was already present
  6040. */
  6041. pushNoDuplicate(value: T): boolean;
  6042. /**
  6043. * Resets the active data to an empty array.
  6044. */
  6045. reset(): void;
  6046. /**
  6047. * Concats the active data with a given array.
  6048. * This ensures no dupplicate will be present in the result.
  6049. * @param array defines the data to concatenate with.
  6050. */
  6051. concatWithNoDuplicate(array: any): void;
  6052. }
  6053. }
  6054. declare module BABYLON {
  6055. /**
  6056. * @ignore
  6057. * This is a list of all the different input types that are available in the application.
  6058. * Fo instance: ArcRotateCameraGamepadInput...
  6059. */
  6060. export var CameraInputTypes: {};
  6061. /**
  6062. * This is the contract to implement in order to create a new input class.
  6063. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6064. */
  6065. export interface ICameraInput<TCamera extends Camera> {
  6066. /**
  6067. * Defines the camera the input is attached to.
  6068. */
  6069. camera: Nullable<TCamera>;
  6070. /**
  6071. * Gets the class name of the current intput.
  6072. * @returns the class name
  6073. */
  6074. getClassName(): string;
  6075. /**
  6076. * Get the friendly name associated with the input class.
  6077. * @returns the input friendly name
  6078. */
  6079. getSimpleName(): string;
  6080. /**
  6081. * Attach the input controls to a specific dom element to get the input from.
  6082. * @param element Defines the element the controls should be listened from
  6083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6084. */
  6085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6086. /**
  6087. * Detach the current controls from the specified dom element.
  6088. * @param element Defines the element to stop listening the inputs from
  6089. */
  6090. detachControl(element: Nullable<HTMLElement>): void;
  6091. /**
  6092. * Update the current camera state depending on the inputs that have been used this frame.
  6093. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6094. */
  6095. checkInputs?: () => void;
  6096. }
  6097. /**
  6098. * Represents a map of input types to input instance or input index to input instance.
  6099. */
  6100. export interface CameraInputsMap<TCamera extends Camera> {
  6101. /**
  6102. * Accessor to the input by input type.
  6103. */
  6104. [name: string]: ICameraInput<TCamera>;
  6105. /**
  6106. * Accessor to the input by input index.
  6107. */
  6108. [idx: number]: ICameraInput<TCamera>;
  6109. }
  6110. /**
  6111. * This represents the input manager used within a camera.
  6112. * It helps dealing with all the different kind of input attached to a camera.
  6113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6114. */
  6115. export class CameraInputsManager<TCamera extends Camera> {
  6116. /**
  6117. * Defines the list of inputs attahed to the camera.
  6118. */
  6119. attached: CameraInputsMap<TCamera>;
  6120. /**
  6121. * Defines the dom element the camera is collecting inputs from.
  6122. * This is null if the controls have not been attached.
  6123. */
  6124. attachedElement: Nullable<HTMLElement>;
  6125. /**
  6126. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6127. */
  6128. noPreventDefault: boolean;
  6129. /**
  6130. * Defined the camera the input manager belongs to.
  6131. */
  6132. camera: TCamera;
  6133. /**
  6134. * Update the current camera state depending on the inputs that have been used this frame.
  6135. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6136. */
  6137. checkInputs: () => void;
  6138. /**
  6139. * Instantiate a new Camera Input Manager.
  6140. * @param camera Defines the camera the input manager blongs to
  6141. */
  6142. constructor(camera: TCamera);
  6143. /**
  6144. * Add an input method to a camera
  6145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6146. * @param input camera input method
  6147. */
  6148. add(input: ICameraInput<TCamera>): void;
  6149. /**
  6150. * Remove a specific input method from a camera
  6151. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6152. * @param inputToRemove camera input method
  6153. */
  6154. remove(inputToRemove: ICameraInput<TCamera>): void;
  6155. /**
  6156. * Remove a specific input type from a camera
  6157. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6158. * @param inputType the type of the input to remove
  6159. */
  6160. removeByType(inputType: string): void;
  6161. private _addCheckInputs;
  6162. /**
  6163. * Attach the input controls to the currently attached dom element to listen the events from.
  6164. * @param input Defines the input to attach
  6165. */
  6166. attachInput(input: ICameraInput<TCamera>): void;
  6167. /**
  6168. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6169. * @param element Defines the dom element to collect the events from
  6170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6171. */
  6172. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6173. /**
  6174. * Detach the current manager inputs controls from a specific dom element.
  6175. * @param element Defines the dom element to collect the events from
  6176. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6177. */
  6178. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6179. /**
  6180. * Rebuild the dynamic inputCheck function from the current list of
  6181. * defined inputs in the manager.
  6182. */
  6183. rebuildInputCheck(): void;
  6184. /**
  6185. * Remove all attached input methods from a camera
  6186. */
  6187. clear(): void;
  6188. /**
  6189. * Serialize the current input manager attached to a camera.
  6190. * This ensures than once parsed,
  6191. * the input associated to the camera will be identical to the current ones
  6192. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6193. */
  6194. serialize(serializedCamera: any): void;
  6195. /**
  6196. * Parses an input manager serialized JSON to restore the previous list of inputs
  6197. * and states associated to a camera.
  6198. * @param parsedCamera Defines the JSON to parse
  6199. */
  6200. parse(parsedCamera: any): void;
  6201. }
  6202. }
  6203. declare module BABYLON {
  6204. /**
  6205. * Class used to store data that will be store in GPU memory
  6206. */
  6207. export class Buffer {
  6208. private _engine;
  6209. private _buffer;
  6210. /** @hidden */
  6211. _data: Nullable<DataArray>;
  6212. private _updatable;
  6213. private _instanced;
  6214. /**
  6215. * Gets the byte stride.
  6216. */
  6217. readonly byteStride: number;
  6218. /**
  6219. * Constructor
  6220. * @param engine the engine
  6221. * @param data the data to use for this buffer
  6222. * @param updatable whether the data is updatable
  6223. * @param stride the stride (optional)
  6224. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6225. * @param instanced whether the buffer is instanced (optional)
  6226. * @param useBytes set to true if the stride in in bytes (optional)
  6227. */
  6228. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6229. /**
  6230. * Create a new VertexBuffer based on the current buffer
  6231. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6232. * @param offset defines offset in the buffer (0 by default)
  6233. * @param size defines the size in floats of attributes (position is 3 for instance)
  6234. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6235. * @param instanced defines if the vertex buffer contains indexed data
  6236. * @param useBytes defines if the offset and stride are in bytes
  6237. * @returns the new vertex buffer
  6238. */
  6239. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6240. /**
  6241. * Gets a boolean indicating if the Buffer is updatable?
  6242. * @returns true if the buffer is updatable
  6243. */
  6244. isUpdatable(): boolean;
  6245. /**
  6246. * Gets current buffer's data
  6247. * @returns a DataArray or null
  6248. */
  6249. getData(): Nullable<DataArray>;
  6250. /**
  6251. * Gets underlying native buffer
  6252. * @returns underlying native buffer
  6253. */
  6254. getBuffer(): Nullable<DataBuffer>;
  6255. /**
  6256. * Gets the stride in float32 units (i.e. byte stride / 4).
  6257. * May not be an integer if the byte stride is not divisible by 4.
  6258. * DEPRECATED. Use byteStride instead.
  6259. * @returns the stride in float32 units
  6260. */
  6261. getStrideSize(): number;
  6262. /**
  6263. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6264. * @param data defines the data to store
  6265. */
  6266. create(data?: Nullable<DataArray>): void;
  6267. /** @hidden */
  6268. _rebuild(): void;
  6269. /**
  6270. * Update current buffer data
  6271. * @param data defines the data to store
  6272. */
  6273. update(data: DataArray): void;
  6274. /**
  6275. * Updates the data directly.
  6276. * @param data the new data
  6277. * @param offset the new offset
  6278. * @param vertexCount the vertex count (optional)
  6279. * @param useBytes set to true if the offset is in bytes
  6280. */
  6281. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6282. /**
  6283. * Release all resources
  6284. */
  6285. dispose(): void;
  6286. }
  6287. /**
  6288. * Specialized buffer used to store vertex data
  6289. */
  6290. export class VertexBuffer {
  6291. /** @hidden */
  6292. _buffer: Buffer;
  6293. private _kind;
  6294. private _size;
  6295. private _ownsBuffer;
  6296. private _instanced;
  6297. private _instanceDivisor;
  6298. /**
  6299. * The byte type.
  6300. */
  6301. static readonly BYTE: number;
  6302. /**
  6303. * The unsigned byte type.
  6304. */
  6305. static readonly UNSIGNED_BYTE: number;
  6306. /**
  6307. * The short type.
  6308. */
  6309. static readonly SHORT: number;
  6310. /**
  6311. * The unsigned short type.
  6312. */
  6313. static readonly UNSIGNED_SHORT: number;
  6314. /**
  6315. * The integer type.
  6316. */
  6317. static readonly INT: number;
  6318. /**
  6319. * The unsigned integer type.
  6320. */
  6321. static readonly UNSIGNED_INT: number;
  6322. /**
  6323. * The float type.
  6324. */
  6325. static readonly FLOAT: number;
  6326. /**
  6327. * Gets or sets the instance divisor when in instanced mode
  6328. */
  6329. instanceDivisor: number;
  6330. /**
  6331. * Gets the byte stride.
  6332. */
  6333. readonly byteStride: number;
  6334. /**
  6335. * Gets the byte offset.
  6336. */
  6337. readonly byteOffset: number;
  6338. /**
  6339. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6340. */
  6341. readonly normalized: boolean;
  6342. /**
  6343. * Gets the data type of each component in the array.
  6344. */
  6345. readonly type: number;
  6346. /**
  6347. * Constructor
  6348. * @param engine the engine
  6349. * @param data the data to use for this vertex buffer
  6350. * @param kind the vertex buffer kind
  6351. * @param updatable whether the data is updatable
  6352. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6353. * @param stride the stride (optional)
  6354. * @param instanced whether the buffer is instanced (optional)
  6355. * @param offset the offset of the data (optional)
  6356. * @param size the number of components (optional)
  6357. * @param type the type of the component (optional)
  6358. * @param normalized whether the data contains normalized data (optional)
  6359. * @param useBytes set to true if stride and offset are in bytes (optional)
  6360. */
  6361. 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);
  6362. /** @hidden */
  6363. _rebuild(): void;
  6364. /**
  6365. * Returns the kind of the VertexBuffer (string)
  6366. * @returns a string
  6367. */
  6368. getKind(): string;
  6369. /**
  6370. * Gets a boolean indicating if the VertexBuffer is updatable?
  6371. * @returns true if the buffer is updatable
  6372. */
  6373. isUpdatable(): boolean;
  6374. /**
  6375. * Gets current buffer's data
  6376. * @returns a DataArray or null
  6377. */
  6378. getData(): Nullable<DataArray>;
  6379. /**
  6380. * Gets underlying native buffer
  6381. * @returns underlying native buffer
  6382. */
  6383. getBuffer(): Nullable<DataBuffer>;
  6384. /**
  6385. * Gets the stride in float32 units (i.e. byte stride / 4).
  6386. * May not be an integer if the byte stride is not divisible by 4.
  6387. * DEPRECATED. Use byteStride instead.
  6388. * @returns the stride in float32 units
  6389. */
  6390. getStrideSize(): number;
  6391. /**
  6392. * Returns the offset as a multiple of the type byte length.
  6393. * DEPRECATED. Use byteOffset instead.
  6394. * @returns the offset in bytes
  6395. */
  6396. getOffset(): number;
  6397. /**
  6398. * Returns the number of components per vertex attribute (integer)
  6399. * @returns the size in float
  6400. */
  6401. getSize(): number;
  6402. /**
  6403. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6404. * @returns true if this buffer is instanced
  6405. */
  6406. getIsInstanced(): boolean;
  6407. /**
  6408. * Returns the instancing divisor, zero for non-instanced (integer).
  6409. * @returns a number
  6410. */
  6411. getInstanceDivisor(): number;
  6412. /**
  6413. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6414. * @param data defines the data to store
  6415. */
  6416. create(data?: DataArray): void;
  6417. /**
  6418. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6419. * This function will create a new buffer if the current one is not updatable
  6420. * @param data defines the data to store
  6421. */
  6422. update(data: DataArray): void;
  6423. /**
  6424. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6425. * Returns the directly updated WebGLBuffer.
  6426. * @param data the new data
  6427. * @param offset the new offset
  6428. * @param useBytes set to true if the offset is in bytes
  6429. */
  6430. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6431. /**
  6432. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6433. */
  6434. dispose(): void;
  6435. /**
  6436. * Enumerates each value of this vertex buffer as numbers.
  6437. * @param count the number of values to enumerate
  6438. * @param callback the callback function called for each value
  6439. */
  6440. forEach(count: number, callback: (value: number, index: number) => void): void;
  6441. /**
  6442. * Positions
  6443. */
  6444. static readonly PositionKind: string;
  6445. /**
  6446. * Normals
  6447. */
  6448. static readonly NormalKind: string;
  6449. /**
  6450. * Tangents
  6451. */
  6452. static readonly TangentKind: string;
  6453. /**
  6454. * Texture coordinates
  6455. */
  6456. static readonly UVKind: string;
  6457. /**
  6458. * Texture coordinates 2
  6459. */
  6460. static readonly UV2Kind: string;
  6461. /**
  6462. * Texture coordinates 3
  6463. */
  6464. static readonly UV3Kind: string;
  6465. /**
  6466. * Texture coordinates 4
  6467. */
  6468. static readonly UV4Kind: string;
  6469. /**
  6470. * Texture coordinates 5
  6471. */
  6472. static readonly UV5Kind: string;
  6473. /**
  6474. * Texture coordinates 6
  6475. */
  6476. static readonly UV6Kind: string;
  6477. /**
  6478. * Colors
  6479. */
  6480. static readonly ColorKind: string;
  6481. /**
  6482. * Matrix indices (for bones)
  6483. */
  6484. static readonly MatricesIndicesKind: string;
  6485. /**
  6486. * Matrix weights (for bones)
  6487. */
  6488. static readonly MatricesWeightsKind: string;
  6489. /**
  6490. * Additional matrix indices (for bones)
  6491. */
  6492. static readonly MatricesIndicesExtraKind: string;
  6493. /**
  6494. * Additional matrix weights (for bones)
  6495. */
  6496. static readonly MatricesWeightsExtraKind: string;
  6497. /**
  6498. * Deduces the stride given a kind.
  6499. * @param kind The kind string to deduce
  6500. * @returns The deduced stride
  6501. */
  6502. static DeduceStride(kind: string): number;
  6503. /**
  6504. * Gets the byte length of the given type.
  6505. * @param type the type
  6506. * @returns the number of bytes
  6507. */
  6508. static GetTypeByteLength(type: number): number;
  6509. /**
  6510. * Enumerates each value of the given parameters as numbers.
  6511. * @param data the data to enumerate
  6512. * @param byteOffset the byte offset of the data
  6513. * @param byteStride the byte stride of the data
  6514. * @param componentCount the number of components per element
  6515. * @param componentType the type of the component
  6516. * @param count the number of values to enumerate
  6517. * @param normalized whether the data is normalized
  6518. * @param callback the callback function called for each value
  6519. */
  6520. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6521. private static _GetFloatValue;
  6522. }
  6523. }
  6524. declare module BABYLON {
  6525. /**
  6526. * @hidden
  6527. */
  6528. export class IntersectionInfo {
  6529. bu: Nullable<number>;
  6530. bv: Nullable<number>;
  6531. distance: number;
  6532. faceId: number;
  6533. subMeshId: number;
  6534. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6535. }
  6536. }
  6537. declare module BABYLON {
  6538. /**
  6539. * Represens a plane by the equation ax + by + cz + d = 0
  6540. */
  6541. export class Plane {
  6542. private static _TmpMatrix;
  6543. /**
  6544. * Normal of the plane (a,b,c)
  6545. */
  6546. normal: Vector3;
  6547. /**
  6548. * d component of the plane
  6549. */
  6550. d: number;
  6551. /**
  6552. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6553. * @param a a component of the plane
  6554. * @param b b component of the plane
  6555. * @param c c component of the plane
  6556. * @param d d component of the plane
  6557. */
  6558. constructor(a: number, b: number, c: number, d: number);
  6559. /**
  6560. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6561. */
  6562. asArray(): number[];
  6563. /**
  6564. * @returns a new plane copied from the current Plane.
  6565. */
  6566. clone(): Plane;
  6567. /**
  6568. * @returns the string "Plane".
  6569. */
  6570. getClassName(): string;
  6571. /**
  6572. * @returns the Plane hash code.
  6573. */
  6574. getHashCode(): number;
  6575. /**
  6576. * Normalize the current Plane in place.
  6577. * @returns the updated Plane.
  6578. */
  6579. normalize(): Plane;
  6580. /**
  6581. * Applies a transformation the plane and returns the result
  6582. * @param transformation the transformation matrix to be applied to the plane
  6583. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6584. */
  6585. transform(transformation: DeepImmutable<Matrix>): Plane;
  6586. /**
  6587. * Calcualtte the dot product between the point and the plane normal
  6588. * @param point point to calculate the dot product with
  6589. * @returns the dot product (float) of the point coordinates and the plane normal.
  6590. */
  6591. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6592. /**
  6593. * Updates the current Plane from the plane defined by the three given points.
  6594. * @param point1 one of the points used to contruct the plane
  6595. * @param point2 one of the points used to contruct the plane
  6596. * @param point3 one of the points used to contruct the plane
  6597. * @returns the updated Plane.
  6598. */
  6599. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6600. /**
  6601. * Checks if the plane is facing a given direction
  6602. * @param direction the direction to check if the plane is facing
  6603. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6604. * @returns True is the vector "direction" is the same side than the plane normal.
  6605. */
  6606. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6607. /**
  6608. * Calculates the distance to a point
  6609. * @param point point to calculate distance to
  6610. * @returns the signed distance (float) from the given point to the Plane.
  6611. */
  6612. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6613. /**
  6614. * Creates a plane from an array
  6615. * @param array the array to create a plane from
  6616. * @returns a new Plane from the given array.
  6617. */
  6618. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6619. /**
  6620. * Creates a plane from three points
  6621. * @param point1 point used to create the plane
  6622. * @param point2 point used to create the plane
  6623. * @param point3 point used to create the plane
  6624. * @returns a new Plane defined by the three given points.
  6625. */
  6626. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6627. /**
  6628. * Creates a plane from an origin point and a normal
  6629. * @param origin origin of the plane to be constructed
  6630. * @param normal normal of the plane to be constructed
  6631. * @returns a new Plane the normal vector to this plane at the given origin point.
  6632. * Note : the vector "normal" is updated because normalized.
  6633. */
  6634. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6635. /**
  6636. * Calculates the distance from a plane and a point
  6637. * @param origin origin of the plane to be constructed
  6638. * @param normal normal of the plane to be constructed
  6639. * @param point point to calculate distance to
  6640. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6641. */
  6642. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6643. }
  6644. }
  6645. declare module BABYLON {
  6646. /**
  6647. * Class used to store bounding sphere information
  6648. */
  6649. export class BoundingSphere {
  6650. /**
  6651. * Gets the center of the bounding sphere in local space
  6652. */
  6653. readonly center: Vector3;
  6654. /**
  6655. * Radius of the bounding sphere in local space
  6656. */
  6657. radius: number;
  6658. /**
  6659. * Gets the center of the bounding sphere in world space
  6660. */
  6661. readonly centerWorld: Vector3;
  6662. /**
  6663. * Radius of the bounding sphere in world space
  6664. */
  6665. radiusWorld: number;
  6666. /**
  6667. * Gets the minimum vector in local space
  6668. */
  6669. readonly minimum: Vector3;
  6670. /**
  6671. * Gets the maximum vector in local space
  6672. */
  6673. readonly maximum: Vector3;
  6674. private _worldMatrix;
  6675. private static readonly TmpVector3;
  6676. /**
  6677. * Creates a new bounding sphere
  6678. * @param min defines the minimum vector (in local space)
  6679. * @param max defines the maximum vector (in local space)
  6680. * @param worldMatrix defines the new world matrix
  6681. */
  6682. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6683. /**
  6684. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6685. * @param min defines the new minimum vector (in local space)
  6686. * @param max defines the new maximum vector (in local space)
  6687. * @param worldMatrix defines the new world matrix
  6688. */
  6689. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6690. /**
  6691. * Scale the current bounding sphere by applying a scale factor
  6692. * @param factor defines the scale factor to apply
  6693. * @returns the current bounding box
  6694. */
  6695. scale(factor: number): BoundingSphere;
  6696. /**
  6697. * Gets the world matrix of the bounding box
  6698. * @returns a matrix
  6699. */
  6700. getWorldMatrix(): DeepImmutable<Matrix>;
  6701. /** @hidden */
  6702. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6703. /**
  6704. * Tests if the bounding sphere is intersecting the frustum planes
  6705. * @param frustumPlanes defines the frustum planes to test
  6706. * @returns true if there is an intersection
  6707. */
  6708. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6709. /**
  6710. * Tests if the bounding sphere center is in between the frustum planes.
  6711. * Used for optimistic fast inclusion.
  6712. * @param frustumPlanes defines the frustum planes to test
  6713. * @returns true if the sphere center is in between the frustum planes
  6714. */
  6715. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6716. /**
  6717. * Tests if a point is inside the bounding sphere
  6718. * @param point defines the point to test
  6719. * @returns true if the point is inside the bounding sphere
  6720. */
  6721. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6722. /**
  6723. * Checks if two sphere intersct
  6724. * @param sphere0 sphere 0
  6725. * @param sphere1 sphere 1
  6726. * @returns true if the speres intersect
  6727. */
  6728. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6729. }
  6730. }
  6731. declare module BABYLON {
  6732. /**
  6733. * Class used to store bounding box information
  6734. */
  6735. export class BoundingBox implements ICullable {
  6736. /**
  6737. * Gets the 8 vectors representing the bounding box in local space
  6738. */
  6739. readonly vectors: Vector3[];
  6740. /**
  6741. * Gets the center of the bounding box in local space
  6742. */
  6743. readonly center: Vector3;
  6744. /**
  6745. * Gets the center of the bounding box in world space
  6746. */
  6747. readonly centerWorld: Vector3;
  6748. /**
  6749. * Gets the extend size in local space
  6750. */
  6751. readonly extendSize: Vector3;
  6752. /**
  6753. * Gets the extend size in world space
  6754. */
  6755. readonly extendSizeWorld: Vector3;
  6756. /**
  6757. * Gets the OBB (object bounding box) directions
  6758. */
  6759. readonly directions: Vector3[];
  6760. /**
  6761. * Gets the 8 vectors representing the bounding box in world space
  6762. */
  6763. readonly vectorsWorld: Vector3[];
  6764. /**
  6765. * Gets the minimum vector in world space
  6766. */
  6767. readonly minimumWorld: Vector3;
  6768. /**
  6769. * Gets the maximum vector in world space
  6770. */
  6771. readonly maximumWorld: Vector3;
  6772. /**
  6773. * Gets the minimum vector in local space
  6774. */
  6775. readonly minimum: Vector3;
  6776. /**
  6777. * Gets the maximum vector in local space
  6778. */
  6779. readonly maximum: Vector3;
  6780. private _worldMatrix;
  6781. private static readonly TmpVector3;
  6782. /**
  6783. * @hidden
  6784. */
  6785. _tag: number;
  6786. /**
  6787. * Creates a new bounding box
  6788. * @param min defines the minimum vector (in local space)
  6789. * @param max defines the maximum vector (in local space)
  6790. * @param worldMatrix defines the new world matrix
  6791. */
  6792. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6793. /**
  6794. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6795. * @param min defines the new minimum vector (in local space)
  6796. * @param max defines the new maximum vector (in local space)
  6797. * @param worldMatrix defines the new world matrix
  6798. */
  6799. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6800. /**
  6801. * Scale the current bounding box by applying a scale factor
  6802. * @param factor defines the scale factor to apply
  6803. * @returns the current bounding box
  6804. */
  6805. scale(factor: number): BoundingBox;
  6806. /**
  6807. * Gets the world matrix of the bounding box
  6808. * @returns a matrix
  6809. */
  6810. getWorldMatrix(): DeepImmutable<Matrix>;
  6811. /** @hidden */
  6812. _update(world: DeepImmutable<Matrix>): void;
  6813. /**
  6814. * Tests if the bounding box is intersecting the frustum planes
  6815. * @param frustumPlanes defines the frustum planes to test
  6816. * @returns true if there is an intersection
  6817. */
  6818. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6819. /**
  6820. * Tests if the bounding box is entirely inside the frustum planes
  6821. * @param frustumPlanes defines the frustum planes to test
  6822. * @returns true if there is an inclusion
  6823. */
  6824. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6825. /**
  6826. * Tests if a point is inside the bounding box
  6827. * @param point defines the point to test
  6828. * @returns true if the point is inside the bounding box
  6829. */
  6830. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6831. /**
  6832. * Tests if the bounding box intersects with a bounding sphere
  6833. * @param sphere defines the sphere to test
  6834. * @returns true if there is an intersection
  6835. */
  6836. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6837. /**
  6838. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6839. * @param min defines the min vector to use
  6840. * @param max defines the max vector to use
  6841. * @returns true if there is an intersection
  6842. */
  6843. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6844. /**
  6845. * Tests if two bounding boxes are intersections
  6846. * @param box0 defines the first box to test
  6847. * @param box1 defines the second box to test
  6848. * @returns true if there is an intersection
  6849. */
  6850. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6851. /**
  6852. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6853. * @param minPoint defines the minimum vector of the bounding box
  6854. * @param maxPoint defines the maximum vector of the bounding box
  6855. * @param sphereCenter defines the sphere center
  6856. * @param sphereRadius defines the sphere radius
  6857. * @returns true if there is an intersection
  6858. */
  6859. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6860. /**
  6861. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6862. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6863. * @param frustumPlanes defines the frustum planes to test
  6864. * @return true if there is an inclusion
  6865. */
  6866. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6867. /**
  6868. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6869. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6870. * @param frustumPlanes defines the frustum planes to test
  6871. * @return true if there is an intersection
  6872. */
  6873. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6874. }
  6875. }
  6876. declare module BABYLON {
  6877. /** @hidden */
  6878. export class Collider {
  6879. /** Define if a collision was found */
  6880. collisionFound: boolean;
  6881. /**
  6882. * Define last intersection point in local space
  6883. */
  6884. intersectionPoint: Vector3;
  6885. /**
  6886. * Define last collided mesh
  6887. */
  6888. collidedMesh: Nullable<AbstractMesh>;
  6889. private _collisionPoint;
  6890. private _planeIntersectionPoint;
  6891. private _tempVector;
  6892. private _tempVector2;
  6893. private _tempVector3;
  6894. private _tempVector4;
  6895. private _edge;
  6896. private _baseToVertex;
  6897. private _destinationPoint;
  6898. private _slidePlaneNormal;
  6899. private _displacementVector;
  6900. /** @hidden */
  6901. _radius: Vector3;
  6902. /** @hidden */
  6903. _retry: number;
  6904. private _velocity;
  6905. private _basePoint;
  6906. private _epsilon;
  6907. /** @hidden */
  6908. _velocityWorldLength: number;
  6909. /** @hidden */
  6910. _basePointWorld: Vector3;
  6911. private _velocityWorld;
  6912. private _normalizedVelocity;
  6913. /** @hidden */
  6914. _initialVelocity: Vector3;
  6915. /** @hidden */
  6916. _initialPosition: Vector3;
  6917. private _nearestDistance;
  6918. private _collisionMask;
  6919. collisionMask: number;
  6920. /**
  6921. * Gets the plane normal used to compute the sliding response (in local space)
  6922. */
  6923. readonly slidePlaneNormal: Vector3;
  6924. /** @hidden */
  6925. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6926. /** @hidden */
  6927. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6928. /** @hidden */
  6929. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6930. /** @hidden */
  6931. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6932. /** @hidden */
  6933. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6934. /** @hidden */
  6935. _getResponse(pos: Vector3, vel: Vector3): void;
  6936. }
  6937. }
  6938. declare module BABYLON {
  6939. /**
  6940. * Interface for cullable objects
  6941. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6942. */
  6943. export interface ICullable {
  6944. /**
  6945. * Checks if the object or part of the object is in the frustum
  6946. * @param frustumPlanes Camera near/planes
  6947. * @returns true if the object is in frustum otherwise false
  6948. */
  6949. isInFrustum(frustumPlanes: Plane[]): boolean;
  6950. /**
  6951. * Checks if a cullable object (mesh...) is in the camera frustum
  6952. * Unlike isInFrustum this cheks the full bounding box
  6953. * @param frustumPlanes Camera near/planes
  6954. * @returns true if the object is in frustum otherwise false
  6955. */
  6956. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6957. }
  6958. /**
  6959. * Info for a bounding data of a mesh
  6960. */
  6961. export class BoundingInfo implements ICullable {
  6962. /**
  6963. * Bounding box for the mesh
  6964. */
  6965. readonly boundingBox: BoundingBox;
  6966. /**
  6967. * Bounding sphere for the mesh
  6968. */
  6969. readonly boundingSphere: BoundingSphere;
  6970. private _isLocked;
  6971. private static readonly TmpVector3;
  6972. /**
  6973. * Constructs bounding info
  6974. * @param minimum min vector of the bounding box/sphere
  6975. * @param maximum max vector of the bounding box/sphere
  6976. * @param worldMatrix defines the new world matrix
  6977. */
  6978. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6979. /**
  6980. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6981. * @param min defines the new minimum vector (in local space)
  6982. * @param max defines the new maximum vector (in local space)
  6983. * @param worldMatrix defines the new world matrix
  6984. */
  6985. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6986. /**
  6987. * min vector of the bounding box/sphere
  6988. */
  6989. readonly minimum: Vector3;
  6990. /**
  6991. * max vector of the bounding box/sphere
  6992. */
  6993. readonly maximum: Vector3;
  6994. /**
  6995. * If the info is locked and won't be updated to avoid perf overhead
  6996. */
  6997. isLocked: boolean;
  6998. /**
  6999. * Updates the bounding sphere and box
  7000. * @param world world matrix to be used to update
  7001. */
  7002. update(world: DeepImmutable<Matrix>): void;
  7003. /**
  7004. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7005. * @param center New center of the bounding info
  7006. * @param extend New extend of the bounding info
  7007. * @returns the current bounding info
  7008. */
  7009. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7010. /**
  7011. * Scale the current bounding info by applying a scale factor
  7012. * @param factor defines the scale factor to apply
  7013. * @returns the current bounding info
  7014. */
  7015. scale(factor: number): BoundingInfo;
  7016. /**
  7017. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7018. * @param frustumPlanes defines the frustum to test
  7019. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7020. * @returns true if the bounding info is in the frustum planes
  7021. */
  7022. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7023. /**
  7024. * Gets the world distance between the min and max points of the bounding box
  7025. */
  7026. readonly diagonalLength: number;
  7027. /**
  7028. * Checks if a cullable object (mesh...) is in the camera frustum
  7029. * Unlike isInFrustum this cheks the full bounding box
  7030. * @param frustumPlanes Camera near/planes
  7031. * @returns true if the object is in frustum otherwise false
  7032. */
  7033. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7034. /** @hidden */
  7035. _checkCollision(collider: Collider): boolean;
  7036. /**
  7037. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7038. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7039. * @param point the point to check intersection with
  7040. * @returns if the point intersects
  7041. */
  7042. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7043. /**
  7044. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7045. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7046. * @param boundingInfo the bounding info to check intersection with
  7047. * @param precise if the intersection should be done using OBB
  7048. * @returns if the bounding info intersects
  7049. */
  7050. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7051. }
  7052. }
  7053. declare module BABYLON {
  7054. /**
  7055. * Extracts minimum and maximum values from a list of indexed positions
  7056. * @param positions defines the positions to use
  7057. * @param indices defines the indices to the positions
  7058. * @param indexStart defines the start index
  7059. * @param indexCount defines the end index
  7060. * @param bias defines bias value to add to the result
  7061. * @return minimum and maximum values
  7062. */
  7063. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7064. minimum: Vector3;
  7065. maximum: Vector3;
  7066. };
  7067. /**
  7068. * Extracts minimum and maximum values from a list of positions
  7069. * @param positions defines the positions to use
  7070. * @param start defines the start index in the positions array
  7071. * @param count defines the number of positions to handle
  7072. * @param bias defines bias value to add to the result
  7073. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7074. * @return minimum and maximum values
  7075. */
  7076. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7077. minimum: Vector3;
  7078. maximum: Vector3;
  7079. };
  7080. }
  7081. declare module BABYLON {
  7082. /** @hidden */
  7083. export class WebGLDataBuffer extends DataBuffer {
  7084. private _buffer;
  7085. constructor(resource: WebGLBuffer);
  7086. readonly underlyingResource: any;
  7087. }
  7088. }
  7089. declare module BABYLON {
  7090. /** @hidden */
  7091. export class WebGLPipelineContext implements IPipelineContext {
  7092. engine: ThinEngine;
  7093. program: Nullable<WebGLProgram>;
  7094. context?: WebGLRenderingContext;
  7095. vertexShader?: WebGLShader;
  7096. fragmentShader?: WebGLShader;
  7097. isParallelCompiled: boolean;
  7098. onCompiled?: () => void;
  7099. transformFeedback?: WebGLTransformFeedback | null;
  7100. readonly isAsync: boolean;
  7101. readonly isReady: boolean;
  7102. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7103. }
  7104. }
  7105. declare module BABYLON {
  7106. interface ThinEngine {
  7107. /**
  7108. * Create an uniform buffer
  7109. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7110. * @param elements defines the content of the uniform buffer
  7111. * @returns the webGL uniform buffer
  7112. */
  7113. createUniformBuffer(elements: FloatArray): DataBuffer;
  7114. /**
  7115. * Create a dynamic uniform buffer
  7116. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7117. * @param elements defines the content of the uniform buffer
  7118. * @returns the webGL uniform buffer
  7119. */
  7120. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7121. /**
  7122. * Update an existing uniform buffer
  7123. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7124. * @param uniformBuffer defines the target uniform buffer
  7125. * @param elements defines the content to update
  7126. * @param offset defines the offset in the uniform buffer where update should start
  7127. * @param count defines the size of the data to update
  7128. */
  7129. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7130. /**
  7131. * Bind an uniform buffer to the current webGL context
  7132. * @param buffer defines the buffer to bind
  7133. */
  7134. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7135. /**
  7136. * Bind a buffer to the current webGL context at a given location
  7137. * @param buffer defines the buffer to bind
  7138. * @param location defines the index where to bind the buffer
  7139. */
  7140. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7141. /**
  7142. * Bind a specific block at a given index in a specific shader program
  7143. * @param pipelineContext defines the pipeline context to use
  7144. * @param blockName defines the block name
  7145. * @param index defines the index where to bind the block
  7146. */
  7147. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7148. }
  7149. }
  7150. declare module BABYLON {
  7151. /**
  7152. * Uniform buffer objects.
  7153. *
  7154. * Handles blocks of uniform on the GPU.
  7155. *
  7156. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7157. *
  7158. * For more information, please refer to :
  7159. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7160. */
  7161. export class UniformBuffer {
  7162. private _engine;
  7163. private _buffer;
  7164. private _data;
  7165. private _bufferData;
  7166. private _dynamic?;
  7167. private _uniformLocations;
  7168. private _uniformSizes;
  7169. private _uniformLocationPointer;
  7170. private _needSync;
  7171. private _noUBO;
  7172. private _currentEffect;
  7173. private static _MAX_UNIFORM_SIZE;
  7174. private static _tempBuffer;
  7175. /**
  7176. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7177. * This is dynamic to allow compat with webgl 1 and 2.
  7178. * You will need to pass the name of the uniform as well as the value.
  7179. */
  7180. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7181. /**
  7182. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7183. * This is dynamic to allow compat with webgl 1 and 2.
  7184. * You will need to pass the name of the uniform as well as the value.
  7185. */
  7186. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7187. /**
  7188. * Lambda to Update a single float in a uniform buffer.
  7189. * This is dynamic to allow compat with webgl 1 and 2.
  7190. * You will need to pass the name of the uniform as well as the value.
  7191. */
  7192. updateFloat: (name: string, x: number) => void;
  7193. /**
  7194. * Lambda to Update a vec2 of float in a uniform buffer.
  7195. * This is dynamic to allow compat with webgl 1 and 2.
  7196. * You will need to pass the name of the uniform as well as the value.
  7197. */
  7198. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7199. /**
  7200. * Lambda to Update a vec3 of float in a uniform buffer.
  7201. * This is dynamic to allow compat with webgl 1 and 2.
  7202. * You will need to pass the name of the uniform as well as the value.
  7203. */
  7204. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7205. /**
  7206. * Lambda to Update a vec4 of float in a uniform buffer.
  7207. * This is dynamic to allow compat with webgl 1 and 2.
  7208. * You will need to pass the name of the uniform as well as the value.
  7209. */
  7210. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7211. /**
  7212. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7213. * This is dynamic to allow compat with webgl 1 and 2.
  7214. * You will need to pass the name of the uniform as well as the value.
  7215. */
  7216. updateMatrix: (name: string, mat: Matrix) => void;
  7217. /**
  7218. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7219. * This is dynamic to allow compat with webgl 1 and 2.
  7220. * You will need to pass the name of the uniform as well as the value.
  7221. */
  7222. updateVector3: (name: string, vector: Vector3) => void;
  7223. /**
  7224. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7225. * This is dynamic to allow compat with webgl 1 and 2.
  7226. * You will need to pass the name of the uniform as well as the value.
  7227. */
  7228. updateVector4: (name: string, vector: Vector4) => void;
  7229. /**
  7230. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7231. * This is dynamic to allow compat with webgl 1 and 2.
  7232. * You will need to pass the name of the uniform as well as the value.
  7233. */
  7234. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7235. /**
  7236. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7237. * This is dynamic to allow compat with webgl 1 and 2.
  7238. * You will need to pass the name of the uniform as well as the value.
  7239. */
  7240. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7241. /**
  7242. * Instantiates a new Uniform buffer objects.
  7243. *
  7244. * Handles blocks of uniform on the GPU.
  7245. *
  7246. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7247. *
  7248. * For more information, please refer to :
  7249. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7250. * @param engine Define the engine the buffer is associated with
  7251. * @param data Define the data contained in the buffer
  7252. * @param dynamic Define if the buffer is updatable
  7253. */
  7254. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7255. /**
  7256. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7257. * or just falling back on setUniformXXX calls.
  7258. */
  7259. readonly useUbo: boolean;
  7260. /**
  7261. * Indicates if the WebGL underlying uniform buffer is in sync
  7262. * with the javascript cache data.
  7263. */
  7264. readonly isSync: boolean;
  7265. /**
  7266. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7267. * Also, a dynamic UniformBuffer will disable cache verification and always
  7268. * update the underlying WebGL uniform buffer to the GPU.
  7269. * @returns if Dynamic, otherwise false
  7270. */
  7271. isDynamic(): boolean;
  7272. /**
  7273. * The data cache on JS side.
  7274. * @returns the underlying data as a float array
  7275. */
  7276. getData(): Float32Array;
  7277. /**
  7278. * The underlying WebGL Uniform buffer.
  7279. * @returns the webgl buffer
  7280. */
  7281. getBuffer(): Nullable<DataBuffer>;
  7282. /**
  7283. * std140 layout specifies how to align data within an UBO structure.
  7284. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7285. * for specs.
  7286. */
  7287. private _fillAlignment;
  7288. /**
  7289. * Adds an uniform in the buffer.
  7290. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7291. * for the layout to be correct !
  7292. * @param name Name of the uniform, as used in the uniform block in the shader.
  7293. * @param size Data size, or data directly.
  7294. */
  7295. addUniform(name: string, size: number | number[]): void;
  7296. /**
  7297. * Adds a Matrix 4x4 to the uniform buffer.
  7298. * @param name Name of the uniform, as used in the uniform block in the shader.
  7299. * @param mat A 4x4 matrix.
  7300. */
  7301. addMatrix(name: string, mat: Matrix): void;
  7302. /**
  7303. * Adds a vec2 to the uniform buffer.
  7304. * @param name Name of the uniform, as used in the uniform block in the shader.
  7305. * @param x Define the x component value of the vec2
  7306. * @param y Define the y component value of the vec2
  7307. */
  7308. addFloat2(name: string, x: number, y: number): void;
  7309. /**
  7310. * Adds a vec3 to the uniform buffer.
  7311. * @param name Name of the uniform, as used in the uniform block in the shader.
  7312. * @param x Define the x component value of the vec3
  7313. * @param y Define the y component value of the vec3
  7314. * @param z Define the z component value of the vec3
  7315. */
  7316. addFloat3(name: string, x: number, y: number, z: number): void;
  7317. /**
  7318. * Adds a vec3 to the uniform buffer.
  7319. * @param name Name of the uniform, as used in the uniform block in the shader.
  7320. * @param color Define the vec3 from a Color
  7321. */
  7322. addColor3(name: string, color: Color3): void;
  7323. /**
  7324. * Adds a vec4 to the uniform buffer.
  7325. * @param name Name of the uniform, as used in the uniform block in the shader.
  7326. * @param color Define the rgb components from a Color
  7327. * @param alpha Define the a component of the vec4
  7328. */
  7329. addColor4(name: string, color: Color3, alpha: number): void;
  7330. /**
  7331. * Adds a vec3 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. * @param vector Define the vec3 components from a Vector
  7334. */
  7335. addVector3(name: string, vector: Vector3): void;
  7336. /**
  7337. * Adds a Matrix 3x3 to the uniform buffer.
  7338. * @param name Name of the uniform, as used in the uniform block in the shader.
  7339. */
  7340. addMatrix3x3(name: string): void;
  7341. /**
  7342. * Adds a Matrix 2x2 to the uniform buffer.
  7343. * @param name Name of the uniform, as used in the uniform block in the shader.
  7344. */
  7345. addMatrix2x2(name: string): void;
  7346. /**
  7347. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7348. */
  7349. create(): void;
  7350. /** @hidden */
  7351. _rebuild(): void;
  7352. /**
  7353. * Updates the WebGL Uniform Buffer on the GPU.
  7354. * If the `dynamic` flag is set to true, no cache comparison is done.
  7355. * Otherwise, the buffer will be updated only if the cache differs.
  7356. */
  7357. update(): void;
  7358. /**
  7359. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7360. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7361. * @param data Define the flattened data
  7362. * @param size Define the size of the data.
  7363. */
  7364. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7365. private _valueCache;
  7366. private _cacheMatrix;
  7367. private _updateMatrix3x3ForUniform;
  7368. private _updateMatrix3x3ForEffect;
  7369. private _updateMatrix2x2ForEffect;
  7370. private _updateMatrix2x2ForUniform;
  7371. private _updateFloatForEffect;
  7372. private _updateFloatForUniform;
  7373. private _updateFloat2ForEffect;
  7374. private _updateFloat2ForUniform;
  7375. private _updateFloat3ForEffect;
  7376. private _updateFloat3ForUniform;
  7377. private _updateFloat4ForEffect;
  7378. private _updateFloat4ForUniform;
  7379. private _updateMatrixForEffect;
  7380. private _updateMatrixForUniform;
  7381. private _updateVector3ForEffect;
  7382. private _updateVector3ForUniform;
  7383. private _updateVector4ForEffect;
  7384. private _updateVector4ForUniform;
  7385. private _updateColor3ForEffect;
  7386. private _updateColor3ForUniform;
  7387. private _updateColor4ForEffect;
  7388. private _updateColor4ForUniform;
  7389. /**
  7390. * Sets a sampler uniform on the effect.
  7391. * @param name Define the name of the sampler.
  7392. * @param texture Define the texture to set in the sampler
  7393. */
  7394. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7395. /**
  7396. * Directly updates the value of the uniform in the cache AND on the GPU.
  7397. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7398. * @param data Define the flattened data
  7399. */
  7400. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7401. /**
  7402. * Binds this uniform buffer to an effect.
  7403. * @param effect Define the effect to bind the buffer to
  7404. * @param name Name of the uniform block in the shader.
  7405. */
  7406. bindToEffect(effect: Effect, name: string): void;
  7407. /**
  7408. * Disposes the uniform buffer.
  7409. */
  7410. dispose(): void;
  7411. }
  7412. }
  7413. declare module BABYLON {
  7414. /**
  7415. * Enum that determines the text-wrapping mode to use.
  7416. */
  7417. export enum InspectableType {
  7418. /**
  7419. * Checkbox for booleans
  7420. */
  7421. Checkbox = 0,
  7422. /**
  7423. * Sliders for numbers
  7424. */
  7425. Slider = 1,
  7426. /**
  7427. * Vector3
  7428. */
  7429. Vector3 = 2,
  7430. /**
  7431. * Quaternions
  7432. */
  7433. Quaternion = 3,
  7434. /**
  7435. * Color3
  7436. */
  7437. Color3 = 4,
  7438. /**
  7439. * String
  7440. */
  7441. String = 5
  7442. }
  7443. /**
  7444. * Interface used to define custom inspectable properties.
  7445. * This interface is used by the inspector to display custom property grids
  7446. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7447. */
  7448. export interface IInspectable {
  7449. /**
  7450. * Gets the label to display
  7451. */
  7452. label: string;
  7453. /**
  7454. * Gets the name of the property to edit
  7455. */
  7456. propertyName: string;
  7457. /**
  7458. * Gets the type of the editor to use
  7459. */
  7460. type: InspectableType;
  7461. /**
  7462. * Gets the minimum value of the property when using in "slider" mode
  7463. */
  7464. min?: number;
  7465. /**
  7466. * Gets the maximum value of the property when using in "slider" mode
  7467. */
  7468. max?: number;
  7469. /**
  7470. * Gets the setp to use when using in "slider" mode
  7471. */
  7472. step?: number;
  7473. }
  7474. }
  7475. declare module BABYLON {
  7476. /**
  7477. * Class used to provide helper for timing
  7478. */
  7479. export class TimingTools {
  7480. /**
  7481. * Polyfill for setImmediate
  7482. * @param action defines the action to execute after the current execution block
  7483. */
  7484. static SetImmediate(action: () => void): void;
  7485. }
  7486. }
  7487. declare module BABYLON {
  7488. /**
  7489. * Class used to enable instatition of objects by class name
  7490. */
  7491. export class InstantiationTools {
  7492. /**
  7493. * Use this object to register external classes like custom textures or material
  7494. * to allow the laoders to instantiate them
  7495. */
  7496. static RegisteredExternalClasses: {
  7497. [key: string]: Object;
  7498. };
  7499. /**
  7500. * Tries to instantiate a new object from a given class name
  7501. * @param className defines the class name to instantiate
  7502. * @returns the new object or null if the system was not able to do the instantiation
  7503. */
  7504. static Instantiate(className: string): any;
  7505. }
  7506. }
  7507. declare module BABYLON {
  7508. /**
  7509. * Define options used to create a depth texture
  7510. */
  7511. export class DepthTextureCreationOptions {
  7512. /** Specifies whether or not a stencil should be allocated in the texture */
  7513. generateStencil?: boolean;
  7514. /** Specifies whether or not bilinear filtering is enable on the texture */
  7515. bilinearFiltering?: boolean;
  7516. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7517. comparisonFunction?: number;
  7518. /** Specifies if the created texture is a cube texture */
  7519. isCube?: boolean;
  7520. }
  7521. }
  7522. declare module BABYLON {
  7523. interface ThinEngine {
  7524. /**
  7525. * Creates a depth stencil cube texture.
  7526. * This is only available in WebGL 2.
  7527. * @param size The size of face edge in the cube texture.
  7528. * @param options The options defining the cube texture.
  7529. * @returns The cube texture
  7530. */
  7531. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7532. /**
  7533. * Creates a cube texture
  7534. * @param rootUrl defines the url where the files to load is located
  7535. * @param scene defines the current scene
  7536. * @param files defines the list of files to load (1 per face)
  7537. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7538. * @param onLoad defines an optional callback raised when the texture is loaded
  7539. * @param onError defines an optional callback raised if there is an issue to load the texture
  7540. * @param format defines the format of the data
  7541. * @param forcedExtension defines the extension to use to pick the right loader
  7542. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7543. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7544. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7545. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7546. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7547. * @returns the cube texture as an InternalTexture
  7548. */
  7549. 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;
  7550. /**
  7551. * Creates a cube texture
  7552. * @param rootUrl defines the url where the files to load is located
  7553. * @param scene defines the current scene
  7554. * @param files defines the list of files to load (1 per face)
  7555. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7556. * @param onLoad defines an optional callback raised when the texture is loaded
  7557. * @param onError defines an optional callback raised if there is an issue to load the texture
  7558. * @param format defines the format of the data
  7559. * @param forcedExtension defines the extension to use to pick the right loader
  7560. * @returns the cube texture as an InternalTexture
  7561. */
  7562. 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;
  7563. /**
  7564. * Creates a cube texture
  7565. * @param rootUrl defines the url where the files to load is located
  7566. * @param scene defines the current scene
  7567. * @param files defines the list of files to load (1 per face)
  7568. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7569. * @param onLoad defines an optional callback raised when the texture is loaded
  7570. * @param onError defines an optional callback raised if there is an issue to load the texture
  7571. * @param format defines the format of the data
  7572. * @param forcedExtension defines the extension to use to pick the right loader
  7573. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7574. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7575. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7576. * @returns the cube texture as an InternalTexture
  7577. */
  7578. 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;
  7579. /** @hidden */
  7580. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7581. /** @hidden */
  7582. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7583. /** @hidden */
  7584. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7585. /** @hidden */
  7586. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7587. }
  7588. }
  7589. declare module BABYLON {
  7590. /**
  7591. * Class for creating a cube texture
  7592. */
  7593. export class CubeTexture extends BaseTexture {
  7594. private _delayedOnLoad;
  7595. /**
  7596. * The url of the texture
  7597. */
  7598. url: string;
  7599. /**
  7600. * Gets or sets the center of the bounding box associated with the cube texture.
  7601. * It must define where the camera used to render the texture was set
  7602. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7603. */
  7604. boundingBoxPosition: Vector3;
  7605. private _boundingBoxSize;
  7606. /**
  7607. * Gets or sets the size of the bounding box associated with the cube texture
  7608. * When defined, the cubemap will switch to local mode
  7609. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7610. * @example https://www.babylonjs-playground.com/#RNASML
  7611. */
  7612. /**
  7613. * Returns the bounding box size
  7614. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7615. */
  7616. boundingBoxSize: Vector3;
  7617. protected _rotationY: number;
  7618. /**
  7619. * Sets texture matrix rotation angle around Y axis in radians.
  7620. */
  7621. /**
  7622. * Gets texture matrix rotation angle around Y axis radians.
  7623. */
  7624. rotationY: number;
  7625. /**
  7626. * Are mip maps generated for this texture or not.
  7627. */
  7628. readonly noMipmap: boolean;
  7629. private _noMipmap;
  7630. private _files;
  7631. protected _forcedExtension: Nullable<string>;
  7632. private _extensions;
  7633. private _textureMatrix;
  7634. private _format;
  7635. private _createPolynomials;
  7636. /** @hidden */
  7637. _prefiltered: boolean;
  7638. /**
  7639. * Creates a cube texture from an array of image urls
  7640. * @param files defines an array of image urls
  7641. * @param scene defines the hosting scene
  7642. * @param noMipmap specifies if mip maps are not used
  7643. * @returns a cube texture
  7644. */
  7645. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7646. /**
  7647. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7648. * @param url defines the url of the prefiltered texture
  7649. * @param scene defines the scene the texture is attached to
  7650. * @param forcedExtension defines the extension of the file if different from the url
  7651. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7652. * @return the prefiltered texture
  7653. */
  7654. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7655. /**
  7656. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7657. * as prefiltered data.
  7658. * @param rootUrl defines the url of the texture or the root name of the six images
  7659. * @param scene defines the scene the texture is attached to
  7660. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7661. * @param noMipmap defines if mipmaps should be created or not
  7662. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7663. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7664. * @param onError defines a callback triggered in case of error during load
  7665. * @param format defines the internal format to use for the texture once loaded
  7666. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7667. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7668. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7669. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7670. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7671. * @return the cube texture
  7672. */
  7673. 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);
  7674. /**
  7675. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7676. */
  7677. readonly isPrefiltered: boolean;
  7678. /**
  7679. * Get the current class name of the texture useful for serialization or dynamic coding.
  7680. * @returns "CubeTexture"
  7681. */
  7682. getClassName(): string;
  7683. /**
  7684. * Update the url (and optional buffer) of this texture if url was null during construction.
  7685. * @param url the url of the texture
  7686. * @param forcedExtension defines the extension to use
  7687. * @param onLoad callback called when the texture is loaded (defaults to null)
  7688. */
  7689. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7690. /**
  7691. * Delays loading of the cube texture
  7692. * @param forcedExtension defines the extension to use
  7693. */
  7694. delayLoad(forcedExtension?: string): void;
  7695. /**
  7696. * Returns the reflection texture matrix
  7697. * @returns the reflection texture matrix
  7698. */
  7699. getReflectionTextureMatrix(): Matrix;
  7700. /**
  7701. * Sets the reflection texture matrix
  7702. * @param value Reflection texture matrix
  7703. */
  7704. setReflectionTextureMatrix(value: Matrix): void;
  7705. /**
  7706. * Parses text to create a cube texture
  7707. * @param parsedTexture define the serialized text to read from
  7708. * @param scene defines the hosting scene
  7709. * @param rootUrl defines the root url of the cube texture
  7710. * @returns a cube texture
  7711. */
  7712. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7713. /**
  7714. * Makes a clone, or deep copy, of the cube texture
  7715. * @returns a new cube texture
  7716. */
  7717. clone(): CubeTexture;
  7718. }
  7719. }
  7720. declare module BABYLON {
  7721. /**
  7722. * Manages the defines for the Material
  7723. */
  7724. export class MaterialDefines {
  7725. /** @hidden */
  7726. protected _keys: string[];
  7727. private _isDirty;
  7728. /** @hidden */
  7729. _renderId: number;
  7730. /** @hidden */
  7731. _areLightsDirty: boolean;
  7732. /** @hidden */
  7733. _areLightsDisposed: boolean;
  7734. /** @hidden */
  7735. _areAttributesDirty: boolean;
  7736. /** @hidden */
  7737. _areTexturesDirty: boolean;
  7738. /** @hidden */
  7739. _areFresnelDirty: boolean;
  7740. /** @hidden */
  7741. _areMiscDirty: boolean;
  7742. /** @hidden */
  7743. _areImageProcessingDirty: boolean;
  7744. /** @hidden */
  7745. _normals: boolean;
  7746. /** @hidden */
  7747. _uvs: boolean;
  7748. /** @hidden */
  7749. _needNormals: boolean;
  7750. /** @hidden */
  7751. _needUVs: boolean;
  7752. [id: string]: any;
  7753. /**
  7754. * Specifies if the material needs to be re-calculated
  7755. */
  7756. readonly isDirty: boolean;
  7757. /**
  7758. * Marks the material to indicate that it has been re-calculated
  7759. */
  7760. markAsProcessed(): void;
  7761. /**
  7762. * Marks the material to indicate that it needs to be re-calculated
  7763. */
  7764. markAsUnprocessed(): void;
  7765. /**
  7766. * Marks the material to indicate all of its defines need to be re-calculated
  7767. */
  7768. markAllAsDirty(): void;
  7769. /**
  7770. * Marks the material to indicate that image processing needs to be re-calculated
  7771. */
  7772. markAsImageProcessingDirty(): void;
  7773. /**
  7774. * Marks the material to indicate the lights need to be re-calculated
  7775. * @param disposed Defines whether the light is dirty due to dispose or not
  7776. */
  7777. markAsLightDirty(disposed?: boolean): void;
  7778. /**
  7779. * Marks the attribute state as changed
  7780. */
  7781. markAsAttributesDirty(): void;
  7782. /**
  7783. * Marks the texture state as changed
  7784. */
  7785. markAsTexturesDirty(): void;
  7786. /**
  7787. * Marks the fresnel state as changed
  7788. */
  7789. markAsFresnelDirty(): void;
  7790. /**
  7791. * Marks the misc state as changed
  7792. */
  7793. markAsMiscDirty(): void;
  7794. /**
  7795. * Rebuilds the material defines
  7796. */
  7797. rebuild(): void;
  7798. /**
  7799. * Specifies if two material defines are equal
  7800. * @param other - A material define instance to compare to
  7801. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7802. */
  7803. isEqual(other: MaterialDefines): boolean;
  7804. /**
  7805. * Clones this instance's defines to another instance
  7806. * @param other - material defines to clone values to
  7807. */
  7808. cloneTo(other: MaterialDefines): void;
  7809. /**
  7810. * Resets the material define values
  7811. */
  7812. reset(): void;
  7813. /**
  7814. * Converts the material define values to a string
  7815. * @returns - String of material define information
  7816. */
  7817. toString(): string;
  7818. }
  7819. }
  7820. declare module BABYLON {
  7821. /**
  7822. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7823. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7824. * 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;
  7825. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7826. */
  7827. export class ColorCurves {
  7828. private _dirty;
  7829. private _tempColor;
  7830. private _globalCurve;
  7831. private _highlightsCurve;
  7832. private _midtonesCurve;
  7833. private _shadowsCurve;
  7834. private _positiveCurve;
  7835. private _negativeCurve;
  7836. private _globalHue;
  7837. private _globalDensity;
  7838. private _globalSaturation;
  7839. private _globalExposure;
  7840. /**
  7841. * Gets the global Hue value.
  7842. * 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).
  7843. */
  7844. /**
  7845. * Sets the global Hue value.
  7846. * 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).
  7847. */
  7848. globalHue: number;
  7849. /**
  7850. * Gets the global Density value.
  7851. * 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.
  7852. * Values less than zero provide a filter of opposite hue.
  7853. */
  7854. /**
  7855. * Sets the global Density value.
  7856. * 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.
  7857. * Values less than zero provide a filter of opposite hue.
  7858. */
  7859. globalDensity: number;
  7860. /**
  7861. * Gets the global Saturation value.
  7862. * 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.
  7863. */
  7864. /**
  7865. * Sets the global Saturation value.
  7866. * 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.
  7867. */
  7868. globalSaturation: number;
  7869. /**
  7870. * Gets the global Exposure value.
  7871. * 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.
  7872. */
  7873. /**
  7874. * Sets the global Exposure value.
  7875. * 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.
  7876. */
  7877. globalExposure: number;
  7878. private _highlightsHue;
  7879. private _highlightsDensity;
  7880. private _highlightsSaturation;
  7881. private _highlightsExposure;
  7882. /**
  7883. * Gets the highlights Hue value.
  7884. * 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).
  7885. */
  7886. /**
  7887. * Sets the highlights Hue value.
  7888. * 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).
  7889. */
  7890. highlightsHue: number;
  7891. /**
  7892. * Gets the highlights Density value.
  7893. * 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.
  7894. * Values less than zero provide a filter of opposite hue.
  7895. */
  7896. /**
  7897. * Sets the highlights Density value.
  7898. * 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.
  7899. * Values less than zero provide a filter of opposite hue.
  7900. */
  7901. highlightsDensity: number;
  7902. /**
  7903. * Gets the highlights Saturation value.
  7904. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7905. */
  7906. /**
  7907. * Sets the highlights Saturation value.
  7908. * 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.
  7909. */
  7910. highlightsSaturation: number;
  7911. /**
  7912. * Gets the highlights Exposure value.
  7913. * 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.
  7914. */
  7915. /**
  7916. * Sets the highlights Exposure value.
  7917. * 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.
  7918. */
  7919. highlightsExposure: number;
  7920. private _midtonesHue;
  7921. private _midtonesDensity;
  7922. private _midtonesSaturation;
  7923. private _midtonesExposure;
  7924. /**
  7925. * Gets the midtones Hue value.
  7926. * 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).
  7927. */
  7928. /**
  7929. * Sets the midtones Hue value.
  7930. * 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).
  7931. */
  7932. midtonesHue: number;
  7933. /**
  7934. * Gets the midtones Density value.
  7935. * 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.
  7936. * Values less than zero provide a filter of opposite hue.
  7937. */
  7938. /**
  7939. * Sets the midtones Density value.
  7940. * 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.
  7941. * Values less than zero provide a filter of opposite hue.
  7942. */
  7943. midtonesDensity: number;
  7944. /**
  7945. * Gets the midtones Saturation value.
  7946. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7947. */
  7948. /**
  7949. * Sets the midtones Saturation value.
  7950. * 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.
  7951. */
  7952. midtonesSaturation: number;
  7953. /**
  7954. * Gets the midtones Exposure value.
  7955. * 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.
  7956. */
  7957. /**
  7958. * Sets the midtones Exposure value.
  7959. * 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.
  7960. */
  7961. midtonesExposure: number;
  7962. private _shadowsHue;
  7963. private _shadowsDensity;
  7964. private _shadowsSaturation;
  7965. private _shadowsExposure;
  7966. /**
  7967. * Gets the shadows Hue value.
  7968. * 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).
  7969. */
  7970. /**
  7971. * Sets the shadows Hue value.
  7972. * 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).
  7973. */
  7974. shadowsHue: number;
  7975. /**
  7976. * Gets the shadows Density value.
  7977. * 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.
  7978. * Values less than zero provide a filter of opposite hue.
  7979. */
  7980. /**
  7981. * Sets the shadows Density value.
  7982. * 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.
  7983. * Values less than zero provide a filter of opposite hue.
  7984. */
  7985. shadowsDensity: number;
  7986. /**
  7987. * Gets the shadows Saturation value.
  7988. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7989. */
  7990. /**
  7991. * Sets the shadows Saturation value.
  7992. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7993. */
  7994. shadowsSaturation: number;
  7995. /**
  7996. * Gets the shadows Exposure value.
  7997. * 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.
  7998. */
  7999. /**
  8000. * Sets the shadows Exposure value.
  8001. * 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.
  8002. */
  8003. shadowsExposure: number;
  8004. /**
  8005. * Returns the class name
  8006. * @returns The class name
  8007. */
  8008. getClassName(): string;
  8009. /**
  8010. * Binds the color curves to the shader.
  8011. * @param colorCurves The color curve to bind
  8012. * @param effect The effect to bind to
  8013. * @param positiveUniform The positive uniform shader parameter
  8014. * @param neutralUniform The neutral uniform shader parameter
  8015. * @param negativeUniform The negative uniform shader parameter
  8016. */
  8017. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8018. /**
  8019. * Prepare the list of uniforms associated with the ColorCurves effects.
  8020. * @param uniformsList The list of uniforms used in the effect
  8021. */
  8022. static PrepareUniforms(uniformsList: string[]): void;
  8023. /**
  8024. * Returns color grading data based on a hue, density, saturation and exposure value.
  8025. * @param filterHue The hue of the color filter.
  8026. * @param filterDensity The density of the color filter.
  8027. * @param saturation The saturation.
  8028. * @param exposure The exposure.
  8029. * @param result The result data container.
  8030. */
  8031. private getColorGradingDataToRef;
  8032. /**
  8033. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8034. * @param value The input slider value in range [-100,100].
  8035. * @returns Adjusted value.
  8036. */
  8037. private static applyColorGradingSliderNonlinear;
  8038. /**
  8039. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8040. * @param hue The hue (H) input.
  8041. * @param saturation The saturation (S) input.
  8042. * @param brightness The brightness (B) input.
  8043. * @result An RGBA color represented as Vector4.
  8044. */
  8045. private static fromHSBToRef;
  8046. /**
  8047. * Returns a value clamped between min and max
  8048. * @param value The value to clamp
  8049. * @param min The minimum of value
  8050. * @param max The maximum of value
  8051. * @returns The clamped value.
  8052. */
  8053. private static clamp;
  8054. /**
  8055. * Clones the current color curve instance.
  8056. * @return The cloned curves
  8057. */
  8058. clone(): ColorCurves;
  8059. /**
  8060. * Serializes the current color curve instance to a json representation.
  8061. * @return a JSON representation
  8062. */
  8063. serialize(): any;
  8064. /**
  8065. * Parses the color curve from a json representation.
  8066. * @param source the JSON source to parse
  8067. * @return The parsed curves
  8068. */
  8069. static Parse(source: any): ColorCurves;
  8070. }
  8071. }
  8072. declare module BABYLON {
  8073. /**
  8074. * Interface to follow in your material defines to integrate easily the
  8075. * Image proccessing functions.
  8076. * @hidden
  8077. */
  8078. export interface IImageProcessingConfigurationDefines {
  8079. IMAGEPROCESSING: boolean;
  8080. VIGNETTE: boolean;
  8081. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8082. VIGNETTEBLENDMODEOPAQUE: boolean;
  8083. TONEMAPPING: boolean;
  8084. TONEMAPPING_ACES: boolean;
  8085. CONTRAST: boolean;
  8086. EXPOSURE: boolean;
  8087. COLORCURVES: boolean;
  8088. COLORGRADING: boolean;
  8089. COLORGRADING3D: boolean;
  8090. SAMPLER3DGREENDEPTH: boolean;
  8091. SAMPLER3DBGRMAP: boolean;
  8092. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8093. }
  8094. /**
  8095. * @hidden
  8096. */
  8097. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8098. IMAGEPROCESSING: boolean;
  8099. VIGNETTE: boolean;
  8100. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8101. VIGNETTEBLENDMODEOPAQUE: boolean;
  8102. TONEMAPPING: boolean;
  8103. TONEMAPPING_ACES: boolean;
  8104. CONTRAST: boolean;
  8105. COLORCURVES: boolean;
  8106. COLORGRADING: boolean;
  8107. COLORGRADING3D: boolean;
  8108. SAMPLER3DGREENDEPTH: boolean;
  8109. SAMPLER3DBGRMAP: boolean;
  8110. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8111. EXPOSURE: boolean;
  8112. constructor();
  8113. }
  8114. /**
  8115. * This groups together the common properties used for image processing either in direct forward pass
  8116. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8117. * or not.
  8118. */
  8119. export class ImageProcessingConfiguration {
  8120. /**
  8121. * Default tone mapping applied in BabylonJS.
  8122. */
  8123. static readonly TONEMAPPING_STANDARD: number;
  8124. /**
  8125. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8126. * to other engines rendering to increase portability.
  8127. */
  8128. static readonly TONEMAPPING_ACES: number;
  8129. /**
  8130. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8131. */
  8132. colorCurves: Nullable<ColorCurves>;
  8133. private _colorCurvesEnabled;
  8134. /**
  8135. * Gets wether the color curves effect is enabled.
  8136. */
  8137. /**
  8138. * Sets wether the color curves effect is enabled.
  8139. */
  8140. colorCurvesEnabled: boolean;
  8141. private _colorGradingTexture;
  8142. /**
  8143. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8144. */
  8145. /**
  8146. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8147. */
  8148. colorGradingTexture: Nullable<BaseTexture>;
  8149. private _colorGradingEnabled;
  8150. /**
  8151. * Gets wether the color grading effect is enabled.
  8152. */
  8153. /**
  8154. * Sets wether the color grading effect is enabled.
  8155. */
  8156. colorGradingEnabled: boolean;
  8157. private _colorGradingWithGreenDepth;
  8158. /**
  8159. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8160. */
  8161. /**
  8162. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8163. */
  8164. colorGradingWithGreenDepth: boolean;
  8165. private _colorGradingBGR;
  8166. /**
  8167. * Gets wether the color grading texture contains BGR values.
  8168. */
  8169. /**
  8170. * Sets wether the color grading texture contains BGR values.
  8171. */
  8172. colorGradingBGR: boolean;
  8173. /** @hidden */
  8174. _exposure: number;
  8175. /**
  8176. * Gets the Exposure used in the effect.
  8177. */
  8178. /**
  8179. * Sets the Exposure used in the effect.
  8180. */
  8181. exposure: number;
  8182. private _toneMappingEnabled;
  8183. /**
  8184. * Gets wether the tone mapping effect is enabled.
  8185. */
  8186. /**
  8187. * Sets wether the tone mapping effect is enabled.
  8188. */
  8189. toneMappingEnabled: boolean;
  8190. private _toneMappingType;
  8191. /**
  8192. * Gets the type of tone mapping effect.
  8193. */
  8194. /**
  8195. * Sets the type of tone mapping effect used in BabylonJS.
  8196. */
  8197. toneMappingType: number;
  8198. protected _contrast: number;
  8199. /**
  8200. * Gets the contrast used in the effect.
  8201. */
  8202. /**
  8203. * Sets the contrast used in the effect.
  8204. */
  8205. contrast: number;
  8206. /**
  8207. * Vignette stretch size.
  8208. */
  8209. vignetteStretch: number;
  8210. /**
  8211. * Vignette centre X Offset.
  8212. */
  8213. vignetteCentreX: number;
  8214. /**
  8215. * Vignette centre Y Offset.
  8216. */
  8217. vignetteCentreY: number;
  8218. /**
  8219. * Vignette weight or intensity of the vignette effect.
  8220. */
  8221. vignetteWeight: number;
  8222. /**
  8223. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8224. * if vignetteEnabled is set to true.
  8225. */
  8226. vignetteColor: Color4;
  8227. /**
  8228. * Camera field of view used by the Vignette effect.
  8229. */
  8230. vignetteCameraFov: number;
  8231. private _vignetteBlendMode;
  8232. /**
  8233. * Gets the vignette blend mode allowing different kind of effect.
  8234. */
  8235. /**
  8236. * Sets the vignette blend mode allowing different kind of effect.
  8237. */
  8238. vignetteBlendMode: number;
  8239. private _vignetteEnabled;
  8240. /**
  8241. * Gets wether the vignette effect is enabled.
  8242. */
  8243. /**
  8244. * Sets wether the vignette effect is enabled.
  8245. */
  8246. vignetteEnabled: boolean;
  8247. private _applyByPostProcess;
  8248. /**
  8249. * Gets wether the image processing is applied through a post process or not.
  8250. */
  8251. /**
  8252. * Sets wether the image processing is applied through a post process or not.
  8253. */
  8254. applyByPostProcess: boolean;
  8255. private _isEnabled;
  8256. /**
  8257. * Gets wether the image processing is enabled or not.
  8258. */
  8259. /**
  8260. * Sets wether the image processing is enabled or not.
  8261. */
  8262. isEnabled: boolean;
  8263. /**
  8264. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8265. */
  8266. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8267. /**
  8268. * Method called each time the image processing information changes requires to recompile the effect.
  8269. */
  8270. protected _updateParameters(): void;
  8271. /**
  8272. * Gets the current class name.
  8273. * @return "ImageProcessingConfiguration"
  8274. */
  8275. getClassName(): string;
  8276. /**
  8277. * Prepare the list of uniforms associated with the Image Processing effects.
  8278. * @param uniforms The list of uniforms used in the effect
  8279. * @param defines the list of defines currently in use
  8280. */
  8281. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8282. /**
  8283. * Prepare the list of samplers associated with the Image Processing effects.
  8284. * @param samplersList The list of uniforms used in the effect
  8285. * @param defines the list of defines currently in use
  8286. */
  8287. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8288. /**
  8289. * Prepare the list of defines associated to the shader.
  8290. * @param defines the list of defines to complete
  8291. * @param forPostProcess Define if we are currently in post process mode or not
  8292. */
  8293. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8294. /**
  8295. * Returns true if all the image processing information are ready.
  8296. * @returns True if ready, otherwise, false
  8297. */
  8298. isReady(): boolean;
  8299. /**
  8300. * Binds the image processing to the shader.
  8301. * @param effect The effect to bind to
  8302. * @param aspectRatio Define the current aspect ratio of the effect
  8303. */
  8304. bind(effect: Effect, aspectRatio?: number): void;
  8305. /**
  8306. * Clones the current image processing instance.
  8307. * @return The cloned image processing
  8308. */
  8309. clone(): ImageProcessingConfiguration;
  8310. /**
  8311. * Serializes the current image processing instance to a json representation.
  8312. * @return a JSON representation
  8313. */
  8314. serialize(): any;
  8315. /**
  8316. * Parses the image processing from a json representation.
  8317. * @param source the JSON source to parse
  8318. * @return The parsed image processing
  8319. */
  8320. static Parse(source: any): ImageProcessingConfiguration;
  8321. private static _VIGNETTEMODE_MULTIPLY;
  8322. private static _VIGNETTEMODE_OPAQUE;
  8323. /**
  8324. * Used to apply the vignette as a mix with the pixel color.
  8325. */
  8326. static readonly VIGNETTEMODE_MULTIPLY: number;
  8327. /**
  8328. * Used to apply the vignette as a replacement of the pixel color.
  8329. */
  8330. static readonly VIGNETTEMODE_OPAQUE: number;
  8331. }
  8332. }
  8333. declare module BABYLON {
  8334. /** @hidden */
  8335. export var postprocessVertexShader: {
  8336. name: string;
  8337. shader: string;
  8338. };
  8339. }
  8340. declare module BABYLON {
  8341. /** Defines supported spaces */
  8342. export enum Space {
  8343. /** Local (object) space */
  8344. LOCAL = 0,
  8345. /** World space */
  8346. WORLD = 1,
  8347. /** Bone space */
  8348. BONE = 2
  8349. }
  8350. /** Defines the 3 main axes */
  8351. export class Axis {
  8352. /** X axis */
  8353. static X: Vector3;
  8354. /** Y axis */
  8355. static Y: Vector3;
  8356. /** Z axis */
  8357. static Z: Vector3;
  8358. }
  8359. }
  8360. declare module BABYLON {
  8361. /**
  8362. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8363. * This is the base of the follow, arc rotate cameras and Free camera
  8364. * @see http://doc.babylonjs.com/features/cameras
  8365. */
  8366. export class TargetCamera extends Camera {
  8367. private static _RigCamTransformMatrix;
  8368. private static _TargetTransformMatrix;
  8369. private static _TargetFocalPoint;
  8370. /**
  8371. * Define the current direction the camera is moving to
  8372. */
  8373. cameraDirection: Vector3;
  8374. /**
  8375. * Define the current rotation the camera is rotating to
  8376. */
  8377. cameraRotation: Vector2;
  8378. /**
  8379. * When set, the up vector of the camera will be updated by the rotation of the camera
  8380. */
  8381. updateUpVectorFromRotation: boolean;
  8382. private _tmpQuaternion;
  8383. /**
  8384. * Define the current rotation of the camera
  8385. */
  8386. rotation: Vector3;
  8387. /**
  8388. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8389. */
  8390. rotationQuaternion: Quaternion;
  8391. /**
  8392. * Define the current speed of the camera
  8393. */
  8394. speed: number;
  8395. /**
  8396. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8397. * around all axis.
  8398. */
  8399. noRotationConstraint: boolean;
  8400. /**
  8401. * Define the current target of the camera as an object or a position.
  8402. */
  8403. lockedTarget: any;
  8404. /** @hidden */
  8405. _currentTarget: Vector3;
  8406. /** @hidden */
  8407. _initialFocalDistance: number;
  8408. /** @hidden */
  8409. _viewMatrix: Matrix;
  8410. /** @hidden */
  8411. _camMatrix: Matrix;
  8412. /** @hidden */
  8413. _cameraTransformMatrix: Matrix;
  8414. /** @hidden */
  8415. _cameraRotationMatrix: Matrix;
  8416. /** @hidden */
  8417. _referencePoint: Vector3;
  8418. /** @hidden */
  8419. _transformedReferencePoint: Vector3;
  8420. protected _globalCurrentTarget: Vector3;
  8421. protected _globalCurrentUpVector: Vector3;
  8422. /** @hidden */
  8423. _reset: () => void;
  8424. private _defaultUp;
  8425. /**
  8426. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8427. * This is the base of the follow, arc rotate cameras and Free camera
  8428. * @see http://doc.babylonjs.com/features/cameras
  8429. * @param name Defines the name of the camera in the scene
  8430. * @param position Defines the start position of the camera in the scene
  8431. * @param scene Defines the scene the camera belongs to
  8432. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8433. */
  8434. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8435. /**
  8436. * Gets the position in front of the camera at a given distance.
  8437. * @param distance The distance from the camera we want the position to be
  8438. * @returns the position
  8439. */
  8440. getFrontPosition(distance: number): Vector3;
  8441. /** @hidden */
  8442. _getLockedTargetPosition(): Nullable<Vector3>;
  8443. private _storedPosition;
  8444. private _storedRotation;
  8445. private _storedRotationQuaternion;
  8446. /**
  8447. * Store current camera state of the camera (fov, position, rotation, etc..)
  8448. * @returns the camera
  8449. */
  8450. storeState(): Camera;
  8451. /**
  8452. * Restored camera state. You must call storeState() first
  8453. * @returns whether it was successful or not
  8454. * @hidden
  8455. */
  8456. _restoreStateValues(): boolean;
  8457. /** @hidden */
  8458. _initCache(): void;
  8459. /** @hidden */
  8460. _updateCache(ignoreParentClass?: boolean): void;
  8461. /** @hidden */
  8462. _isSynchronizedViewMatrix(): boolean;
  8463. /** @hidden */
  8464. _computeLocalCameraSpeed(): number;
  8465. /**
  8466. * Defines the target the camera should look at.
  8467. * @param target Defines the new target as a Vector or a mesh
  8468. */
  8469. setTarget(target: Vector3): void;
  8470. /**
  8471. * Return the current target position of the camera. This value is expressed in local space.
  8472. * @returns the target position
  8473. */
  8474. getTarget(): Vector3;
  8475. /** @hidden */
  8476. _decideIfNeedsToMove(): boolean;
  8477. /** @hidden */
  8478. _updatePosition(): void;
  8479. /** @hidden */
  8480. _checkInputs(): void;
  8481. protected _updateCameraRotationMatrix(): void;
  8482. /**
  8483. * 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)
  8484. * @returns the current camera
  8485. */
  8486. private _rotateUpVectorWithCameraRotationMatrix;
  8487. private _cachedRotationZ;
  8488. private _cachedQuaternionRotationZ;
  8489. /** @hidden */
  8490. _getViewMatrix(): Matrix;
  8491. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8492. /**
  8493. * @hidden
  8494. */
  8495. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8496. /**
  8497. * @hidden
  8498. */
  8499. _updateRigCameras(): void;
  8500. private _getRigCamPositionAndTarget;
  8501. /**
  8502. * Gets the current object class name.
  8503. * @return the class name
  8504. */
  8505. getClassName(): string;
  8506. }
  8507. }
  8508. declare module BABYLON {
  8509. /**
  8510. * Gather the list of keyboard event types as constants.
  8511. */
  8512. export class KeyboardEventTypes {
  8513. /**
  8514. * The keydown event is fired when a key becomes active (pressed).
  8515. */
  8516. static readonly KEYDOWN: number;
  8517. /**
  8518. * The keyup event is fired when a key has been released.
  8519. */
  8520. static readonly KEYUP: number;
  8521. }
  8522. /**
  8523. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8524. */
  8525. export class KeyboardInfo {
  8526. /**
  8527. * Defines the type of event (KeyboardEventTypes)
  8528. */
  8529. type: number;
  8530. /**
  8531. * Defines the related dom event
  8532. */
  8533. event: KeyboardEvent;
  8534. /**
  8535. * Instantiates a new keyboard info.
  8536. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8537. * @param type Defines the type of event (KeyboardEventTypes)
  8538. * @param event Defines the related dom event
  8539. */
  8540. constructor(
  8541. /**
  8542. * Defines the type of event (KeyboardEventTypes)
  8543. */
  8544. type: number,
  8545. /**
  8546. * Defines the related dom event
  8547. */
  8548. event: KeyboardEvent);
  8549. }
  8550. /**
  8551. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8552. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8553. */
  8554. export class KeyboardInfoPre extends KeyboardInfo {
  8555. /**
  8556. * Defines the type of event (KeyboardEventTypes)
  8557. */
  8558. type: number;
  8559. /**
  8560. * Defines the related dom event
  8561. */
  8562. event: KeyboardEvent;
  8563. /**
  8564. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8565. */
  8566. skipOnPointerObservable: boolean;
  8567. /**
  8568. * Instantiates a new keyboard pre info.
  8569. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8570. * @param type Defines the type of event (KeyboardEventTypes)
  8571. * @param event Defines the related dom event
  8572. */
  8573. constructor(
  8574. /**
  8575. * Defines the type of event (KeyboardEventTypes)
  8576. */
  8577. type: number,
  8578. /**
  8579. * Defines the related dom event
  8580. */
  8581. event: KeyboardEvent);
  8582. }
  8583. }
  8584. declare module BABYLON {
  8585. /**
  8586. * Manage the keyboard inputs to control the movement of a free camera.
  8587. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8588. */
  8589. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8590. /**
  8591. * Defines the camera the input is attached to.
  8592. */
  8593. camera: FreeCamera;
  8594. /**
  8595. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8596. */
  8597. keysUp: number[];
  8598. /**
  8599. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8600. */
  8601. keysDown: number[];
  8602. /**
  8603. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8604. */
  8605. keysLeft: number[];
  8606. /**
  8607. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8608. */
  8609. keysRight: number[];
  8610. private _keys;
  8611. private _onCanvasBlurObserver;
  8612. private _onKeyboardObserver;
  8613. private _engine;
  8614. private _scene;
  8615. /**
  8616. * Attach the input controls to a specific dom element to get the input from.
  8617. * @param element Defines the element the controls should be listened from
  8618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8619. */
  8620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8621. /**
  8622. * Detach the current controls from the specified dom element.
  8623. * @param element Defines the element to stop listening the inputs from
  8624. */
  8625. detachControl(element: Nullable<HTMLElement>): void;
  8626. /**
  8627. * Update the current camera state depending on the inputs that have been used this frame.
  8628. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8629. */
  8630. checkInputs(): void;
  8631. /**
  8632. * Gets the class name of the current intput.
  8633. * @returns the class name
  8634. */
  8635. getClassName(): string;
  8636. /** @hidden */
  8637. _onLostFocus(): void;
  8638. /**
  8639. * Get the friendly name associated with the input class.
  8640. * @returns the input friendly name
  8641. */
  8642. getSimpleName(): string;
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * Interface describing all the common properties and methods a shadow light needs to implement.
  8648. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8649. * as well as binding the different shadow properties to the effects.
  8650. */
  8651. export interface IShadowLight extends Light {
  8652. /**
  8653. * The light id in the scene (used in scene.findLighById for instance)
  8654. */
  8655. id: string;
  8656. /**
  8657. * The position the shdow will be casted from.
  8658. */
  8659. position: Vector3;
  8660. /**
  8661. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8662. */
  8663. direction: Vector3;
  8664. /**
  8665. * The transformed position. Position of the light in world space taking parenting in account.
  8666. */
  8667. transformedPosition: Vector3;
  8668. /**
  8669. * The transformed direction. Direction of the light in world space taking parenting in account.
  8670. */
  8671. transformedDirection: Vector3;
  8672. /**
  8673. * The friendly name of the light in the scene.
  8674. */
  8675. name: string;
  8676. /**
  8677. * Defines the shadow projection clipping minimum z value.
  8678. */
  8679. shadowMinZ: number;
  8680. /**
  8681. * Defines the shadow projection clipping maximum z value.
  8682. */
  8683. shadowMaxZ: number;
  8684. /**
  8685. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8686. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8687. */
  8688. computeTransformedInformation(): boolean;
  8689. /**
  8690. * Gets the scene the light belongs to.
  8691. * @returns The scene
  8692. */
  8693. getScene(): Scene;
  8694. /**
  8695. * Callback defining a custom Projection Matrix Builder.
  8696. * This can be used to override the default projection matrix computation.
  8697. */
  8698. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8699. /**
  8700. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8701. * @param matrix The materix to updated with the projection information
  8702. * @param viewMatrix The transform matrix of the light
  8703. * @param renderList The list of mesh to render in the map
  8704. * @returns The current light
  8705. */
  8706. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8707. /**
  8708. * Gets the current depth scale used in ESM.
  8709. * @returns The scale
  8710. */
  8711. getDepthScale(): number;
  8712. /**
  8713. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8714. * @returns true if a cube texture needs to be use
  8715. */
  8716. needCube(): boolean;
  8717. /**
  8718. * Detects if the projection matrix requires to be recomputed this frame.
  8719. * @returns true if it requires to be recomputed otherwise, false.
  8720. */
  8721. needProjectionMatrixCompute(): boolean;
  8722. /**
  8723. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8724. */
  8725. forceProjectionMatrixCompute(): void;
  8726. /**
  8727. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8728. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8729. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8730. */
  8731. getShadowDirection(faceIndex?: number): Vector3;
  8732. /**
  8733. * Gets the minZ used for shadow according to both the scene and the light.
  8734. * @param activeCamera The camera we are returning the min for
  8735. * @returns the depth min z
  8736. */
  8737. getDepthMinZ(activeCamera: Camera): number;
  8738. /**
  8739. * Gets the maxZ used for shadow according to both the scene and the light.
  8740. * @param activeCamera The camera we are returning the max for
  8741. * @returns the depth max z
  8742. */
  8743. getDepthMaxZ(activeCamera: Camera): number;
  8744. }
  8745. /**
  8746. * Base implementation IShadowLight
  8747. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8748. */
  8749. export abstract class ShadowLight extends Light implements IShadowLight {
  8750. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8751. protected _position: Vector3;
  8752. protected _setPosition(value: Vector3): void;
  8753. /**
  8754. * Sets the position the shadow will be casted from. Also use as the light position for both
  8755. * point and spot lights.
  8756. */
  8757. /**
  8758. * Sets the position the shadow will be casted from. Also use as the light position for both
  8759. * point and spot lights.
  8760. */
  8761. position: Vector3;
  8762. protected _direction: Vector3;
  8763. protected _setDirection(value: Vector3): void;
  8764. /**
  8765. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8766. * Also use as the light direction on spot and directional lights.
  8767. */
  8768. /**
  8769. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8770. * Also use as the light direction on spot and directional lights.
  8771. */
  8772. direction: Vector3;
  8773. private _shadowMinZ;
  8774. /**
  8775. * Gets the shadow projection clipping minimum z value.
  8776. */
  8777. /**
  8778. * Sets the shadow projection clipping minimum z value.
  8779. */
  8780. shadowMinZ: number;
  8781. private _shadowMaxZ;
  8782. /**
  8783. * Sets the shadow projection clipping maximum z value.
  8784. */
  8785. /**
  8786. * Gets the shadow projection clipping maximum z value.
  8787. */
  8788. shadowMaxZ: number;
  8789. /**
  8790. * Callback defining a custom Projection Matrix Builder.
  8791. * This can be used to override the default projection matrix computation.
  8792. */
  8793. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8794. /**
  8795. * The transformed position. Position of the light in world space taking parenting in account.
  8796. */
  8797. transformedPosition: Vector3;
  8798. /**
  8799. * The transformed direction. Direction of the light in world space taking parenting in account.
  8800. */
  8801. transformedDirection: Vector3;
  8802. private _needProjectionMatrixCompute;
  8803. /**
  8804. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8805. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8806. */
  8807. computeTransformedInformation(): boolean;
  8808. /**
  8809. * Return the depth scale used for the shadow map.
  8810. * @returns the depth scale.
  8811. */
  8812. getDepthScale(): number;
  8813. /**
  8814. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8815. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8816. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8817. */
  8818. getShadowDirection(faceIndex?: number): Vector3;
  8819. /**
  8820. * Returns the ShadowLight absolute position in the World.
  8821. * @returns the position vector in world space
  8822. */
  8823. getAbsolutePosition(): Vector3;
  8824. /**
  8825. * Sets the ShadowLight direction toward the passed target.
  8826. * @param target The point to target in local space
  8827. * @returns the updated ShadowLight direction
  8828. */
  8829. setDirectionToTarget(target: Vector3): Vector3;
  8830. /**
  8831. * Returns the light rotation in euler definition.
  8832. * @returns the x y z rotation in local space.
  8833. */
  8834. getRotation(): Vector3;
  8835. /**
  8836. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8837. * @returns true if a cube texture needs to be use
  8838. */
  8839. needCube(): boolean;
  8840. /**
  8841. * Detects if the projection matrix requires to be recomputed this frame.
  8842. * @returns true if it requires to be recomputed otherwise, false.
  8843. */
  8844. needProjectionMatrixCompute(): boolean;
  8845. /**
  8846. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8847. */
  8848. forceProjectionMatrixCompute(): void;
  8849. /** @hidden */
  8850. _initCache(): void;
  8851. /** @hidden */
  8852. _isSynchronized(): boolean;
  8853. /**
  8854. * Computes the world matrix of the node
  8855. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8856. * @returns the world matrix
  8857. */
  8858. computeWorldMatrix(force?: boolean): Matrix;
  8859. /**
  8860. * Gets the minZ used for shadow according to both the scene and the light.
  8861. * @param activeCamera The camera we are returning the min for
  8862. * @returns the depth min z
  8863. */
  8864. getDepthMinZ(activeCamera: Camera): number;
  8865. /**
  8866. * Gets the maxZ used for shadow according to both the scene and the light.
  8867. * @param activeCamera The camera we are returning the max for
  8868. * @returns the depth max z
  8869. */
  8870. getDepthMaxZ(activeCamera: Camera): number;
  8871. /**
  8872. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8873. * @param matrix The materix to updated with the projection information
  8874. * @param viewMatrix The transform matrix of the light
  8875. * @param renderList The list of mesh to render in the map
  8876. * @returns The current light
  8877. */
  8878. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8879. }
  8880. }
  8881. declare module BABYLON {
  8882. /**
  8883. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8884. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8885. */
  8886. export class EffectFallbacks implements IEffectFallbacks {
  8887. private _defines;
  8888. private _currentRank;
  8889. private _maxRank;
  8890. private _mesh;
  8891. /**
  8892. * Removes the fallback from the bound mesh.
  8893. */
  8894. unBindMesh(): void;
  8895. /**
  8896. * Adds a fallback on the specified property.
  8897. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8898. * @param define The name of the define in the shader
  8899. */
  8900. addFallback(rank: number, define: string): void;
  8901. /**
  8902. * Sets the mesh to use CPU skinning when needing to fallback.
  8903. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8904. * @param mesh The mesh to use the fallbacks.
  8905. */
  8906. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8907. /**
  8908. * Checks to see if more fallbacks are still availible.
  8909. */
  8910. readonly hasMoreFallbacks: boolean;
  8911. /**
  8912. * Removes the defines that should be removed when falling back.
  8913. * @param currentDefines defines the current define statements for the shader.
  8914. * @param effect defines the current effect we try to compile
  8915. * @returns The resulting defines with defines of the current rank removed.
  8916. */
  8917. reduce(currentDefines: string, effect: Effect): string;
  8918. }
  8919. }
  8920. declare module BABYLON {
  8921. /**
  8922. * "Static Class" containing the most commonly used helper while dealing with material for
  8923. * rendering purpose.
  8924. *
  8925. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8926. *
  8927. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8928. */
  8929. export class MaterialHelper {
  8930. /**
  8931. * Bind the current view position to an effect.
  8932. * @param effect The effect to be bound
  8933. * @param scene The scene the eyes position is used from
  8934. */
  8935. static BindEyePosition(effect: Effect, scene: Scene): void;
  8936. /**
  8937. * Helps preparing the defines values about the UVs in used in the effect.
  8938. * UVs are shared as much as we can accross channels in the shaders.
  8939. * @param texture The texture we are preparing the UVs for
  8940. * @param defines The defines to update
  8941. * @param key The channel key "diffuse", "specular"... used in the shader
  8942. */
  8943. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8944. /**
  8945. * Binds a texture matrix value to its corrsponding uniform
  8946. * @param texture The texture to bind the matrix for
  8947. * @param uniformBuffer The uniform buffer receivin the data
  8948. * @param key The channel key "diffuse", "specular"... used in the shader
  8949. */
  8950. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8951. /**
  8952. * Gets the current status of the fog (should it be enabled?)
  8953. * @param mesh defines the mesh to evaluate for fog support
  8954. * @param scene defines the hosting scene
  8955. * @returns true if fog must be enabled
  8956. */
  8957. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8958. /**
  8959. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8960. * @param mesh defines the current mesh
  8961. * @param scene defines the current scene
  8962. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8963. * @param pointsCloud defines if point cloud rendering has to be turned on
  8964. * @param fogEnabled defines if fog has to be turned on
  8965. * @param alphaTest defines if alpha testing has to be turned on
  8966. * @param defines defines the current list of defines
  8967. */
  8968. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8969. /**
  8970. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8971. * @param scene defines the current scene
  8972. * @param engine defines the current engine
  8973. * @param defines specifies the list of active defines
  8974. * @param useInstances defines if instances have to be turned on
  8975. * @param useClipPlane defines if clip plane have to be turned on
  8976. */
  8977. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8978. /**
  8979. * Prepares the defines for bones
  8980. * @param mesh The mesh containing the geometry data we will draw
  8981. * @param defines The defines to update
  8982. */
  8983. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8984. /**
  8985. * Prepares the defines for morph targets
  8986. * @param mesh The mesh containing the geometry data we will draw
  8987. * @param defines The defines to update
  8988. */
  8989. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8990. /**
  8991. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8992. * @param mesh The mesh containing the geometry data we will draw
  8993. * @param defines The defines to update
  8994. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8995. * @param useBones Precise whether bones should be used or not (override mesh info)
  8996. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8997. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8998. * @returns false if defines are considered not dirty and have not been checked
  8999. */
  9000. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9001. /**
  9002. * Prepares the defines related to multiview
  9003. * @param scene The scene we are intending to draw
  9004. * @param defines The defines to update
  9005. */
  9006. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9007. /**
  9008. * Prepares the defines related to the light information passed in parameter
  9009. * @param scene The scene we are intending to draw
  9010. * @param mesh The mesh the effect is compiling for
  9011. * @param light The light the effect is compiling for
  9012. * @param lightIndex The index of the light
  9013. * @param defines The defines to update
  9014. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9015. * @param state Defines the current state regarding what is needed (normals, etc...)
  9016. */
  9017. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9018. needNormals: boolean;
  9019. needRebuild: boolean;
  9020. shadowEnabled: boolean;
  9021. specularEnabled: boolean;
  9022. lightmapMode: boolean;
  9023. }): void;
  9024. /**
  9025. * Prepares the defines related to the light information passed in parameter
  9026. * @param scene The scene we are intending to draw
  9027. * @param mesh The mesh the effect is compiling for
  9028. * @param defines The defines to update
  9029. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9030. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9031. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9032. * @returns true if normals will be required for the rest of the effect
  9033. */
  9034. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9035. /**
  9036. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9037. * @param lightIndex defines the light index
  9038. * @param uniformsList The uniform list
  9039. * @param samplersList The sampler list
  9040. * @param projectedLightTexture defines if projected texture must be used
  9041. * @param uniformBuffersList defines an optional list of uniform buffers
  9042. */
  9043. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9044. /**
  9045. * Prepares the uniforms and samplers list to be used in the effect
  9046. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9047. * @param samplersList The sampler list
  9048. * @param defines The defines helping in the list generation
  9049. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9050. */
  9051. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9052. /**
  9053. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9054. * @param defines The defines to update while falling back
  9055. * @param fallbacks The authorized effect fallbacks
  9056. * @param maxSimultaneousLights The maximum number of lights allowed
  9057. * @param rank the current rank of the Effect
  9058. * @returns The newly affected rank
  9059. */
  9060. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9061. private static _TmpMorphInfluencers;
  9062. /**
  9063. * Prepares the list of attributes required for morph targets according to the effect defines.
  9064. * @param attribs The current list of supported attribs
  9065. * @param mesh The mesh to prepare the morph targets attributes for
  9066. * @param influencers The number of influencers
  9067. */
  9068. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9069. /**
  9070. * Prepares the list of attributes required for morph targets according to the effect defines.
  9071. * @param attribs The current list of supported attribs
  9072. * @param mesh The mesh to prepare the morph targets attributes for
  9073. * @param defines The current Defines of the effect
  9074. */
  9075. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9076. /**
  9077. * Prepares the list of attributes required for bones according to the effect defines.
  9078. * @param attribs The current list of supported attribs
  9079. * @param mesh The mesh to prepare the bones attributes for
  9080. * @param defines The current Defines of the effect
  9081. * @param fallbacks The current efffect fallback strategy
  9082. */
  9083. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9084. /**
  9085. * Check and prepare the list of attributes required for instances according to the effect defines.
  9086. * @param attribs The current list of supported attribs
  9087. * @param defines The current MaterialDefines of the effect
  9088. */
  9089. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9090. /**
  9091. * Add the list of attributes required for instances to the attribs array.
  9092. * @param attribs The current list of supported attribs
  9093. */
  9094. static PushAttributesForInstances(attribs: string[]): void;
  9095. /**
  9096. * Binds the light shadow information to the effect for the given mesh.
  9097. * @param light The light containing the generator
  9098. * @param scene The scene the lights belongs to
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param lightIndex The light index in the effect used to render the mesh
  9101. * @param effect The effect we are binding the data to
  9102. */
  9103. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9104. /**
  9105. * Binds the light information to the effect.
  9106. * @param light The light containing the generator
  9107. * @param effect The effect we are binding the data to
  9108. * @param lightIndex The light index in the effect used to render
  9109. */
  9110. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9111. /**
  9112. * Binds the lights information from the scene to the effect for the given mesh.
  9113. * @param light Light to bind
  9114. * @param lightIndex Light index
  9115. * @param scene The scene where the light belongs to
  9116. * @param mesh The mesh we are binding the information to render
  9117. * @param effect The effect we are binding the data to
  9118. * @param useSpecular Defines if specular is supported
  9119. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9120. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9121. */
  9122. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9123. /**
  9124. * Binds the lights information from the scene to the effect for the given mesh.
  9125. * @param scene The scene the lights belongs to
  9126. * @param mesh The mesh we are binding the information to render
  9127. * @param effect The effect we are binding the data to
  9128. * @param defines The generated defines for the effect
  9129. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9130. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9131. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9132. */
  9133. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9134. private static _tempFogColor;
  9135. /**
  9136. * Binds the fog information from the scene to the effect for the given mesh.
  9137. * @param scene The scene the lights belongs to
  9138. * @param mesh The mesh we are binding the information to render
  9139. * @param effect The effect we are binding the data to
  9140. * @param linearSpace Defines if the fog effect is applied in linear space
  9141. */
  9142. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9143. /**
  9144. * Binds the bones information from the mesh to the effect.
  9145. * @param mesh The mesh we are binding the information to render
  9146. * @param effect The effect we are binding the data to
  9147. */
  9148. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9149. /**
  9150. * Binds the morph targets information from the mesh to the effect.
  9151. * @param abstractMesh The mesh we are binding the information to render
  9152. * @param effect The effect we are binding the data to
  9153. */
  9154. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9155. /**
  9156. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9157. * @param defines The generated defines used in the effect
  9158. * @param effect The effect we are binding the data to
  9159. * @param scene The scene we are willing to render with logarithmic scale for
  9160. */
  9161. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9162. /**
  9163. * Binds the clip plane information from the scene to the effect.
  9164. * @param scene The scene the clip plane information are extracted from
  9165. * @param effect The effect we are binding the data to
  9166. */
  9167. static BindClipPlane(effect: Effect, scene: Scene): void;
  9168. }
  9169. }
  9170. declare module BABYLON {
  9171. /** @hidden */
  9172. export var packingFunctions: {
  9173. name: string;
  9174. shader: string;
  9175. };
  9176. }
  9177. declare module BABYLON {
  9178. /** @hidden */
  9179. export var shadowMapPixelShader: {
  9180. name: string;
  9181. shader: string;
  9182. };
  9183. }
  9184. declare module BABYLON {
  9185. /** @hidden */
  9186. export var bonesDeclaration: {
  9187. name: string;
  9188. shader: string;
  9189. };
  9190. }
  9191. declare module BABYLON {
  9192. /** @hidden */
  9193. export var morphTargetsVertexGlobalDeclaration: {
  9194. name: string;
  9195. shader: string;
  9196. };
  9197. }
  9198. declare module BABYLON {
  9199. /** @hidden */
  9200. export var morphTargetsVertexDeclaration: {
  9201. name: string;
  9202. shader: string;
  9203. };
  9204. }
  9205. declare module BABYLON {
  9206. /** @hidden */
  9207. export var instancesDeclaration: {
  9208. name: string;
  9209. shader: string;
  9210. };
  9211. }
  9212. declare module BABYLON {
  9213. /** @hidden */
  9214. export var helperFunctions: {
  9215. name: string;
  9216. shader: string;
  9217. };
  9218. }
  9219. declare module BABYLON {
  9220. /** @hidden */
  9221. export var morphTargetsVertex: {
  9222. name: string;
  9223. shader: string;
  9224. };
  9225. }
  9226. declare module BABYLON {
  9227. /** @hidden */
  9228. export var instancesVertex: {
  9229. name: string;
  9230. shader: string;
  9231. };
  9232. }
  9233. declare module BABYLON {
  9234. /** @hidden */
  9235. export var bonesVertex: {
  9236. name: string;
  9237. shader: string;
  9238. };
  9239. }
  9240. declare module BABYLON {
  9241. /** @hidden */
  9242. export var shadowMapVertexShader: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module BABYLON {
  9248. /** @hidden */
  9249. export var depthBoxBlurPixelShader: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module BABYLON {
  9255. /**
  9256. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9257. */
  9258. export interface ICustomShaderOptions {
  9259. /**
  9260. * Gets or sets the custom shader name to use
  9261. */
  9262. shaderName: string;
  9263. /**
  9264. * The list of attribute names used in the shader
  9265. */
  9266. attributes?: string[];
  9267. /**
  9268. * The list of unifrom names used in the shader
  9269. */
  9270. uniforms?: string[];
  9271. /**
  9272. * The list of sampler names used in the shader
  9273. */
  9274. samplers?: string[];
  9275. /**
  9276. * The list of defines used in the shader
  9277. */
  9278. defines?: string[];
  9279. }
  9280. /**
  9281. * Interface to implement to create a shadow generator compatible with BJS.
  9282. */
  9283. export interface IShadowGenerator {
  9284. /**
  9285. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9286. * @returns The render target texture if present otherwise, null
  9287. */
  9288. getShadowMap(): Nullable<RenderTargetTexture>;
  9289. /**
  9290. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9291. * @returns The render target texture if the shadow map is present otherwise, null
  9292. */
  9293. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9294. /**
  9295. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9296. * @param subMesh The submesh we want to render in the shadow map
  9297. * @param useInstances Defines wether will draw in the map using instances
  9298. * @returns true if ready otherwise, false
  9299. */
  9300. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9301. /**
  9302. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9303. * @param defines Defines of the material we want to update
  9304. * @param lightIndex Index of the light in the enabled light list of the material
  9305. */
  9306. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9307. /**
  9308. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9309. * defined in the generator but impacting the effect).
  9310. * It implies the unifroms available on the materials are the standard BJS ones.
  9311. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9312. * @param effect The effect we are binfing the information for
  9313. */
  9314. bindShadowLight(lightIndex: string, effect: Effect): void;
  9315. /**
  9316. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9317. * (eq to shadow prjection matrix * light transform matrix)
  9318. * @returns The transform matrix used to create the shadow map
  9319. */
  9320. getTransformMatrix(): Matrix;
  9321. /**
  9322. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9323. * Cube and 2D textures for instance.
  9324. */
  9325. recreateShadowMap(): void;
  9326. /**
  9327. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9328. * @param onCompiled Callback triggered at the and of the effects compilation
  9329. * @param options Sets of optional options forcing the compilation with different modes
  9330. */
  9331. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9332. useInstances: boolean;
  9333. }>): void;
  9334. /**
  9335. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9336. * @param options Sets of optional options forcing the compilation with different modes
  9337. * @returns A promise that resolves when the compilation completes
  9338. */
  9339. forceCompilationAsync(options?: Partial<{
  9340. useInstances: boolean;
  9341. }>): Promise<void>;
  9342. /**
  9343. * Serializes the shadow generator setup to a json object.
  9344. * @returns The serialized JSON object
  9345. */
  9346. serialize(): any;
  9347. /**
  9348. * Disposes the Shadow map and related Textures and effects.
  9349. */
  9350. dispose(): void;
  9351. }
  9352. /**
  9353. * Default implementation IShadowGenerator.
  9354. * This is the main object responsible of generating shadows in the framework.
  9355. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9356. */
  9357. export class ShadowGenerator implements IShadowGenerator {
  9358. /**
  9359. * Shadow generator mode None: no filtering applied.
  9360. */
  9361. static readonly FILTER_NONE: number;
  9362. /**
  9363. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9364. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9365. */
  9366. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9367. /**
  9368. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9369. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9370. */
  9371. static readonly FILTER_POISSONSAMPLING: number;
  9372. /**
  9373. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9374. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9375. */
  9376. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9377. /**
  9378. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9379. * edge artifacts on steep falloff.
  9380. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9381. */
  9382. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9383. /**
  9384. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9385. * edge artifacts on steep falloff.
  9386. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9387. */
  9388. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9389. /**
  9390. * Shadow generator mode PCF: Percentage Closer Filtering
  9391. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9392. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9393. */
  9394. static readonly FILTER_PCF: number;
  9395. /**
  9396. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9397. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9398. * Contact Hardening
  9399. */
  9400. static readonly FILTER_PCSS: number;
  9401. /**
  9402. * Reserved for PCF and PCSS
  9403. * Highest Quality.
  9404. *
  9405. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9406. *
  9407. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9408. */
  9409. static readonly QUALITY_HIGH: number;
  9410. /**
  9411. * Reserved for PCF and PCSS
  9412. * Good tradeoff for quality/perf cross devices
  9413. *
  9414. * Execute PCF on a 3*3 kernel.
  9415. *
  9416. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9417. */
  9418. static readonly QUALITY_MEDIUM: number;
  9419. /**
  9420. * Reserved for PCF and PCSS
  9421. * The lowest quality but the fastest.
  9422. *
  9423. * Execute PCF on a 1*1 kernel.
  9424. *
  9425. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9426. */
  9427. static readonly QUALITY_LOW: number;
  9428. /** Gets or sets the custom shader name to use */
  9429. customShaderOptions: ICustomShaderOptions;
  9430. /**
  9431. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9432. */
  9433. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9434. /**
  9435. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9436. */
  9437. onAfterShadowMapRenderObservable: Observable<Effect>;
  9438. /**
  9439. * Observable triggered before a mesh is rendered in the shadow map.
  9440. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9441. */
  9442. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9443. /**
  9444. * Observable triggered after a mesh is rendered in the shadow map.
  9445. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9446. */
  9447. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9448. private _bias;
  9449. /**
  9450. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9451. */
  9452. /**
  9453. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9454. */
  9455. bias: number;
  9456. private _normalBias;
  9457. /**
  9458. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9459. */
  9460. /**
  9461. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9462. */
  9463. normalBias: number;
  9464. private _blurBoxOffset;
  9465. /**
  9466. * Gets the blur box offset: offset applied during the blur pass.
  9467. * Only useful if useKernelBlur = false
  9468. */
  9469. /**
  9470. * Sets the blur box offset: offset applied during the blur pass.
  9471. * Only useful if useKernelBlur = false
  9472. */
  9473. blurBoxOffset: number;
  9474. private _blurScale;
  9475. /**
  9476. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9477. * 2 means half of the size.
  9478. */
  9479. /**
  9480. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9481. * 2 means half of the size.
  9482. */
  9483. blurScale: number;
  9484. private _blurKernel;
  9485. /**
  9486. * Gets the blur kernel: kernel size of the blur pass.
  9487. * Only useful if useKernelBlur = true
  9488. */
  9489. /**
  9490. * Sets the blur kernel: kernel size of the blur pass.
  9491. * Only useful if useKernelBlur = true
  9492. */
  9493. blurKernel: number;
  9494. private _useKernelBlur;
  9495. /**
  9496. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9497. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9498. */
  9499. /**
  9500. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9501. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9502. */
  9503. useKernelBlur: boolean;
  9504. private _depthScale;
  9505. /**
  9506. * Gets the depth scale used in ESM mode.
  9507. */
  9508. /**
  9509. * Sets the depth scale used in ESM mode.
  9510. * This can override the scale stored on the light.
  9511. */
  9512. depthScale: number;
  9513. private _filter;
  9514. /**
  9515. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9516. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9517. */
  9518. /**
  9519. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9520. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9521. */
  9522. filter: number;
  9523. /**
  9524. * Gets if the current filter is set to Poisson Sampling.
  9525. */
  9526. /**
  9527. * Sets the current filter to Poisson Sampling.
  9528. */
  9529. usePoissonSampling: boolean;
  9530. /**
  9531. * Gets if the current filter is set to ESM.
  9532. */
  9533. /**
  9534. * Sets the current filter is to ESM.
  9535. */
  9536. useExponentialShadowMap: boolean;
  9537. /**
  9538. * Gets if the current filter is set to filtered ESM.
  9539. */
  9540. /**
  9541. * Gets if the current filter is set to filtered ESM.
  9542. */
  9543. useBlurExponentialShadowMap: boolean;
  9544. /**
  9545. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9546. * exponential to prevent steep falloff artifacts).
  9547. */
  9548. /**
  9549. * Sets the current filter to "close ESM" (using the inverse of the
  9550. * exponential to prevent steep falloff artifacts).
  9551. */
  9552. useCloseExponentialShadowMap: boolean;
  9553. /**
  9554. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9555. * exponential to prevent steep falloff artifacts).
  9556. */
  9557. /**
  9558. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9559. * exponential to prevent steep falloff artifacts).
  9560. */
  9561. useBlurCloseExponentialShadowMap: boolean;
  9562. /**
  9563. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9564. */
  9565. /**
  9566. * Sets the current filter to "PCF" (percentage closer filtering).
  9567. */
  9568. usePercentageCloserFiltering: boolean;
  9569. private _filteringQuality;
  9570. /**
  9571. * Gets the PCF or PCSS Quality.
  9572. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9573. */
  9574. /**
  9575. * Sets the PCF or PCSS Quality.
  9576. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9577. */
  9578. filteringQuality: number;
  9579. /**
  9580. * Gets if the current filter is set to "PCSS" (contact hardening).
  9581. */
  9582. /**
  9583. * Sets the current filter to "PCSS" (contact hardening).
  9584. */
  9585. useContactHardeningShadow: boolean;
  9586. private _contactHardeningLightSizeUVRatio;
  9587. /**
  9588. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9589. * Using a ratio helps keeping shape stability independently of the map size.
  9590. *
  9591. * It does not account for the light projection as it was having too much
  9592. * instability during the light setup or during light position changes.
  9593. *
  9594. * Only valid if useContactHardeningShadow is true.
  9595. */
  9596. /**
  9597. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9598. * Using a ratio helps keeping shape stability independently of the map size.
  9599. *
  9600. * It does not account for the light projection as it was having too much
  9601. * instability during the light setup or during light position changes.
  9602. *
  9603. * Only valid if useContactHardeningShadow is true.
  9604. */
  9605. contactHardeningLightSizeUVRatio: number;
  9606. private _darkness;
  9607. /** Gets or sets the actual darkness of a shadow */
  9608. darkness: number;
  9609. /**
  9610. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9611. * 0 means strongest and 1 would means no shadow.
  9612. * @returns the darkness.
  9613. */
  9614. getDarkness(): number;
  9615. /**
  9616. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9617. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9618. * @returns the shadow generator allowing fluent coding.
  9619. */
  9620. setDarkness(darkness: number): ShadowGenerator;
  9621. private _transparencyShadow;
  9622. /** Gets or sets the ability to have transparent shadow */
  9623. transparencyShadow: boolean;
  9624. /**
  9625. * Sets the ability to have transparent shadow (boolean).
  9626. * @param transparent True if transparent else False
  9627. * @returns the shadow generator allowing fluent coding
  9628. */
  9629. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9630. private _shadowMap;
  9631. private _shadowMap2;
  9632. /**
  9633. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9634. * @returns The render target texture if present otherwise, null
  9635. */
  9636. getShadowMap(): Nullable<RenderTargetTexture>;
  9637. /**
  9638. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9639. * @returns The render target texture if the shadow map is present otherwise, null
  9640. */
  9641. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9642. /**
  9643. * Gets the class name of that object
  9644. * @returns "ShadowGenerator"
  9645. */
  9646. getClassName(): string;
  9647. /**
  9648. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9649. * @param mesh Mesh to add
  9650. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9651. * @returns the Shadow Generator itself
  9652. */
  9653. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9654. /**
  9655. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9656. * @param mesh Mesh to remove
  9657. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9658. * @returns the Shadow Generator itself
  9659. */
  9660. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9661. /**
  9662. * Controls the extent to which the shadows fade out at the edge of the frustum
  9663. * Used only by directionals and spots
  9664. */
  9665. frustumEdgeFalloff: number;
  9666. private _light;
  9667. /**
  9668. * Returns the associated light object.
  9669. * @returns the light generating the shadow
  9670. */
  9671. getLight(): IShadowLight;
  9672. /**
  9673. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9674. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9675. * It might on the other hand introduce peter panning.
  9676. */
  9677. forceBackFacesOnly: boolean;
  9678. private _scene;
  9679. private _lightDirection;
  9680. private _effect;
  9681. private _viewMatrix;
  9682. private _projectionMatrix;
  9683. private _transformMatrix;
  9684. private _cachedPosition;
  9685. private _cachedDirection;
  9686. private _cachedDefines;
  9687. private _currentRenderID;
  9688. private _boxBlurPostprocess;
  9689. private _kernelBlurXPostprocess;
  9690. private _kernelBlurYPostprocess;
  9691. private _blurPostProcesses;
  9692. private _mapSize;
  9693. private _currentFaceIndex;
  9694. private _currentFaceIndexCache;
  9695. private _textureType;
  9696. private _defaultTextureMatrix;
  9697. private _storedUniqueId;
  9698. /** @hidden */
  9699. static _SceneComponentInitialization: (scene: Scene) => void;
  9700. /**
  9701. * Creates a ShadowGenerator object.
  9702. * A ShadowGenerator is the required tool to use the shadows.
  9703. * Each light casting shadows needs to use its own ShadowGenerator.
  9704. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9705. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9706. * @param light The light object generating the shadows.
  9707. * @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.
  9708. */
  9709. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9710. private _initializeGenerator;
  9711. private _initializeShadowMap;
  9712. private _initializeBlurRTTAndPostProcesses;
  9713. private _renderForShadowMap;
  9714. private _renderSubMeshForShadowMap;
  9715. private _applyFilterValues;
  9716. /**
  9717. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9718. * @param onCompiled Callback triggered at the and of the effects compilation
  9719. * @param options Sets of optional options forcing the compilation with different modes
  9720. */
  9721. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9722. useInstances: boolean;
  9723. }>): void;
  9724. /**
  9725. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9726. * @param options Sets of optional options forcing the compilation with different modes
  9727. * @returns A promise that resolves when the compilation completes
  9728. */
  9729. forceCompilationAsync(options?: Partial<{
  9730. useInstances: boolean;
  9731. }>): Promise<void>;
  9732. /**
  9733. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9734. * @param subMesh The submesh we want to render in the shadow map
  9735. * @param useInstances Defines wether will draw in the map using instances
  9736. * @returns true if ready otherwise, false
  9737. */
  9738. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9739. /**
  9740. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9741. * @param defines Defines of the material we want to update
  9742. * @param lightIndex Index of the light in the enabled light list of the material
  9743. */
  9744. prepareDefines(defines: any, lightIndex: number): void;
  9745. /**
  9746. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9747. * defined in the generator but impacting the effect).
  9748. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9749. * @param effect The effect we are binfing the information for
  9750. */
  9751. bindShadowLight(lightIndex: string, effect: Effect): void;
  9752. /**
  9753. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9754. * (eq to shadow prjection matrix * light transform matrix)
  9755. * @returns The transform matrix used to create the shadow map
  9756. */
  9757. getTransformMatrix(): Matrix;
  9758. /**
  9759. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9760. * Cube and 2D textures for instance.
  9761. */
  9762. recreateShadowMap(): void;
  9763. private _disposeBlurPostProcesses;
  9764. private _disposeRTTandPostProcesses;
  9765. /**
  9766. * Disposes the ShadowGenerator.
  9767. * Returns nothing.
  9768. */
  9769. dispose(): void;
  9770. /**
  9771. * Serializes the shadow generator setup to a json object.
  9772. * @returns The serialized JSON object
  9773. */
  9774. serialize(): any;
  9775. /**
  9776. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9777. * @param parsedShadowGenerator The JSON object to parse
  9778. * @param scene The scene to create the shadow map for
  9779. * @returns The parsed shadow generator
  9780. */
  9781. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9782. }
  9783. }
  9784. declare module BABYLON {
  9785. /**
  9786. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9787. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9788. * 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.
  9789. */
  9790. export abstract class Light extends Node {
  9791. /**
  9792. * Falloff Default: light is falling off following the material specification:
  9793. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9794. */
  9795. static readonly FALLOFF_DEFAULT: number;
  9796. /**
  9797. * Falloff Physical: light is falling off following the inverse squared distance law.
  9798. */
  9799. static readonly FALLOFF_PHYSICAL: number;
  9800. /**
  9801. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9802. * to enhance interoperability with other engines.
  9803. */
  9804. static readonly FALLOFF_GLTF: number;
  9805. /**
  9806. * Falloff Standard: light is falling off like in the standard material
  9807. * to enhance interoperability with other materials.
  9808. */
  9809. static readonly FALLOFF_STANDARD: number;
  9810. /**
  9811. * If every light affecting the material is in this lightmapMode,
  9812. * material.lightmapTexture adds or multiplies
  9813. * (depends on material.useLightmapAsShadowmap)
  9814. * after every other light calculations.
  9815. */
  9816. static readonly LIGHTMAP_DEFAULT: number;
  9817. /**
  9818. * material.lightmapTexture as only diffuse lighting from this light
  9819. * adds only specular lighting from this light
  9820. * adds dynamic shadows
  9821. */
  9822. static readonly LIGHTMAP_SPECULAR: number;
  9823. /**
  9824. * material.lightmapTexture as only lighting
  9825. * no light calculation from this light
  9826. * only adds dynamic shadows from this light
  9827. */
  9828. static readonly LIGHTMAP_SHADOWSONLY: number;
  9829. /**
  9830. * Each light type uses the default quantity according to its type:
  9831. * point/spot lights use luminous intensity
  9832. * directional lights use illuminance
  9833. */
  9834. static readonly INTENSITYMODE_AUTOMATIC: number;
  9835. /**
  9836. * lumen (lm)
  9837. */
  9838. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9839. /**
  9840. * candela (lm/sr)
  9841. */
  9842. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9843. /**
  9844. * lux (lm/m^2)
  9845. */
  9846. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9847. /**
  9848. * nit (cd/m^2)
  9849. */
  9850. static readonly INTENSITYMODE_LUMINANCE: number;
  9851. /**
  9852. * Light type const id of the point light.
  9853. */
  9854. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9855. /**
  9856. * Light type const id of the directional light.
  9857. */
  9858. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9859. /**
  9860. * Light type const id of the spot light.
  9861. */
  9862. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9863. /**
  9864. * Light type const id of the hemispheric light.
  9865. */
  9866. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9867. /**
  9868. * Diffuse gives the basic color to an object.
  9869. */
  9870. diffuse: Color3;
  9871. /**
  9872. * Specular produces a highlight color on an object.
  9873. * Note: This is note affecting PBR materials.
  9874. */
  9875. specular: Color3;
  9876. /**
  9877. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9878. * falling off base on range or angle.
  9879. * This can be set to any values in Light.FALLOFF_x.
  9880. *
  9881. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9882. * other types of materials.
  9883. */
  9884. falloffType: number;
  9885. /**
  9886. * Strength of the light.
  9887. * Note: By default it is define in the framework own unit.
  9888. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9889. */
  9890. intensity: number;
  9891. private _range;
  9892. protected _inverseSquaredRange: number;
  9893. /**
  9894. * Defines how far from the source the light is impacting in scene units.
  9895. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9896. */
  9897. /**
  9898. * Defines how far from the source the light is impacting in scene units.
  9899. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9900. */
  9901. range: number;
  9902. /**
  9903. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9904. * of light.
  9905. */
  9906. private _photometricScale;
  9907. private _intensityMode;
  9908. /**
  9909. * Gets the photometric scale used to interpret the intensity.
  9910. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9911. */
  9912. /**
  9913. * Sets the photometric scale used to interpret the intensity.
  9914. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9915. */
  9916. intensityMode: number;
  9917. private _radius;
  9918. /**
  9919. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9920. */
  9921. /**
  9922. * sets the light radius used by PBR Materials to simulate soft area lights.
  9923. */
  9924. radius: number;
  9925. private _renderPriority;
  9926. /**
  9927. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9928. * exceeding the number allowed of the materials.
  9929. */
  9930. renderPriority: number;
  9931. private _shadowEnabled;
  9932. /**
  9933. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9934. * the current shadow generator.
  9935. */
  9936. /**
  9937. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9938. * the current shadow generator.
  9939. */
  9940. shadowEnabled: boolean;
  9941. private _includedOnlyMeshes;
  9942. /**
  9943. * Gets the only meshes impacted by this light.
  9944. */
  9945. /**
  9946. * Sets the only meshes impacted by this light.
  9947. */
  9948. includedOnlyMeshes: AbstractMesh[];
  9949. private _excludedMeshes;
  9950. /**
  9951. * Gets the meshes not impacted by this light.
  9952. */
  9953. /**
  9954. * Sets the meshes not impacted by this light.
  9955. */
  9956. excludedMeshes: AbstractMesh[];
  9957. private _excludeWithLayerMask;
  9958. /**
  9959. * Gets the layer id use to find what meshes are not impacted by the light.
  9960. * Inactive if 0
  9961. */
  9962. /**
  9963. * Sets the layer id use to find what meshes are not impacted by the light.
  9964. * Inactive if 0
  9965. */
  9966. excludeWithLayerMask: number;
  9967. private _includeOnlyWithLayerMask;
  9968. /**
  9969. * Gets the layer id use to find what meshes are impacted by the light.
  9970. * Inactive if 0
  9971. */
  9972. /**
  9973. * Sets the layer id use to find what meshes are impacted by the light.
  9974. * Inactive if 0
  9975. */
  9976. includeOnlyWithLayerMask: number;
  9977. private _lightmapMode;
  9978. /**
  9979. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9980. */
  9981. /**
  9982. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9983. */
  9984. lightmapMode: number;
  9985. /**
  9986. * Shadow generator associted to the light.
  9987. * @hidden Internal use only.
  9988. */
  9989. _shadowGenerator: Nullable<IShadowGenerator>;
  9990. /**
  9991. * @hidden Internal use only.
  9992. */
  9993. _excludedMeshesIds: string[];
  9994. /**
  9995. * @hidden Internal use only.
  9996. */
  9997. _includedOnlyMeshesIds: string[];
  9998. /**
  9999. * The current light unifom buffer.
  10000. * @hidden Internal use only.
  10001. */
  10002. _uniformBuffer: UniformBuffer;
  10003. /**
  10004. * Creates a Light object in the scene.
  10005. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10006. * @param name The firendly name of the light
  10007. * @param scene The scene the light belongs too
  10008. */
  10009. constructor(name: string, scene: Scene);
  10010. protected abstract _buildUniformLayout(): void;
  10011. /**
  10012. * Sets the passed Effect "effect" with the Light information.
  10013. * @param effect The effect to update
  10014. * @param lightIndex The index of the light in the effect to update
  10015. * @returns The light
  10016. */
  10017. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10018. /**
  10019. * Sets the passed Effect "effect" with the Light information.
  10020. * @param effect The effect to update
  10021. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10022. * @returns The light
  10023. */
  10024. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10025. /**
  10026. * Returns the string "Light".
  10027. * @returns the class name
  10028. */
  10029. getClassName(): string;
  10030. /** @hidden */
  10031. readonly _isLight: boolean;
  10032. /**
  10033. * Converts the light information to a readable string for debug purpose.
  10034. * @param fullDetails Supports for multiple levels of logging within scene loading
  10035. * @returns the human readable light info
  10036. */
  10037. toString(fullDetails?: boolean): string;
  10038. /** @hidden */
  10039. protected _syncParentEnabledState(): void;
  10040. /**
  10041. * Set the enabled state of this node.
  10042. * @param value - the new enabled state
  10043. */
  10044. setEnabled(value: boolean): void;
  10045. /**
  10046. * Returns the Light associated shadow generator if any.
  10047. * @return the associated shadow generator.
  10048. */
  10049. getShadowGenerator(): Nullable<IShadowGenerator>;
  10050. /**
  10051. * Returns a Vector3, the absolute light position in the World.
  10052. * @returns the world space position of the light
  10053. */
  10054. getAbsolutePosition(): Vector3;
  10055. /**
  10056. * Specifies if the light will affect the passed mesh.
  10057. * @param mesh The mesh to test against the light
  10058. * @return true the mesh is affected otherwise, false.
  10059. */
  10060. canAffectMesh(mesh: AbstractMesh): boolean;
  10061. /**
  10062. * Sort function to order lights for rendering.
  10063. * @param a First Light object to compare to second.
  10064. * @param b Second Light object to compare first.
  10065. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10066. */
  10067. static CompareLightsPriority(a: Light, b: Light): number;
  10068. /**
  10069. * Releases resources associated with this node.
  10070. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10071. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10072. */
  10073. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10074. /**
  10075. * Returns the light type ID (integer).
  10076. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10077. */
  10078. getTypeID(): number;
  10079. /**
  10080. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10081. * @returns the scaled intensity in intensity mode unit
  10082. */
  10083. getScaledIntensity(): number;
  10084. /**
  10085. * Returns a new Light object, named "name", from the current one.
  10086. * @param name The name of the cloned light
  10087. * @returns the new created light
  10088. */
  10089. clone(name: string): Nullable<Light>;
  10090. /**
  10091. * Serializes the current light into a Serialization object.
  10092. * @returns the serialized object.
  10093. */
  10094. serialize(): any;
  10095. /**
  10096. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10097. * This new light is named "name" and added to the passed scene.
  10098. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10099. * @param name The friendly name of the light
  10100. * @param scene The scene the new light will belong to
  10101. * @returns the constructor function
  10102. */
  10103. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10104. /**
  10105. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10106. * @param parsedLight The JSON representation of the light
  10107. * @param scene The scene to create the parsed light in
  10108. * @returns the created light after parsing
  10109. */
  10110. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10111. private _hookArrayForExcluded;
  10112. private _hookArrayForIncludedOnly;
  10113. private _resyncMeshes;
  10114. /**
  10115. * Forces the meshes to update their light related information in their rendering used effects
  10116. * @hidden Internal Use Only
  10117. */
  10118. _markMeshesAsLightDirty(): void;
  10119. /**
  10120. * Recomputes the cached photometric scale if needed.
  10121. */
  10122. private _computePhotometricScale;
  10123. /**
  10124. * Returns the Photometric Scale according to the light type and intensity mode.
  10125. */
  10126. private _getPhotometricScale;
  10127. /**
  10128. * Reorder the light in the scene according to their defined priority.
  10129. * @hidden Internal Use Only
  10130. */
  10131. _reorderLightsInScene(): void;
  10132. /**
  10133. * Prepares the list of defines specific to the light type.
  10134. * @param defines the list of defines
  10135. * @param lightIndex defines the index of the light for the effect
  10136. */
  10137. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10138. }
  10139. }
  10140. declare module BABYLON {
  10141. /**
  10142. * Interface used to define Action
  10143. */
  10144. export interface IAction {
  10145. /**
  10146. * Trigger for the action
  10147. */
  10148. trigger: number;
  10149. /** Options of the trigger */
  10150. triggerOptions: any;
  10151. /**
  10152. * Gets the trigger parameters
  10153. * @returns the trigger parameters
  10154. */
  10155. getTriggerParameter(): any;
  10156. /**
  10157. * Internal only - executes current action event
  10158. * @hidden
  10159. */
  10160. _executeCurrent(evt?: ActionEvent): void;
  10161. /**
  10162. * Serialize placeholder for child classes
  10163. * @param parent of child
  10164. * @returns the serialized object
  10165. */
  10166. serialize(parent: any): any;
  10167. /**
  10168. * Internal only
  10169. * @hidden
  10170. */
  10171. _prepare(): void;
  10172. /**
  10173. * Internal only - manager for action
  10174. * @hidden
  10175. */
  10176. _actionManager: AbstractActionManager;
  10177. /**
  10178. * Adds action to chain of actions, may be a DoNothingAction
  10179. * @param action defines the next action to execute
  10180. * @returns The action passed in
  10181. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10182. */
  10183. then(action: IAction): IAction;
  10184. }
  10185. /**
  10186. * The action to be carried out following a trigger
  10187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10188. */
  10189. export class Action implements IAction {
  10190. /** the trigger, with or without parameters, for the action */
  10191. triggerOptions: any;
  10192. /**
  10193. * Trigger for the action
  10194. */
  10195. trigger: number;
  10196. /**
  10197. * Internal only - manager for action
  10198. * @hidden
  10199. */
  10200. _actionManager: ActionManager;
  10201. private _nextActiveAction;
  10202. private _child;
  10203. private _condition?;
  10204. private _triggerParameter;
  10205. /**
  10206. * An event triggered prior to action being executed.
  10207. */
  10208. onBeforeExecuteObservable: Observable<Action>;
  10209. /**
  10210. * Creates a new Action
  10211. * @param triggerOptions the trigger, with or without parameters, for the action
  10212. * @param condition an optional determinant of action
  10213. */
  10214. constructor(
  10215. /** the trigger, with or without parameters, for the action */
  10216. triggerOptions: any, condition?: Condition);
  10217. /**
  10218. * Internal only
  10219. * @hidden
  10220. */
  10221. _prepare(): void;
  10222. /**
  10223. * Gets the trigger parameters
  10224. * @returns the trigger parameters
  10225. */
  10226. getTriggerParameter(): any;
  10227. /**
  10228. * Internal only - executes current action event
  10229. * @hidden
  10230. */
  10231. _executeCurrent(evt?: ActionEvent): void;
  10232. /**
  10233. * Execute placeholder for child classes
  10234. * @param evt optional action event
  10235. */
  10236. execute(evt?: ActionEvent): void;
  10237. /**
  10238. * Skips to next active action
  10239. */
  10240. skipToNextActiveAction(): void;
  10241. /**
  10242. * Adds action to chain of actions, may be a DoNothingAction
  10243. * @param action defines the next action to execute
  10244. * @returns The action passed in
  10245. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10246. */
  10247. then(action: Action): Action;
  10248. /**
  10249. * Internal only
  10250. * @hidden
  10251. */
  10252. _getProperty(propertyPath: string): string;
  10253. /**
  10254. * Internal only
  10255. * @hidden
  10256. */
  10257. _getEffectiveTarget(target: any, propertyPath: string): any;
  10258. /**
  10259. * Serialize placeholder for child classes
  10260. * @param parent of child
  10261. * @returns the serialized object
  10262. */
  10263. serialize(parent: any): any;
  10264. /**
  10265. * Internal only called by serialize
  10266. * @hidden
  10267. */
  10268. protected _serialize(serializedAction: any, parent?: any): any;
  10269. /**
  10270. * Internal only
  10271. * @hidden
  10272. */
  10273. static _SerializeValueAsString: (value: any) => string;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. static _GetTargetProperty: (target: Node | Scene) => {
  10279. name: string;
  10280. targetType: string;
  10281. value: string;
  10282. };
  10283. }
  10284. }
  10285. declare module BABYLON {
  10286. /**
  10287. * A Condition applied to an Action
  10288. */
  10289. export class Condition {
  10290. /**
  10291. * Internal only - manager for action
  10292. * @hidden
  10293. */
  10294. _actionManager: ActionManager;
  10295. /**
  10296. * Internal only
  10297. * @hidden
  10298. */
  10299. _evaluationId: number;
  10300. /**
  10301. * Internal only
  10302. * @hidden
  10303. */
  10304. _currentResult: boolean;
  10305. /**
  10306. * Creates a new Condition
  10307. * @param actionManager the manager of the action the condition is applied to
  10308. */
  10309. constructor(actionManager: ActionManager);
  10310. /**
  10311. * Check if the current condition is valid
  10312. * @returns a boolean
  10313. */
  10314. isValid(): boolean;
  10315. /**
  10316. * Internal only
  10317. * @hidden
  10318. */
  10319. _getProperty(propertyPath: string): string;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. _getEffectiveTarget(target: any, propertyPath: string): any;
  10325. /**
  10326. * Serialize placeholder for child classes
  10327. * @returns the serialized object
  10328. */
  10329. serialize(): any;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. protected _serialize(serializedCondition: any): any;
  10335. }
  10336. /**
  10337. * Defines specific conditional operators as extensions of Condition
  10338. */
  10339. export class ValueCondition extends Condition {
  10340. /** path to specify the property of the target the conditional operator uses */
  10341. propertyPath: string;
  10342. /** the value compared by the conditional operator against the current value of the property */
  10343. value: any;
  10344. /** the conditional operator, default ValueCondition.IsEqual */
  10345. operator: number;
  10346. /**
  10347. * Internal only
  10348. * @hidden
  10349. */
  10350. private static _IsEqual;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */
  10355. private static _IsDifferent;
  10356. /**
  10357. * Internal only
  10358. * @hidden
  10359. */
  10360. private static _IsGreater;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. private static _IsLesser;
  10366. /**
  10367. * returns the number for IsEqual
  10368. */
  10369. static readonly IsEqual: number;
  10370. /**
  10371. * Returns the number for IsDifferent
  10372. */
  10373. static readonly IsDifferent: number;
  10374. /**
  10375. * Returns the number for IsGreater
  10376. */
  10377. static readonly IsGreater: number;
  10378. /**
  10379. * Returns the number for IsLesser
  10380. */
  10381. static readonly IsLesser: number;
  10382. /**
  10383. * Internal only The action manager for the condition
  10384. * @hidden
  10385. */
  10386. _actionManager: ActionManager;
  10387. /**
  10388. * Internal only
  10389. * @hidden
  10390. */
  10391. private _target;
  10392. /**
  10393. * Internal only
  10394. * @hidden
  10395. */
  10396. private _effectiveTarget;
  10397. /**
  10398. * Internal only
  10399. * @hidden
  10400. */
  10401. private _property;
  10402. /**
  10403. * Creates a new ValueCondition
  10404. * @param actionManager manager for the action the condition applies to
  10405. * @param target for the action
  10406. * @param propertyPath path to specify the property of the target the conditional operator uses
  10407. * @param value the value compared by the conditional operator against the current value of the property
  10408. * @param operator the conditional operator, default ValueCondition.IsEqual
  10409. */
  10410. constructor(actionManager: ActionManager, target: any,
  10411. /** path to specify the property of the target the conditional operator uses */
  10412. propertyPath: string,
  10413. /** the value compared by the conditional operator against the current value of the property */
  10414. value: any,
  10415. /** the conditional operator, default ValueCondition.IsEqual */
  10416. operator?: number);
  10417. /**
  10418. * Compares the given value with the property value for the specified conditional operator
  10419. * @returns the result of the comparison
  10420. */
  10421. isValid(): boolean;
  10422. /**
  10423. * Serialize the ValueCondition into a JSON compatible object
  10424. * @returns serialization object
  10425. */
  10426. serialize(): any;
  10427. /**
  10428. * Gets the name of the conditional operator for the ValueCondition
  10429. * @param operator the conditional operator
  10430. * @returns the name
  10431. */
  10432. static GetOperatorName(operator: number): string;
  10433. }
  10434. /**
  10435. * Defines a predicate condition as an extension of Condition
  10436. */
  10437. export class PredicateCondition extends Condition {
  10438. /** defines the predicate function used to validate the condition */
  10439. predicate: () => boolean;
  10440. /**
  10441. * Internal only - manager for action
  10442. * @hidden
  10443. */
  10444. _actionManager: ActionManager;
  10445. /**
  10446. * Creates a new PredicateCondition
  10447. * @param actionManager manager for the action the condition applies to
  10448. * @param predicate defines the predicate function used to validate the condition
  10449. */
  10450. constructor(actionManager: ActionManager,
  10451. /** defines the predicate function used to validate the condition */
  10452. predicate: () => boolean);
  10453. /**
  10454. * @returns the validity of the predicate condition
  10455. */
  10456. isValid(): boolean;
  10457. }
  10458. /**
  10459. * Defines a state condition as an extension of Condition
  10460. */
  10461. export class StateCondition extends Condition {
  10462. /** Value to compare with target state */
  10463. value: string;
  10464. /**
  10465. * Internal only - manager for action
  10466. * @hidden
  10467. */
  10468. _actionManager: ActionManager;
  10469. /**
  10470. * Internal only
  10471. * @hidden
  10472. */
  10473. private _target;
  10474. /**
  10475. * Creates a new StateCondition
  10476. * @param actionManager manager for the action the condition applies to
  10477. * @param target of the condition
  10478. * @param value to compare with target state
  10479. */
  10480. constructor(actionManager: ActionManager, target: any,
  10481. /** Value to compare with target state */
  10482. value: string);
  10483. /**
  10484. * Gets a boolean indicating if the current condition is met
  10485. * @returns the validity of the state
  10486. */
  10487. isValid(): boolean;
  10488. /**
  10489. * Serialize the StateCondition into a JSON compatible object
  10490. * @returns serialization object
  10491. */
  10492. serialize(): any;
  10493. }
  10494. }
  10495. declare module BABYLON {
  10496. /**
  10497. * This defines an action responsible to toggle a boolean once triggered.
  10498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10499. */
  10500. export class SwitchBooleanAction extends Action {
  10501. /**
  10502. * The path to the boolean property in the target object
  10503. */
  10504. propertyPath: string;
  10505. private _target;
  10506. private _effectiveTarget;
  10507. private _property;
  10508. /**
  10509. * Instantiate the action
  10510. * @param triggerOptions defines the trigger options
  10511. * @param target defines the object containing the boolean
  10512. * @param propertyPath defines the path to the boolean property in the target object
  10513. * @param condition defines the trigger related conditions
  10514. */
  10515. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10516. /** @hidden */
  10517. _prepare(): void;
  10518. /**
  10519. * Execute the action toggle the boolean value.
  10520. */
  10521. execute(): void;
  10522. /**
  10523. * Serializes the actions and its related information.
  10524. * @param parent defines the object to serialize in
  10525. * @returns the serialized object
  10526. */
  10527. serialize(parent: any): any;
  10528. }
  10529. /**
  10530. * This defines an action responsible to set a the state field of the target
  10531. * to a desired value once triggered.
  10532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10533. */
  10534. export class SetStateAction extends Action {
  10535. /**
  10536. * The value to store in the state field.
  10537. */
  10538. value: string;
  10539. private _target;
  10540. /**
  10541. * Instantiate the action
  10542. * @param triggerOptions defines the trigger options
  10543. * @param target defines the object containing the state property
  10544. * @param value defines the value to store in the state field
  10545. * @param condition defines the trigger related conditions
  10546. */
  10547. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10548. /**
  10549. * Execute the action and store the value on the target state property.
  10550. */
  10551. execute(): void;
  10552. /**
  10553. * Serializes the actions and its related information.
  10554. * @param parent defines the object to serialize in
  10555. * @returns the serialized object
  10556. */
  10557. serialize(parent: any): any;
  10558. }
  10559. /**
  10560. * This defines an action responsible to set a property of the target
  10561. * to a desired value once triggered.
  10562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10563. */
  10564. export class SetValueAction extends Action {
  10565. /**
  10566. * The path of the property to set in the target.
  10567. */
  10568. propertyPath: string;
  10569. /**
  10570. * The value to set in the property
  10571. */
  10572. value: any;
  10573. private _target;
  10574. private _effectiveTarget;
  10575. private _property;
  10576. /**
  10577. * Instantiate the action
  10578. * @param triggerOptions defines the trigger options
  10579. * @param target defines the object containing the property
  10580. * @param propertyPath defines the path of the property to set in the target
  10581. * @param value defines the value to set in the property
  10582. * @param condition defines the trigger related conditions
  10583. */
  10584. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10585. /** @hidden */
  10586. _prepare(): void;
  10587. /**
  10588. * Execute the action and set the targetted property to the desired value.
  10589. */
  10590. execute(): void;
  10591. /**
  10592. * Serializes the actions and its related information.
  10593. * @param parent defines the object to serialize in
  10594. * @returns the serialized object
  10595. */
  10596. serialize(parent: any): any;
  10597. }
  10598. /**
  10599. * This defines an action responsible to increment the target value
  10600. * to a desired value once triggered.
  10601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10602. */
  10603. export class IncrementValueAction extends Action {
  10604. /**
  10605. * The path of the property to increment in the target.
  10606. */
  10607. propertyPath: string;
  10608. /**
  10609. * The value we should increment the property by.
  10610. */
  10611. value: any;
  10612. private _target;
  10613. private _effectiveTarget;
  10614. private _property;
  10615. /**
  10616. * Instantiate the action
  10617. * @param triggerOptions defines the trigger options
  10618. * @param target defines the object containing the property
  10619. * @param propertyPath defines the path of the property to increment in the target
  10620. * @param value defines the value value we should increment the property by
  10621. * @param condition defines the trigger related conditions
  10622. */
  10623. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10624. /** @hidden */
  10625. _prepare(): void;
  10626. /**
  10627. * Execute the action and increment the target of the value amount.
  10628. */
  10629. execute(): void;
  10630. /**
  10631. * Serializes the actions and its related information.
  10632. * @param parent defines the object to serialize in
  10633. * @returns the serialized object
  10634. */
  10635. serialize(parent: any): any;
  10636. }
  10637. /**
  10638. * This defines an action responsible to start an animation once triggered.
  10639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10640. */
  10641. export class PlayAnimationAction extends Action {
  10642. /**
  10643. * Where the animation should start (animation frame)
  10644. */
  10645. from: number;
  10646. /**
  10647. * Where the animation should stop (animation frame)
  10648. */
  10649. to: number;
  10650. /**
  10651. * Define if the animation should loop or stop after the first play.
  10652. */
  10653. loop?: boolean;
  10654. private _target;
  10655. /**
  10656. * Instantiate the action
  10657. * @param triggerOptions defines the trigger options
  10658. * @param target defines the target animation or animation name
  10659. * @param from defines from where the animation should start (animation frame)
  10660. * @param end defines where the animation should stop (animation frame)
  10661. * @param loop defines if the animation should loop or stop after the first play
  10662. * @param condition defines the trigger related conditions
  10663. */
  10664. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10665. /** @hidden */
  10666. _prepare(): void;
  10667. /**
  10668. * Execute the action and play the animation.
  10669. */
  10670. execute(): void;
  10671. /**
  10672. * Serializes the actions and its related information.
  10673. * @param parent defines the object to serialize in
  10674. * @returns the serialized object
  10675. */
  10676. serialize(parent: any): any;
  10677. }
  10678. /**
  10679. * This defines an action responsible to stop an animation once triggered.
  10680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10681. */
  10682. export class StopAnimationAction extends Action {
  10683. private _target;
  10684. /**
  10685. * Instantiate the action
  10686. * @param triggerOptions defines the trigger options
  10687. * @param target defines the target animation or animation name
  10688. * @param condition defines the trigger related conditions
  10689. */
  10690. constructor(triggerOptions: any, target: any, condition?: Condition);
  10691. /** @hidden */
  10692. _prepare(): void;
  10693. /**
  10694. * Execute the action and stop the animation.
  10695. */
  10696. execute(): void;
  10697. /**
  10698. * Serializes the actions and its related information.
  10699. * @param parent defines the object to serialize in
  10700. * @returns the serialized object
  10701. */
  10702. serialize(parent: any): any;
  10703. }
  10704. /**
  10705. * This defines an action responsible that does nothing once triggered.
  10706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10707. */
  10708. export class DoNothingAction extends Action {
  10709. /**
  10710. * Instantiate the action
  10711. * @param triggerOptions defines the trigger options
  10712. * @param condition defines the trigger related conditions
  10713. */
  10714. constructor(triggerOptions?: any, condition?: Condition);
  10715. /**
  10716. * Execute the action and do nothing.
  10717. */
  10718. execute(): void;
  10719. /**
  10720. * Serializes the actions and its related information.
  10721. * @param parent defines the object to serialize in
  10722. * @returns the serialized object
  10723. */
  10724. serialize(parent: any): any;
  10725. }
  10726. /**
  10727. * This defines an action responsible to trigger several actions once triggered.
  10728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10729. */
  10730. export class CombineAction extends Action {
  10731. /**
  10732. * The list of aggregated animations to run.
  10733. */
  10734. children: Action[];
  10735. /**
  10736. * Instantiate the action
  10737. * @param triggerOptions defines the trigger options
  10738. * @param children defines the list of aggregated animations to run
  10739. * @param condition defines the trigger related conditions
  10740. */
  10741. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10742. /** @hidden */
  10743. _prepare(): void;
  10744. /**
  10745. * Execute the action and executes all the aggregated actions.
  10746. */
  10747. execute(evt: ActionEvent): void;
  10748. /**
  10749. * Serializes the actions and its related information.
  10750. * @param parent defines the object to serialize in
  10751. * @returns the serialized object
  10752. */
  10753. serialize(parent: any): any;
  10754. }
  10755. /**
  10756. * This defines an action responsible to run code (external event) once triggered.
  10757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10758. */
  10759. export class ExecuteCodeAction extends Action {
  10760. /**
  10761. * The callback function to run.
  10762. */
  10763. func: (evt: ActionEvent) => void;
  10764. /**
  10765. * Instantiate the action
  10766. * @param triggerOptions defines the trigger options
  10767. * @param func defines the callback function to run
  10768. * @param condition defines the trigger related conditions
  10769. */
  10770. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10771. /**
  10772. * Execute the action and run the attached code.
  10773. */
  10774. execute(evt: ActionEvent): void;
  10775. }
  10776. /**
  10777. * This defines an action responsible to set the parent property of the target once triggered.
  10778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10779. */
  10780. export class SetParentAction extends Action {
  10781. private _parent;
  10782. private _target;
  10783. /**
  10784. * Instantiate the action
  10785. * @param triggerOptions defines the trigger options
  10786. * @param target defines the target containing the parent property
  10787. * @param parent defines from where the animation should start (animation frame)
  10788. * @param condition defines the trigger related conditions
  10789. */
  10790. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10791. /** @hidden */
  10792. _prepare(): void;
  10793. /**
  10794. * Execute the action and set the parent property.
  10795. */
  10796. execute(): void;
  10797. /**
  10798. * Serializes the actions and its related information.
  10799. * @param parent defines the object to serialize in
  10800. * @returns the serialized object
  10801. */
  10802. serialize(parent: any): any;
  10803. }
  10804. }
  10805. declare module BABYLON {
  10806. /**
  10807. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10808. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10810. */
  10811. export class ActionManager extends AbstractActionManager {
  10812. /**
  10813. * Nothing
  10814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10815. */
  10816. static readonly NothingTrigger: number;
  10817. /**
  10818. * On pick
  10819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10820. */
  10821. static readonly OnPickTrigger: number;
  10822. /**
  10823. * On left pick
  10824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10825. */
  10826. static readonly OnLeftPickTrigger: number;
  10827. /**
  10828. * On right pick
  10829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10830. */
  10831. static readonly OnRightPickTrigger: number;
  10832. /**
  10833. * On center pick
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10835. */
  10836. static readonly OnCenterPickTrigger: number;
  10837. /**
  10838. * On pick down
  10839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10840. */
  10841. static readonly OnPickDownTrigger: number;
  10842. /**
  10843. * On double pick
  10844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10845. */
  10846. static readonly OnDoublePickTrigger: number;
  10847. /**
  10848. * On pick up
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10850. */
  10851. static readonly OnPickUpTrigger: number;
  10852. /**
  10853. * On pick out.
  10854. * This trigger will only be raised if you also declared a OnPickDown
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10856. */
  10857. static readonly OnPickOutTrigger: number;
  10858. /**
  10859. * On long press
  10860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10861. */
  10862. static readonly OnLongPressTrigger: number;
  10863. /**
  10864. * On pointer over
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10866. */
  10867. static readonly OnPointerOverTrigger: number;
  10868. /**
  10869. * On pointer out
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10871. */
  10872. static readonly OnPointerOutTrigger: number;
  10873. /**
  10874. * On every frame
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10876. */
  10877. static readonly OnEveryFrameTrigger: number;
  10878. /**
  10879. * On intersection enter
  10880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10881. */
  10882. static readonly OnIntersectionEnterTrigger: number;
  10883. /**
  10884. * On intersection exit
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10886. */
  10887. static readonly OnIntersectionExitTrigger: number;
  10888. /**
  10889. * On key down
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10891. */
  10892. static readonly OnKeyDownTrigger: number;
  10893. /**
  10894. * On key up
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10896. */
  10897. static readonly OnKeyUpTrigger: number;
  10898. private _scene;
  10899. /**
  10900. * Creates a new action manager
  10901. * @param scene defines the hosting scene
  10902. */
  10903. constructor(scene: Scene);
  10904. /**
  10905. * Releases all associated resources
  10906. */
  10907. dispose(): void;
  10908. /**
  10909. * Gets hosting scene
  10910. * @returns the hosting scene
  10911. */
  10912. getScene(): Scene;
  10913. /**
  10914. * Does this action manager handles actions of any of the given triggers
  10915. * @param triggers defines the triggers to be tested
  10916. * @return a boolean indicating whether one (or more) of the triggers is handled
  10917. */
  10918. hasSpecificTriggers(triggers: number[]): boolean;
  10919. /**
  10920. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10921. * speed.
  10922. * @param triggerA defines the trigger to be tested
  10923. * @param triggerB defines the trigger to be tested
  10924. * @return a boolean indicating whether one (or more) of the triggers is handled
  10925. */
  10926. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10927. /**
  10928. * Does this action manager handles actions of a given trigger
  10929. * @param trigger defines the trigger to be tested
  10930. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10931. * @return whether the trigger is handled
  10932. */
  10933. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10934. /**
  10935. * Does this action manager has pointer triggers
  10936. */
  10937. readonly hasPointerTriggers: boolean;
  10938. /**
  10939. * Does this action manager has pick triggers
  10940. */
  10941. readonly hasPickTriggers: boolean;
  10942. /**
  10943. * Registers an action to this action manager
  10944. * @param action defines the action to be registered
  10945. * @return the action amended (prepared) after registration
  10946. */
  10947. registerAction(action: IAction): Nullable<IAction>;
  10948. /**
  10949. * Unregisters an action to this action manager
  10950. * @param action defines the action to be unregistered
  10951. * @return a boolean indicating whether the action has been unregistered
  10952. */
  10953. unregisterAction(action: IAction): Boolean;
  10954. /**
  10955. * Process a specific trigger
  10956. * @param trigger defines the trigger to process
  10957. * @param evt defines the event details to be processed
  10958. */
  10959. processTrigger(trigger: number, evt?: IActionEvent): void;
  10960. /** @hidden */
  10961. _getEffectiveTarget(target: any, propertyPath: string): any;
  10962. /** @hidden */
  10963. _getProperty(propertyPath: string): string;
  10964. /**
  10965. * Serialize this manager to a JSON object
  10966. * @param name defines the property name to store this manager
  10967. * @returns a JSON representation of this manager
  10968. */
  10969. serialize(name: string): any;
  10970. /**
  10971. * Creates a new ActionManager from a JSON data
  10972. * @param parsedActions defines the JSON data to read from
  10973. * @param object defines the hosting mesh
  10974. * @param scene defines the hosting scene
  10975. */
  10976. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10977. /**
  10978. * Get a trigger name by index
  10979. * @param trigger defines the trigger index
  10980. * @returns a trigger name
  10981. */
  10982. static GetTriggerName(trigger: number): string;
  10983. }
  10984. }
  10985. declare module BABYLON {
  10986. /**
  10987. * Class representing a ray with position and direction
  10988. */
  10989. export class Ray {
  10990. /** origin point */
  10991. origin: Vector3;
  10992. /** direction */
  10993. direction: Vector3;
  10994. /** length of the ray */
  10995. length: number;
  10996. private static readonly TmpVector3;
  10997. private _tmpRay;
  10998. /**
  10999. * Creates a new ray
  11000. * @param origin origin point
  11001. * @param direction direction
  11002. * @param length length of the ray
  11003. */
  11004. constructor(
  11005. /** origin point */
  11006. origin: Vector3,
  11007. /** direction */
  11008. direction: Vector3,
  11009. /** length of the ray */
  11010. length?: number);
  11011. /**
  11012. * Checks if the ray intersects a box
  11013. * @param minimum bound of the box
  11014. * @param maximum bound of the box
  11015. * @param intersectionTreshold extra extend to be added to the box in all direction
  11016. * @returns if the box was hit
  11017. */
  11018. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11019. /**
  11020. * Checks if the ray intersects a box
  11021. * @param box the bounding box to check
  11022. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11023. * @returns if the box was hit
  11024. */
  11025. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11026. /**
  11027. * If the ray hits a sphere
  11028. * @param sphere the bounding sphere to check
  11029. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11030. * @returns true if it hits the sphere
  11031. */
  11032. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11033. /**
  11034. * If the ray hits a triange
  11035. * @param vertex0 triangle vertex
  11036. * @param vertex1 triangle vertex
  11037. * @param vertex2 triangle vertex
  11038. * @returns intersection information if hit
  11039. */
  11040. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11041. /**
  11042. * Checks if ray intersects a plane
  11043. * @param plane the plane to check
  11044. * @returns the distance away it was hit
  11045. */
  11046. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11047. /**
  11048. * Calculate the intercept of a ray on a given axis
  11049. * @param axis to check 'x' | 'y' | 'z'
  11050. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11051. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11052. */
  11053. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11054. /**
  11055. * Checks if ray intersects a mesh
  11056. * @param mesh the mesh to check
  11057. * @param fastCheck if only the bounding box should checked
  11058. * @returns picking info of the intersecton
  11059. */
  11060. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11061. /**
  11062. * Checks if ray intersects a mesh
  11063. * @param meshes the meshes to check
  11064. * @param fastCheck if only the bounding box should checked
  11065. * @param results array to store result in
  11066. * @returns Array of picking infos
  11067. */
  11068. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11069. private _comparePickingInfo;
  11070. private static smallnum;
  11071. private static rayl;
  11072. /**
  11073. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11074. * @param sega the first point of the segment to test the intersection against
  11075. * @param segb the second point of the segment to test the intersection against
  11076. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11077. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11078. */
  11079. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11080. /**
  11081. * Update the ray from viewport position
  11082. * @param x position
  11083. * @param y y position
  11084. * @param viewportWidth viewport width
  11085. * @param viewportHeight viewport height
  11086. * @param world world matrix
  11087. * @param view view matrix
  11088. * @param projection projection matrix
  11089. * @returns this ray updated
  11090. */
  11091. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11092. /**
  11093. * Creates a ray with origin and direction of 0,0,0
  11094. * @returns the new ray
  11095. */
  11096. static Zero(): Ray;
  11097. /**
  11098. * Creates a new ray from screen space and viewport
  11099. * @param x position
  11100. * @param y y position
  11101. * @param viewportWidth viewport width
  11102. * @param viewportHeight viewport height
  11103. * @param world world matrix
  11104. * @param view view matrix
  11105. * @param projection projection matrix
  11106. * @returns new ray
  11107. */
  11108. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11109. /**
  11110. * 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
  11111. * transformed to the given world matrix.
  11112. * @param origin The origin point
  11113. * @param end The end point
  11114. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11115. * @returns the new ray
  11116. */
  11117. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11118. /**
  11119. * Transforms a ray by a matrix
  11120. * @param ray ray to transform
  11121. * @param matrix matrix to apply
  11122. * @returns the resulting new ray
  11123. */
  11124. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11125. /**
  11126. * Transforms a ray by a matrix
  11127. * @param ray ray to transform
  11128. * @param matrix matrix to apply
  11129. * @param result ray to store result in
  11130. */
  11131. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11132. /**
  11133. * Unproject a ray from screen space to object space
  11134. * @param sourceX defines the screen space x coordinate to use
  11135. * @param sourceY defines the screen space y coordinate to use
  11136. * @param viewportWidth defines the current width of the viewport
  11137. * @param viewportHeight defines the current height of the viewport
  11138. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11139. * @param view defines the view matrix to use
  11140. * @param projection defines the projection matrix to use
  11141. */
  11142. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11143. }
  11144. /**
  11145. * Type used to define predicate used to select faces when a mesh intersection is detected
  11146. */
  11147. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11148. interface Scene {
  11149. /** @hidden */
  11150. _tempPickingRay: Nullable<Ray>;
  11151. /** @hidden */
  11152. _cachedRayForTransform: Ray;
  11153. /** @hidden */
  11154. _pickWithRayInverseMatrix: Matrix;
  11155. /** @hidden */
  11156. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11157. /** @hidden */
  11158. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11159. }
  11160. }
  11161. declare module BABYLON {
  11162. /**
  11163. * Groups all the scene component constants in one place to ease maintenance.
  11164. * @hidden
  11165. */
  11166. export class SceneComponentConstants {
  11167. static readonly NAME_EFFECTLAYER: string;
  11168. static readonly NAME_LAYER: string;
  11169. static readonly NAME_LENSFLARESYSTEM: string;
  11170. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11171. static readonly NAME_PARTICLESYSTEM: string;
  11172. static readonly NAME_GAMEPAD: string;
  11173. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11174. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11175. static readonly NAME_DEPTHRENDERER: string;
  11176. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11177. static readonly NAME_SPRITE: string;
  11178. static readonly NAME_OUTLINERENDERER: string;
  11179. static readonly NAME_PROCEDURALTEXTURE: string;
  11180. static readonly NAME_SHADOWGENERATOR: string;
  11181. static readonly NAME_OCTREE: string;
  11182. static readonly NAME_PHYSICSENGINE: string;
  11183. static readonly NAME_AUDIO: string;
  11184. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11185. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11186. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11187. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11188. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11189. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11190. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11191. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11192. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11193. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11194. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11195. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11196. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11197. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11198. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11199. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11200. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11201. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11202. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11203. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11204. static readonly STEP_AFTERRENDER_AUDIO: number;
  11205. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11206. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11207. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11208. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11209. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11210. static readonly STEP_POINTERMOVE_SPRITE: number;
  11211. static readonly STEP_POINTERDOWN_SPRITE: number;
  11212. static readonly STEP_POINTERUP_SPRITE: number;
  11213. }
  11214. /**
  11215. * This represents a scene component.
  11216. *
  11217. * This is used to decouple the dependency the scene is having on the different workloads like
  11218. * layers, post processes...
  11219. */
  11220. export interface ISceneComponent {
  11221. /**
  11222. * The name of the component. Each component must have a unique name.
  11223. */
  11224. name: string;
  11225. /**
  11226. * The scene the component belongs to.
  11227. */
  11228. scene: Scene;
  11229. /**
  11230. * Register the component to one instance of a scene.
  11231. */
  11232. register(): void;
  11233. /**
  11234. * Rebuilds the elements related to this component in case of
  11235. * context lost for instance.
  11236. */
  11237. rebuild(): void;
  11238. /**
  11239. * Disposes the component and the associated ressources.
  11240. */
  11241. dispose(): void;
  11242. }
  11243. /**
  11244. * This represents a SERIALIZABLE scene component.
  11245. *
  11246. * This extends Scene Component to add Serialization methods on top.
  11247. */
  11248. export interface ISceneSerializableComponent extends ISceneComponent {
  11249. /**
  11250. * Adds all the elements from the container to the scene
  11251. * @param container the container holding the elements
  11252. */
  11253. addFromContainer(container: AbstractScene): void;
  11254. /**
  11255. * Removes all the elements in the container from the scene
  11256. * @param container contains the elements to remove
  11257. * @param dispose if the removed element should be disposed (default: false)
  11258. */
  11259. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11260. /**
  11261. * Serializes the component data to the specified json object
  11262. * @param serializationObject The object to serialize to
  11263. */
  11264. serialize(serializationObject: any): void;
  11265. }
  11266. /**
  11267. * Strong typing of a Mesh related stage step action
  11268. */
  11269. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11270. /**
  11271. * Strong typing of a Evaluate Sub Mesh related stage step action
  11272. */
  11273. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11274. /**
  11275. * Strong typing of a Active Mesh related stage step action
  11276. */
  11277. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11278. /**
  11279. * Strong typing of a Camera related stage step action
  11280. */
  11281. export type CameraStageAction = (camera: Camera) => void;
  11282. /**
  11283. * Strong typing of a Camera Frame buffer related stage step action
  11284. */
  11285. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11286. /**
  11287. * Strong typing of a Render Target related stage step action
  11288. */
  11289. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11290. /**
  11291. * Strong typing of a RenderingGroup related stage step action
  11292. */
  11293. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11294. /**
  11295. * Strong typing of a Mesh Render related stage step action
  11296. */
  11297. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11298. /**
  11299. * Strong typing of a simple stage step action
  11300. */
  11301. export type SimpleStageAction = () => void;
  11302. /**
  11303. * Strong typing of a render target action.
  11304. */
  11305. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11306. /**
  11307. * Strong typing of a pointer move action.
  11308. */
  11309. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11310. /**
  11311. * Strong typing of a pointer up/down action.
  11312. */
  11313. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11314. /**
  11315. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11316. * @hidden
  11317. */
  11318. export class Stage<T extends Function> extends Array<{
  11319. index: number;
  11320. component: ISceneComponent;
  11321. action: T;
  11322. }> {
  11323. /**
  11324. * Hide ctor from the rest of the world.
  11325. * @param items The items to add.
  11326. */
  11327. private constructor();
  11328. /**
  11329. * Creates a new Stage.
  11330. * @returns A new instance of a Stage
  11331. */
  11332. static Create<T extends Function>(): Stage<T>;
  11333. /**
  11334. * Registers a step in an ordered way in the targeted stage.
  11335. * @param index Defines the position to register the step in
  11336. * @param component Defines the component attached to the step
  11337. * @param action Defines the action to launch during the step
  11338. */
  11339. registerStep(index: number, component: ISceneComponent, action: T): void;
  11340. /**
  11341. * Clears all the steps from the stage.
  11342. */
  11343. clear(): void;
  11344. }
  11345. }
  11346. declare module BABYLON {
  11347. interface Scene {
  11348. /** @hidden */
  11349. _pointerOverSprite: Nullable<Sprite>;
  11350. /** @hidden */
  11351. _pickedDownSprite: Nullable<Sprite>;
  11352. /** @hidden */
  11353. _tempSpritePickingRay: Nullable<Ray>;
  11354. /**
  11355. * All of the sprite managers added to this scene
  11356. * @see http://doc.babylonjs.com/babylon101/sprites
  11357. */
  11358. spriteManagers: Array<ISpriteManager>;
  11359. /**
  11360. * An event triggered when sprites rendering is about to start
  11361. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11362. */
  11363. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11364. /**
  11365. * An event triggered when sprites rendering is done
  11366. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11367. */
  11368. onAfterSpritesRenderingObservable: Observable<Scene>;
  11369. /** @hidden */
  11370. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11371. /** Launch a ray to try to pick a sprite in the scene
  11372. * @param x position on screen
  11373. * @param y position on screen
  11374. * @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
  11375. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11376. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11377. * @returns a PickingInfo
  11378. */
  11379. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11380. /** Use the given ray to pick a sprite in the scene
  11381. * @param ray The ray (in world space) to use to pick meshes
  11382. * @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
  11383. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11384. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11385. * @returns a PickingInfo
  11386. */
  11387. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11388. /** @hidden */
  11389. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11390. /** Launch a ray to try to pick sprites in the scene
  11391. * @param x position on screen
  11392. * @param y position on screen
  11393. * @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
  11394. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11395. * @returns a PickingInfo array
  11396. */
  11397. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11398. /** Use the given ray to pick sprites in the scene
  11399. * @param ray The ray (in world space) to use to pick meshes
  11400. * @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
  11401. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11402. * @returns a PickingInfo array
  11403. */
  11404. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11405. /**
  11406. * Force the sprite under the pointer
  11407. * @param sprite defines the sprite to use
  11408. */
  11409. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11410. /**
  11411. * Gets the sprite under the pointer
  11412. * @returns a Sprite or null if no sprite is under the pointer
  11413. */
  11414. getPointerOverSprite(): Nullable<Sprite>;
  11415. }
  11416. /**
  11417. * Defines the sprite scene component responsible to manage sprites
  11418. * in a given scene.
  11419. */
  11420. export class SpriteSceneComponent implements ISceneComponent {
  11421. /**
  11422. * The component name helpfull to identify the component in the list of scene components.
  11423. */
  11424. readonly name: string;
  11425. /**
  11426. * The scene the component belongs to.
  11427. */
  11428. scene: Scene;
  11429. /** @hidden */
  11430. private _spritePredicate;
  11431. /**
  11432. * Creates a new instance of the component for the given scene
  11433. * @param scene Defines the scene to register the component in
  11434. */
  11435. constructor(scene: Scene);
  11436. /**
  11437. * Registers the component in a given scene
  11438. */
  11439. register(): void;
  11440. /**
  11441. * Rebuilds the elements related to this component in case of
  11442. * context lost for instance.
  11443. */
  11444. rebuild(): void;
  11445. /**
  11446. * Disposes the component and the associated ressources.
  11447. */
  11448. dispose(): void;
  11449. private _pickSpriteButKeepRay;
  11450. private _pointerMove;
  11451. private _pointerDown;
  11452. private _pointerUp;
  11453. }
  11454. }
  11455. declare module BABYLON {
  11456. /** @hidden */
  11457. export var fogFragmentDeclaration: {
  11458. name: string;
  11459. shader: string;
  11460. };
  11461. }
  11462. declare module BABYLON {
  11463. /** @hidden */
  11464. export var fogFragment: {
  11465. name: string;
  11466. shader: string;
  11467. };
  11468. }
  11469. declare module BABYLON {
  11470. /** @hidden */
  11471. export var spritesPixelShader: {
  11472. name: string;
  11473. shader: string;
  11474. };
  11475. }
  11476. declare module BABYLON {
  11477. /** @hidden */
  11478. export var fogVertexDeclaration: {
  11479. name: string;
  11480. shader: string;
  11481. };
  11482. }
  11483. declare module BABYLON {
  11484. /** @hidden */
  11485. export var spritesVertexShader: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module BABYLON {
  11491. /**
  11492. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11493. */
  11494. export interface ISpriteManager extends IDisposable {
  11495. /**
  11496. * Restricts the camera to viewing objects with the same layerMask.
  11497. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11498. */
  11499. layerMask: number;
  11500. /**
  11501. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11502. */
  11503. isPickable: boolean;
  11504. /**
  11505. * Specifies the rendering group id for this mesh (0 by default)
  11506. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11507. */
  11508. renderingGroupId: number;
  11509. /**
  11510. * Defines the list of sprites managed by the manager.
  11511. */
  11512. sprites: Array<Sprite>;
  11513. /**
  11514. * Tests the intersection of a sprite with a specific ray.
  11515. * @param ray The ray we are sending to test the collision
  11516. * @param camera The camera space we are sending rays in
  11517. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11518. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11519. * @returns picking info or null.
  11520. */
  11521. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11522. /**
  11523. * Intersects the sprites with a ray
  11524. * @param ray defines the ray to intersect with
  11525. * @param camera defines the current active camera
  11526. * @param predicate defines a predicate used to select candidate sprites
  11527. * @returns null if no hit or a PickingInfo array
  11528. */
  11529. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11530. /**
  11531. * Renders the list of sprites on screen.
  11532. */
  11533. render(): void;
  11534. }
  11535. /**
  11536. * Class used to manage multiple sprites on the same spritesheet
  11537. * @see http://doc.babylonjs.com/babylon101/sprites
  11538. */
  11539. export class SpriteManager implements ISpriteManager {
  11540. /** defines the manager's name */
  11541. name: string;
  11542. /** Gets the list of sprites */
  11543. sprites: Sprite[];
  11544. /** Gets or sets the rendering group id (0 by default) */
  11545. renderingGroupId: number;
  11546. /** Gets or sets camera layer mask */
  11547. layerMask: number;
  11548. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11549. fogEnabled: boolean;
  11550. /** Gets or sets a boolean indicating if the sprites are pickable */
  11551. isPickable: boolean;
  11552. /** Defines the default width of a cell in the spritesheet */
  11553. cellWidth: number;
  11554. /** Defines the default height of a cell in the spritesheet */
  11555. cellHeight: number;
  11556. /** Associative array from JSON sprite data file */
  11557. private _cellData;
  11558. /** Array of sprite names from JSON sprite data file */
  11559. private _spriteMap;
  11560. /** True when packed cell data from JSON file is ready*/
  11561. private _packedAndReady;
  11562. /**
  11563. * An event triggered when the manager is disposed.
  11564. */
  11565. onDisposeObservable: Observable<SpriteManager>;
  11566. private _onDisposeObserver;
  11567. /**
  11568. * Callback called when the manager is disposed
  11569. */
  11570. onDispose: () => void;
  11571. private _capacity;
  11572. private _fromPacked;
  11573. private _spriteTexture;
  11574. private _epsilon;
  11575. private _scene;
  11576. private _vertexData;
  11577. private _buffer;
  11578. private _vertexBuffers;
  11579. private _indexBuffer;
  11580. private _effectBase;
  11581. private _effectFog;
  11582. /**
  11583. * Gets or sets the spritesheet texture
  11584. */
  11585. texture: Texture;
  11586. /**
  11587. * Creates a new sprite manager
  11588. * @param name defines the manager's name
  11589. * @param imgUrl defines the sprite sheet url
  11590. * @param capacity defines the maximum allowed number of sprites
  11591. * @param cellSize defines the size of a sprite cell
  11592. * @param scene defines the hosting scene
  11593. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11594. * @param samplingMode defines the smapling mode to use with spritesheet
  11595. * @param fromPacked set to false; do not alter
  11596. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11597. */
  11598. constructor(
  11599. /** defines the manager's name */
  11600. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11601. private _makePacked;
  11602. private _appendSpriteVertex;
  11603. /**
  11604. * Intersects the sprites with a ray
  11605. * @param ray defines the ray to intersect with
  11606. * @param camera defines the current active camera
  11607. * @param predicate defines a predicate used to select candidate sprites
  11608. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11609. * @returns null if no hit or a PickingInfo
  11610. */
  11611. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11612. /**
  11613. * Intersects the sprites with a ray
  11614. * @param ray defines the ray to intersect with
  11615. * @param camera defines the current active camera
  11616. * @param predicate defines a predicate used to select candidate sprites
  11617. * @returns null if no hit or a PickingInfo array
  11618. */
  11619. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11620. /**
  11621. * Render all child sprites
  11622. */
  11623. render(): void;
  11624. /**
  11625. * Release associated resources
  11626. */
  11627. dispose(): void;
  11628. }
  11629. }
  11630. declare module BABYLON {
  11631. /**
  11632. * Class used to represent a sprite
  11633. * @see http://doc.babylonjs.com/babylon101/sprites
  11634. */
  11635. export class Sprite {
  11636. /** defines the name */
  11637. name: string;
  11638. /** Gets or sets the current world position */
  11639. position: Vector3;
  11640. /** Gets or sets the main color */
  11641. color: Color4;
  11642. /** Gets or sets the width */
  11643. width: number;
  11644. /** Gets or sets the height */
  11645. height: number;
  11646. /** Gets or sets rotation angle */
  11647. angle: number;
  11648. /** Gets or sets the cell index in the sprite sheet */
  11649. cellIndex: number;
  11650. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11651. cellRef: string;
  11652. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11653. invertU: number;
  11654. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11655. invertV: number;
  11656. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11657. disposeWhenFinishedAnimating: boolean;
  11658. /** Gets the list of attached animations */
  11659. animations: Animation[];
  11660. /** Gets or sets a boolean indicating if the sprite can be picked */
  11661. isPickable: boolean;
  11662. /**
  11663. * Gets or sets the associated action manager
  11664. */
  11665. actionManager: Nullable<ActionManager>;
  11666. private _animationStarted;
  11667. private _loopAnimation;
  11668. private _fromIndex;
  11669. private _toIndex;
  11670. private _delay;
  11671. private _direction;
  11672. private _manager;
  11673. private _time;
  11674. private _onAnimationEnd;
  11675. /**
  11676. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11677. */
  11678. isVisible: boolean;
  11679. /**
  11680. * Gets or sets the sprite size
  11681. */
  11682. size: number;
  11683. /**
  11684. * Creates a new Sprite
  11685. * @param name defines the name
  11686. * @param manager defines the manager
  11687. */
  11688. constructor(
  11689. /** defines the name */
  11690. name: string, manager: ISpriteManager);
  11691. /**
  11692. * Starts an animation
  11693. * @param from defines the initial key
  11694. * @param to defines the end key
  11695. * @param loop defines if the animation must loop
  11696. * @param delay defines the start delay (in ms)
  11697. * @param onAnimationEnd defines a callback to call when animation ends
  11698. */
  11699. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11700. /** Stops current animation (if any) */
  11701. stopAnimation(): void;
  11702. /** @hidden */
  11703. _animate(deltaTime: number): void;
  11704. /** Release associated resources */
  11705. dispose(): void;
  11706. }
  11707. }
  11708. declare module BABYLON {
  11709. /**
  11710. * Information about the result of picking within a scene
  11711. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11712. */
  11713. export class PickingInfo {
  11714. /** @hidden */
  11715. _pickingUnavailable: boolean;
  11716. /**
  11717. * If the pick collided with an object
  11718. */
  11719. hit: boolean;
  11720. /**
  11721. * Distance away where the pick collided
  11722. */
  11723. distance: number;
  11724. /**
  11725. * The location of pick collision
  11726. */
  11727. pickedPoint: Nullable<Vector3>;
  11728. /**
  11729. * The mesh corresponding the the pick collision
  11730. */
  11731. pickedMesh: Nullable<AbstractMesh>;
  11732. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11733. bu: number;
  11734. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11735. bv: number;
  11736. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11737. faceId: number;
  11738. /** Id of the the submesh that was picked */
  11739. subMeshId: number;
  11740. /** If a sprite was picked, this will be the sprite the pick collided with */
  11741. pickedSprite: Nullable<Sprite>;
  11742. /**
  11743. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11744. */
  11745. originMesh: Nullable<AbstractMesh>;
  11746. /**
  11747. * The ray that was used to perform the picking.
  11748. */
  11749. ray: Nullable<Ray>;
  11750. /**
  11751. * Gets the normal correspodning to the face the pick collided with
  11752. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11753. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11754. * @returns The normal correspodning to the face the pick collided with
  11755. */
  11756. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11757. /**
  11758. * Gets the texture coordinates of where the pick occured
  11759. * @returns the vector containing the coordnates of the texture
  11760. */
  11761. getTextureCoordinates(): Nullable<Vector2>;
  11762. }
  11763. }
  11764. declare module BABYLON {
  11765. /**
  11766. * Gather the list of pointer event types as constants.
  11767. */
  11768. export class PointerEventTypes {
  11769. /**
  11770. * 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.
  11771. */
  11772. static readonly POINTERDOWN: number;
  11773. /**
  11774. * The pointerup event is fired when a pointer is no longer active.
  11775. */
  11776. static readonly POINTERUP: number;
  11777. /**
  11778. * The pointermove event is fired when a pointer changes coordinates.
  11779. */
  11780. static readonly POINTERMOVE: number;
  11781. /**
  11782. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11783. */
  11784. static readonly POINTERWHEEL: number;
  11785. /**
  11786. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11787. */
  11788. static readonly POINTERPICK: number;
  11789. /**
  11790. * The pointertap event is fired when a the object has been touched and released without drag.
  11791. */
  11792. static readonly POINTERTAP: number;
  11793. /**
  11794. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11795. */
  11796. static readonly POINTERDOUBLETAP: number;
  11797. }
  11798. /**
  11799. * Base class of pointer info types.
  11800. */
  11801. export class PointerInfoBase {
  11802. /**
  11803. * Defines the type of event (PointerEventTypes)
  11804. */
  11805. type: number;
  11806. /**
  11807. * Defines the related dom event
  11808. */
  11809. event: PointerEvent | MouseWheelEvent;
  11810. /**
  11811. * Instantiates the base class of pointers info.
  11812. * @param type Defines the type of event (PointerEventTypes)
  11813. * @param event Defines the related dom event
  11814. */
  11815. constructor(
  11816. /**
  11817. * Defines the type of event (PointerEventTypes)
  11818. */
  11819. type: number,
  11820. /**
  11821. * Defines the related dom event
  11822. */
  11823. event: PointerEvent | MouseWheelEvent);
  11824. }
  11825. /**
  11826. * This class is used to store pointer related info for the onPrePointerObservable event.
  11827. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11828. */
  11829. export class PointerInfoPre extends PointerInfoBase {
  11830. /**
  11831. * Ray from a pointer if availible (eg. 6dof controller)
  11832. */
  11833. ray: Nullable<Ray>;
  11834. /**
  11835. * Defines the local position of the pointer on the canvas.
  11836. */
  11837. localPosition: Vector2;
  11838. /**
  11839. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11840. */
  11841. skipOnPointerObservable: boolean;
  11842. /**
  11843. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11844. * @param type Defines the type of event (PointerEventTypes)
  11845. * @param event Defines the related dom event
  11846. * @param localX Defines the local x coordinates of the pointer when the event occured
  11847. * @param localY Defines the local y coordinates of the pointer when the event occured
  11848. */
  11849. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11850. }
  11851. /**
  11852. * This type contains all the data related to a pointer event in Babylon.js.
  11853. * 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.
  11854. */
  11855. export class PointerInfo extends PointerInfoBase {
  11856. /**
  11857. * Defines the picking info associated to the info (if any)\
  11858. */
  11859. pickInfo: Nullable<PickingInfo>;
  11860. /**
  11861. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11862. * @param type Defines the type of event (PointerEventTypes)
  11863. * @param event Defines the related dom event
  11864. * @param pickInfo Defines the picking info associated to the info (if any)\
  11865. */
  11866. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11867. /**
  11868. * Defines the picking info associated to the info (if any)\
  11869. */
  11870. pickInfo: Nullable<PickingInfo>);
  11871. }
  11872. /**
  11873. * Data relating to a touch event on the screen.
  11874. */
  11875. export interface PointerTouch {
  11876. /**
  11877. * X coordinate of touch.
  11878. */
  11879. x: number;
  11880. /**
  11881. * Y coordinate of touch.
  11882. */
  11883. y: number;
  11884. /**
  11885. * Id of touch. Unique for each finger.
  11886. */
  11887. pointerId: number;
  11888. /**
  11889. * Event type passed from DOM.
  11890. */
  11891. type: any;
  11892. }
  11893. }
  11894. declare module BABYLON {
  11895. /**
  11896. * Manage the mouse inputs to control the movement of a free camera.
  11897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11898. */
  11899. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11900. /**
  11901. * Define if touch is enabled in the mouse input
  11902. */
  11903. touchEnabled: boolean;
  11904. /**
  11905. * Defines the camera the input is attached to.
  11906. */
  11907. camera: FreeCamera;
  11908. /**
  11909. * Defines the buttons associated with the input to handle camera move.
  11910. */
  11911. buttons: number[];
  11912. /**
  11913. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11914. */
  11915. angularSensibility: number;
  11916. private _pointerInput;
  11917. private _onMouseMove;
  11918. private _observer;
  11919. private previousPosition;
  11920. /**
  11921. * Observable for when a pointer move event occurs containing the move offset
  11922. */
  11923. onPointerMovedObservable: Observable<{
  11924. offsetX: number;
  11925. offsetY: number;
  11926. }>;
  11927. /**
  11928. * @hidden
  11929. * If the camera should be rotated automatically based on pointer movement
  11930. */
  11931. _allowCameraRotation: boolean;
  11932. /**
  11933. * Manage the mouse inputs to control the movement of a free camera.
  11934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11935. * @param touchEnabled Defines if touch is enabled or not
  11936. */
  11937. constructor(
  11938. /**
  11939. * Define if touch is enabled in the mouse input
  11940. */
  11941. touchEnabled?: boolean);
  11942. /**
  11943. * Attach the input controls to a specific dom element to get the input from.
  11944. * @param element Defines the element the controls should be listened from
  11945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11946. */
  11947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11948. /**
  11949. * Called on JS contextmenu event.
  11950. * Override this method to provide functionality.
  11951. */
  11952. protected onContextMenu(evt: PointerEvent): void;
  11953. /**
  11954. * Detach the current controls from the specified dom element.
  11955. * @param element Defines the element to stop listening the inputs from
  11956. */
  11957. detachControl(element: Nullable<HTMLElement>): void;
  11958. /**
  11959. * Gets the class name of the current intput.
  11960. * @returns the class name
  11961. */
  11962. getClassName(): string;
  11963. /**
  11964. * Get the friendly name associated with the input class.
  11965. * @returns the input friendly name
  11966. */
  11967. getSimpleName(): string;
  11968. }
  11969. }
  11970. declare module BABYLON {
  11971. /**
  11972. * Manage the touch inputs to control the movement of a free camera.
  11973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11974. */
  11975. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11976. /**
  11977. * Defines the camera the input is attached to.
  11978. */
  11979. camera: FreeCamera;
  11980. /**
  11981. * Defines the touch sensibility for rotation.
  11982. * The higher the faster.
  11983. */
  11984. touchAngularSensibility: number;
  11985. /**
  11986. * Defines the touch sensibility for move.
  11987. * The higher the faster.
  11988. */
  11989. touchMoveSensibility: number;
  11990. private _offsetX;
  11991. private _offsetY;
  11992. private _pointerPressed;
  11993. private _pointerInput;
  11994. private _observer;
  11995. private _onLostFocus;
  11996. /**
  11997. * Attach the input controls to a specific dom element to get the input from.
  11998. * @param element Defines the element the controls should be listened from
  11999. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12000. */
  12001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12002. /**
  12003. * Detach the current controls from the specified dom element.
  12004. * @param element Defines the element to stop listening the inputs from
  12005. */
  12006. detachControl(element: Nullable<HTMLElement>): void;
  12007. /**
  12008. * Update the current camera state depending on the inputs that have been used this frame.
  12009. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12010. */
  12011. checkInputs(): void;
  12012. /**
  12013. * Gets the class name of the current intput.
  12014. * @returns the class name
  12015. */
  12016. getClassName(): string;
  12017. /**
  12018. * Get the friendly name associated with the input class.
  12019. * @returns the input friendly name
  12020. */
  12021. getSimpleName(): string;
  12022. }
  12023. }
  12024. declare module BABYLON {
  12025. /**
  12026. * Default Inputs manager for the FreeCamera.
  12027. * It groups all the default supported inputs for ease of use.
  12028. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12029. */
  12030. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12031. /**
  12032. * @hidden
  12033. */
  12034. _mouseInput: Nullable<FreeCameraMouseInput>;
  12035. /**
  12036. * Instantiates a new FreeCameraInputsManager.
  12037. * @param camera Defines the camera the inputs belong to
  12038. */
  12039. constructor(camera: FreeCamera);
  12040. /**
  12041. * Add keyboard input support to the input manager.
  12042. * @returns the current input manager
  12043. */
  12044. addKeyboard(): FreeCameraInputsManager;
  12045. /**
  12046. * Add mouse input support to the input manager.
  12047. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12048. * @returns the current input manager
  12049. */
  12050. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12051. /**
  12052. * Removes the mouse input support from the manager
  12053. * @returns the current input manager
  12054. */
  12055. removeMouse(): FreeCameraInputsManager;
  12056. /**
  12057. * Add touch input support to the input manager.
  12058. * @returns the current input manager
  12059. */
  12060. addTouch(): FreeCameraInputsManager;
  12061. /**
  12062. * Remove all attached input methods from a camera
  12063. */
  12064. clear(): void;
  12065. }
  12066. }
  12067. declare module BABYLON {
  12068. /**
  12069. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12070. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12071. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12072. */
  12073. export class FreeCamera extends TargetCamera {
  12074. /**
  12075. * Define the collision ellipsoid of the camera.
  12076. * This is helpful to simulate a camera body like the player body around the camera
  12077. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12078. */
  12079. ellipsoid: Vector3;
  12080. /**
  12081. * Define an offset for the position of the ellipsoid around the camera.
  12082. * This can be helpful to determine the center of the body near the gravity center of the body
  12083. * instead of its head.
  12084. */
  12085. ellipsoidOffset: Vector3;
  12086. /**
  12087. * Enable or disable collisions of the camera with the rest of the scene objects.
  12088. */
  12089. checkCollisions: boolean;
  12090. /**
  12091. * Enable or disable gravity on the camera.
  12092. */
  12093. applyGravity: boolean;
  12094. /**
  12095. * Define the input manager associated to the camera.
  12096. */
  12097. inputs: FreeCameraInputsManager;
  12098. /**
  12099. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12100. * Higher values reduce sensitivity.
  12101. */
  12102. /**
  12103. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12104. * Higher values reduce sensitivity.
  12105. */
  12106. angularSensibility: number;
  12107. /**
  12108. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12109. */
  12110. keysUp: number[];
  12111. /**
  12112. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12113. */
  12114. keysDown: number[];
  12115. /**
  12116. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12117. */
  12118. keysLeft: number[];
  12119. /**
  12120. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12121. */
  12122. keysRight: number[];
  12123. /**
  12124. * Event raised when the camera collide with a mesh in the scene.
  12125. */
  12126. onCollide: (collidedMesh: AbstractMesh) => void;
  12127. private _collider;
  12128. private _needMoveForGravity;
  12129. private _oldPosition;
  12130. private _diffPosition;
  12131. private _newPosition;
  12132. /** @hidden */
  12133. _localDirection: Vector3;
  12134. /** @hidden */
  12135. _transformedDirection: Vector3;
  12136. /**
  12137. * Instantiates a Free Camera.
  12138. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12139. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12140. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12141. * @param name Define the name of the camera in the scene
  12142. * @param position Define the start position of the camera in the scene
  12143. * @param scene Define the scene the camera belongs to
  12144. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12145. */
  12146. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12147. /**
  12148. * Attached controls to the current camera.
  12149. * @param element Defines the element the controls should be listened from
  12150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12151. */
  12152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12153. /**
  12154. * Detach the current controls from the camera.
  12155. * The camera will stop reacting to inputs.
  12156. * @param element Defines the element to stop listening the inputs from
  12157. */
  12158. detachControl(element: HTMLElement): void;
  12159. private _collisionMask;
  12160. /**
  12161. * Define a collision mask to limit the list of object the camera can collide with
  12162. */
  12163. collisionMask: number;
  12164. /** @hidden */
  12165. _collideWithWorld(displacement: Vector3): void;
  12166. private _onCollisionPositionChange;
  12167. /** @hidden */
  12168. _checkInputs(): void;
  12169. /** @hidden */
  12170. _decideIfNeedsToMove(): boolean;
  12171. /** @hidden */
  12172. _updatePosition(): void;
  12173. /**
  12174. * Destroy the camera and release the current resources hold by it.
  12175. */
  12176. dispose(): void;
  12177. /**
  12178. * Gets the current object class name.
  12179. * @return the class name
  12180. */
  12181. getClassName(): string;
  12182. }
  12183. }
  12184. declare module BABYLON {
  12185. /**
  12186. * Represents a gamepad control stick position
  12187. */
  12188. export class StickValues {
  12189. /**
  12190. * The x component of the control stick
  12191. */
  12192. x: number;
  12193. /**
  12194. * The y component of the control stick
  12195. */
  12196. y: number;
  12197. /**
  12198. * Initializes the gamepad x and y control stick values
  12199. * @param x The x component of the gamepad control stick value
  12200. * @param y The y component of the gamepad control stick value
  12201. */
  12202. constructor(
  12203. /**
  12204. * The x component of the control stick
  12205. */
  12206. x: number,
  12207. /**
  12208. * The y component of the control stick
  12209. */
  12210. y: number);
  12211. }
  12212. /**
  12213. * An interface which manages callbacks for gamepad button changes
  12214. */
  12215. export interface GamepadButtonChanges {
  12216. /**
  12217. * Called when a gamepad has been changed
  12218. */
  12219. changed: boolean;
  12220. /**
  12221. * Called when a gamepad press event has been triggered
  12222. */
  12223. pressChanged: boolean;
  12224. /**
  12225. * Called when a touch event has been triggered
  12226. */
  12227. touchChanged: boolean;
  12228. /**
  12229. * Called when a value has changed
  12230. */
  12231. valueChanged: boolean;
  12232. }
  12233. /**
  12234. * Represents a gamepad
  12235. */
  12236. export class Gamepad {
  12237. /**
  12238. * The id of the gamepad
  12239. */
  12240. id: string;
  12241. /**
  12242. * The index of the gamepad
  12243. */
  12244. index: number;
  12245. /**
  12246. * The browser gamepad
  12247. */
  12248. browserGamepad: any;
  12249. /**
  12250. * Specifies what type of gamepad this represents
  12251. */
  12252. type: number;
  12253. private _leftStick;
  12254. private _rightStick;
  12255. /** @hidden */
  12256. _isConnected: boolean;
  12257. private _leftStickAxisX;
  12258. private _leftStickAxisY;
  12259. private _rightStickAxisX;
  12260. private _rightStickAxisY;
  12261. /**
  12262. * Triggered when the left control stick has been changed
  12263. */
  12264. private _onleftstickchanged;
  12265. /**
  12266. * Triggered when the right control stick has been changed
  12267. */
  12268. private _onrightstickchanged;
  12269. /**
  12270. * Represents a gamepad controller
  12271. */
  12272. static GAMEPAD: number;
  12273. /**
  12274. * Represents a generic controller
  12275. */
  12276. static GENERIC: number;
  12277. /**
  12278. * Represents an XBox controller
  12279. */
  12280. static XBOX: number;
  12281. /**
  12282. * Represents a pose-enabled controller
  12283. */
  12284. static POSE_ENABLED: number;
  12285. /**
  12286. * Represents an Dual Shock controller
  12287. */
  12288. static DUALSHOCK: number;
  12289. /**
  12290. * Specifies whether the left control stick should be Y-inverted
  12291. */
  12292. protected _invertLeftStickY: boolean;
  12293. /**
  12294. * Specifies if the gamepad has been connected
  12295. */
  12296. readonly isConnected: boolean;
  12297. /**
  12298. * Initializes the gamepad
  12299. * @param id The id of the gamepad
  12300. * @param index The index of the gamepad
  12301. * @param browserGamepad The browser gamepad
  12302. * @param leftStickX The x component of the left joystick
  12303. * @param leftStickY The y component of the left joystick
  12304. * @param rightStickX The x component of the right joystick
  12305. * @param rightStickY The y component of the right joystick
  12306. */
  12307. constructor(
  12308. /**
  12309. * The id of the gamepad
  12310. */
  12311. id: string,
  12312. /**
  12313. * The index of the gamepad
  12314. */
  12315. index: number,
  12316. /**
  12317. * The browser gamepad
  12318. */
  12319. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12320. /**
  12321. * Callback triggered when the left joystick has changed
  12322. * @param callback
  12323. */
  12324. onleftstickchanged(callback: (values: StickValues) => void): void;
  12325. /**
  12326. * Callback triggered when the right joystick has changed
  12327. * @param callback
  12328. */
  12329. onrightstickchanged(callback: (values: StickValues) => void): void;
  12330. /**
  12331. * Gets the left joystick
  12332. */
  12333. /**
  12334. * Sets the left joystick values
  12335. */
  12336. leftStick: StickValues;
  12337. /**
  12338. * Gets the right joystick
  12339. */
  12340. /**
  12341. * Sets the right joystick value
  12342. */
  12343. rightStick: StickValues;
  12344. /**
  12345. * Updates the gamepad joystick positions
  12346. */
  12347. update(): void;
  12348. /**
  12349. * Disposes the gamepad
  12350. */
  12351. dispose(): void;
  12352. }
  12353. /**
  12354. * Represents a generic gamepad
  12355. */
  12356. export class GenericPad extends Gamepad {
  12357. private _buttons;
  12358. private _onbuttondown;
  12359. private _onbuttonup;
  12360. /**
  12361. * Observable triggered when a button has been pressed
  12362. */
  12363. onButtonDownObservable: Observable<number>;
  12364. /**
  12365. * Observable triggered when a button has been released
  12366. */
  12367. onButtonUpObservable: Observable<number>;
  12368. /**
  12369. * Callback triggered when a button has been pressed
  12370. * @param callback Called when a button has been pressed
  12371. */
  12372. onbuttondown(callback: (buttonPressed: number) => void): void;
  12373. /**
  12374. * Callback triggered when a button has been released
  12375. * @param callback Called when a button has been released
  12376. */
  12377. onbuttonup(callback: (buttonReleased: number) => void): void;
  12378. /**
  12379. * Initializes the generic gamepad
  12380. * @param id The id of the generic gamepad
  12381. * @param index The index of the generic gamepad
  12382. * @param browserGamepad The browser gamepad
  12383. */
  12384. constructor(id: string, index: number, browserGamepad: any);
  12385. private _setButtonValue;
  12386. /**
  12387. * Updates the generic gamepad
  12388. */
  12389. update(): void;
  12390. /**
  12391. * Disposes the generic gamepad
  12392. */
  12393. dispose(): void;
  12394. }
  12395. }
  12396. declare module BABYLON {
  12397. interface Engine {
  12398. /**
  12399. * Creates a raw texture
  12400. * @param data defines the data to store in the texture
  12401. * @param width defines the width of the texture
  12402. * @param height defines the height of the texture
  12403. * @param format defines the format of the data
  12404. * @param generateMipMaps defines if the engine should generate the mip levels
  12405. * @param invertY defines if data must be stored with Y axis inverted
  12406. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12407. * @param compression defines the compression used (null by default)
  12408. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12409. * @returns the raw texture inside an InternalTexture
  12410. */
  12411. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12412. /**
  12413. * Update a raw texture
  12414. * @param texture defines the texture to update
  12415. * @param data defines the data to store in the texture
  12416. * @param format defines the format of the data
  12417. * @param invertY defines if data must be stored with Y axis inverted
  12418. */
  12419. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12420. /**
  12421. * Update a raw texture
  12422. * @param texture defines the texture to update
  12423. * @param data defines the data to store in the texture
  12424. * @param format defines the format of the data
  12425. * @param invertY defines if data must be stored with Y axis inverted
  12426. * @param compression defines the compression used (null by default)
  12427. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12428. */
  12429. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12430. /**
  12431. * Creates a new raw cube texture
  12432. * @param data defines the array of data to use to create each face
  12433. * @param size defines the size of the textures
  12434. * @param format defines the format of the data
  12435. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12436. * @param generateMipMaps defines if the engine should generate the mip levels
  12437. * @param invertY defines if data must be stored with Y axis inverted
  12438. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12439. * @param compression defines the compression used (null by default)
  12440. * @returns the cube texture as an InternalTexture
  12441. */
  12442. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12443. /**
  12444. * Update a raw cube texture
  12445. * @param texture defines the texture to udpdate
  12446. * @param data defines the data to store
  12447. * @param format defines the data format
  12448. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12449. * @param invertY defines if data must be stored with Y axis inverted
  12450. */
  12451. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12452. /**
  12453. * Update a raw cube texture
  12454. * @param texture defines the texture to udpdate
  12455. * @param data defines the data to store
  12456. * @param format defines the data format
  12457. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12458. * @param invertY defines if data must be stored with Y axis inverted
  12459. * @param compression defines the compression used (null by default)
  12460. */
  12461. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12462. /**
  12463. * Update a raw cube texture
  12464. * @param texture defines the texture to udpdate
  12465. * @param data defines the data to store
  12466. * @param format defines the data format
  12467. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12468. * @param invertY defines if data must be stored with Y axis inverted
  12469. * @param compression defines the compression used (null by default)
  12470. * @param level defines which level of the texture to update
  12471. */
  12472. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12473. /**
  12474. * Creates a new raw cube texture from a specified url
  12475. * @param url defines the url where the data is located
  12476. * @param scene defines the current scene
  12477. * @param size defines the size of the textures
  12478. * @param format defines the format of the data
  12479. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12480. * @param noMipmap defines if the engine should avoid generating the mip levels
  12481. * @param callback defines a callback used to extract texture data from loaded data
  12482. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12483. * @param onLoad defines a callback called when texture is loaded
  12484. * @param onError defines a callback called if there is an error
  12485. * @returns the cube texture as an InternalTexture
  12486. */
  12487. 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;
  12488. /**
  12489. * Creates a new raw cube texture from a specified url
  12490. * @param url defines the url where the data is located
  12491. * @param scene defines the current scene
  12492. * @param size defines the size of the textures
  12493. * @param format defines the format of the data
  12494. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12495. * @param noMipmap defines if the engine should avoid generating the mip levels
  12496. * @param callback defines a callback used to extract texture data from loaded data
  12497. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12498. * @param onLoad defines a callback called when texture is loaded
  12499. * @param onError defines a callback called if there is an error
  12500. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12501. * @param invertY defines if data must be stored with Y axis inverted
  12502. * @returns the cube texture as an InternalTexture
  12503. */
  12504. 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;
  12505. /**
  12506. * Creates a new raw 3D texture
  12507. * @param data defines the data used to create the texture
  12508. * @param width defines the width of the texture
  12509. * @param height defines the height of the texture
  12510. * @param depth defines the depth of the texture
  12511. * @param format defines the format of the texture
  12512. * @param generateMipMaps defines if the engine must generate mip levels
  12513. * @param invertY defines if data must be stored with Y axis inverted
  12514. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12515. * @param compression defines the compressed used (can be null)
  12516. * @param textureType defines the compressed used (can be null)
  12517. * @returns a new raw 3D texture (stored in an InternalTexture)
  12518. */
  12519. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12520. /**
  12521. * Update a raw 3D texture
  12522. * @param texture defines the texture to update
  12523. * @param data defines the data to store
  12524. * @param format defines the data format
  12525. * @param invertY defines if data must be stored with Y axis inverted
  12526. */
  12527. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12528. /**
  12529. * Update a raw 3D texture
  12530. * @param texture defines the texture to update
  12531. * @param data defines the data to store
  12532. * @param format defines the data format
  12533. * @param invertY defines if data must be stored with Y axis inverted
  12534. * @param compression defines the used compression (can be null)
  12535. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12536. */
  12537. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12538. }
  12539. }
  12540. declare module BABYLON {
  12541. /**
  12542. * Raw texture can help creating a texture directly from an array of data.
  12543. * This can be super useful if you either get the data from an uncompressed source or
  12544. * if you wish to create your texture pixel by pixel.
  12545. */
  12546. export class RawTexture extends Texture {
  12547. /**
  12548. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12549. */
  12550. format: number;
  12551. private _engine;
  12552. /**
  12553. * Instantiates a new RawTexture.
  12554. * Raw texture can help creating a texture directly from an array of data.
  12555. * This can be super useful if you either get the data from an uncompressed source or
  12556. * if you wish to create your texture pixel by pixel.
  12557. * @param data define the array of data to use to create the texture
  12558. * @param width define the width of the texture
  12559. * @param height define the height of the texture
  12560. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12561. * @param scene define the scene the texture belongs to
  12562. * @param generateMipMaps define whether mip maps should be generated or not
  12563. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12564. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12565. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12566. */
  12567. constructor(data: ArrayBufferView, width: number, height: number,
  12568. /**
  12569. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12570. */
  12571. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12572. /**
  12573. * Updates the texture underlying data.
  12574. * @param data Define the new data of the texture
  12575. */
  12576. update(data: ArrayBufferView): void;
  12577. /**
  12578. * Creates a luminance texture from some data.
  12579. * @param data Define the texture data
  12580. * @param width Define the width of the texture
  12581. * @param height Define the height of the texture
  12582. * @param scene Define the scene the texture belongs to
  12583. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12584. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12585. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12586. * @returns the luminance texture
  12587. */
  12588. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12589. /**
  12590. * Creates a luminance alpha texture from some data.
  12591. * @param data Define the texture data
  12592. * @param width Define the width of the texture
  12593. * @param height Define the height of the texture
  12594. * @param scene Define the scene the texture belongs to
  12595. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12596. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12597. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12598. * @returns the luminance alpha texture
  12599. */
  12600. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12601. /**
  12602. * Creates an alpha texture from some data.
  12603. * @param data Define the texture data
  12604. * @param width Define the width of the texture
  12605. * @param height Define the height of the texture
  12606. * @param scene Define the scene the texture belongs to
  12607. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12608. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12609. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12610. * @returns the alpha texture
  12611. */
  12612. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12613. /**
  12614. * Creates a RGB texture from some data.
  12615. * @param data Define the texture data
  12616. * @param width Define the width of the texture
  12617. * @param height Define the height of the texture
  12618. * @param scene Define the scene the texture belongs to
  12619. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12620. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12621. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12622. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12623. * @returns the RGB alpha texture
  12624. */
  12625. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12626. /**
  12627. * Creates a RGBA texture from some data.
  12628. * @param data Define the texture data
  12629. * @param width Define the width of the texture
  12630. * @param height Define the height of the texture
  12631. * @param scene Define the scene the texture belongs to
  12632. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12633. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12634. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12635. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12636. * @returns the RGBA texture
  12637. */
  12638. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12639. /**
  12640. * Creates a R texture from some data.
  12641. * @param data Define the texture data
  12642. * @param width Define the width of the texture
  12643. * @param height Define the height of the texture
  12644. * @param scene Define the scene the texture belongs to
  12645. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12648. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12649. * @returns the R texture
  12650. */
  12651. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12652. }
  12653. }
  12654. declare module BABYLON {
  12655. /**
  12656. * Interface for the size containing width and height
  12657. */
  12658. export interface ISize {
  12659. /**
  12660. * Width
  12661. */
  12662. width: number;
  12663. /**
  12664. * Heighht
  12665. */
  12666. height: number;
  12667. }
  12668. /**
  12669. * Size containing widht and height
  12670. */
  12671. export class Size implements ISize {
  12672. /**
  12673. * Width
  12674. */
  12675. width: number;
  12676. /**
  12677. * Height
  12678. */
  12679. height: number;
  12680. /**
  12681. * Creates a Size object from the given width and height (floats).
  12682. * @param width width of the new size
  12683. * @param height height of the new size
  12684. */
  12685. constructor(width: number, height: number);
  12686. /**
  12687. * Returns a string with the Size width and height
  12688. * @returns a string with the Size width and height
  12689. */
  12690. toString(): string;
  12691. /**
  12692. * "Size"
  12693. * @returns the string "Size"
  12694. */
  12695. getClassName(): string;
  12696. /**
  12697. * Returns the Size hash code.
  12698. * @returns a hash code for a unique width and height
  12699. */
  12700. getHashCode(): number;
  12701. /**
  12702. * Updates the current size from the given one.
  12703. * @param src the given size
  12704. */
  12705. copyFrom(src: Size): void;
  12706. /**
  12707. * Updates in place the current Size from the given floats.
  12708. * @param width width of the new size
  12709. * @param height height of the new size
  12710. * @returns the updated Size.
  12711. */
  12712. copyFromFloats(width: number, height: number): Size;
  12713. /**
  12714. * Updates in place the current Size from the given floats.
  12715. * @param width width to set
  12716. * @param height height to set
  12717. * @returns the updated Size.
  12718. */
  12719. set(width: number, height: number): Size;
  12720. /**
  12721. * Multiplies the width and height by numbers
  12722. * @param w factor to multiple the width by
  12723. * @param h factor to multiple the height by
  12724. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12725. */
  12726. multiplyByFloats(w: number, h: number): Size;
  12727. /**
  12728. * Clones the size
  12729. * @returns a new Size copied from the given one.
  12730. */
  12731. clone(): Size;
  12732. /**
  12733. * True if the current Size and the given one width and height are strictly equal.
  12734. * @param other the other size to compare against
  12735. * @returns True if the current Size and the given one width and height are strictly equal.
  12736. */
  12737. equals(other: Size): boolean;
  12738. /**
  12739. * The surface of the Size : width * height (float).
  12740. */
  12741. readonly surface: number;
  12742. /**
  12743. * Create a new size of zero
  12744. * @returns a new Size set to (0.0, 0.0)
  12745. */
  12746. static Zero(): Size;
  12747. /**
  12748. * Sums the width and height of two sizes
  12749. * @param otherSize size to add to this size
  12750. * @returns a new Size set as the addition result of the current Size and the given one.
  12751. */
  12752. add(otherSize: Size): Size;
  12753. /**
  12754. * Subtracts the width and height of two
  12755. * @param otherSize size to subtract to this size
  12756. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12757. */
  12758. subtract(otherSize: Size): Size;
  12759. /**
  12760. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12761. * @param start starting size to lerp between
  12762. * @param end end size to lerp between
  12763. * @param amount amount to lerp between the start and end values
  12764. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12765. */
  12766. static Lerp(start: Size, end: Size, amount: number): Size;
  12767. }
  12768. }
  12769. declare module BABYLON {
  12770. /**
  12771. * Defines a runtime animation
  12772. */
  12773. export class RuntimeAnimation {
  12774. private _events;
  12775. /**
  12776. * The current frame of the runtime animation
  12777. */
  12778. private _currentFrame;
  12779. /**
  12780. * The animation used by the runtime animation
  12781. */
  12782. private _animation;
  12783. /**
  12784. * The target of the runtime animation
  12785. */
  12786. private _target;
  12787. /**
  12788. * The initiating animatable
  12789. */
  12790. private _host;
  12791. /**
  12792. * The original value of the runtime animation
  12793. */
  12794. private _originalValue;
  12795. /**
  12796. * The original blend value of the runtime animation
  12797. */
  12798. private _originalBlendValue;
  12799. /**
  12800. * The offsets cache of the runtime animation
  12801. */
  12802. private _offsetsCache;
  12803. /**
  12804. * The high limits cache of the runtime animation
  12805. */
  12806. private _highLimitsCache;
  12807. /**
  12808. * Specifies if the runtime animation has been stopped
  12809. */
  12810. private _stopped;
  12811. /**
  12812. * The blending factor of the runtime animation
  12813. */
  12814. private _blendingFactor;
  12815. /**
  12816. * The BabylonJS scene
  12817. */
  12818. private _scene;
  12819. /**
  12820. * The current value of the runtime animation
  12821. */
  12822. private _currentValue;
  12823. /** @hidden */
  12824. _animationState: _IAnimationState;
  12825. /**
  12826. * The active target of the runtime animation
  12827. */
  12828. private _activeTargets;
  12829. private _currentActiveTarget;
  12830. private _directTarget;
  12831. /**
  12832. * The target path of the runtime animation
  12833. */
  12834. private _targetPath;
  12835. /**
  12836. * The weight of the runtime animation
  12837. */
  12838. private _weight;
  12839. /**
  12840. * The ratio offset of the runtime animation
  12841. */
  12842. private _ratioOffset;
  12843. /**
  12844. * The previous delay of the runtime animation
  12845. */
  12846. private _previousDelay;
  12847. /**
  12848. * The previous ratio of the runtime animation
  12849. */
  12850. private _previousRatio;
  12851. private _enableBlending;
  12852. private _keys;
  12853. private _minFrame;
  12854. private _maxFrame;
  12855. private _minValue;
  12856. private _maxValue;
  12857. private _targetIsArray;
  12858. /**
  12859. * Gets the current frame of the runtime animation
  12860. */
  12861. readonly currentFrame: number;
  12862. /**
  12863. * Gets the weight of the runtime animation
  12864. */
  12865. readonly weight: number;
  12866. /**
  12867. * Gets the current value of the runtime animation
  12868. */
  12869. readonly currentValue: any;
  12870. /**
  12871. * Gets the target path of the runtime animation
  12872. */
  12873. readonly targetPath: string;
  12874. /**
  12875. * Gets the actual target of the runtime animation
  12876. */
  12877. readonly target: any;
  12878. /** @hidden */
  12879. _onLoop: () => void;
  12880. /**
  12881. * Create a new RuntimeAnimation object
  12882. * @param target defines the target of the animation
  12883. * @param animation defines the source animation object
  12884. * @param scene defines the hosting scene
  12885. * @param host defines the initiating Animatable
  12886. */
  12887. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12888. private _preparePath;
  12889. /**
  12890. * Gets the animation from the runtime animation
  12891. */
  12892. readonly animation: Animation;
  12893. /**
  12894. * Resets the runtime animation to the beginning
  12895. * @param restoreOriginal defines whether to restore the target property to the original value
  12896. */
  12897. reset(restoreOriginal?: boolean): void;
  12898. /**
  12899. * Specifies if the runtime animation is stopped
  12900. * @returns Boolean specifying if the runtime animation is stopped
  12901. */
  12902. isStopped(): boolean;
  12903. /**
  12904. * Disposes of the runtime animation
  12905. */
  12906. dispose(): void;
  12907. /**
  12908. * Apply the interpolated value to the target
  12909. * @param currentValue defines the value computed by the animation
  12910. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12911. */
  12912. setValue(currentValue: any, weight: number): void;
  12913. private _getOriginalValues;
  12914. private _setValue;
  12915. /**
  12916. * Gets the loop pmode of the runtime animation
  12917. * @returns Loop Mode
  12918. */
  12919. private _getCorrectLoopMode;
  12920. /**
  12921. * Move the current animation to a given frame
  12922. * @param frame defines the frame to move to
  12923. */
  12924. goToFrame(frame: number): void;
  12925. /**
  12926. * @hidden Internal use only
  12927. */
  12928. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12929. /**
  12930. * Execute the current animation
  12931. * @param delay defines the delay to add to the current frame
  12932. * @param from defines the lower bound of the animation range
  12933. * @param to defines the upper bound of the animation range
  12934. * @param loop defines if the current animation must loop
  12935. * @param speedRatio defines the current speed ratio
  12936. * @param weight defines the weight of the animation (default is -1 so no weight)
  12937. * @param onLoop optional callback called when animation loops
  12938. * @returns a boolean indicating if the animation is running
  12939. */
  12940. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12941. }
  12942. }
  12943. declare module BABYLON {
  12944. /**
  12945. * Class used to store an actual running animation
  12946. */
  12947. export class Animatable {
  12948. /** defines the target object */
  12949. target: any;
  12950. /** defines the starting frame number (default is 0) */
  12951. fromFrame: number;
  12952. /** defines the ending frame number (default is 100) */
  12953. toFrame: number;
  12954. /** defines if the animation must loop (default is false) */
  12955. loopAnimation: boolean;
  12956. /** defines a callback to call when animation ends if it is not looping */
  12957. onAnimationEnd?: (() => void) | null | undefined;
  12958. /** defines a callback to call when animation loops */
  12959. onAnimationLoop?: (() => void) | null | undefined;
  12960. private _localDelayOffset;
  12961. private _pausedDelay;
  12962. private _runtimeAnimations;
  12963. private _paused;
  12964. private _scene;
  12965. private _speedRatio;
  12966. private _weight;
  12967. private _syncRoot;
  12968. /**
  12969. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12970. * This will only apply for non looping animation (default is true)
  12971. */
  12972. disposeOnEnd: boolean;
  12973. /**
  12974. * Gets a boolean indicating if the animation has started
  12975. */
  12976. animationStarted: boolean;
  12977. /**
  12978. * Observer raised when the animation ends
  12979. */
  12980. onAnimationEndObservable: Observable<Animatable>;
  12981. /**
  12982. * Observer raised when the animation loops
  12983. */
  12984. onAnimationLoopObservable: Observable<Animatable>;
  12985. /**
  12986. * Gets the root Animatable used to synchronize and normalize animations
  12987. */
  12988. readonly syncRoot: Nullable<Animatable>;
  12989. /**
  12990. * Gets the current frame of the first RuntimeAnimation
  12991. * Used to synchronize Animatables
  12992. */
  12993. readonly masterFrame: number;
  12994. /**
  12995. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12996. */
  12997. weight: number;
  12998. /**
  12999. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13000. */
  13001. speedRatio: number;
  13002. /**
  13003. * Creates a new Animatable
  13004. * @param scene defines the hosting scene
  13005. * @param target defines the target object
  13006. * @param fromFrame defines the starting frame number (default is 0)
  13007. * @param toFrame defines the ending frame number (default is 100)
  13008. * @param loopAnimation defines if the animation must loop (default is false)
  13009. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13010. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13011. * @param animations defines a group of animation to add to the new Animatable
  13012. * @param onAnimationLoop defines a callback to call when animation loops
  13013. */
  13014. constructor(scene: Scene,
  13015. /** defines the target object */
  13016. target: any,
  13017. /** defines the starting frame number (default is 0) */
  13018. fromFrame?: number,
  13019. /** defines the ending frame number (default is 100) */
  13020. toFrame?: number,
  13021. /** defines if the animation must loop (default is false) */
  13022. loopAnimation?: boolean, speedRatio?: number,
  13023. /** defines a callback to call when animation ends if it is not looping */
  13024. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13025. /** defines a callback to call when animation loops */
  13026. onAnimationLoop?: (() => void) | null | undefined);
  13027. /**
  13028. * Synchronize and normalize current Animatable with a source Animatable
  13029. * This is useful when using animation weights and when animations are not of the same length
  13030. * @param root defines the root Animatable to synchronize with
  13031. * @returns the current Animatable
  13032. */
  13033. syncWith(root: Animatable): Animatable;
  13034. /**
  13035. * Gets the list of runtime animations
  13036. * @returns an array of RuntimeAnimation
  13037. */
  13038. getAnimations(): RuntimeAnimation[];
  13039. /**
  13040. * Adds more animations to the current animatable
  13041. * @param target defines the target of the animations
  13042. * @param animations defines the new animations to add
  13043. */
  13044. appendAnimations(target: any, animations: Animation[]): void;
  13045. /**
  13046. * Gets the source animation for a specific property
  13047. * @param property defines the propertyu to look for
  13048. * @returns null or the source animation for the given property
  13049. */
  13050. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13051. /**
  13052. * Gets the runtime animation for a specific property
  13053. * @param property defines the propertyu to look for
  13054. * @returns null or the runtime animation for the given property
  13055. */
  13056. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13057. /**
  13058. * Resets the animatable to its original state
  13059. */
  13060. reset(): void;
  13061. /**
  13062. * Allows the animatable to blend with current running animations
  13063. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13064. * @param blendingSpeed defines the blending speed to use
  13065. */
  13066. enableBlending(blendingSpeed: number): void;
  13067. /**
  13068. * Disable animation blending
  13069. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13070. */
  13071. disableBlending(): void;
  13072. /**
  13073. * Jump directly to a given frame
  13074. * @param frame defines the frame to jump to
  13075. */
  13076. goToFrame(frame: number): void;
  13077. /**
  13078. * Pause the animation
  13079. */
  13080. pause(): void;
  13081. /**
  13082. * Restart the animation
  13083. */
  13084. restart(): void;
  13085. private _raiseOnAnimationEnd;
  13086. /**
  13087. * Stop and delete the current animation
  13088. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13089. * @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)
  13090. */
  13091. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13092. /**
  13093. * Wait asynchronously for the animation to end
  13094. * @returns a promise which will be fullfilled when the animation ends
  13095. */
  13096. waitAsync(): Promise<Animatable>;
  13097. /** @hidden */
  13098. _animate(delay: number): boolean;
  13099. }
  13100. interface Scene {
  13101. /** @hidden */
  13102. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13103. /** @hidden */
  13104. _processLateAnimationBindingsForMatrices(holder: {
  13105. totalWeight: number;
  13106. animations: RuntimeAnimation[];
  13107. originalValue: Matrix;
  13108. }): any;
  13109. /** @hidden */
  13110. _processLateAnimationBindingsForQuaternions(holder: {
  13111. totalWeight: number;
  13112. animations: RuntimeAnimation[];
  13113. originalValue: Quaternion;
  13114. }, refQuaternion: Quaternion): Quaternion;
  13115. /** @hidden */
  13116. _processLateAnimationBindings(): void;
  13117. /**
  13118. * Will start the animation sequence of a given target
  13119. * @param target defines the target
  13120. * @param from defines from which frame should animation start
  13121. * @param to defines until which frame should animation run.
  13122. * @param weight defines the weight to apply to the animation (1.0 by default)
  13123. * @param loop defines if the animation loops
  13124. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13125. * @param onAnimationEnd defines the function to be executed when the animation ends
  13126. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13127. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13128. * @param onAnimationLoop defines the callback to call when an animation loops
  13129. * @returns the animatable object created for this animation
  13130. */
  13131. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13132. /**
  13133. * Will start the animation sequence of a given target
  13134. * @param target defines the target
  13135. * @param from defines from which frame should animation start
  13136. * @param to defines until which frame should animation run.
  13137. * @param loop defines if the animation loops
  13138. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13139. * @param onAnimationEnd defines the function to be executed when the animation ends
  13140. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13141. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13142. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13143. * @param onAnimationLoop defines the callback to call when an animation loops
  13144. * @returns the animatable object created for this animation
  13145. */
  13146. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13147. /**
  13148. * Will start the animation sequence of a given target and its hierarchy
  13149. * @param target defines the target
  13150. * @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.
  13151. * @param from defines from which frame should animation start
  13152. * @param to defines until which frame should animation run.
  13153. * @param loop defines if the animation loops
  13154. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13155. * @param onAnimationEnd defines the function to be executed when the animation ends
  13156. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13157. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13158. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13159. * @param onAnimationLoop defines the callback to call when an animation loops
  13160. * @returns the list of created animatables
  13161. */
  13162. 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[];
  13163. /**
  13164. * Begin a new animation on a given node
  13165. * @param target defines the target where the animation will take place
  13166. * @param animations defines the list of animations to start
  13167. * @param from defines the initial value
  13168. * @param to defines the final value
  13169. * @param loop defines if you want animation to loop (off by default)
  13170. * @param speedRatio defines the speed ratio to apply to all animations
  13171. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13172. * @param onAnimationLoop defines the callback to call when an animation loops
  13173. * @returns the list of created animatables
  13174. */
  13175. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13176. /**
  13177. * Begin a new animation on a given node and its hierarchy
  13178. * @param target defines the root node where the animation will take place
  13179. * @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.
  13180. * @param animations defines the list of animations to start
  13181. * @param from defines the initial value
  13182. * @param to defines the final value
  13183. * @param loop defines if you want animation to loop (off by default)
  13184. * @param speedRatio defines the speed ratio to apply to all animations
  13185. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13186. * @param onAnimationLoop defines the callback to call when an animation loops
  13187. * @returns the list of animatables created for all nodes
  13188. */
  13189. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13190. /**
  13191. * Gets the animatable associated with a specific target
  13192. * @param target defines the target of the animatable
  13193. * @returns the required animatable if found
  13194. */
  13195. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13196. /**
  13197. * Gets all animatables associated with a given target
  13198. * @param target defines the target to look animatables for
  13199. * @returns an array of Animatables
  13200. */
  13201. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13202. /**
  13203. * Stops and removes all animations that have been applied to the scene
  13204. */
  13205. stopAllAnimations(): void;
  13206. /**
  13207. * Gets the current delta time used by animation engine
  13208. */
  13209. deltaTime: number;
  13210. }
  13211. interface Bone {
  13212. /**
  13213. * Copy an animation range from another bone
  13214. * @param source defines the source bone
  13215. * @param rangeName defines the range name to copy
  13216. * @param frameOffset defines the frame offset
  13217. * @param rescaleAsRequired defines if rescaling must be applied if required
  13218. * @param skelDimensionsRatio defines the scaling ratio
  13219. * @returns true if operation was successful
  13220. */
  13221. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13222. }
  13223. }
  13224. declare module BABYLON {
  13225. /**
  13226. * Class used to override all child animations of a given target
  13227. */
  13228. export class AnimationPropertiesOverride {
  13229. /**
  13230. * Gets or sets a value indicating if animation blending must be used
  13231. */
  13232. enableBlending: boolean;
  13233. /**
  13234. * Gets or sets the blending speed to use when enableBlending is true
  13235. */
  13236. blendingSpeed: number;
  13237. /**
  13238. * Gets or sets the default loop mode to use
  13239. */
  13240. loopMode: number;
  13241. }
  13242. }
  13243. declare module BABYLON {
  13244. /**
  13245. * Class used to handle skinning animations
  13246. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13247. */
  13248. export class Skeleton implements IAnimatable {
  13249. /** defines the skeleton name */
  13250. name: string;
  13251. /** defines the skeleton Id */
  13252. id: string;
  13253. /**
  13254. * Defines the list of child bones
  13255. */
  13256. bones: Bone[];
  13257. /**
  13258. * Defines an estimate of the dimension of the skeleton at rest
  13259. */
  13260. dimensionsAtRest: Vector3;
  13261. /**
  13262. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13263. */
  13264. needInitialSkinMatrix: boolean;
  13265. /**
  13266. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13267. */
  13268. overrideMesh: Nullable<AbstractMesh>;
  13269. /**
  13270. * Gets the list of animations attached to this skeleton
  13271. */
  13272. animations: Array<Animation>;
  13273. private _scene;
  13274. private _isDirty;
  13275. private _transformMatrices;
  13276. private _transformMatrixTexture;
  13277. private _meshesWithPoseMatrix;
  13278. private _animatables;
  13279. private _identity;
  13280. private _synchronizedWithMesh;
  13281. private _ranges;
  13282. private _lastAbsoluteTransformsUpdateId;
  13283. private _canUseTextureForBones;
  13284. private _uniqueId;
  13285. /** @hidden */
  13286. _numBonesWithLinkedTransformNode: number;
  13287. /** @hidden */
  13288. _hasWaitingData: Nullable<boolean>;
  13289. /**
  13290. * Specifies if the skeleton should be serialized
  13291. */
  13292. doNotSerialize: boolean;
  13293. private _useTextureToStoreBoneMatrices;
  13294. /**
  13295. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13296. * Please note that this option is not available if the hardware does not support it
  13297. */
  13298. useTextureToStoreBoneMatrices: boolean;
  13299. private _animationPropertiesOverride;
  13300. /**
  13301. * Gets or sets the animation properties override
  13302. */
  13303. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13304. /**
  13305. * List of inspectable custom properties (used by the Inspector)
  13306. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13307. */
  13308. inspectableCustomProperties: IInspectable[];
  13309. /**
  13310. * An observable triggered before computing the skeleton's matrices
  13311. */
  13312. onBeforeComputeObservable: Observable<Skeleton>;
  13313. /**
  13314. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13315. */
  13316. readonly isUsingTextureForMatrices: boolean;
  13317. /**
  13318. * Gets the unique ID of this skeleton
  13319. */
  13320. readonly uniqueId: number;
  13321. /**
  13322. * Creates a new skeleton
  13323. * @param name defines the skeleton name
  13324. * @param id defines the skeleton Id
  13325. * @param scene defines the hosting scene
  13326. */
  13327. constructor(
  13328. /** defines the skeleton name */
  13329. name: string,
  13330. /** defines the skeleton Id */
  13331. id: string, scene: Scene);
  13332. /**
  13333. * Gets the current object class name.
  13334. * @return the class name
  13335. */
  13336. getClassName(): string;
  13337. /**
  13338. * Returns an array containing the root bones
  13339. * @returns an array containing the root bones
  13340. */
  13341. getChildren(): Array<Bone>;
  13342. /**
  13343. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13344. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13345. * @returns a Float32Array containing matrices data
  13346. */
  13347. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13348. /**
  13349. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13350. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13351. * @returns a raw texture containing the data
  13352. */
  13353. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13354. /**
  13355. * Gets the current hosting scene
  13356. * @returns a scene object
  13357. */
  13358. getScene(): Scene;
  13359. /**
  13360. * Gets a string representing the current skeleton data
  13361. * @param fullDetails defines a boolean indicating if we want a verbose version
  13362. * @returns a string representing the current skeleton data
  13363. */
  13364. toString(fullDetails?: boolean): string;
  13365. /**
  13366. * Get bone's index searching by name
  13367. * @param name defines bone's name to search for
  13368. * @return the indice of the bone. Returns -1 if not found
  13369. */
  13370. getBoneIndexByName(name: string): number;
  13371. /**
  13372. * Creater a new animation range
  13373. * @param name defines the name of the range
  13374. * @param from defines the start key
  13375. * @param to defines the end key
  13376. */
  13377. createAnimationRange(name: string, from: number, to: number): void;
  13378. /**
  13379. * Delete a specific animation range
  13380. * @param name defines the name of the range
  13381. * @param deleteFrames defines if frames must be removed as well
  13382. */
  13383. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13384. /**
  13385. * Gets a specific animation range
  13386. * @param name defines the name of the range to look for
  13387. * @returns the requested animation range or null if not found
  13388. */
  13389. getAnimationRange(name: string): Nullable<AnimationRange>;
  13390. /**
  13391. * Gets the list of all animation ranges defined on this skeleton
  13392. * @returns an array
  13393. */
  13394. getAnimationRanges(): Nullable<AnimationRange>[];
  13395. /**
  13396. * Copy animation range from a source skeleton.
  13397. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13398. * @param source defines the source skeleton
  13399. * @param name defines the name of the range to copy
  13400. * @param rescaleAsRequired defines if rescaling must be applied if required
  13401. * @returns true if operation was successful
  13402. */
  13403. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13404. /**
  13405. * Forces the skeleton to go to rest pose
  13406. */
  13407. returnToRest(): void;
  13408. private _getHighestAnimationFrame;
  13409. /**
  13410. * Begin a specific animation range
  13411. * @param name defines the name of the range to start
  13412. * @param loop defines if looping must be turned on (false by default)
  13413. * @param speedRatio defines the speed ratio to apply (1 by default)
  13414. * @param onAnimationEnd defines a callback which will be called when animation will end
  13415. * @returns a new animatable
  13416. */
  13417. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13418. /** @hidden */
  13419. _markAsDirty(): void;
  13420. /** @hidden */
  13421. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13422. /** @hidden */
  13423. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13424. private _computeTransformMatrices;
  13425. /**
  13426. * Build all resources required to render a skeleton
  13427. */
  13428. prepare(): void;
  13429. /**
  13430. * Gets the list of animatables currently running for this skeleton
  13431. * @returns an array of animatables
  13432. */
  13433. getAnimatables(): IAnimatable[];
  13434. /**
  13435. * Clone the current skeleton
  13436. * @param name defines the name of the new skeleton
  13437. * @param id defines the id of the new skeleton
  13438. * @returns the new skeleton
  13439. */
  13440. clone(name: string, id: string): Skeleton;
  13441. /**
  13442. * Enable animation blending for this skeleton
  13443. * @param blendingSpeed defines the blending speed to apply
  13444. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13445. */
  13446. enableBlending(blendingSpeed?: number): void;
  13447. /**
  13448. * Releases all resources associated with the current skeleton
  13449. */
  13450. dispose(): void;
  13451. /**
  13452. * Serialize the skeleton in a JSON object
  13453. * @returns a JSON object
  13454. */
  13455. serialize(): any;
  13456. /**
  13457. * Creates a new skeleton from serialized data
  13458. * @param parsedSkeleton defines the serialized data
  13459. * @param scene defines the hosting scene
  13460. * @returns a new skeleton
  13461. */
  13462. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13463. /**
  13464. * Compute all node absolute transforms
  13465. * @param forceUpdate defines if computation must be done even if cache is up to date
  13466. */
  13467. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13468. /**
  13469. * Gets the root pose matrix
  13470. * @returns a matrix
  13471. */
  13472. getPoseMatrix(): Nullable<Matrix>;
  13473. /**
  13474. * Sorts bones per internal index
  13475. */
  13476. sortBones(): void;
  13477. private _sortBones;
  13478. }
  13479. }
  13480. declare module BABYLON {
  13481. /**
  13482. * Class used to store bone information
  13483. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13484. */
  13485. export class Bone extends Node {
  13486. /**
  13487. * defines the bone name
  13488. */
  13489. name: string;
  13490. private static _tmpVecs;
  13491. private static _tmpQuat;
  13492. private static _tmpMats;
  13493. /**
  13494. * Gets the list of child bones
  13495. */
  13496. children: Bone[];
  13497. /** Gets the animations associated with this bone */
  13498. animations: Animation[];
  13499. /**
  13500. * Gets or sets bone length
  13501. */
  13502. length: number;
  13503. /**
  13504. * @hidden Internal only
  13505. * Set this value to map this bone to a different index in the transform matrices
  13506. * Set this value to -1 to exclude the bone from the transform matrices
  13507. */
  13508. _index: Nullable<number>;
  13509. private _skeleton;
  13510. private _localMatrix;
  13511. private _restPose;
  13512. private _baseMatrix;
  13513. private _absoluteTransform;
  13514. private _invertedAbsoluteTransform;
  13515. private _parent;
  13516. private _scalingDeterminant;
  13517. private _worldTransform;
  13518. private _localScaling;
  13519. private _localRotation;
  13520. private _localPosition;
  13521. private _needToDecompose;
  13522. private _needToCompose;
  13523. /** @hidden */
  13524. _linkedTransformNode: Nullable<TransformNode>;
  13525. /** @hidden */
  13526. _waitingTransformNodeId: Nullable<string>;
  13527. /** @hidden */
  13528. /** @hidden */
  13529. _matrix: Matrix;
  13530. /**
  13531. * Create a new bone
  13532. * @param name defines the bone name
  13533. * @param skeleton defines the parent skeleton
  13534. * @param parentBone defines the parent (can be null if the bone is the root)
  13535. * @param localMatrix defines the local matrix
  13536. * @param restPose defines the rest pose matrix
  13537. * @param baseMatrix defines the base matrix
  13538. * @param index defines index of the bone in the hiearchy
  13539. */
  13540. constructor(
  13541. /**
  13542. * defines the bone name
  13543. */
  13544. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13545. /**
  13546. * Gets the current object class name.
  13547. * @return the class name
  13548. */
  13549. getClassName(): string;
  13550. /**
  13551. * Gets the parent skeleton
  13552. * @returns a skeleton
  13553. */
  13554. getSkeleton(): Skeleton;
  13555. /**
  13556. * Gets parent bone
  13557. * @returns a bone or null if the bone is the root of the bone hierarchy
  13558. */
  13559. getParent(): Nullable<Bone>;
  13560. /**
  13561. * Returns an array containing the root bones
  13562. * @returns an array containing the root bones
  13563. */
  13564. getChildren(): Array<Bone>;
  13565. /**
  13566. * Sets the parent bone
  13567. * @param parent defines the parent (can be null if the bone is the root)
  13568. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13569. */
  13570. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13571. /**
  13572. * Gets the local matrix
  13573. * @returns a matrix
  13574. */
  13575. getLocalMatrix(): Matrix;
  13576. /**
  13577. * Gets the base matrix (initial matrix which remains unchanged)
  13578. * @returns a matrix
  13579. */
  13580. getBaseMatrix(): Matrix;
  13581. /**
  13582. * Gets the rest pose matrix
  13583. * @returns a matrix
  13584. */
  13585. getRestPose(): Matrix;
  13586. /**
  13587. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13588. */
  13589. getWorldMatrix(): Matrix;
  13590. /**
  13591. * Sets the local matrix to rest pose matrix
  13592. */
  13593. returnToRest(): void;
  13594. /**
  13595. * Gets the inverse of the absolute transform matrix.
  13596. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13597. * @returns a matrix
  13598. */
  13599. getInvertedAbsoluteTransform(): Matrix;
  13600. /**
  13601. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13602. * @returns a matrix
  13603. */
  13604. getAbsoluteTransform(): Matrix;
  13605. /**
  13606. * Links with the given transform node.
  13607. * The local matrix of this bone is copied from the transform node every frame.
  13608. * @param transformNode defines the transform node to link to
  13609. */
  13610. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13611. /**
  13612. * Gets the node used to drive the bone's transformation
  13613. * @returns a transform node or null
  13614. */
  13615. getTransformNode(): Nullable<TransformNode>;
  13616. /** Gets or sets current position (in local space) */
  13617. position: Vector3;
  13618. /** Gets or sets current rotation (in local space) */
  13619. rotation: Vector3;
  13620. /** Gets or sets current rotation quaternion (in local space) */
  13621. rotationQuaternion: Quaternion;
  13622. /** Gets or sets current scaling (in local space) */
  13623. scaling: Vector3;
  13624. /**
  13625. * Gets the animation properties override
  13626. */
  13627. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13628. private _decompose;
  13629. private _compose;
  13630. /**
  13631. * Update the base and local matrices
  13632. * @param matrix defines the new base or local matrix
  13633. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13634. * @param updateLocalMatrix defines if the local matrix should be updated
  13635. */
  13636. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13637. /** @hidden */
  13638. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13639. /**
  13640. * Flag the bone as dirty (Forcing it to update everything)
  13641. */
  13642. markAsDirty(): void;
  13643. /** @hidden */
  13644. _markAsDirtyAndCompose(): void;
  13645. private _markAsDirtyAndDecompose;
  13646. /**
  13647. * Translate the bone in local or world space
  13648. * @param vec The amount to translate the bone
  13649. * @param space The space that the translation is in
  13650. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13651. */
  13652. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13653. /**
  13654. * Set the postion of the bone in local or world space
  13655. * @param position The position to set the bone
  13656. * @param space The space that the position is in
  13657. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13658. */
  13659. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13660. /**
  13661. * Set the absolute position of the bone (world space)
  13662. * @param position The position to set the bone
  13663. * @param mesh The mesh that this bone is attached to
  13664. */
  13665. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13666. /**
  13667. * Scale the bone on the x, y and z axes (in local space)
  13668. * @param x The amount to scale the bone on the x axis
  13669. * @param y The amount to scale the bone on the y axis
  13670. * @param z The amount to scale the bone on the z axis
  13671. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13672. */
  13673. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13674. /**
  13675. * Set the bone scaling in local space
  13676. * @param scale defines the scaling vector
  13677. */
  13678. setScale(scale: Vector3): void;
  13679. /**
  13680. * Gets the current scaling in local space
  13681. * @returns the current scaling vector
  13682. */
  13683. getScale(): Vector3;
  13684. /**
  13685. * Gets the current scaling in local space and stores it in a target vector
  13686. * @param result defines the target vector
  13687. */
  13688. getScaleToRef(result: Vector3): void;
  13689. /**
  13690. * Set the yaw, pitch, and roll of the bone in local or world space
  13691. * @param yaw The rotation of the bone on the y axis
  13692. * @param pitch The rotation of the bone on the x axis
  13693. * @param roll The rotation of the bone on the z axis
  13694. * @param space The space that the axes of rotation are in
  13695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13696. */
  13697. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13698. /**
  13699. * Add a rotation to the bone on an axis in local or world space
  13700. * @param axis The axis to rotate the bone on
  13701. * @param amount The amount to rotate the bone
  13702. * @param space The space that the axis is in
  13703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13704. */
  13705. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13706. /**
  13707. * Set the rotation of the bone to a particular axis angle in local or world space
  13708. * @param axis The axis to rotate the bone on
  13709. * @param angle The angle that the bone should be rotated to
  13710. * @param space The space that the axis is in
  13711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13712. */
  13713. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13714. /**
  13715. * Set the euler rotation of the bone in local of world space
  13716. * @param rotation The euler rotation that the bone should be set to
  13717. * @param space The space that the rotation is in
  13718. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13719. */
  13720. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13721. /**
  13722. * Set the quaternion rotation of the bone in local of world space
  13723. * @param quat The quaternion rotation that the bone should be set to
  13724. * @param space The space that the rotation is in
  13725. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13726. */
  13727. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13728. /**
  13729. * Set the rotation matrix of the bone in local of world space
  13730. * @param rotMat The rotation matrix that the bone should be set to
  13731. * @param space The space that the rotation is in
  13732. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13733. */
  13734. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13735. private _rotateWithMatrix;
  13736. private _getNegativeRotationToRef;
  13737. /**
  13738. * Get the position of the bone in local or world space
  13739. * @param space The space that the returned position is in
  13740. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13741. * @returns The position of the bone
  13742. */
  13743. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13744. /**
  13745. * Copy the position of the bone to a vector3 in local or world space
  13746. * @param space The space that the returned position is in
  13747. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13748. * @param result The vector3 to copy the position to
  13749. */
  13750. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13751. /**
  13752. * Get the absolute position of the bone (world space)
  13753. * @param mesh The mesh that this bone is attached to
  13754. * @returns The absolute position of the bone
  13755. */
  13756. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13757. /**
  13758. * Copy the absolute position of the bone (world space) to the result param
  13759. * @param mesh The mesh that this bone is attached to
  13760. * @param result The vector3 to copy the absolute position to
  13761. */
  13762. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13763. /**
  13764. * Compute the absolute transforms of this bone and its children
  13765. */
  13766. computeAbsoluteTransforms(): void;
  13767. /**
  13768. * Get the world direction from an axis that is in the local space of the bone
  13769. * @param localAxis The local direction that is used to compute the world direction
  13770. * @param mesh The mesh that this bone is attached to
  13771. * @returns The world direction
  13772. */
  13773. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13774. /**
  13775. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13776. * @param localAxis The local direction that is used to compute the world direction
  13777. * @param mesh The mesh that this bone is attached to
  13778. * @param result The vector3 that the world direction will be copied to
  13779. */
  13780. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13781. /**
  13782. * Get the euler rotation of the bone in local or world space
  13783. * @param space The space that the rotation should be in
  13784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13785. * @returns The euler rotation
  13786. */
  13787. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13788. /**
  13789. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13790. * @param space The space that the rotation should be in
  13791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13792. * @param result The vector3 that the rotation should be copied to
  13793. */
  13794. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13795. /**
  13796. * Get the quaternion rotation of the bone in either local or world space
  13797. * @param space The space that the rotation should be in
  13798. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13799. * @returns The quaternion rotation
  13800. */
  13801. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13802. /**
  13803. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13804. * @param space The space that the rotation should be in
  13805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13806. * @param result The quaternion that the rotation should be copied to
  13807. */
  13808. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13809. /**
  13810. * Get the rotation matrix of the bone in local or world space
  13811. * @param space The space that the rotation should be in
  13812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13813. * @returns The rotation matrix
  13814. */
  13815. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13816. /**
  13817. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13818. * @param space The space that the rotation should be in
  13819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13820. * @param result The quaternion that the rotation should be copied to
  13821. */
  13822. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13823. /**
  13824. * Get the world position of a point that is in the local space of the bone
  13825. * @param position The local position
  13826. * @param mesh The mesh that this bone is attached to
  13827. * @returns The world position
  13828. */
  13829. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13830. /**
  13831. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13832. * @param position The local position
  13833. * @param mesh The mesh that this bone is attached to
  13834. * @param result The vector3 that the world position should be copied to
  13835. */
  13836. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13837. /**
  13838. * Get the local position of a point that is in world space
  13839. * @param position The world position
  13840. * @param mesh The mesh that this bone is attached to
  13841. * @returns The local position
  13842. */
  13843. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13844. /**
  13845. * Get the local position of a point that is in world space and copy it to the result param
  13846. * @param position The world position
  13847. * @param mesh The mesh that this bone is attached to
  13848. * @param result The vector3 that the local position should be copied to
  13849. */
  13850. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13851. }
  13852. }
  13853. declare module BABYLON {
  13854. /**
  13855. * 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.
  13856. * @see https://doc.babylonjs.com/how_to/transformnode
  13857. */
  13858. export class TransformNode extends Node {
  13859. /**
  13860. * Object will not rotate to face the camera
  13861. */
  13862. static BILLBOARDMODE_NONE: number;
  13863. /**
  13864. * Object will rotate to face the camera but only on the x axis
  13865. */
  13866. static BILLBOARDMODE_X: number;
  13867. /**
  13868. * Object will rotate to face the camera but only on the y axis
  13869. */
  13870. static BILLBOARDMODE_Y: number;
  13871. /**
  13872. * Object will rotate to face the camera but only on the z axis
  13873. */
  13874. static BILLBOARDMODE_Z: number;
  13875. /**
  13876. * Object will rotate to face the camera
  13877. */
  13878. static BILLBOARDMODE_ALL: number;
  13879. /**
  13880. * Object will rotate to face the camera's position instead of orientation
  13881. */
  13882. static BILLBOARDMODE_USE_POSITION: number;
  13883. private _forward;
  13884. private _forwardInverted;
  13885. private _up;
  13886. private _right;
  13887. private _rightInverted;
  13888. private _position;
  13889. private _rotation;
  13890. private _rotationQuaternion;
  13891. protected _scaling: Vector3;
  13892. protected _isDirty: boolean;
  13893. private _transformToBoneReferal;
  13894. private _isAbsoluteSynced;
  13895. private _billboardMode;
  13896. /**
  13897. * Gets or sets the billboard mode. Default is 0.
  13898. *
  13899. * | Value | Type | Description |
  13900. * | --- | --- | --- |
  13901. * | 0 | BILLBOARDMODE_NONE | |
  13902. * | 1 | BILLBOARDMODE_X | |
  13903. * | 2 | BILLBOARDMODE_Y | |
  13904. * | 4 | BILLBOARDMODE_Z | |
  13905. * | 7 | BILLBOARDMODE_ALL | |
  13906. *
  13907. */
  13908. billboardMode: number;
  13909. private _preserveParentRotationForBillboard;
  13910. /**
  13911. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13912. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13913. */
  13914. preserveParentRotationForBillboard: boolean;
  13915. /**
  13916. * 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
  13917. */
  13918. scalingDeterminant: number;
  13919. private _infiniteDistance;
  13920. /**
  13921. * Gets or sets the distance of the object to max, often used by skybox
  13922. */
  13923. infiniteDistance: boolean;
  13924. /**
  13925. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13926. * By default the system will update normals to compensate
  13927. */
  13928. ignoreNonUniformScaling: boolean;
  13929. /**
  13930. * 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
  13931. */
  13932. reIntegrateRotationIntoRotationQuaternion: boolean;
  13933. /** @hidden */
  13934. _poseMatrix: Nullable<Matrix>;
  13935. /** @hidden */
  13936. _localMatrix: Matrix;
  13937. private _usePivotMatrix;
  13938. private _absolutePosition;
  13939. private _absoluteScaling;
  13940. private _absoluteRotationQuaternion;
  13941. private _pivotMatrix;
  13942. private _pivotMatrixInverse;
  13943. protected _postMultiplyPivotMatrix: boolean;
  13944. protected _isWorldMatrixFrozen: boolean;
  13945. /** @hidden */
  13946. _indexInSceneTransformNodesArray: number;
  13947. /**
  13948. * An event triggered after the world matrix is updated
  13949. */
  13950. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13951. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13952. /**
  13953. * Gets a string identifying the name of the class
  13954. * @returns "TransformNode" string
  13955. */
  13956. getClassName(): string;
  13957. /**
  13958. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13959. */
  13960. position: Vector3;
  13961. /**
  13962. * 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)).
  13963. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13964. */
  13965. rotation: Vector3;
  13966. /**
  13967. * 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)).
  13968. */
  13969. scaling: Vector3;
  13970. /**
  13971. * 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).
  13972. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13973. */
  13974. rotationQuaternion: Nullable<Quaternion>;
  13975. /**
  13976. * The forward direction of that transform in world space.
  13977. */
  13978. readonly forward: Vector3;
  13979. /**
  13980. * The up direction of that transform in world space.
  13981. */
  13982. readonly up: Vector3;
  13983. /**
  13984. * The right direction of that transform in world space.
  13985. */
  13986. readonly right: Vector3;
  13987. /**
  13988. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13989. * @param matrix the matrix to copy the pose from
  13990. * @returns this TransformNode.
  13991. */
  13992. updatePoseMatrix(matrix: Matrix): TransformNode;
  13993. /**
  13994. * Returns the mesh Pose matrix.
  13995. * @returns the pose matrix
  13996. */
  13997. getPoseMatrix(): Matrix;
  13998. /** @hidden */
  13999. _isSynchronized(): boolean;
  14000. /** @hidden */
  14001. _initCache(): void;
  14002. /**
  14003. * Flag the transform node as dirty (Forcing it to update everything)
  14004. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14005. * @returns this transform node
  14006. */
  14007. markAsDirty(property: string): TransformNode;
  14008. /**
  14009. * Returns the current mesh absolute position.
  14010. * Returns a Vector3.
  14011. */
  14012. readonly absolutePosition: Vector3;
  14013. /**
  14014. * Returns the current mesh absolute scaling.
  14015. * Returns a Vector3.
  14016. */
  14017. readonly absoluteScaling: Vector3;
  14018. /**
  14019. * Returns the current mesh absolute rotation.
  14020. * Returns a Quaternion.
  14021. */
  14022. readonly absoluteRotationQuaternion: Quaternion;
  14023. /**
  14024. * Sets a new matrix to apply before all other transformation
  14025. * @param matrix defines the transform matrix
  14026. * @returns the current TransformNode
  14027. */
  14028. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14029. /**
  14030. * Sets a new pivot matrix to the current node
  14031. * @param matrix defines the new pivot matrix to use
  14032. * @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
  14033. * @returns the current TransformNode
  14034. */
  14035. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14036. /**
  14037. * Returns the mesh pivot matrix.
  14038. * Default : Identity.
  14039. * @returns the matrix
  14040. */
  14041. getPivotMatrix(): Matrix;
  14042. /**
  14043. * Instantiate (when possible) or clone that node with its hierarchy
  14044. * @param newParent defines the new parent to use for the instance (or clone)
  14045. * @returns an instance (or a clone) of the current node with its hiearchy
  14046. */
  14047. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14048. /**
  14049. * Prevents the World matrix to be computed any longer
  14050. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14051. * @returns the TransformNode.
  14052. */
  14053. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14054. /**
  14055. * Allows back the World matrix computation.
  14056. * @returns the TransformNode.
  14057. */
  14058. unfreezeWorldMatrix(): this;
  14059. /**
  14060. * True if the World matrix has been frozen.
  14061. */
  14062. readonly isWorldMatrixFrozen: boolean;
  14063. /**
  14064. * Retuns the mesh absolute position in the World.
  14065. * @returns a Vector3.
  14066. */
  14067. getAbsolutePosition(): Vector3;
  14068. /**
  14069. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14070. * @param absolutePosition the absolute position to set
  14071. * @returns the TransformNode.
  14072. */
  14073. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14074. /**
  14075. * Sets the mesh position in its local space.
  14076. * @param vector3 the position to set in localspace
  14077. * @returns the TransformNode.
  14078. */
  14079. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14080. /**
  14081. * Returns the mesh position in the local space from the current World matrix values.
  14082. * @returns a new Vector3.
  14083. */
  14084. getPositionExpressedInLocalSpace(): Vector3;
  14085. /**
  14086. * Translates the mesh along the passed Vector3 in its local space.
  14087. * @param vector3 the distance to translate in localspace
  14088. * @returns the TransformNode.
  14089. */
  14090. locallyTranslate(vector3: Vector3): TransformNode;
  14091. private static _lookAtVectorCache;
  14092. /**
  14093. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14094. * @param targetPoint the position (must be in same space as current mesh) to look at
  14095. * @param yawCor optional yaw (y-axis) correction in radians
  14096. * @param pitchCor optional pitch (x-axis) correction in radians
  14097. * @param rollCor optional roll (z-axis) correction in radians
  14098. * @param space the choosen space of the target
  14099. * @returns the TransformNode.
  14100. */
  14101. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14102. /**
  14103. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14104. * This Vector3 is expressed in the World space.
  14105. * @param localAxis axis to rotate
  14106. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14107. */
  14108. getDirection(localAxis: Vector3): Vector3;
  14109. /**
  14110. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14111. * localAxis is expressed in the mesh local space.
  14112. * result is computed in the Wordl space from the mesh World matrix.
  14113. * @param localAxis axis to rotate
  14114. * @param result the resulting transformnode
  14115. * @returns this TransformNode.
  14116. */
  14117. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14118. /**
  14119. * Sets this transform node rotation to the given local axis.
  14120. * @param localAxis the axis in local space
  14121. * @param yawCor optional yaw (y-axis) correction in radians
  14122. * @param pitchCor optional pitch (x-axis) correction in radians
  14123. * @param rollCor optional roll (z-axis) correction in radians
  14124. * @returns this TransformNode
  14125. */
  14126. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14127. /**
  14128. * Sets a new pivot point to the current node
  14129. * @param point defines the new pivot point to use
  14130. * @param space defines if the point is in world or local space (local by default)
  14131. * @returns the current TransformNode
  14132. */
  14133. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14134. /**
  14135. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14136. * @returns the pivot point
  14137. */
  14138. getPivotPoint(): Vector3;
  14139. /**
  14140. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14141. * @param result the vector3 to store the result
  14142. * @returns this TransformNode.
  14143. */
  14144. getPivotPointToRef(result: Vector3): TransformNode;
  14145. /**
  14146. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14147. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14148. */
  14149. getAbsolutePivotPoint(): Vector3;
  14150. /**
  14151. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14152. * @param result vector3 to store the result
  14153. * @returns this TransformNode.
  14154. */
  14155. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14156. /**
  14157. * Defines the passed node as the parent of the current node.
  14158. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14159. * @see https://doc.babylonjs.com/how_to/parenting
  14160. * @param node the node ot set as the parent
  14161. * @returns this TransformNode.
  14162. */
  14163. setParent(node: Nullable<Node>): TransformNode;
  14164. private _nonUniformScaling;
  14165. /**
  14166. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14167. */
  14168. readonly nonUniformScaling: boolean;
  14169. /** @hidden */
  14170. _updateNonUniformScalingState(value: boolean): boolean;
  14171. /**
  14172. * Attach the current TransformNode to another TransformNode associated with a bone
  14173. * @param bone Bone affecting the TransformNode
  14174. * @param affectedTransformNode TransformNode associated with the bone
  14175. * @returns this object
  14176. */
  14177. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14178. /**
  14179. * Detach the transform node if its associated with a bone
  14180. * @returns this object
  14181. */
  14182. detachFromBone(): TransformNode;
  14183. private static _rotationAxisCache;
  14184. /**
  14185. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14186. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14187. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14188. * The passed axis is also normalized.
  14189. * @param axis the axis to rotate around
  14190. * @param amount the amount to rotate in radians
  14191. * @param space Space to rotate in (Default: local)
  14192. * @returns the TransformNode.
  14193. */
  14194. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14195. /**
  14196. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14197. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14198. * The passed axis is also normalized. .
  14199. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14200. * @param point the point to rotate around
  14201. * @param axis the axis to rotate around
  14202. * @param amount the amount to rotate in radians
  14203. * @returns the TransformNode
  14204. */
  14205. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14206. /**
  14207. * Translates the mesh along the axis vector for the passed distance in the given space.
  14208. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14209. * @param axis the axis to translate in
  14210. * @param distance the distance to translate
  14211. * @param space Space to rotate in (Default: local)
  14212. * @returns the TransformNode.
  14213. */
  14214. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14215. /**
  14216. * Adds a rotation step to the mesh current rotation.
  14217. * x, y, z are Euler angles expressed in radians.
  14218. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14219. * This means this rotation is made in the mesh local space only.
  14220. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14221. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14222. * ```javascript
  14223. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14224. * ```
  14225. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14226. * 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.
  14227. * @param x Rotation to add
  14228. * @param y Rotation to add
  14229. * @param z Rotation to add
  14230. * @returns the TransformNode.
  14231. */
  14232. addRotation(x: number, y: number, z: number): TransformNode;
  14233. /**
  14234. * @hidden
  14235. */
  14236. protected _getEffectiveParent(): Nullable<Node>;
  14237. /**
  14238. * Computes the world matrix of the node
  14239. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14240. * @returns the world matrix
  14241. */
  14242. computeWorldMatrix(force?: boolean): Matrix;
  14243. protected _afterComputeWorldMatrix(): void;
  14244. /**
  14245. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14246. * @param func callback function to add
  14247. *
  14248. * @returns the TransformNode.
  14249. */
  14250. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14251. /**
  14252. * Removes a registered callback function.
  14253. * @param func callback function to remove
  14254. * @returns the TransformNode.
  14255. */
  14256. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14257. /**
  14258. * Gets the position of the current mesh in camera space
  14259. * @param camera defines the camera to use
  14260. * @returns a position
  14261. */
  14262. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14263. /**
  14264. * Returns the distance from the mesh to the active camera
  14265. * @param camera defines the camera to use
  14266. * @returns the distance
  14267. */
  14268. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14269. /**
  14270. * Clone the current transform node
  14271. * @param name Name of the new clone
  14272. * @param newParent New parent for the clone
  14273. * @param doNotCloneChildren Do not clone children hierarchy
  14274. * @returns the new transform node
  14275. */
  14276. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14277. /**
  14278. * Serializes the objects information.
  14279. * @param currentSerializationObject defines the object to serialize in
  14280. * @returns the serialized object
  14281. */
  14282. serialize(currentSerializationObject?: any): any;
  14283. /**
  14284. * Returns a new TransformNode object parsed from the source provided.
  14285. * @param parsedTransformNode is the source.
  14286. * @param scene the scne the object belongs to
  14287. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14288. * @returns a new TransformNode object parsed from the source provided.
  14289. */
  14290. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14291. /**
  14292. * Get all child-transformNodes of this node
  14293. * @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
  14294. * @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
  14295. * @returns an array of TransformNode
  14296. */
  14297. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14298. /**
  14299. * Releases resources associated with this transform node.
  14300. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14301. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14302. */
  14303. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14304. /**
  14305. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14306. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14307. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14308. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14309. * @returns the current mesh
  14310. */
  14311. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14312. private _syncAbsoluteScalingAndRotation;
  14313. }
  14314. }
  14315. declare module BABYLON {
  14316. /**
  14317. * Defines the types of pose enabled controllers that are supported
  14318. */
  14319. export enum PoseEnabledControllerType {
  14320. /**
  14321. * HTC Vive
  14322. */
  14323. VIVE = 0,
  14324. /**
  14325. * Oculus Rift
  14326. */
  14327. OCULUS = 1,
  14328. /**
  14329. * Windows mixed reality
  14330. */
  14331. WINDOWS = 2,
  14332. /**
  14333. * Samsung gear VR
  14334. */
  14335. GEAR_VR = 3,
  14336. /**
  14337. * Google Daydream
  14338. */
  14339. DAYDREAM = 4,
  14340. /**
  14341. * Generic
  14342. */
  14343. GENERIC = 5
  14344. }
  14345. /**
  14346. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14347. */
  14348. export interface MutableGamepadButton {
  14349. /**
  14350. * Value of the button/trigger
  14351. */
  14352. value: number;
  14353. /**
  14354. * If the button/trigger is currently touched
  14355. */
  14356. touched: boolean;
  14357. /**
  14358. * If the button/trigger is currently pressed
  14359. */
  14360. pressed: boolean;
  14361. }
  14362. /**
  14363. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14364. * @hidden
  14365. */
  14366. export interface ExtendedGamepadButton extends GamepadButton {
  14367. /**
  14368. * If the button/trigger is currently pressed
  14369. */
  14370. readonly pressed: boolean;
  14371. /**
  14372. * If the button/trigger is currently touched
  14373. */
  14374. readonly touched: boolean;
  14375. /**
  14376. * Value of the button/trigger
  14377. */
  14378. readonly value: number;
  14379. }
  14380. /** @hidden */
  14381. export interface _GamePadFactory {
  14382. /**
  14383. * Returns wether or not the current gamepad can be created for this type of controller.
  14384. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14385. * @returns true if it can be created, otherwise false
  14386. */
  14387. canCreate(gamepadInfo: any): boolean;
  14388. /**
  14389. * Creates a new instance of the Gamepad.
  14390. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14391. * @returns the new gamepad instance
  14392. */
  14393. create(gamepadInfo: any): Gamepad;
  14394. }
  14395. /**
  14396. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14397. */
  14398. export class PoseEnabledControllerHelper {
  14399. /** @hidden */
  14400. static _ControllerFactories: _GamePadFactory[];
  14401. /** @hidden */
  14402. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14403. /**
  14404. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14405. * @param vrGamepad the gamepad to initialized
  14406. * @returns a vr controller of the type the gamepad identified as
  14407. */
  14408. static InitiateController(vrGamepad: any): Gamepad;
  14409. }
  14410. /**
  14411. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14412. */
  14413. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14414. /**
  14415. * If the controller is used in a webXR session
  14416. */
  14417. isXR: boolean;
  14418. private _deviceRoomPosition;
  14419. private _deviceRoomRotationQuaternion;
  14420. /**
  14421. * The device position in babylon space
  14422. */
  14423. devicePosition: Vector3;
  14424. /**
  14425. * The device rotation in babylon space
  14426. */
  14427. deviceRotationQuaternion: Quaternion;
  14428. /**
  14429. * The scale factor of the device in babylon space
  14430. */
  14431. deviceScaleFactor: number;
  14432. /**
  14433. * (Likely devicePosition should be used instead) The device position in its room space
  14434. */
  14435. position: Vector3;
  14436. /**
  14437. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14438. */
  14439. rotationQuaternion: Quaternion;
  14440. /**
  14441. * The type of controller (Eg. Windows mixed reality)
  14442. */
  14443. controllerType: PoseEnabledControllerType;
  14444. protected _calculatedPosition: Vector3;
  14445. private _calculatedRotation;
  14446. /**
  14447. * The raw pose from the device
  14448. */
  14449. rawPose: DevicePose;
  14450. private _trackPosition;
  14451. private _maxRotationDistFromHeadset;
  14452. private _draggedRoomRotation;
  14453. /**
  14454. * @hidden
  14455. */
  14456. _disableTrackPosition(fixedPosition: Vector3): void;
  14457. /**
  14458. * Internal, the mesh attached to the controller
  14459. * @hidden
  14460. */
  14461. _mesh: Nullable<AbstractMesh>;
  14462. private _poseControlledCamera;
  14463. private _leftHandSystemQuaternion;
  14464. /**
  14465. * Internal, matrix used to convert room space to babylon space
  14466. * @hidden
  14467. */
  14468. _deviceToWorld: Matrix;
  14469. /**
  14470. * Node to be used when casting a ray from the controller
  14471. * @hidden
  14472. */
  14473. _pointingPoseNode: Nullable<TransformNode>;
  14474. /**
  14475. * Name of the child mesh that can be used to cast a ray from the controller
  14476. */
  14477. static readonly POINTING_POSE: string;
  14478. /**
  14479. * Creates a new PoseEnabledController from a gamepad
  14480. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14481. */
  14482. constructor(browserGamepad: any);
  14483. private _workingMatrix;
  14484. /**
  14485. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14486. */
  14487. update(): void;
  14488. /**
  14489. * Updates only the pose device and mesh without doing any button event checking
  14490. */
  14491. protected _updatePoseAndMesh(): void;
  14492. /**
  14493. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14494. * @param poseData raw pose fromthe device
  14495. */
  14496. updateFromDevice(poseData: DevicePose): void;
  14497. /**
  14498. * @hidden
  14499. */
  14500. _meshAttachedObservable: Observable<AbstractMesh>;
  14501. /**
  14502. * Attaches a mesh to the controller
  14503. * @param mesh the mesh to be attached
  14504. */
  14505. attachToMesh(mesh: AbstractMesh): void;
  14506. /**
  14507. * Attaches the controllers mesh to a camera
  14508. * @param camera the camera the mesh should be attached to
  14509. */
  14510. attachToPoseControlledCamera(camera: TargetCamera): void;
  14511. /**
  14512. * Disposes of the controller
  14513. */
  14514. dispose(): void;
  14515. /**
  14516. * The mesh that is attached to the controller
  14517. */
  14518. readonly mesh: Nullable<AbstractMesh>;
  14519. /**
  14520. * Gets the ray of the controller in the direction the controller is pointing
  14521. * @param length the length the resulting ray should be
  14522. * @returns a ray in the direction the controller is pointing
  14523. */
  14524. getForwardRay(length?: number): Ray;
  14525. }
  14526. }
  14527. declare module BABYLON {
  14528. /**
  14529. * Defines the WebVRController object that represents controllers tracked in 3D space
  14530. */
  14531. export abstract class WebVRController extends PoseEnabledController {
  14532. /**
  14533. * Internal, the default controller model for the controller
  14534. */
  14535. protected _defaultModel: Nullable<AbstractMesh>;
  14536. /**
  14537. * Fired when the trigger state has changed
  14538. */
  14539. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14540. /**
  14541. * Fired when the main button state has changed
  14542. */
  14543. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14544. /**
  14545. * Fired when the secondary button state has changed
  14546. */
  14547. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14548. /**
  14549. * Fired when the pad state has changed
  14550. */
  14551. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14552. /**
  14553. * Fired when controllers stick values have changed
  14554. */
  14555. onPadValuesChangedObservable: Observable<StickValues>;
  14556. /**
  14557. * Array of button availible on the controller
  14558. */
  14559. protected _buttons: Array<MutableGamepadButton>;
  14560. private _onButtonStateChange;
  14561. /**
  14562. * Fired when a controller button's state has changed
  14563. * @param callback the callback containing the button that was modified
  14564. */
  14565. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14566. /**
  14567. * X and Y axis corresponding to the controllers joystick
  14568. */
  14569. pad: StickValues;
  14570. /**
  14571. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14572. */
  14573. hand: string;
  14574. /**
  14575. * The default controller model for the controller
  14576. */
  14577. readonly defaultModel: Nullable<AbstractMesh>;
  14578. /**
  14579. * Creates a new WebVRController from a gamepad
  14580. * @param vrGamepad the gamepad that the WebVRController should be created from
  14581. */
  14582. constructor(vrGamepad: any);
  14583. /**
  14584. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14585. */
  14586. update(): void;
  14587. /**
  14588. * Function to be called when a button is modified
  14589. */
  14590. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14591. /**
  14592. * Loads a mesh and attaches it to the controller
  14593. * @param scene the scene the mesh should be added to
  14594. * @param meshLoaded callback for when the mesh has been loaded
  14595. */
  14596. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14597. private _setButtonValue;
  14598. private _changes;
  14599. private _checkChanges;
  14600. /**
  14601. * Disposes of th webVRCOntroller
  14602. */
  14603. dispose(): void;
  14604. }
  14605. }
  14606. declare module BABYLON {
  14607. /**
  14608. * The HemisphericLight simulates the ambient environment light,
  14609. * so the passed direction is the light reflection direction, not the incoming direction.
  14610. */
  14611. export class HemisphericLight extends Light {
  14612. /**
  14613. * The groundColor is the light in the opposite direction to the one specified during creation.
  14614. * 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.
  14615. */
  14616. groundColor: Color3;
  14617. /**
  14618. * The light reflection direction, not the incoming direction.
  14619. */
  14620. direction: Vector3;
  14621. /**
  14622. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14623. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14624. * The HemisphericLight can't cast shadows.
  14625. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14626. * @param name The friendly name of the light
  14627. * @param direction The direction of the light reflection
  14628. * @param scene The scene the light belongs to
  14629. */
  14630. constructor(name: string, direction: Vector3, scene: Scene);
  14631. protected _buildUniformLayout(): void;
  14632. /**
  14633. * Returns the string "HemisphericLight".
  14634. * @return The class name
  14635. */
  14636. getClassName(): string;
  14637. /**
  14638. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14639. * Returns the updated direction.
  14640. * @param target The target the direction should point to
  14641. * @return The computed direction
  14642. */
  14643. setDirectionToTarget(target: Vector3): Vector3;
  14644. /**
  14645. * Returns the shadow generator associated to the light.
  14646. * @returns Always null for hemispheric lights because it does not support shadows.
  14647. */
  14648. getShadowGenerator(): Nullable<IShadowGenerator>;
  14649. /**
  14650. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14651. * @param effect The effect to update
  14652. * @param lightIndex The index of the light in the effect to update
  14653. * @returns The hemispheric light
  14654. */
  14655. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14656. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14657. /**
  14658. * Computes the world matrix of the node
  14659. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14660. * @param useWasUpdatedFlag defines a reserved property
  14661. * @returns the world matrix
  14662. */
  14663. computeWorldMatrix(): Matrix;
  14664. /**
  14665. * Returns the integer 3.
  14666. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14667. */
  14668. getTypeID(): number;
  14669. /**
  14670. * Prepares the list of defines specific to the light type.
  14671. * @param defines the list of defines
  14672. * @param lightIndex defines the index of the light for the effect
  14673. */
  14674. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14675. }
  14676. }
  14677. declare module BABYLON {
  14678. /** @hidden */
  14679. export var vrMultiviewToSingleviewPixelShader: {
  14680. name: string;
  14681. shader: string;
  14682. };
  14683. }
  14684. declare module BABYLON {
  14685. /**
  14686. * Renders to multiple views with a single draw call
  14687. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14688. */
  14689. export class MultiviewRenderTarget extends RenderTargetTexture {
  14690. /**
  14691. * Creates a multiview render target
  14692. * @param scene scene used with the render target
  14693. * @param size the size of the render target (used for each view)
  14694. */
  14695. constructor(scene: Scene, size?: number | {
  14696. width: number;
  14697. height: number;
  14698. } | {
  14699. ratio: number;
  14700. });
  14701. /**
  14702. * @hidden
  14703. * @param faceIndex the face index, if its a cube texture
  14704. */
  14705. _bindFrameBuffer(faceIndex?: number): void;
  14706. /**
  14707. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14708. * @returns the view count
  14709. */
  14710. getViewCount(): number;
  14711. }
  14712. }
  14713. declare module BABYLON {
  14714. /**
  14715. * Represents a camera frustum
  14716. */
  14717. export class Frustum {
  14718. /**
  14719. * Gets the planes representing the frustum
  14720. * @param transform matrix to be applied to the returned planes
  14721. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14722. */
  14723. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14724. /**
  14725. * Gets the near frustum plane transformed by the transform matrix
  14726. * @param transform transformation matrix to be applied to the resulting frustum plane
  14727. * @param frustumPlane the resuling frustum plane
  14728. */
  14729. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14730. /**
  14731. * Gets the far frustum plane transformed by the transform matrix
  14732. * @param transform transformation matrix to be applied to the resulting frustum plane
  14733. * @param frustumPlane the resuling frustum plane
  14734. */
  14735. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14736. /**
  14737. * Gets the left frustum plane transformed by the transform matrix
  14738. * @param transform transformation matrix to be applied to the resulting frustum plane
  14739. * @param frustumPlane the resuling frustum plane
  14740. */
  14741. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14742. /**
  14743. * Gets the right frustum plane transformed by the transform matrix
  14744. * @param transform transformation matrix to be applied to the resulting frustum plane
  14745. * @param frustumPlane the resuling frustum plane
  14746. */
  14747. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14748. /**
  14749. * Gets the top frustum plane transformed by the transform matrix
  14750. * @param transform transformation matrix to be applied to the resulting frustum plane
  14751. * @param frustumPlane the resuling frustum plane
  14752. */
  14753. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14754. /**
  14755. * Gets the bottom frustum plane transformed by the transform matrix
  14756. * @param transform transformation matrix to be applied to the resulting frustum plane
  14757. * @param frustumPlane the resuling frustum plane
  14758. */
  14759. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14760. /**
  14761. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14762. * @param transform transformation matrix to be applied to the resulting frustum planes
  14763. * @param frustumPlanes the resuling frustum planes
  14764. */
  14765. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14766. }
  14767. }
  14768. declare module BABYLON {
  14769. interface Engine {
  14770. /**
  14771. * Creates a new multiview render target
  14772. * @param width defines the width of the texture
  14773. * @param height defines the height of the texture
  14774. * @returns the created multiview texture
  14775. */
  14776. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14777. /**
  14778. * Binds a multiview framebuffer to be drawn to
  14779. * @param multiviewTexture texture to bind
  14780. */
  14781. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14782. }
  14783. interface Camera {
  14784. /**
  14785. * @hidden
  14786. * 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)
  14787. */
  14788. _useMultiviewToSingleView: boolean;
  14789. /**
  14790. * @hidden
  14791. * 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)
  14792. */
  14793. _multiviewTexture: Nullable<RenderTargetTexture>;
  14794. /**
  14795. * @hidden
  14796. * ensures the multiview texture of the camera exists and has the specified width/height
  14797. * @param width height to set on the multiview texture
  14798. * @param height width to set on the multiview texture
  14799. */
  14800. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14801. }
  14802. interface Scene {
  14803. /** @hidden */
  14804. _transformMatrixR: Matrix;
  14805. /** @hidden */
  14806. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14807. /** @hidden */
  14808. _createMultiviewUbo(): void;
  14809. /** @hidden */
  14810. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14811. /** @hidden */
  14812. _renderMultiviewToSingleView(camera: Camera): void;
  14813. }
  14814. }
  14815. declare module BABYLON {
  14816. /**
  14817. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14818. * This will not be used for webXR as it supports displaying texture arrays directly
  14819. */
  14820. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14821. /**
  14822. * Initializes a VRMultiviewToSingleview
  14823. * @param name name of the post process
  14824. * @param camera camera to be applied to
  14825. * @param scaleFactor scaling factor to the size of the output texture
  14826. */
  14827. constructor(name: string, camera: Camera, scaleFactor: number);
  14828. }
  14829. }
  14830. declare module BABYLON {
  14831. interface Engine {
  14832. /** @hidden */
  14833. _vrDisplay: any;
  14834. /** @hidden */
  14835. _vrSupported: boolean;
  14836. /** @hidden */
  14837. _oldSize: Size;
  14838. /** @hidden */
  14839. _oldHardwareScaleFactor: number;
  14840. /** @hidden */
  14841. _vrExclusivePointerMode: boolean;
  14842. /** @hidden */
  14843. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14844. /** @hidden */
  14845. _onVRDisplayPointerRestricted: () => void;
  14846. /** @hidden */
  14847. _onVRDisplayPointerUnrestricted: () => void;
  14848. /** @hidden */
  14849. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14850. /** @hidden */
  14851. _onVrDisplayDisconnect: Nullable<() => void>;
  14852. /** @hidden */
  14853. _onVrDisplayPresentChange: Nullable<() => void>;
  14854. /**
  14855. * Observable signaled when VR display mode changes
  14856. */
  14857. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14858. /**
  14859. * Observable signaled when VR request present is complete
  14860. */
  14861. onVRRequestPresentComplete: Observable<boolean>;
  14862. /**
  14863. * Observable signaled when VR request present starts
  14864. */
  14865. onVRRequestPresentStart: Observable<Engine>;
  14866. /**
  14867. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14868. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14869. */
  14870. isInVRExclusivePointerMode: boolean;
  14871. /**
  14872. * Gets a boolean indicating if a webVR device was detected
  14873. * @returns true if a webVR device was detected
  14874. */
  14875. isVRDevicePresent(): boolean;
  14876. /**
  14877. * Gets the current webVR device
  14878. * @returns the current webVR device (or null)
  14879. */
  14880. getVRDevice(): any;
  14881. /**
  14882. * Initializes a webVR display and starts listening to display change events
  14883. * The onVRDisplayChangedObservable will be notified upon these changes
  14884. * @returns A promise containing a VRDisplay and if vr is supported
  14885. */
  14886. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14887. /** @hidden */
  14888. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14889. /**
  14890. * Call this function to switch to webVR mode
  14891. * Will do nothing if webVR is not supported or if there is no webVR device
  14892. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14893. */
  14894. enableVR(): void;
  14895. /** @hidden */
  14896. _onVRFullScreenTriggered(): void;
  14897. }
  14898. }
  14899. declare module BABYLON {
  14900. /**
  14901. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14902. * IMPORTANT!! The data is right-hand data.
  14903. * @export
  14904. * @interface DevicePose
  14905. */
  14906. export interface DevicePose {
  14907. /**
  14908. * The position of the device, values in array are [x,y,z].
  14909. */
  14910. readonly position: Nullable<Float32Array>;
  14911. /**
  14912. * The linearVelocity of the device, values in array are [x,y,z].
  14913. */
  14914. readonly linearVelocity: Nullable<Float32Array>;
  14915. /**
  14916. * The linearAcceleration of the device, values in array are [x,y,z].
  14917. */
  14918. readonly linearAcceleration: Nullable<Float32Array>;
  14919. /**
  14920. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14921. */
  14922. readonly orientation: Nullable<Float32Array>;
  14923. /**
  14924. * The angularVelocity of the device, values in array are [x,y,z].
  14925. */
  14926. readonly angularVelocity: Nullable<Float32Array>;
  14927. /**
  14928. * The angularAcceleration of the device, values in array are [x,y,z].
  14929. */
  14930. readonly angularAcceleration: Nullable<Float32Array>;
  14931. }
  14932. /**
  14933. * Interface representing a pose controlled object in Babylon.
  14934. * A pose controlled object has both regular pose values as well as pose values
  14935. * from an external device such as a VR head mounted display
  14936. */
  14937. export interface PoseControlled {
  14938. /**
  14939. * The position of the object in babylon space.
  14940. */
  14941. position: Vector3;
  14942. /**
  14943. * The rotation quaternion of the object in babylon space.
  14944. */
  14945. rotationQuaternion: Quaternion;
  14946. /**
  14947. * The position of the device in babylon space.
  14948. */
  14949. devicePosition?: Vector3;
  14950. /**
  14951. * The rotation quaternion of the device in babylon space.
  14952. */
  14953. deviceRotationQuaternion: Quaternion;
  14954. /**
  14955. * The raw pose coming from the device.
  14956. */
  14957. rawPose: Nullable<DevicePose>;
  14958. /**
  14959. * The scale of the device to be used when translating from device space to babylon space.
  14960. */
  14961. deviceScaleFactor: number;
  14962. /**
  14963. * Updates the poseControlled values based on the input device pose.
  14964. * @param poseData the pose data to update the object with
  14965. */
  14966. updateFromDevice(poseData: DevicePose): void;
  14967. }
  14968. /**
  14969. * Set of options to customize the webVRCamera
  14970. */
  14971. export interface WebVROptions {
  14972. /**
  14973. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14974. */
  14975. trackPosition?: boolean;
  14976. /**
  14977. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14978. */
  14979. positionScale?: number;
  14980. /**
  14981. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14982. */
  14983. displayName?: string;
  14984. /**
  14985. * Should the native controller meshes be initialized. (default: true)
  14986. */
  14987. controllerMeshes?: boolean;
  14988. /**
  14989. * Creating a default HemiLight only on controllers. (default: true)
  14990. */
  14991. defaultLightingOnControllers?: boolean;
  14992. /**
  14993. * If you don't want to use the default VR button of the helper. (default: false)
  14994. */
  14995. useCustomVRButton?: boolean;
  14996. /**
  14997. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14998. */
  14999. customVRButton?: HTMLButtonElement;
  15000. /**
  15001. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15002. */
  15003. rayLength?: number;
  15004. /**
  15005. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15006. */
  15007. defaultHeight?: number;
  15008. /**
  15009. * If multiview should be used if availible (default: false)
  15010. */
  15011. useMultiview?: boolean;
  15012. }
  15013. /**
  15014. * This represents a WebVR camera.
  15015. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15016. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15017. */
  15018. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15019. private webVROptions;
  15020. /**
  15021. * @hidden
  15022. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15023. */
  15024. _vrDevice: any;
  15025. /**
  15026. * The rawPose of the vrDevice.
  15027. */
  15028. rawPose: Nullable<DevicePose>;
  15029. private _onVREnabled;
  15030. private _specsVersion;
  15031. private _attached;
  15032. private _frameData;
  15033. protected _descendants: Array<Node>;
  15034. private _deviceRoomPosition;
  15035. /** @hidden */
  15036. _deviceRoomRotationQuaternion: Quaternion;
  15037. private _standingMatrix;
  15038. /**
  15039. * Represents device position in babylon space.
  15040. */
  15041. devicePosition: Vector3;
  15042. /**
  15043. * Represents device rotation in babylon space.
  15044. */
  15045. deviceRotationQuaternion: Quaternion;
  15046. /**
  15047. * The scale of the device to be used when translating from device space to babylon space.
  15048. */
  15049. deviceScaleFactor: number;
  15050. private _deviceToWorld;
  15051. private _worldToDevice;
  15052. /**
  15053. * References to the webVR controllers for the vrDevice.
  15054. */
  15055. controllers: Array<WebVRController>;
  15056. /**
  15057. * Emits an event when a controller is attached.
  15058. */
  15059. onControllersAttachedObservable: Observable<WebVRController[]>;
  15060. /**
  15061. * Emits an event when a controller's mesh has been loaded;
  15062. */
  15063. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15064. /**
  15065. * Emits an event when the HMD's pose has been updated.
  15066. */
  15067. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15068. private _poseSet;
  15069. /**
  15070. * If the rig cameras be used as parent instead of this camera.
  15071. */
  15072. rigParenting: boolean;
  15073. private _lightOnControllers;
  15074. private _defaultHeight?;
  15075. /**
  15076. * Instantiates a WebVRFreeCamera.
  15077. * @param name The name of the WebVRFreeCamera
  15078. * @param position The starting anchor position for the camera
  15079. * @param scene The scene the camera belongs to
  15080. * @param webVROptions a set of customizable options for the webVRCamera
  15081. */
  15082. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15083. /**
  15084. * Gets the device distance from the ground in meters.
  15085. * @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.
  15086. */
  15087. deviceDistanceToRoomGround(): number;
  15088. /**
  15089. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15090. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15091. */
  15092. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15093. /**
  15094. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15095. * @returns A promise with a boolean set to if the standing matrix is supported.
  15096. */
  15097. useStandingMatrixAsync(): Promise<boolean>;
  15098. /**
  15099. * Disposes the camera
  15100. */
  15101. dispose(): void;
  15102. /**
  15103. * Gets a vrController by name.
  15104. * @param name The name of the controller to retreive
  15105. * @returns the controller matching the name specified or null if not found
  15106. */
  15107. getControllerByName(name: string): Nullable<WebVRController>;
  15108. private _leftController;
  15109. /**
  15110. * The controller corresponding to the users left hand.
  15111. */
  15112. readonly leftController: Nullable<WebVRController>;
  15113. private _rightController;
  15114. /**
  15115. * The controller corresponding to the users right hand.
  15116. */
  15117. readonly rightController: Nullable<WebVRController>;
  15118. /**
  15119. * Casts a ray forward from the vrCamera's gaze.
  15120. * @param length Length of the ray (default: 100)
  15121. * @returns the ray corresponding to the gaze
  15122. */
  15123. getForwardRay(length?: number): Ray;
  15124. /**
  15125. * @hidden
  15126. * Updates the camera based on device's frame data
  15127. */
  15128. _checkInputs(): void;
  15129. /**
  15130. * Updates the poseControlled values based on the input device pose.
  15131. * @param poseData Pose coming from the device
  15132. */
  15133. updateFromDevice(poseData: DevicePose): void;
  15134. private _htmlElementAttached;
  15135. private _detachIfAttached;
  15136. /**
  15137. * WebVR's attach control will start broadcasting frames to the device.
  15138. * Note that in certain browsers (chrome for example) this function must be called
  15139. * within a user-interaction callback. Example:
  15140. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15141. *
  15142. * @param element html element to attach the vrDevice to
  15143. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15144. */
  15145. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15146. /**
  15147. * Detaches the camera from the html element and disables VR
  15148. *
  15149. * @param element html element to detach from
  15150. */
  15151. detachControl(element: HTMLElement): void;
  15152. /**
  15153. * @returns the name of this class
  15154. */
  15155. getClassName(): string;
  15156. /**
  15157. * Calls resetPose on the vrDisplay
  15158. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15159. */
  15160. resetToCurrentRotation(): void;
  15161. /**
  15162. * @hidden
  15163. * Updates the rig cameras (left and right eye)
  15164. */
  15165. _updateRigCameras(): void;
  15166. private _workingVector;
  15167. private _oneVector;
  15168. private _workingMatrix;
  15169. private updateCacheCalled;
  15170. private _correctPositionIfNotTrackPosition;
  15171. /**
  15172. * @hidden
  15173. * Updates the cached values of the camera
  15174. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15175. */
  15176. _updateCache(ignoreParentClass?: boolean): void;
  15177. /**
  15178. * @hidden
  15179. * Get current device position in babylon world
  15180. */
  15181. _computeDevicePosition(): void;
  15182. /**
  15183. * Updates the current device position and rotation in the babylon world
  15184. */
  15185. update(): void;
  15186. /**
  15187. * @hidden
  15188. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15189. * @returns an identity matrix
  15190. */
  15191. _getViewMatrix(): Matrix;
  15192. private _tmpMatrix;
  15193. /**
  15194. * This function is called by the two RIG cameras.
  15195. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15196. * @hidden
  15197. */
  15198. _getWebVRViewMatrix(): Matrix;
  15199. /** @hidden */
  15200. _getWebVRProjectionMatrix(): Matrix;
  15201. private _onGamepadConnectedObserver;
  15202. private _onGamepadDisconnectedObserver;
  15203. private _updateCacheWhenTrackingDisabledObserver;
  15204. /**
  15205. * Initializes the controllers and their meshes
  15206. */
  15207. initControllers(): void;
  15208. }
  15209. }
  15210. declare module BABYLON {
  15211. /**
  15212. * Size options for a post process
  15213. */
  15214. export type PostProcessOptions = {
  15215. width: number;
  15216. height: number;
  15217. };
  15218. /**
  15219. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15220. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15221. */
  15222. export class PostProcess {
  15223. /** Name of the PostProcess. */
  15224. name: string;
  15225. /**
  15226. * Gets or sets the unique id of the post process
  15227. */
  15228. uniqueId: number;
  15229. /**
  15230. * Width of the texture to apply the post process on
  15231. */
  15232. width: number;
  15233. /**
  15234. * Height of the texture to apply the post process on
  15235. */
  15236. height: number;
  15237. /**
  15238. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15239. * @hidden
  15240. */
  15241. _outputTexture: Nullable<InternalTexture>;
  15242. /**
  15243. * Sampling mode used by the shader
  15244. * See https://doc.babylonjs.com/classes/3.1/texture
  15245. */
  15246. renderTargetSamplingMode: number;
  15247. /**
  15248. * Clear color to use when screen clearing
  15249. */
  15250. clearColor: Color4;
  15251. /**
  15252. * If the buffer needs to be cleared before applying the post process. (default: true)
  15253. * Should be set to false if shader will overwrite all previous pixels.
  15254. */
  15255. autoClear: boolean;
  15256. /**
  15257. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15258. */
  15259. alphaMode: number;
  15260. /**
  15261. * Sets the setAlphaBlendConstants of the babylon engine
  15262. */
  15263. alphaConstants: Color4;
  15264. /**
  15265. * Animations to be used for the post processing
  15266. */
  15267. animations: Animation[];
  15268. /**
  15269. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15270. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15271. */
  15272. enablePixelPerfectMode: boolean;
  15273. /**
  15274. * Force the postprocess to be applied without taking in account viewport
  15275. */
  15276. forceFullscreenViewport: boolean;
  15277. /**
  15278. * List of inspectable custom properties (used by the Inspector)
  15279. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15280. */
  15281. inspectableCustomProperties: IInspectable[];
  15282. /**
  15283. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15284. *
  15285. * | Value | Type | Description |
  15286. * | ----- | ----------------------------------- | ----------- |
  15287. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15288. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15289. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15290. *
  15291. */
  15292. scaleMode: number;
  15293. /**
  15294. * Force textures to be a power of two (default: false)
  15295. */
  15296. alwaysForcePOT: boolean;
  15297. private _samples;
  15298. /**
  15299. * Number of sample textures (default: 1)
  15300. */
  15301. samples: number;
  15302. /**
  15303. * Modify the scale of the post process to be the same as the viewport (default: false)
  15304. */
  15305. adaptScaleToCurrentViewport: boolean;
  15306. private _camera;
  15307. private _scene;
  15308. private _engine;
  15309. private _options;
  15310. private _reusable;
  15311. private _textureType;
  15312. /**
  15313. * Smart array of input and output textures for the post process.
  15314. * @hidden
  15315. */
  15316. _textures: SmartArray<InternalTexture>;
  15317. /**
  15318. * The index in _textures that corresponds to the output texture.
  15319. * @hidden
  15320. */
  15321. _currentRenderTextureInd: number;
  15322. private _effect;
  15323. private _samplers;
  15324. private _fragmentUrl;
  15325. private _vertexUrl;
  15326. private _parameters;
  15327. private _scaleRatio;
  15328. protected _indexParameters: any;
  15329. private _shareOutputWithPostProcess;
  15330. private _texelSize;
  15331. private _forcedOutputTexture;
  15332. /**
  15333. * Returns the fragment url or shader name used in the post process.
  15334. * @returns the fragment url or name in the shader store.
  15335. */
  15336. getEffectName(): string;
  15337. /**
  15338. * An event triggered when the postprocess is activated.
  15339. */
  15340. onActivateObservable: Observable<Camera>;
  15341. private _onActivateObserver;
  15342. /**
  15343. * A function that is added to the onActivateObservable
  15344. */
  15345. onActivate: Nullable<(camera: Camera) => void>;
  15346. /**
  15347. * An event triggered when the postprocess changes its size.
  15348. */
  15349. onSizeChangedObservable: Observable<PostProcess>;
  15350. private _onSizeChangedObserver;
  15351. /**
  15352. * A function that is added to the onSizeChangedObservable
  15353. */
  15354. onSizeChanged: (postProcess: PostProcess) => void;
  15355. /**
  15356. * An event triggered when the postprocess applies its effect.
  15357. */
  15358. onApplyObservable: Observable<Effect>;
  15359. private _onApplyObserver;
  15360. /**
  15361. * A function that is added to the onApplyObservable
  15362. */
  15363. onApply: (effect: Effect) => void;
  15364. /**
  15365. * An event triggered before rendering the postprocess
  15366. */
  15367. onBeforeRenderObservable: Observable<Effect>;
  15368. private _onBeforeRenderObserver;
  15369. /**
  15370. * A function that is added to the onBeforeRenderObservable
  15371. */
  15372. onBeforeRender: (effect: Effect) => void;
  15373. /**
  15374. * An event triggered after rendering the postprocess
  15375. */
  15376. onAfterRenderObservable: Observable<Effect>;
  15377. private _onAfterRenderObserver;
  15378. /**
  15379. * A function that is added to the onAfterRenderObservable
  15380. */
  15381. onAfterRender: (efect: Effect) => void;
  15382. /**
  15383. * 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
  15384. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15385. */
  15386. inputTexture: InternalTexture;
  15387. /**
  15388. * Gets the camera which post process is applied to.
  15389. * @returns The camera the post process is applied to.
  15390. */
  15391. getCamera(): Camera;
  15392. /**
  15393. * Gets the texel size of the postprocess.
  15394. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15395. */
  15396. readonly texelSize: Vector2;
  15397. /**
  15398. * Creates a new instance PostProcess
  15399. * @param name The name of the PostProcess.
  15400. * @param fragmentUrl The url of the fragment shader to be used.
  15401. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15402. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15403. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15404. * @param camera The camera to apply the render pass to.
  15405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15406. * @param engine The engine which the post process will be applied. (default: current engine)
  15407. * @param reusable If the post process can be reused on the same frame. (default: false)
  15408. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15409. * @param textureType Type of textures used when performing the post process. (default: 0)
  15410. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15411. * @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
  15412. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15413. */
  15414. constructor(
  15415. /** Name of the PostProcess. */
  15416. 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);
  15417. /**
  15418. * Gets a string idenfifying the name of the class
  15419. * @returns "PostProcess" string
  15420. */
  15421. getClassName(): string;
  15422. /**
  15423. * Gets the engine which this post process belongs to.
  15424. * @returns The engine the post process was enabled with.
  15425. */
  15426. getEngine(): Engine;
  15427. /**
  15428. * The effect that is created when initializing the post process.
  15429. * @returns The created effect corresponding the the postprocess.
  15430. */
  15431. getEffect(): Effect;
  15432. /**
  15433. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15434. * @param postProcess The post process to share the output with.
  15435. * @returns This post process.
  15436. */
  15437. shareOutputWith(postProcess: PostProcess): PostProcess;
  15438. /**
  15439. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15440. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15441. */
  15442. useOwnOutput(): void;
  15443. /**
  15444. * Updates the effect with the current post process compile time values and recompiles the shader.
  15445. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15446. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15447. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15448. * @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
  15449. * @param onCompiled Called when the shader has been compiled.
  15450. * @param onError Called if there is an error when compiling a shader.
  15451. */
  15452. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15453. /**
  15454. * The post process is reusable if it can be used multiple times within one frame.
  15455. * @returns If the post process is reusable
  15456. */
  15457. isReusable(): boolean;
  15458. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15459. markTextureDirty(): void;
  15460. /**
  15461. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15462. * 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.
  15463. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15464. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15465. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15466. * @returns The target texture that was bound to be written to.
  15467. */
  15468. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15469. /**
  15470. * If the post process is supported.
  15471. */
  15472. readonly isSupported: boolean;
  15473. /**
  15474. * The aspect ratio of the output texture.
  15475. */
  15476. readonly aspectRatio: number;
  15477. /**
  15478. * Get a value indicating if the post-process is ready to be used
  15479. * @returns true if the post-process is ready (shader is compiled)
  15480. */
  15481. isReady(): boolean;
  15482. /**
  15483. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15484. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15485. */
  15486. apply(): Nullable<Effect>;
  15487. private _disposeTextures;
  15488. /**
  15489. * Disposes the post process.
  15490. * @param camera The camera to dispose the post process on.
  15491. */
  15492. dispose(camera?: Camera): void;
  15493. }
  15494. }
  15495. declare module BABYLON {
  15496. /** @hidden */
  15497. export var kernelBlurVaryingDeclaration: {
  15498. name: string;
  15499. shader: string;
  15500. };
  15501. }
  15502. declare module BABYLON {
  15503. /** @hidden */
  15504. export var kernelBlurFragment: {
  15505. name: string;
  15506. shader: string;
  15507. };
  15508. }
  15509. declare module BABYLON {
  15510. /** @hidden */
  15511. export var kernelBlurFragment2: {
  15512. name: string;
  15513. shader: string;
  15514. };
  15515. }
  15516. declare module BABYLON {
  15517. /** @hidden */
  15518. export var kernelBlurPixelShader: {
  15519. name: string;
  15520. shader: string;
  15521. };
  15522. }
  15523. declare module BABYLON {
  15524. /** @hidden */
  15525. export var kernelBlurVertex: {
  15526. name: string;
  15527. shader: string;
  15528. };
  15529. }
  15530. declare module BABYLON {
  15531. /** @hidden */
  15532. export var kernelBlurVertexShader: {
  15533. name: string;
  15534. shader: string;
  15535. };
  15536. }
  15537. declare module BABYLON {
  15538. /**
  15539. * The Blur Post Process which blurs an image based on a kernel and direction.
  15540. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15541. */
  15542. export class BlurPostProcess extends PostProcess {
  15543. /** The direction in which to blur the image. */
  15544. direction: Vector2;
  15545. private blockCompilation;
  15546. protected _kernel: number;
  15547. protected _idealKernel: number;
  15548. protected _packedFloat: boolean;
  15549. private _staticDefines;
  15550. /**
  15551. * Sets the length in pixels of the blur sample region
  15552. */
  15553. /**
  15554. * Gets the length in pixels of the blur sample region
  15555. */
  15556. kernel: number;
  15557. /**
  15558. * Sets wether or not the blur needs to unpack/repack floats
  15559. */
  15560. /**
  15561. * Gets wether or not the blur is unpacking/repacking floats
  15562. */
  15563. packedFloat: boolean;
  15564. /**
  15565. * Creates a new instance BlurPostProcess
  15566. * @param name The name of the effect.
  15567. * @param direction The direction in which to blur the image.
  15568. * @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.
  15569. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15570. * @param camera The camera to apply the render pass to.
  15571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15572. * @param engine The engine which the post process will be applied. (default: current engine)
  15573. * @param reusable If the post process can be reused on the same frame. (default: false)
  15574. * @param textureType Type of textures used when performing the post process. (default: 0)
  15575. * @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)
  15576. */
  15577. constructor(name: string,
  15578. /** The direction in which to blur the image. */
  15579. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15580. /**
  15581. * Updates the effect with the current post process compile time values and recompiles the shader.
  15582. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15583. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15584. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15585. * @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
  15586. * @param onCompiled Called when the shader has been compiled.
  15587. * @param onError Called if there is an error when compiling a shader.
  15588. */
  15589. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15590. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15591. /**
  15592. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15593. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15594. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15595. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15596. * The gaps between physical kernels are compensated for in the weighting of the samples
  15597. * @param idealKernel Ideal blur kernel.
  15598. * @return Nearest best kernel.
  15599. */
  15600. protected _nearestBestKernel(idealKernel: number): number;
  15601. /**
  15602. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15603. * @param x The point on the Gaussian distribution to sample.
  15604. * @return the value of the Gaussian function at x.
  15605. */
  15606. protected _gaussianWeight(x: number): number;
  15607. /**
  15608. * Generates a string that can be used as a floating point number in GLSL.
  15609. * @param x Value to print.
  15610. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15611. * @return GLSL float string.
  15612. */
  15613. protected _glslFloat(x: number, decimalFigures?: number): string;
  15614. }
  15615. }
  15616. declare module BABYLON {
  15617. /**
  15618. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15619. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15620. * You can then easily use it as a reflectionTexture on a flat surface.
  15621. * In case the surface is not a plane, please consider relying on reflection probes.
  15622. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15623. */
  15624. export class MirrorTexture extends RenderTargetTexture {
  15625. private scene;
  15626. /**
  15627. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15628. * 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.
  15629. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15630. */
  15631. mirrorPlane: Plane;
  15632. /**
  15633. * Define the blur ratio used to blur the reflection if needed.
  15634. */
  15635. blurRatio: number;
  15636. /**
  15637. * Define the adaptive blur kernel used to blur the reflection if needed.
  15638. * This will autocompute the closest best match for the `blurKernel`
  15639. */
  15640. adaptiveBlurKernel: number;
  15641. /**
  15642. * Define the blur kernel used to blur the reflection if needed.
  15643. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15644. */
  15645. blurKernel: number;
  15646. /**
  15647. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15648. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15649. */
  15650. blurKernelX: number;
  15651. /**
  15652. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15653. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15654. */
  15655. blurKernelY: number;
  15656. private _autoComputeBlurKernel;
  15657. protected _onRatioRescale(): void;
  15658. private _updateGammaSpace;
  15659. private _imageProcessingConfigChangeObserver;
  15660. private _transformMatrix;
  15661. private _mirrorMatrix;
  15662. private _savedViewMatrix;
  15663. private _blurX;
  15664. private _blurY;
  15665. private _adaptiveBlurKernel;
  15666. private _blurKernelX;
  15667. private _blurKernelY;
  15668. private _blurRatio;
  15669. /**
  15670. * Instantiates a Mirror Texture.
  15671. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15672. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15673. * You can then easily use it as a reflectionTexture on a flat surface.
  15674. * In case the surface is not a plane, please consider relying on reflection probes.
  15675. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15676. * @param name
  15677. * @param size
  15678. * @param scene
  15679. * @param generateMipMaps
  15680. * @param type
  15681. * @param samplingMode
  15682. * @param generateDepthBuffer
  15683. */
  15684. constructor(name: string, size: number | {
  15685. width: number;
  15686. height: number;
  15687. } | {
  15688. ratio: number;
  15689. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15690. private _preparePostProcesses;
  15691. /**
  15692. * Clone the mirror texture.
  15693. * @returns the cloned texture
  15694. */
  15695. clone(): MirrorTexture;
  15696. /**
  15697. * Serialize the texture to a JSON representation you could use in Parse later on
  15698. * @returns the serialized JSON representation
  15699. */
  15700. serialize(): any;
  15701. /**
  15702. * Dispose the texture and release its associated resources.
  15703. */
  15704. dispose(): void;
  15705. }
  15706. }
  15707. declare module BABYLON {
  15708. /**
  15709. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15710. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15711. */
  15712. export class Texture extends BaseTexture {
  15713. /**
  15714. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15715. */
  15716. static SerializeBuffers: boolean;
  15717. /** @hidden */
  15718. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15719. /** @hidden */
  15720. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15721. /** @hidden */
  15722. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15723. /** nearest is mag = nearest and min = nearest and mip = linear */
  15724. static readonly NEAREST_SAMPLINGMODE: number;
  15725. /** nearest is mag = nearest and min = nearest and mip = linear */
  15726. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15727. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15728. static readonly BILINEAR_SAMPLINGMODE: number;
  15729. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15730. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15731. /** Trilinear is mag = linear and min = linear and mip = linear */
  15732. static readonly TRILINEAR_SAMPLINGMODE: number;
  15733. /** Trilinear is mag = linear and min = linear and mip = linear */
  15734. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15735. /** mag = nearest and min = nearest and mip = nearest */
  15736. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15737. /** mag = nearest and min = linear and mip = nearest */
  15738. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15739. /** mag = nearest and min = linear and mip = linear */
  15740. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15741. /** mag = nearest and min = linear and mip = none */
  15742. static readonly NEAREST_LINEAR: number;
  15743. /** mag = nearest and min = nearest and mip = none */
  15744. static readonly NEAREST_NEAREST: number;
  15745. /** mag = linear and min = nearest and mip = nearest */
  15746. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15747. /** mag = linear and min = nearest and mip = linear */
  15748. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15749. /** mag = linear and min = linear and mip = none */
  15750. static readonly LINEAR_LINEAR: number;
  15751. /** mag = linear and min = nearest and mip = none */
  15752. static readonly LINEAR_NEAREST: number;
  15753. /** Explicit coordinates mode */
  15754. static readonly EXPLICIT_MODE: number;
  15755. /** Spherical coordinates mode */
  15756. static readonly SPHERICAL_MODE: number;
  15757. /** Planar coordinates mode */
  15758. static readonly PLANAR_MODE: number;
  15759. /** Cubic coordinates mode */
  15760. static readonly CUBIC_MODE: number;
  15761. /** Projection coordinates mode */
  15762. static readonly PROJECTION_MODE: number;
  15763. /** Inverse Cubic coordinates mode */
  15764. static readonly SKYBOX_MODE: number;
  15765. /** Inverse Cubic coordinates mode */
  15766. static readonly INVCUBIC_MODE: number;
  15767. /** Equirectangular coordinates mode */
  15768. static readonly EQUIRECTANGULAR_MODE: number;
  15769. /** Equirectangular Fixed coordinates mode */
  15770. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15771. /** Equirectangular Fixed Mirrored coordinates mode */
  15772. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15773. /** Texture is not repeating outside of 0..1 UVs */
  15774. static readonly CLAMP_ADDRESSMODE: number;
  15775. /** Texture is repeating outside of 0..1 UVs */
  15776. static readonly WRAP_ADDRESSMODE: number;
  15777. /** Texture is repeating and mirrored */
  15778. static readonly MIRROR_ADDRESSMODE: number;
  15779. /**
  15780. * 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
  15781. */
  15782. static UseSerializedUrlIfAny: boolean;
  15783. /**
  15784. * Define the url of the texture.
  15785. */
  15786. url: Nullable<string>;
  15787. /**
  15788. * Define an offset on the texture to offset the u coordinates of the UVs
  15789. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15790. */
  15791. uOffset: number;
  15792. /**
  15793. * Define an offset on the texture to offset the v coordinates of the UVs
  15794. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15795. */
  15796. vOffset: number;
  15797. /**
  15798. * Define an offset on the texture to scale the u coordinates of the UVs
  15799. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15800. */
  15801. uScale: number;
  15802. /**
  15803. * Define an offset on the texture to scale the v coordinates of the UVs
  15804. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15805. */
  15806. vScale: number;
  15807. /**
  15808. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15809. * @see http://doc.babylonjs.com/how_to/more_materials
  15810. */
  15811. uAng: number;
  15812. /**
  15813. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15814. * @see http://doc.babylonjs.com/how_to/more_materials
  15815. */
  15816. vAng: number;
  15817. /**
  15818. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15819. * @see http://doc.babylonjs.com/how_to/more_materials
  15820. */
  15821. wAng: number;
  15822. /**
  15823. * Defines the center of rotation (U)
  15824. */
  15825. uRotationCenter: number;
  15826. /**
  15827. * Defines the center of rotation (V)
  15828. */
  15829. vRotationCenter: number;
  15830. /**
  15831. * Defines the center of rotation (W)
  15832. */
  15833. wRotationCenter: number;
  15834. /**
  15835. * Are mip maps generated for this texture or not.
  15836. */
  15837. readonly noMipmap: boolean;
  15838. /**
  15839. * List of inspectable custom properties (used by the Inspector)
  15840. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15841. */
  15842. inspectableCustomProperties: Nullable<IInspectable[]>;
  15843. private _noMipmap;
  15844. /** @hidden */
  15845. _invertY: boolean;
  15846. private _rowGenerationMatrix;
  15847. private _cachedTextureMatrix;
  15848. private _projectionModeMatrix;
  15849. private _t0;
  15850. private _t1;
  15851. private _t2;
  15852. private _cachedUOffset;
  15853. private _cachedVOffset;
  15854. private _cachedUScale;
  15855. private _cachedVScale;
  15856. private _cachedUAng;
  15857. private _cachedVAng;
  15858. private _cachedWAng;
  15859. private _cachedProjectionMatrixId;
  15860. private _cachedCoordinatesMode;
  15861. /** @hidden */
  15862. protected _initialSamplingMode: number;
  15863. /** @hidden */
  15864. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15865. private _deleteBuffer;
  15866. protected _format: Nullable<number>;
  15867. private _delayedOnLoad;
  15868. private _delayedOnError;
  15869. /**
  15870. * Observable triggered once the texture has been loaded.
  15871. */
  15872. onLoadObservable: Observable<Texture>;
  15873. protected _isBlocking: boolean;
  15874. /**
  15875. * Is the texture preventing material to render while loading.
  15876. * If false, a default texture will be used instead of the loading one during the preparation step.
  15877. */
  15878. isBlocking: boolean;
  15879. /**
  15880. * Get the current sampling mode associated with the texture.
  15881. */
  15882. readonly samplingMode: number;
  15883. /**
  15884. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15885. */
  15886. readonly invertY: boolean;
  15887. /**
  15888. * Instantiates a new texture.
  15889. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15890. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15891. * @param url define the url of the picture to load as a texture
  15892. * @param scene define the scene or engine the texture will belong to
  15893. * @param noMipmap define if the texture will require mip maps or not
  15894. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15895. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15896. * @param onLoad define a callback triggered when the texture has been loaded
  15897. * @param onError define a callback triggered when an error occurred during the loading session
  15898. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15899. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15900. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15901. */
  15902. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15903. /**
  15904. * Update the url (and optional buffer) of this texture if url was null during construction.
  15905. * @param url the url of the texture
  15906. * @param buffer the buffer of the texture (defaults to null)
  15907. * @param onLoad callback called when the texture is loaded (defaults to null)
  15908. */
  15909. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15910. /**
  15911. * Finish the loading sequence of a texture flagged as delayed load.
  15912. * @hidden
  15913. */
  15914. delayLoad(): void;
  15915. private _prepareRowForTextureGeneration;
  15916. /**
  15917. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15918. * @returns the transform matrix of the texture.
  15919. */
  15920. getTextureMatrix(): Matrix;
  15921. /**
  15922. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15923. * @returns The reflection texture transform
  15924. */
  15925. getReflectionTextureMatrix(): Matrix;
  15926. /**
  15927. * Clones the texture.
  15928. * @returns the cloned texture
  15929. */
  15930. clone(): Texture;
  15931. /**
  15932. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15933. * @returns The JSON representation of the texture
  15934. */
  15935. serialize(): any;
  15936. /**
  15937. * Get the current class name of the texture useful for serialization or dynamic coding.
  15938. * @returns "Texture"
  15939. */
  15940. getClassName(): string;
  15941. /**
  15942. * Dispose the texture and release its associated resources.
  15943. */
  15944. dispose(): void;
  15945. /**
  15946. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15947. * @param parsedTexture Define the JSON representation of the texture
  15948. * @param scene Define the scene the parsed texture should be instantiated in
  15949. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15950. * @returns The parsed texture if successful
  15951. */
  15952. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15953. /**
  15954. * Creates a texture from its base 64 representation.
  15955. * @param data Define the base64 payload without the data: prefix
  15956. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15957. * @param scene Define the scene the texture should belong to
  15958. * @param noMipmap Forces the texture to not create mip map information if true
  15959. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15960. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15961. * @param onLoad define a callback triggered when the texture has been loaded
  15962. * @param onError define a callback triggered when an error occurred during the loading session
  15963. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15964. * @returns the created texture
  15965. */
  15966. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15967. /**
  15968. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15969. * @param data Define the base64 payload without the data: prefix
  15970. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15971. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15972. * @param scene Define the scene the texture should belong to
  15973. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15974. * @param noMipmap Forces the texture to not create mip map information if true
  15975. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15976. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15977. * @param onLoad define a callback triggered when the texture has been loaded
  15978. * @param onError define a callback triggered when an error occurred during the loading session
  15979. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15980. * @returns the created texture
  15981. */
  15982. 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;
  15983. }
  15984. }
  15985. declare module BABYLON {
  15986. /**
  15987. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15988. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15989. */
  15990. export class PostProcessManager {
  15991. private _scene;
  15992. private _indexBuffer;
  15993. private _vertexBuffers;
  15994. /**
  15995. * Creates a new instance PostProcess
  15996. * @param scene The scene that the post process is associated with.
  15997. */
  15998. constructor(scene: Scene);
  15999. private _prepareBuffers;
  16000. private _buildIndexBuffer;
  16001. /**
  16002. * Rebuilds the vertex buffers of the manager.
  16003. * @hidden
  16004. */
  16005. _rebuild(): void;
  16006. /**
  16007. * Prepares a frame to be run through a post process.
  16008. * @param sourceTexture The input texture to the post procesess. (default: null)
  16009. * @param postProcesses An array of post processes to be run. (default: null)
  16010. * @returns True if the post processes were able to be run.
  16011. * @hidden
  16012. */
  16013. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16014. /**
  16015. * Manually render a set of post processes to a texture.
  16016. * @param postProcesses An array of post processes to be run.
  16017. * @param targetTexture The target texture to render to.
  16018. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16019. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16020. * @param lodLevel defines which lod of the texture to render to
  16021. */
  16022. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16023. /**
  16024. * Finalize the result of the output of the postprocesses.
  16025. * @param doNotPresent If true the result will not be displayed to the screen.
  16026. * @param targetTexture The target texture to render to.
  16027. * @param faceIndex The index of the face to bind the target texture to.
  16028. * @param postProcesses The array of post processes to render.
  16029. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16030. * @hidden
  16031. */
  16032. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16033. /**
  16034. * Disposes of the post process manager.
  16035. */
  16036. dispose(): void;
  16037. }
  16038. }
  16039. declare module BABYLON {
  16040. /** Interface used by value gradients (color, factor, ...) */
  16041. export interface IValueGradient {
  16042. /**
  16043. * Gets or sets the gradient value (between 0 and 1)
  16044. */
  16045. gradient: number;
  16046. }
  16047. /** Class used to store color4 gradient */
  16048. export class ColorGradient implements IValueGradient {
  16049. /**
  16050. * Gets or sets the gradient value (between 0 and 1)
  16051. */
  16052. gradient: number;
  16053. /**
  16054. * Gets or sets first associated color
  16055. */
  16056. color1: Color4;
  16057. /**
  16058. * Gets or sets second associated color
  16059. */
  16060. color2?: Color4;
  16061. /**
  16062. * Will get a color picked randomly between color1 and color2.
  16063. * If color2 is undefined then color1 will be used
  16064. * @param result defines the target Color4 to store the result in
  16065. */
  16066. getColorToRef(result: Color4): void;
  16067. }
  16068. /** Class used to store color 3 gradient */
  16069. export class Color3Gradient implements IValueGradient {
  16070. /**
  16071. * Gets or sets the gradient value (between 0 and 1)
  16072. */
  16073. gradient: number;
  16074. /**
  16075. * Gets or sets the associated color
  16076. */
  16077. color: Color3;
  16078. }
  16079. /** Class used to store factor gradient */
  16080. export class FactorGradient implements IValueGradient {
  16081. /**
  16082. * Gets or sets the gradient value (between 0 and 1)
  16083. */
  16084. gradient: number;
  16085. /**
  16086. * Gets or sets first associated factor
  16087. */
  16088. factor1: number;
  16089. /**
  16090. * Gets or sets second associated factor
  16091. */
  16092. factor2?: number;
  16093. /**
  16094. * Will get a number picked randomly between factor1 and factor2.
  16095. * If factor2 is undefined then factor1 will be used
  16096. * @returns the picked number
  16097. */
  16098. getFactor(): number;
  16099. }
  16100. /**
  16101. * Helper used to simplify some generic gradient tasks
  16102. */
  16103. export class GradientHelper {
  16104. /**
  16105. * Gets the current gradient from an array of IValueGradient
  16106. * @param ratio defines the current ratio to get
  16107. * @param gradients defines the array of IValueGradient
  16108. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16109. */
  16110. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16111. }
  16112. }
  16113. declare module BABYLON {
  16114. interface ThinEngine {
  16115. /**
  16116. * Creates a dynamic texture
  16117. * @param width defines the width of the texture
  16118. * @param height defines the height of the texture
  16119. * @param generateMipMaps defines if the engine should generate the mip levels
  16120. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16121. * @returns the dynamic texture inside an InternalTexture
  16122. */
  16123. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16124. /**
  16125. * Update the content of a dynamic texture
  16126. * @param texture defines the texture to update
  16127. * @param canvas defines the canvas containing the source
  16128. * @param invertY defines if data must be stored with Y axis inverted
  16129. * @param premulAlpha defines if alpha is stored as premultiplied
  16130. * @param format defines the format of the data
  16131. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16132. */
  16133. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16134. }
  16135. }
  16136. declare module BABYLON {
  16137. /**
  16138. * A class extending Texture allowing drawing on a texture
  16139. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16140. */
  16141. export class DynamicTexture extends Texture {
  16142. private _generateMipMaps;
  16143. private _canvas;
  16144. private _context;
  16145. private _engine;
  16146. /**
  16147. * Creates a DynamicTexture
  16148. * @param name defines the name of the texture
  16149. * @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
  16150. * @param scene defines the scene where you want the texture
  16151. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16152. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16153. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16154. */
  16155. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16156. /**
  16157. * Get the current class name of the texture useful for serialization or dynamic coding.
  16158. * @returns "DynamicTexture"
  16159. */
  16160. getClassName(): string;
  16161. /**
  16162. * Gets the current state of canRescale
  16163. */
  16164. readonly canRescale: boolean;
  16165. private _recreate;
  16166. /**
  16167. * Scales the texture
  16168. * @param ratio the scale factor to apply to both width and height
  16169. */
  16170. scale(ratio: number): void;
  16171. /**
  16172. * Resizes the texture
  16173. * @param width the new width
  16174. * @param height the new height
  16175. */
  16176. scaleTo(width: number, height: number): void;
  16177. /**
  16178. * Gets the context of the canvas used by the texture
  16179. * @returns the canvas context of the dynamic texture
  16180. */
  16181. getContext(): CanvasRenderingContext2D;
  16182. /**
  16183. * Clears the texture
  16184. */
  16185. clear(): void;
  16186. /**
  16187. * Updates the texture
  16188. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16189. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16190. */
  16191. update(invertY?: boolean, premulAlpha?: boolean): void;
  16192. /**
  16193. * Draws text onto the texture
  16194. * @param text defines the text to be drawn
  16195. * @param x defines the placement of the text from the left
  16196. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16197. * @param font defines the font to be used with font-style, font-size, font-name
  16198. * @param color defines the color used for the text
  16199. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16200. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16201. * @param update defines whether texture is immediately update (default is true)
  16202. */
  16203. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16204. /**
  16205. * Clones the texture
  16206. * @returns the clone of the texture.
  16207. */
  16208. clone(): DynamicTexture;
  16209. /**
  16210. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16211. * @returns a serialized dynamic texture object
  16212. */
  16213. serialize(): any;
  16214. /** @hidden */
  16215. _rebuild(): void;
  16216. }
  16217. }
  16218. declare module BABYLON {
  16219. interface AbstractScene {
  16220. /**
  16221. * The list of procedural textures added to the scene
  16222. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16223. */
  16224. proceduralTextures: Array<ProceduralTexture>;
  16225. }
  16226. /**
  16227. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16228. * in a given scene.
  16229. */
  16230. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16231. /**
  16232. * The component name helpfull to identify the component in the list of scene components.
  16233. */
  16234. readonly name: string;
  16235. /**
  16236. * The scene the component belongs to.
  16237. */
  16238. scene: Scene;
  16239. /**
  16240. * Creates a new instance of the component for the given scene
  16241. * @param scene Defines the scene to register the component in
  16242. */
  16243. constructor(scene: Scene);
  16244. /**
  16245. * Registers the component in a given scene
  16246. */
  16247. register(): void;
  16248. /**
  16249. * Rebuilds the elements related to this component in case of
  16250. * context lost for instance.
  16251. */
  16252. rebuild(): void;
  16253. /**
  16254. * Disposes the component and the associated ressources.
  16255. */
  16256. dispose(): void;
  16257. private _beforeClear;
  16258. }
  16259. }
  16260. declare module BABYLON {
  16261. interface ThinEngine {
  16262. /**
  16263. * Creates a new render target cube texture
  16264. * @param size defines the size of the texture
  16265. * @param options defines the options used to create the texture
  16266. * @returns a new render target cube texture stored in an InternalTexture
  16267. */
  16268. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16269. }
  16270. }
  16271. declare module BABYLON {
  16272. /** @hidden */
  16273. export var proceduralVertexShader: {
  16274. name: string;
  16275. shader: string;
  16276. };
  16277. }
  16278. declare module BABYLON {
  16279. /**
  16280. * 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.
  16281. * This is the base class of any Procedural texture and contains most of the shareable code.
  16282. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16283. */
  16284. export class ProceduralTexture extends Texture {
  16285. isCube: boolean;
  16286. /**
  16287. * Define if the texture is enabled or not (disabled texture will not render)
  16288. */
  16289. isEnabled: boolean;
  16290. /**
  16291. * Define if the texture must be cleared before rendering (default is true)
  16292. */
  16293. autoClear: boolean;
  16294. /**
  16295. * Callback called when the texture is generated
  16296. */
  16297. onGenerated: () => void;
  16298. /**
  16299. * Event raised when the texture is generated
  16300. */
  16301. onGeneratedObservable: Observable<ProceduralTexture>;
  16302. /** @hidden */
  16303. _generateMipMaps: boolean;
  16304. /** @hidden **/
  16305. _effect: Effect;
  16306. /** @hidden */
  16307. _textures: {
  16308. [key: string]: Texture;
  16309. };
  16310. private _size;
  16311. private _currentRefreshId;
  16312. private _refreshRate;
  16313. private _vertexBuffers;
  16314. private _indexBuffer;
  16315. private _uniforms;
  16316. private _samplers;
  16317. private _fragment;
  16318. private _floats;
  16319. private _ints;
  16320. private _floatsArrays;
  16321. private _colors3;
  16322. private _colors4;
  16323. private _vectors2;
  16324. private _vectors3;
  16325. private _matrices;
  16326. private _fallbackTexture;
  16327. private _fallbackTextureUsed;
  16328. private _engine;
  16329. private _cachedDefines;
  16330. private _contentUpdateId;
  16331. private _contentData;
  16332. /**
  16333. * Instantiates a new procedural texture.
  16334. * 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.
  16335. * This is the base class of any Procedural texture and contains most of the shareable code.
  16336. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16337. * @param name Define the name of the texture
  16338. * @param size Define the size of the texture to create
  16339. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16340. * @param scene Define the scene the texture belongs to
  16341. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16342. * @param generateMipMaps Define if the texture should creates mip maps or not
  16343. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16344. */
  16345. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16346. /**
  16347. * The effect that is created when initializing the post process.
  16348. * @returns The created effect corresponding the the postprocess.
  16349. */
  16350. getEffect(): Effect;
  16351. /**
  16352. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16353. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16354. */
  16355. getContent(): Nullable<ArrayBufferView>;
  16356. private _createIndexBuffer;
  16357. /** @hidden */
  16358. _rebuild(): void;
  16359. /**
  16360. * Resets the texture in order to recreate its associated resources.
  16361. * This can be called in case of context loss
  16362. */
  16363. reset(): void;
  16364. protected _getDefines(): string;
  16365. /**
  16366. * Is the texture ready to be used ? (rendered at least once)
  16367. * @returns true if ready, otherwise, false.
  16368. */
  16369. isReady(): boolean;
  16370. /**
  16371. * Resets the refresh counter of the texture and start bak from scratch.
  16372. * Could be useful to regenerate the texture if it is setup to render only once.
  16373. */
  16374. resetRefreshCounter(): void;
  16375. /**
  16376. * Set the fragment shader to use in order to render the texture.
  16377. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16378. */
  16379. setFragment(fragment: any): void;
  16380. /**
  16381. * Define the refresh rate of the texture or the rendering frequency.
  16382. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16383. */
  16384. refreshRate: number;
  16385. /** @hidden */
  16386. _shouldRender(): boolean;
  16387. /**
  16388. * Get the size the texture is rendering at.
  16389. * @returns the size (texture is always squared)
  16390. */
  16391. getRenderSize(): number;
  16392. /**
  16393. * Resize the texture to new value.
  16394. * @param size Define the new size the texture should have
  16395. * @param generateMipMaps Define whether the new texture should create mip maps
  16396. */
  16397. resize(size: number, generateMipMaps: boolean): void;
  16398. private _checkUniform;
  16399. /**
  16400. * Set a texture in the shader program used to render.
  16401. * @param name Define the name of the uniform samplers as defined in the shader
  16402. * @param texture Define the texture to bind to this sampler
  16403. * @return the texture itself allowing "fluent" like uniform updates
  16404. */
  16405. setTexture(name: string, texture: Texture): ProceduralTexture;
  16406. /**
  16407. * Set a float in the shader.
  16408. * @param name Define the name of the uniform as defined in the shader
  16409. * @param value Define the value to give to the uniform
  16410. * @return the texture itself allowing "fluent" like uniform updates
  16411. */
  16412. setFloat(name: string, value: number): ProceduralTexture;
  16413. /**
  16414. * Set a int in the shader.
  16415. * @param name Define the name of the uniform as defined in the shader
  16416. * @param value Define the value to give to the uniform
  16417. * @return the texture itself allowing "fluent" like uniform updates
  16418. */
  16419. setInt(name: string, value: number): ProceduralTexture;
  16420. /**
  16421. * Set an array of floats in the shader.
  16422. * @param name Define the name of the uniform as defined in the shader
  16423. * @param value Define the value to give to the uniform
  16424. * @return the texture itself allowing "fluent" like uniform updates
  16425. */
  16426. setFloats(name: string, value: number[]): ProceduralTexture;
  16427. /**
  16428. * Set a vec3 in the shader from a Color3.
  16429. * @param name Define the name of the uniform as defined in the shader
  16430. * @param value Define the value to give to the uniform
  16431. * @return the texture itself allowing "fluent" like uniform updates
  16432. */
  16433. setColor3(name: string, value: Color3): ProceduralTexture;
  16434. /**
  16435. * Set a vec4 in the shader from a Color4.
  16436. * @param name Define the name of the uniform as defined in the shader
  16437. * @param value Define the value to give to the uniform
  16438. * @return the texture itself allowing "fluent" like uniform updates
  16439. */
  16440. setColor4(name: string, value: Color4): ProceduralTexture;
  16441. /**
  16442. * Set a vec2 in the shader from a Vector2.
  16443. * @param name Define the name of the uniform as defined in the shader
  16444. * @param value Define the value to give to the uniform
  16445. * @return the texture itself allowing "fluent" like uniform updates
  16446. */
  16447. setVector2(name: string, value: Vector2): ProceduralTexture;
  16448. /**
  16449. * Set a vec3 in the shader from a Vector3.
  16450. * @param name Define the name of the uniform as defined in the shader
  16451. * @param value Define the value to give to the uniform
  16452. * @return the texture itself allowing "fluent" like uniform updates
  16453. */
  16454. setVector3(name: string, value: Vector3): ProceduralTexture;
  16455. /**
  16456. * Set a mat4 in the shader from a MAtrix.
  16457. * @param name Define the name of the uniform as defined in the shader
  16458. * @param value Define the value to give to the uniform
  16459. * @return the texture itself allowing "fluent" like uniform updates
  16460. */
  16461. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16462. /**
  16463. * Render the texture to its associated render target.
  16464. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16465. */
  16466. render(useCameraPostProcess?: boolean): void;
  16467. /**
  16468. * Clone the texture.
  16469. * @returns the cloned texture
  16470. */
  16471. clone(): ProceduralTexture;
  16472. /**
  16473. * Dispose the texture and release its asoociated resources.
  16474. */
  16475. dispose(): void;
  16476. }
  16477. }
  16478. declare module BABYLON {
  16479. /**
  16480. * This represents the base class for particle system in Babylon.
  16481. * 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.
  16482. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16483. * @example https://doc.babylonjs.com/babylon101/particles
  16484. */
  16485. export class BaseParticleSystem {
  16486. /**
  16487. * Source color is added to the destination color without alpha affecting the result
  16488. */
  16489. static BLENDMODE_ONEONE: number;
  16490. /**
  16491. * Blend current color and particle color using particle’s alpha
  16492. */
  16493. static BLENDMODE_STANDARD: number;
  16494. /**
  16495. * Add current color and particle color multiplied by particle’s alpha
  16496. */
  16497. static BLENDMODE_ADD: number;
  16498. /**
  16499. * Multiply current color with particle color
  16500. */
  16501. static BLENDMODE_MULTIPLY: number;
  16502. /**
  16503. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16504. */
  16505. static BLENDMODE_MULTIPLYADD: number;
  16506. /**
  16507. * List of animations used by the particle system.
  16508. */
  16509. animations: Animation[];
  16510. /**
  16511. * The id of the Particle system.
  16512. */
  16513. id: string;
  16514. /**
  16515. * The friendly name of the Particle system.
  16516. */
  16517. name: string;
  16518. /**
  16519. * The rendering group used by the Particle system to chose when to render.
  16520. */
  16521. renderingGroupId: number;
  16522. /**
  16523. * The emitter represents the Mesh or position we are attaching the particle system to.
  16524. */
  16525. emitter: Nullable<AbstractMesh | Vector3>;
  16526. /**
  16527. * The maximum number of particles to emit per frame
  16528. */
  16529. emitRate: number;
  16530. /**
  16531. * If you want to launch only a few particles at once, that can be done, as well.
  16532. */
  16533. manualEmitCount: number;
  16534. /**
  16535. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16536. */
  16537. updateSpeed: number;
  16538. /**
  16539. * The amount of time the particle system is running (depends of the overall update speed).
  16540. */
  16541. targetStopDuration: number;
  16542. /**
  16543. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16544. */
  16545. disposeOnStop: boolean;
  16546. /**
  16547. * Minimum power of emitting particles.
  16548. */
  16549. minEmitPower: number;
  16550. /**
  16551. * Maximum power of emitting particles.
  16552. */
  16553. maxEmitPower: number;
  16554. /**
  16555. * Minimum life time of emitting particles.
  16556. */
  16557. minLifeTime: number;
  16558. /**
  16559. * Maximum life time of emitting particles.
  16560. */
  16561. maxLifeTime: number;
  16562. /**
  16563. * Minimum Size of emitting particles.
  16564. */
  16565. minSize: number;
  16566. /**
  16567. * Maximum Size of emitting particles.
  16568. */
  16569. maxSize: number;
  16570. /**
  16571. * Minimum scale of emitting particles on X axis.
  16572. */
  16573. minScaleX: number;
  16574. /**
  16575. * Maximum scale of emitting particles on X axis.
  16576. */
  16577. maxScaleX: number;
  16578. /**
  16579. * Minimum scale of emitting particles on Y axis.
  16580. */
  16581. minScaleY: number;
  16582. /**
  16583. * Maximum scale of emitting particles on Y axis.
  16584. */
  16585. maxScaleY: number;
  16586. /**
  16587. * Gets or sets the minimal initial rotation in radians.
  16588. */
  16589. minInitialRotation: number;
  16590. /**
  16591. * Gets or sets the maximal initial rotation in radians.
  16592. */
  16593. maxInitialRotation: number;
  16594. /**
  16595. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16596. */
  16597. minAngularSpeed: number;
  16598. /**
  16599. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16600. */
  16601. maxAngularSpeed: number;
  16602. /**
  16603. * The texture used to render each particle. (this can be a spritesheet)
  16604. */
  16605. particleTexture: Nullable<Texture>;
  16606. /**
  16607. * The layer mask we are rendering the particles through.
  16608. */
  16609. layerMask: number;
  16610. /**
  16611. * This can help using your own shader to render the particle system.
  16612. * The according effect will be created
  16613. */
  16614. customShader: any;
  16615. /**
  16616. * By default particle system starts as soon as they are created. This prevents the
  16617. * automatic start to happen and let you decide when to start emitting particles.
  16618. */
  16619. preventAutoStart: boolean;
  16620. private _noiseTexture;
  16621. /**
  16622. * Gets or sets a texture used to add random noise to particle positions
  16623. */
  16624. noiseTexture: Nullable<ProceduralTexture>;
  16625. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16626. noiseStrength: Vector3;
  16627. /**
  16628. * Callback triggered when the particle animation is ending.
  16629. */
  16630. onAnimationEnd: Nullable<() => void>;
  16631. /**
  16632. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16633. */
  16634. blendMode: number;
  16635. /**
  16636. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16637. * to override the particles.
  16638. */
  16639. forceDepthWrite: boolean;
  16640. /** 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 */
  16641. preWarmCycles: number;
  16642. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16643. preWarmStepOffset: number;
  16644. /**
  16645. * 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)
  16646. */
  16647. spriteCellChangeSpeed: number;
  16648. /**
  16649. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16650. */
  16651. startSpriteCellID: number;
  16652. /**
  16653. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16654. */
  16655. endSpriteCellID: number;
  16656. /**
  16657. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16658. */
  16659. spriteCellWidth: number;
  16660. /**
  16661. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16662. */
  16663. spriteCellHeight: number;
  16664. /**
  16665. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16666. */
  16667. spriteRandomStartCell: boolean;
  16668. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16669. translationPivot: Vector2;
  16670. /** @hidden */
  16671. protected _isAnimationSheetEnabled: boolean;
  16672. /**
  16673. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16674. */
  16675. beginAnimationOnStart: boolean;
  16676. /**
  16677. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16678. */
  16679. beginAnimationFrom: number;
  16680. /**
  16681. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16682. */
  16683. beginAnimationTo: number;
  16684. /**
  16685. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16686. */
  16687. beginAnimationLoop: boolean;
  16688. /**
  16689. * Gets or sets a world offset applied to all particles
  16690. */
  16691. worldOffset: Vector3;
  16692. /**
  16693. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16694. */
  16695. isAnimationSheetEnabled: boolean;
  16696. /**
  16697. * Get hosting scene
  16698. * @returns the scene
  16699. */
  16700. getScene(): Scene;
  16701. /**
  16702. * You can use gravity if you want to give an orientation to your particles.
  16703. */
  16704. gravity: Vector3;
  16705. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16706. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16707. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16708. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16709. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16710. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16711. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16712. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16713. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16714. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16715. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16716. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16717. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16718. /**
  16719. * Defines the delay in milliseconds before starting the system (0 by default)
  16720. */
  16721. startDelay: number;
  16722. /**
  16723. * Gets the current list of drag gradients.
  16724. * You must use addDragGradient and removeDragGradient to udpate this list
  16725. * @returns the list of drag gradients
  16726. */
  16727. getDragGradients(): Nullable<Array<FactorGradient>>;
  16728. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16729. limitVelocityDamping: number;
  16730. /**
  16731. * Gets the current list of limit velocity gradients.
  16732. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16733. * @returns the list of limit velocity gradients
  16734. */
  16735. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16736. /**
  16737. * Gets the current list of color gradients.
  16738. * You must use addColorGradient and removeColorGradient to udpate this list
  16739. * @returns the list of color gradients
  16740. */
  16741. getColorGradients(): Nullable<Array<ColorGradient>>;
  16742. /**
  16743. * Gets the current list of size gradients.
  16744. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16745. * @returns the list of size gradients
  16746. */
  16747. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16748. /**
  16749. * Gets the current list of color remap gradients.
  16750. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16751. * @returns the list of color remap gradients
  16752. */
  16753. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16754. /**
  16755. * Gets the current list of alpha remap gradients.
  16756. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16757. * @returns the list of alpha remap gradients
  16758. */
  16759. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16760. /**
  16761. * Gets the current list of life time gradients.
  16762. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16763. * @returns the list of life time gradients
  16764. */
  16765. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16766. /**
  16767. * Gets the current list of angular speed gradients.
  16768. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16769. * @returns the list of angular speed gradients
  16770. */
  16771. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16772. /**
  16773. * Gets the current list of velocity gradients.
  16774. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16775. * @returns the list of velocity gradients
  16776. */
  16777. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16778. /**
  16779. * Gets the current list of start size gradients.
  16780. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16781. * @returns the list of start size gradients
  16782. */
  16783. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16784. /**
  16785. * Gets the current list of emit rate gradients.
  16786. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16787. * @returns the list of emit rate gradients
  16788. */
  16789. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16790. /**
  16791. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16792. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16793. */
  16794. direction1: Vector3;
  16795. /**
  16796. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16797. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16798. */
  16799. direction2: Vector3;
  16800. /**
  16801. * 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.
  16802. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16803. */
  16804. minEmitBox: Vector3;
  16805. /**
  16806. * 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.
  16807. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16808. */
  16809. maxEmitBox: Vector3;
  16810. /**
  16811. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16812. */
  16813. color1: Color4;
  16814. /**
  16815. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16816. */
  16817. color2: Color4;
  16818. /**
  16819. * Color the particle will have at the end of its lifetime
  16820. */
  16821. colorDead: Color4;
  16822. /**
  16823. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16824. */
  16825. textureMask: Color4;
  16826. /**
  16827. * The particle emitter type defines the emitter used by the particle system.
  16828. * It can be for example box, sphere, or cone...
  16829. */
  16830. particleEmitterType: IParticleEmitterType;
  16831. /** @hidden */
  16832. _isSubEmitter: boolean;
  16833. /**
  16834. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16835. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16836. */
  16837. billboardMode: number;
  16838. protected _isBillboardBased: boolean;
  16839. /**
  16840. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16841. */
  16842. isBillboardBased: boolean;
  16843. /**
  16844. * The scene the particle system belongs to.
  16845. */
  16846. protected _scene: Scene;
  16847. /**
  16848. * Local cache of defines for image processing.
  16849. */
  16850. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16851. /**
  16852. * Default configuration related to image processing available in the standard Material.
  16853. */
  16854. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16855. /**
  16856. * Gets the image processing configuration used either in this material.
  16857. */
  16858. /**
  16859. * Sets the Default image processing configuration used either in the this material.
  16860. *
  16861. * If sets to null, the scene one is in use.
  16862. */
  16863. imageProcessingConfiguration: ImageProcessingConfiguration;
  16864. /**
  16865. * Attaches a new image processing configuration to the Standard Material.
  16866. * @param configuration
  16867. */
  16868. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16869. /** @hidden */
  16870. protected _reset(): void;
  16871. /** @hidden */
  16872. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16873. /**
  16874. * Instantiates a particle system.
  16875. * 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.
  16876. * @param name The name of the particle system
  16877. */
  16878. constructor(name: string);
  16879. /**
  16880. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16881. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16882. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16883. * @returns the emitter
  16884. */
  16885. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16886. /**
  16887. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16888. * @param radius The radius of the hemisphere to emit from
  16889. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16890. * @returns the emitter
  16891. */
  16892. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16893. /**
  16894. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16895. * @param radius The radius of the sphere to emit from
  16896. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16897. * @returns the emitter
  16898. */
  16899. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16900. /**
  16901. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16902. * @param radius The radius of the sphere to emit from
  16903. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16904. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16905. * @returns the emitter
  16906. */
  16907. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16908. /**
  16909. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16910. * @param radius The radius of the emission cylinder
  16911. * @param height The height of the emission cylinder
  16912. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16913. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16914. * @returns the emitter
  16915. */
  16916. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16917. /**
  16918. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16919. * @param radius The radius of the cylinder to emit from
  16920. * @param height The height of the emission cylinder
  16921. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16922. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16923. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16924. * @returns the emitter
  16925. */
  16926. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16927. /**
  16928. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16929. * @param radius The radius of the cone to emit from
  16930. * @param angle The base angle of the cone
  16931. * @returns the emitter
  16932. */
  16933. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16934. /**
  16935. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16936. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16937. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16938. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16939. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16940. * @returns the emitter
  16941. */
  16942. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16943. }
  16944. }
  16945. declare module BABYLON {
  16946. /**
  16947. * Type of sub emitter
  16948. */
  16949. export enum SubEmitterType {
  16950. /**
  16951. * Attached to the particle over it's lifetime
  16952. */
  16953. ATTACHED = 0,
  16954. /**
  16955. * Created when the particle dies
  16956. */
  16957. END = 1
  16958. }
  16959. /**
  16960. * Sub emitter class used to emit particles from an existing particle
  16961. */
  16962. export class SubEmitter {
  16963. /**
  16964. * the particle system to be used by the sub emitter
  16965. */
  16966. particleSystem: ParticleSystem;
  16967. /**
  16968. * Type of the submitter (Default: END)
  16969. */
  16970. type: SubEmitterType;
  16971. /**
  16972. * 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)
  16973. * Note: This only is supported when using an emitter of type Mesh
  16974. */
  16975. inheritDirection: boolean;
  16976. /**
  16977. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16978. */
  16979. inheritedVelocityAmount: number;
  16980. /**
  16981. * Creates a sub emitter
  16982. * @param particleSystem the particle system to be used by the sub emitter
  16983. */
  16984. constructor(
  16985. /**
  16986. * the particle system to be used by the sub emitter
  16987. */
  16988. particleSystem: ParticleSystem);
  16989. /**
  16990. * Clones the sub emitter
  16991. * @returns the cloned sub emitter
  16992. */
  16993. clone(): SubEmitter;
  16994. /**
  16995. * Serialize current object to a JSON object
  16996. * @returns the serialized object
  16997. */
  16998. serialize(): any;
  16999. /** @hidden */
  17000. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17001. /**
  17002. * Creates a new SubEmitter from a serialized JSON version
  17003. * @param serializationObject defines the JSON object to read from
  17004. * @param scene defines the hosting scene
  17005. * @param rootUrl defines the rootUrl for data loading
  17006. * @returns a new SubEmitter
  17007. */
  17008. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17009. /** Release associated resources */
  17010. dispose(): void;
  17011. }
  17012. }
  17013. declare module BABYLON {
  17014. /** @hidden */
  17015. export var clipPlaneFragmentDeclaration: {
  17016. name: string;
  17017. shader: string;
  17018. };
  17019. }
  17020. declare module BABYLON {
  17021. /** @hidden */
  17022. export var imageProcessingDeclaration: {
  17023. name: string;
  17024. shader: string;
  17025. };
  17026. }
  17027. declare module BABYLON {
  17028. /** @hidden */
  17029. export var imageProcessingFunctions: {
  17030. name: string;
  17031. shader: string;
  17032. };
  17033. }
  17034. declare module BABYLON {
  17035. /** @hidden */
  17036. export var clipPlaneFragment: {
  17037. name: string;
  17038. shader: string;
  17039. };
  17040. }
  17041. declare module BABYLON {
  17042. /** @hidden */
  17043. export var particlesPixelShader: {
  17044. name: string;
  17045. shader: string;
  17046. };
  17047. }
  17048. declare module BABYLON {
  17049. /** @hidden */
  17050. export var clipPlaneVertexDeclaration: {
  17051. name: string;
  17052. shader: string;
  17053. };
  17054. }
  17055. declare module BABYLON {
  17056. /** @hidden */
  17057. export var clipPlaneVertex: {
  17058. name: string;
  17059. shader: string;
  17060. };
  17061. }
  17062. declare module BABYLON {
  17063. /** @hidden */
  17064. export var particlesVertexShader: {
  17065. name: string;
  17066. shader: string;
  17067. };
  17068. }
  17069. declare module BABYLON {
  17070. /**
  17071. * This represents a particle system in Babylon.
  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. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17074. * @example https://doc.babylonjs.com/babylon101/particles
  17075. */
  17076. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17077. /**
  17078. * Billboard mode will only apply to Y axis
  17079. */
  17080. static readonly BILLBOARDMODE_Y: number;
  17081. /**
  17082. * Billboard mode will apply to all axes
  17083. */
  17084. static readonly BILLBOARDMODE_ALL: number;
  17085. /**
  17086. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17087. */
  17088. static readonly BILLBOARDMODE_STRETCHED: number;
  17089. /**
  17090. * This function can be defined to provide custom update for active particles.
  17091. * This function will be called instead of regular update (age, position, color, etc.).
  17092. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17093. */
  17094. updateFunction: (particles: Particle[]) => void;
  17095. private _emitterWorldMatrix;
  17096. /**
  17097. * This function can be defined to specify initial direction for every new particle.
  17098. * It by default use the emitterType defined function
  17099. */
  17100. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17101. /**
  17102. * This function can be defined to specify initial position for every new particle.
  17103. * It by default use the emitterType defined function
  17104. */
  17105. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17106. /**
  17107. * @hidden
  17108. */
  17109. _inheritedVelocityOffset: Vector3;
  17110. /**
  17111. * An event triggered when the system is disposed
  17112. */
  17113. onDisposeObservable: Observable<ParticleSystem>;
  17114. private _onDisposeObserver;
  17115. /**
  17116. * Sets a callback that will be triggered when the system is disposed
  17117. */
  17118. onDispose: () => void;
  17119. private _particles;
  17120. private _epsilon;
  17121. private _capacity;
  17122. private _stockParticles;
  17123. private _newPartsExcess;
  17124. private _vertexData;
  17125. private _vertexBuffer;
  17126. private _vertexBuffers;
  17127. private _spriteBuffer;
  17128. private _indexBuffer;
  17129. private _effect;
  17130. private _customEffect;
  17131. private _cachedDefines;
  17132. private _scaledColorStep;
  17133. private _colorDiff;
  17134. private _scaledDirection;
  17135. private _scaledGravity;
  17136. private _currentRenderId;
  17137. private _alive;
  17138. private _useInstancing;
  17139. private _started;
  17140. private _stopped;
  17141. private _actualFrame;
  17142. private _scaledUpdateSpeed;
  17143. private _vertexBufferSize;
  17144. /** @hidden */
  17145. _currentEmitRateGradient: Nullable<FactorGradient>;
  17146. /** @hidden */
  17147. _currentEmitRate1: number;
  17148. /** @hidden */
  17149. _currentEmitRate2: number;
  17150. /** @hidden */
  17151. _currentStartSizeGradient: Nullable<FactorGradient>;
  17152. /** @hidden */
  17153. _currentStartSize1: number;
  17154. /** @hidden */
  17155. _currentStartSize2: number;
  17156. private readonly _rawTextureWidth;
  17157. private _rampGradientsTexture;
  17158. private _useRampGradients;
  17159. /** Gets or sets a boolean indicating that ramp gradients must be used
  17160. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17161. */
  17162. useRampGradients: boolean;
  17163. /**
  17164. * 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.
  17165. * 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: [])
  17166. */
  17167. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17168. private _subEmitters;
  17169. /**
  17170. * @hidden
  17171. * If the particle systems emitter should be disposed when the particle system is disposed
  17172. */
  17173. _disposeEmitterOnDispose: boolean;
  17174. /**
  17175. * The current active Sub-systems, this property is used by the root particle system only.
  17176. */
  17177. activeSubSystems: Array<ParticleSystem>;
  17178. private _rootParticleSystem;
  17179. /**
  17180. * Gets the current list of active particles
  17181. */
  17182. readonly particles: Particle[];
  17183. /**
  17184. * Returns the string "ParticleSystem"
  17185. * @returns a string containing the class name
  17186. */
  17187. getClassName(): string;
  17188. /**
  17189. * Instantiates a particle system.
  17190. * 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.
  17191. * @param name The name of the particle system
  17192. * @param capacity The max number of particles alive at the same time
  17193. * @param scene The scene the particle system belongs to
  17194. * @param customEffect a custom effect used to change the way particles are rendered by default
  17195. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17196. * @param epsilon Offset used to render the particles
  17197. */
  17198. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17199. private _addFactorGradient;
  17200. private _removeFactorGradient;
  17201. /**
  17202. * Adds a new life time gradient
  17203. * @param gradient defines the gradient to use (between 0 and 1)
  17204. * @param factor defines the life time factor to affect to the specified gradient
  17205. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17206. * @returns the current particle system
  17207. */
  17208. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17209. /**
  17210. * Remove a specific life time gradient
  17211. * @param gradient defines the gradient to remove
  17212. * @returns the current particle system
  17213. */
  17214. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17215. /**
  17216. * Adds a new size gradient
  17217. * @param gradient defines the gradient to use (between 0 and 1)
  17218. * @param factor defines the size factor to affect to the specified gradient
  17219. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17220. * @returns the current particle system
  17221. */
  17222. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17223. /**
  17224. * Remove a specific size gradient
  17225. * @param gradient defines the gradient to remove
  17226. * @returns the current particle system
  17227. */
  17228. removeSizeGradient(gradient: number): IParticleSystem;
  17229. /**
  17230. * Adds a new color remap gradient
  17231. * @param gradient defines the gradient to use (between 0 and 1)
  17232. * @param min defines the color remap minimal range
  17233. * @param max defines the color remap maximal range
  17234. * @returns the current particle system
  17235. */
  17236. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17237. /**
  17238. * Remove a specific color remap gradient
  17239. * @param gradient defines the gradient to remove
  17240. * @returns the current particle system
  17241. */
  17242. removeColorRemapGradient(gradient: number): IParticleSystem;
  17243. /**
  17244. * Adds a new alpha remap gradient
  17245. * @param gradient defines the gradient to use (between 0 and 1)
  17246. * @param min defines the alpha remap minimal range
  17247. * @param max defines the alpha remap maximal range
  17248. * @returns the current particle system
  17249. */
  17250. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17251. /**
  17252. * Remove a specific alpha remap gradient
  17253. * @param gradient defines the gradient to remove
  17254. * @returns the current particle system
  17255. */
  17256. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17257. /**
  17258. * Adds a new angular speed gradient
  17259. * @param gradient defines the gradient to use (between 0 and 1)
  17260. * @param factor defines the angular speed to affect to the specified gradient
  17261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17262. * @returns the current particle system
  17263. */
  17264. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17265. /**
  17266. * Remove a specific angular speed gradient
  17267. * @param gradient defines the gradient to remove
  17268. * @returns the current particle system
  17269. */
  17270. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17271. /**
  17272. * Adds a new velocity gradient
  17273. * @param gradient defines the gradient to use (between 0 and 1)
  17274. * @param factor defines the velocity to affect to the specified gradient
  17275. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17276. * @returns the current particle system
  17277. */
  17278. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17279. /**
  17280. * Remove a specific velocity gradient
  17281. * @param gradient defines the gradient to remove
  17282. * @returns the current particle system
  17283. */
  17284. removeVelocityGradient(gradient: number): IParticleSystem;
  17285. /**
  17286. * Adds a new limit velocity gradient
  17287. * @param gradient defines the gradient to use (between 0 and 1)
  17288. * @param factor defines the limit velocity value to affect to the specified gradient
  17289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17290. * @returns the current particle system
  17291. */
  17292. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17293. /**
  17294. * Remove a specific limit velocity gradient
  17295. * @param gradient defines the gradient to remove
  17296. * @returns the current particle system
  17297. */
  17298. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17299. /**
  17300. * Adds a new drag gradient
  17301. * @param gradient defines the gradient to use (between 0 and 1)
  17302. * @param factor defines the drag value to affect to the specified gradient
  17303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17304. * @returns the current particle system
  17305. */
  17306. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17307. /**
  17308. * Remove a specific drag gradient
  17309. * @param gradient defines the gradient to remove
  17310. * @returns the current particle system
  17311. */
  17312. removeDragGradient(gradient: number): IParticleSystem;
  17313. /**
  17314. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17315. * @param gradient defines the gradient to use (between 0 and 1)
  17316. * @param factor defines the emit rate value to affect to the specified gradient
  17317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17318. * @returns the current particle system
  17319. */
  17320. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17321. /**
  17322. * Remove a specific emit rate gradient
  17323. * @param gradient defines the gradient to remove
  17324. * @returns the current particle system
  17325. */
  17326. removeEmitRateGradient(gradient: number): IParticleSystem;
  17327. /**
  17328. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17329. * @param gradient defines the gradient to use (between 0 and 1)
  17330. * @param factor defines the start size value to affect to the specified gradient
  17331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17332. * @returns the current particle system
  17333. */
  17334. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17335. /**
  17336. * Remove a specific start size gradient
  17337. * @param gradient defines the gradient to remove
  17338. * @returns the current particle system
  17339. */
  17340. removeStartSizeGradient(gradient: number): IParticleSystem;
  17341. private _createRampGradientTexture;
  17342. /**
  17343. * Gets the current list of ramp gradients.
  17344. * You must use addRampGradient and removeRampGradient to udpate this list
  17345. * @returns the list of ramp gradients
  17346. */
  17347. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17348. /**
  17349. * Adds a new ramp gradient used to remap particle colors
  17350. * @param gradient defines the gradient to use (between 0 and 1)
  17351. * @param color defines the color to affect to the specified gradient
  17352. * @returns the current particle system
  17353. */
  17354. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17355. /**
  17356. * Remove a specific ramp gradient
  17357. * @param gradient defines the gradient to remove
  17358. * @returns the current particle system
  17359. */
  17360. removeRampGradient(gradient: number): ParticleSystem;
  17361. /**
  17362. * Adds a new color gradient
  17363. * @param gradient defines the gradient to use (between 0 and 1)
  17364. * @param color1 defines the color to affect to the specified gradient
  17365. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17366. * @returns this particle system
  17367. */
  17368. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17369. /**
  17370. * Remove a specific color gradient
  17371. * @param gradient defines the gradient to remove
  17372. * @returns this particle system
  17373. */
  17374. removeColorGradient(gradient: number): IParticleSystem;
  17375. private _fetchR;
  17376. protected _reset(): void;
  17377. private _resetEffect;
  17378. private _createVertexBuffers;
  17379. private _createIndexBuffer;
  17380. /**
  17381. * Gets the maximum number of particles active at the same time.
  17382. * @returns The max number of active particles.
  17383. */
  17384. getCapacity(): number;
  17385. /**
  17386. * Gets whether there are still active particles in the system.
  17387. * @returns True if it is alive, otherwise false.
  17388. */
  17389. isAlive(): boolean;
  17390. /**
  17391. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17392. * @returns True if it has been started, otherwise false.
  17393. */
  17394. isStarted(): boolean;
  17395. private _prepareSubEmitterInternalArray;
  17396. /**
  17397. * Starts the particle system and begins to emit
  17398. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17399. */
  17400. start(delay?: number): void;
  17401. /**
  17402. * Stops the particle system.
  17403. * @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.
  17404. */
  17405. stop(stopSubEmitters?: boolean): void;
  17406. /**
  17407. * Remove all active particles
  17408. */
  17409. reset(): void;
  17410. /**
  17411. * @hidden (for internal use only)
  17412. */
  17413. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17414. /**
  17415. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17416. * Its lifetime will start back at 0.
  17417. */
  17418. recycleParticle: (particle: Particle) => void;
  17419. private _stopSubEmitters;
  17420. private _createParticle;
  17421. private _removeFromRoot;
  17422. private _emitFromParticle;
  17423. private _update;
  17424. /** @hidden */
  17425. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17426. /** @hidden */
  17427. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17428. /** @hidden */
  17429. private _getEffect;
  17430. /**
  17431. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17432. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17433. */
  17434. animate(preWarmOnly?: boolean): void;
  17435. private _appendParticleVertices;
  17436. /**
  17437. * Rebuilds the particle system.
  17438. */
  17439. rebuild(): void;
  17440. /**
  17441. * Is this system ready to be used/rendered
  17442. * @return true if the system is ready
  17443. */
  17444. isReady(): boolean;
  17445. private _render;
  17446. /**
  17447. * Renders the particle system in its current state.
  17448. * @returns the current number of particles
  17449. */
  17450. render(): number;
  17451. /**
  17452. * Disposes the particle system and free the associated resources
  17453. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17454. */
  17455. dispose(disposeTexture?: boolean): void;
  17456. /**
  17457. * Clones the particle system.
  17458. * @param name The name of the cloned object
  17459. * @param newEmitter The new emitter to use
  17460. * @returns the cloned particle system
  17461. */
  17462. clone(name: string, newEmitter: any): ParticleSystem;
  17463. /**
  17464. * Serializes the particle system to a JSON object.
  17465. * @returns the JSON object
  17466. */
  17467. serialize(): any;
  17468. /** @hidden */
  17469. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17470. /** @hidden */
  17471. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17472. /**
  17473. * Parses a JSON object to create a particle system.
  17474. * @param parsedParticleSystem The JSON object to parse
  17475. * @param scene The scene to create the particle system in
  17476. * @param rootUrl The root url to use to load external dependencies like texture
  17477. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17478. * @returns the Parsed particle system
  17479. */
  17480. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17481. }
  17482. }
  17483. declare module BABYLON {
  17484. /**
  17485. * A particle represents one of the element emitted by a particle system.
  17486. * This is mainly define by its coordinates, direction, velocity and age.
  17487. */
  17488. export class Particle {
  17489. /**
  17490. * The particle system the particle belongs to.
  17491. */
  17492. particleSystem: ParticleSystem;
  17493. private static _Count;
  17494. /**
  17495. * Unique ID of the particle
  17496. */
  17497. id: number;
  17498. /**
  17499. * The world position of the particle in the scene.
  17500. */
  17501. position: Vector3;
  17502. /**
  17503. * The world direction of the particle in the scene.
  17504. */
  17505. direction: Vector3;
  17506. /**
  17507. * The color of the particle.
  17508. */
  17509. color: Color4;
  17510. /**
  17511. * The color change of the particle per step.
  17512. */
  17513. colorStep: Color4;
  17514. /**
  17515. * Defines how long will the life of the particle be.
  17516. */
  17517. lifeTime: number;
  17518. /**
  17519. * The current age of the particle.
  17520. */
  17521. age: number;
  17522. /**
  17523. * The current size of the particle.
  17524. */
  17525. size: number;
  17526. /**
  17527. * The current scale of the particle.
  17528. */
  17529. scale: Vector2;
  17530. /**
  17531. * The current angle of the particle.
  17532. */
  17533. angle: number;
  17534. /**
  17535. * Defines how fast is the angle changing.
  17536. */
  17537. angularSpeed: number;
  17538. /**
  17539. * Defines the cell index used by the particle to be rendered from a sprite.
  17540. */
  17541. cellIndex: number;
  17542. /**
  17543. * The information required to support color remapping
  17544. */
  17545. remapData: Vector4;
  17546. /** @hidden */
  17547. _randomCellOffset?: number;
  17548. /** @hidden */
  17549. _initialDirection: Nullable<Vector3>;
  17550. /** @hidden */
  17551. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17552. /** @hidden */
  17553. _initialStartSpriteCellID: number;
  17554. /** @hidden */
  17555. _initialEndSpriteCellID: number;
  17556. /** @hidden */
  17557. _currentColorGradient: Nullable<ColorGradient>;
  17558. /** @hidden */
  17559. _currentColor1: Color4;
  17560. /** @hidden */
  17561. _currentColor2: Color4;
  17562. /** @hidden */
  17563. _currentSizeGradient: Nullable<FactorGradient>;
  17564. /** @hidden */
  17565. _currentSize1: number;
  17566. /** @hidden */
  17567. _currentSize2: number;
  17568. /** @hidden */
  17569. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17570. /** @hidden */
  17571. _currentAngularSpeed1: number;
  17572. /** @hidden */
  17573. _currentAngularSpeed2: number;
  17574. /** @hidden */
  17575. _currentVelocityGradient: Nullable<FactorGradient>;
  17576. /** @hidden */
  17577. _currentVelocity1: number;
  17578. /** @hidden */
  17579. _currentVelocity2: number;
  17580. /** @hidden */
  17581. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17582. /** @hidden */
  17583. _currentLimitVelocity1: number;
  17584. /** @hidden */
  17585. _currentLimitVelocity2: number;
  17586. /** @hidden */
  17587. _currentDragGradient: Nullable<FactorGradient>;
  17588. /** @hidden */
  17589. _currentDrag1: number;
  17590. /** @hidden */
  17591. _currentDrag2: number;
  17592. /** @hidden */
  17593. _randomNoiseCoordinates1: Vector3;
  17594. /** @hidden */
  17595. _randomNoiseCoordinates2: Vector3;
  17596. /**
  17597. * Creates a new instance Particle
  17598. * @param particleSystem the particle system the particle belongs to
  17599. */
  17600. constructor(
  17601. /**
  17602. * The particle system the particle belongs to.
  17603. */
  17604. particleSystem: ParticleSystem);
  17605. private updateCellInfoFromSystem;
  17606. /**
  17607. * Defines how the sprite cell index is updated for the particle
  17608. */
  17609. updateCellIndex(): void;
  17610. /** @hidden */
  17611. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17612. /** @hidden */
  17613. _inheritParticleInfoToSubEmitters(): void;
  17614. /** @hidden */
  17615. _reset(): void;
  17616. /**
  17617. * Copy the properties of particle to another one.
  17618. * @param other the particle to copy the information to.
  17619. */
  17620. copyTo(other: Particle): void;
  17621. }
  17622. }
  17623. declare module BABYLON {
  17624. /**
  17625. * Particle emitter represents a volume emitting particles.
  17626. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17627. */
  17628. export interface IParticleEmitterType {
  17629. /**
  17630. * Called by the particle System when the direction is computed for the created particle.
  17631. * @param worldMatrix is the world matrix of the particle system
  17632. * @param directionToUpdate is the direction vector to update with the result
  17633. * @param particle is the particle we are computed the direction for
  17634. */
  17635. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17636. /**
  17637. * Called by the particle System when the position is computed for the created particle.
  17638. * @param worldMatrix is the world matrix of the particle system
  17639. * @param positionToUpdate is the position vector to update with the result
  17640. * @param particle is the particle we are computed the position for
  17641. */
  17642. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17643. /**
  17644. * Clones the current emitter and returns a copy of it
  17645. * @returns the new emitter
  17646. */
  17647. clone(): IParticleEmitterType;
  17648. /**
  17649. * Called by the GPUParticleSystem to setup the update shader
  17650. * @param effect defines the update shader
  17651. */
  17652. applyToShader(effect: Effect): void;
  17653. /**
  17654. * Returns a string to use to update the GPU particles update shader
  17655. * @returns the effect defines string
  17656. */
  17657. getEffectDefines(): string;
  17658. /**
  17659. * Returns a string representing the class name
  17660. * @returns a string containing the class name
  17661. */
  17662. getClassName(): string;
  17663. /**
  17664. * Serializes the particle system to a JSON object.
  17665. * @returns the JSON object
  17666. */
  17667. serialize(): any;
  17668. /**
  17669. * Parse properties from a JSON object
  17670. * @param serializationObject defines the JSON object
  17671. */
  17672. parse(serializationObject: any): void;
  17673. }
  17674. }
  17675. declare module BABYLON {
  17676. /**
  17677. * Particle emitter emitting particles from the inside of a box.
  17678. * It emits the particles randomly between 2 given directions.
  17679. */
  17680. export class BoxParticleEmitter implements IParticleEmitterType {
  17681. /**
  17682. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17683. */
  17684. direction1: Vector3;
  17685. /**
  17686. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17687. */
  17688. direction2: Vector3;
  17689. /**
  17690. * 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.
  17691. */
  17692. minEmitBox: Vector3;
  17693. /**
  17694. * 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.
  17695. */
  17696. maxEmitBox: Vector3;
  17697. /**
  17698. * Creates a new instance BoxParticleEmitter
  17699. */
  17700. constructor();
  17701. /**
  17702. * Called by the particle System when the direction is computed for the created particle.
  17703. * @param worldMatrix is the world matrix of the particle system
  17704. * @param directionToUpdate is the direction vector to update with the result
  17705. * @param particle is the particle we are computed the direction for
  17706. */
  17707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17708. /**
  17709. * Called by the particle System when the position is computed for the created particle.
  17710. * @param worldMatrix is the world matrix of the particle system
  17711. * @param positionToUpdate is the position vector to update with the result
  17712. * @param particle is the particle we are computed the position for
  17713. */
  17714. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17715. /**
  17716. * Clones the current emitter and returns a copy of it
  17717. * @returns the new emitter
  17718. */
  17719. clone(): BoxParticleEmitter;
  17720. /**
  17721. * Called by the GPUParticleSystem to setup the update shader
  17722. * @param effect defines the update shader
  17723. */
  17724. applyToShader(effect: Effect): void;
  17725. /**
  17726. * Returns a string to use to update the GPU particles update shader
  17727. * @returns a string containng the defines string
  17728. */
  17729. getEffectDefines(): string;
  17730. /**
  17731. * Returns the string "BoxParticleEmitter"
  17732. * @returns a string containing the class name
  17733. */
  17734. getClassName(): string;
  17735. /**
  17736. * Serializes the particle system to a JSON object.
  17737. * @returns the JSON object
  17738. */
  17739. serialize(): any;
  17740. /**
  17741. * Parse properties from a JSON object
  17742. * @param serializationObject defines the JSON object
  17743. */
  17744. parse(serializationObject: any): void;
  17745. }
  17746. }
  17747. declare module BABYLON {
  17748. /**
  17749. * Particle emitter emitting particles from the inside of a cone.
  17750. * It emits the particles alongside the cone volume from the base to the particle.
  17751. * The emission direction might be randomized.
  17752. */
  17753. export class ConeParticleEmitter implements IParticleEmitterType {
  17754. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17755. directionRandomizer: number;
  17756. private _radius;
  17757. private _angle;
  17758. private _height;
  17759. /**
  17760. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17761. */
  17762. radiusRange: number;
  17763. /**
  17764. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17765. */
  17766. heightRange: number;
  17767. /**
  17768. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17769. */
  17770. emitFromSpawnPointOnly: boolean;
  17771. /**
  17772. * Gets or sets the radius of the emission cone
  17773. */
  17774. radius: number;
  17775. /**
  17776. * Gets or sets the angle of the emission cone
  17777. */
  17778. angle: number;
  17779. private _buildHeight;
  17780. /**
  17781. * Creates a new instance ConeParticleEmitter
  17782. * @param radius the radius of the emission cone (1 by default)
  17783. * @param angle the cone base angle (PI by default)
  17784. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17785. */
  17786. constructor(radius?: number, angle?: number,
  17787. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17788. directionRandomizer?: number);
  17789. /**
  17790. * Called by the particle System when the direction is computed for the created particle.
  17791. * @param worldMatrix is the world matrix of the particle system
  17792. * @param directionToUpdate is the direction vector to update with the result
  17793. * @param particle is the particle we are computed the direction for
  17794. */
  17795. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17796. /**
  17797. * Called by the particle System when the position is computed for the created particle.
  17798. * @param worldMatrix is the world matrix of the particle system
  17799. * @param positionToUpdate is the position vector to update with the result
  17800. * @param particle is the particle we are computed the position for
  17801. */
  17802. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17803. /**
  17804. * Clones the current emitter and returns a copy of it
  17805. * @returns the new emitter
  17806. */
  17807. clone(): ConeParticleEmitter;
  17808. /**
  17809. * Called by the GPUParticleSystem to setup the update shader
  17810. * @param effect defines the update shader
  17811. */
  17812. applyToShader(effect: Effect): void;
  17813. /**
  17814. * Returns a string to use to update the GPU particles update shader
  17815. * @returns a string containng the defines string
  17816. */
  17817. getEffectDefines(): string;
  17818. /**
  17819. * Returns the string "ConeParticleEmitter"
  17820. * @returns a string containing the class name
  17821. */
  17822. getClassName(): string;
  17823. /**
  17824. * Serializes the particle system to a JSON object.
  17825. * @returns the JSON object
  17826. */
  17827. serialize(): any;
  17828. /**
  17829. * Parse properties from a JSON object
  17830. * @param serializationObject defines the JSON object
  17831. */
  17832. parse(serializationObject: any): void;
  17833. }
  17834. }
  17835. declare module BABYLON {
  17836. /**
  17837. * Particle emitter emitting particles from the inside of a cylinder.
  17838. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17839. */
  17840. export class CylinderParticleEmitter implements IParticleEmitterType {
  17841. /**
  17842. * The radius of the emission cylinder.
  17843. */
  17844. radius: number;
  17845. /**
  17846. * The height of the emission cylinder.
  17847. */
  17848. height: number;
  17849. /**
  17850. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17851. */
  17852. radiusRange: number;
  17853. /**
  17854. * How much to randomize the particle direction [0-1].
  17855. */
  17856. directionRandomizer: number;
  17857. /**
  17858. * Creates a new instance CylinderParticleEmitter
  17859. * @param radius the radius of the emission cylinder (1 by default)
  17860. * @param height the height of the emission cylinder (1 by default)
  17861. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17862. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17863. */
  17864. constructor(
  17865. /**
  17866. * The radius of the emission cylinder.
  17867. */
  17868. radius?: number,
  17869. /**
  17870. * The height of the emission cylinder.
  17871. */
  17872. height?: number,
  17873. /**
  17874. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17875. */
  17876. radiusRange?: number,
  17877. /**
  17878. * How much to randomize the particle direction [0-1].
  17879. */
  17880. directionRandomizer?: number);
  17881. /**
  17882. * Called by the particle System when the direction is computed for the created particle.
  17883. * @param worldMatrix is the world matrix of the particle system
  17884. * @param directionToUpdate is the direction vector to update with the result
  17885. * @param particle is the particle we are computed the direction for
  17886. */
  17887. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17888. /**
  17889. * Called by the particle System when the position is computed for the created particle.
  17890. * @param worldMatrix is the world matrix of the particle system
  17891. * @param positionToUpdate is the position vector to update with the result
  17892. * @param particle is the particle we are computed the position for
  17893. */
  17894. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17895. /**
  17896. * Clones the current emitter and returns a copy of it
  17897. * @returns the new emitter
  17898. */
  17899. clone(): CylinderParticleEmitter;
  17900. /**
  17901. * Called by the GPUParticleSystem to setup the update shader
  17902. * @param effect defines the update shader
  17903. */
  17904. applyToShader(effect: Effect): void;
  17905. /**
  17906. * Returns a string to use to update the GPU particles update shader
  17907. * @returns a string containng the defines string
  17908. */
  17909. getEffectDefines(): string;
  17910. /**
  17911. * Returns the string "CylinderParticleEmitter"
  17912. * @returns a string containing the class name
  17913. */
  17914. getClassName(): string;
  17915. /**
  17916. * Serializes the particle system to a JSON object.
  17917. * @returns the JSON object
  17918. */
  17919. serialize(): any;
  17920. /**
  17921. * Parse properties from a JSON object
  17922. * @param serializationObject defines the JSON object
  17923. */
  17924. parse(serializationObject: any): void;
  17925. }
  17926. /**
  17927. * Particle emitter emitting particles from the inside of a cylinder.
  17928. * It emits the particles randomly between two vectors.
  17929. */
  17930. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17931. /**
  17932. * The min limit of the emission direction.
  17933. */
  17934. direction1: Vector3;
  17935. /**
  17936. * The max limit of the emission direction.
  17937. */
  17938. direction2: Vector3;
  17939. /**
  17940. * Creates a new instance CylinderDirectedParticleEmitter
  17941. * @param radius the radius of the emission cylinder (1 by default)
  17942. * @param height the height of the emission cylinder (1 by default)
  17943. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17944. * @param direction1 the min limit of the emission direction (up vector by default)
  17945. * @param direction2 the max limit of the emission direction (up vector by default)
  17946. */
  17947. constructor(radius?: number, height?: number, radiusRange?: number,
  17948. /**
  17949. * The min limit of the emission direction.
  17950. */
  17951. direction1?: Vector3,
  17952. /**
  17953. * The max limit of the emission direction.
  17954. */
  17955. direction2?: Vector3);
  17956. /**
  17957. * Called by the particle System when the direction is computed for the created particle.
  17958. * @param worldMatrix is the world matrix of the particle system
  17959. * @param directionToUpdate is the direction vector to update with the result
  17960. * @param particle is the particle we are computed the direction for
  17961. */
  17962. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17963. /**
  17964. * Clones the current emitter and returns a copy of it
  17965. * @returns the new emitter
  17966. */
  17967. clone(): CylinderDirectedParticleEmitter;
  17968. /**
  17969. * Called by the GPUParticleSystem to setup the update shader
  17970. * @param effect defines the update shader
  17971. */
  17972. applyToShader(effect: Effect): void;
  17973. /**
  17974. * Returns a string to use to update the GPU particles update shader
  17975. * @returns a string containng the defines string
  17976. */
  17977. getEffectDefines(): string;
  17978. /**
  17979. * Returns the string "CylinderDirectedParticleEmitter"
  17980. * @returns a string containing the class name
  17981. */
  17982. getClassName(): string;
  17983. /**
  17984. * Serializes the particle system to a JSON object.
  17985. * @returns the JSON object
  17986. */
  17987. serialize(): any;
  17988. /**
  17989. * Parse properties from a JSON object
  17990. * @param serializationObject defines the JSON object
  17991. */
  17992. parse(serializationObject: any): void;
  17993. }
  17994. }
  17995. declare module BABYLON {
  17996. /**
  17997. * Particle emitter emitting particles from the inside of a hemisphere.
  17998. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17999. */
  18000. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18001. /**
  18002. * The radius of the emission hemisphere.
  18003. */
  18004. radius: number;
  18005. /**
  18006. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18007. */
  18008. radiusRange: number;
  18009. /**
  18010. * How much to randomize the particle direction [0-1].
  18011. */
  18012. directionRandomizer: number;
  18013. /**
  18014. * Creates a new instance HemisphericParticleEmitter
  18015. * @param radius the radius of the emission hemisphere (1 by default)
  18016. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18017. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18018. */
  18019. constructor(
  18020. /**
  18021. * The radius of the emission hemisphere.
  18022. */
  18023. radius?: number,
  18024. /**
  18025. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18026. */
  18027. radiusRange?: number,
  18028. /**
  18029. * How much to randomize the particle direction [0-1].
  18030. */
  18031. directionRandomizer?: number);
  18032. /**
  18033. * Called by the particle System when the direction is computed for the created particle.
  18034. * @param worldMatrix is the world matrix of the particle system
  18035. * @param directionToUpdate is the direction vector to update with the result
  18036. * @param particle is the particle we are computed the direction for
  18037. */
  18038. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18039. /**
  18040. * Called by the particle System when the position is computed for the created particle.
  18041. * @param worldMatrix is the world matrix of the particle system
  18042. * @param positionToUpdate is the position vector to update with the result
  18043. * @param particle is the particle we are computed the position for
  18044. */
  18045. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18046. /**
  18047. * Clones the current emitter and returns a copy of it
  18048. * @returns the new emitter
  18049. */
  18050. clone(): HemisphericParticleEmitter;
  18051. /**
  18052. * Called by the GPUParticleSystem to setup the update shader
  18053. * @param effect defines the update shader
  18054. */
  18055. applyToShader(effect: Effect): void;
  18056. /**
  18057. * Returns a string to use to update the GPU particles update shader
  18058. * @returns a string containng the defines string
  18059. */
  18060. getEffectDefines(): string;
  18061. /**
  18062. * Returns the string "HemisphericParticleEmitter"
  18063. * @returns a string containing the class name
  18064. */
  18065. getClassName(): string;
  18066. /**
  18067. * Serializes the particle system to a JSON object.
  18068. * @returns the JSON object
  18069. */
  18070. serialize(): any;
  18071. /**
  18072. * Parse properties from a JSON object
  18073. * @param serializationObject defines the JSON object
  18074. */
  18075. parse(serializationObject: any): void;
  18076. }
  18077. }
  18078. declare module BABYLON {
  18079. /**
  18080. * Particle emitter emitting particles from a point.
  18081. * It emits the particles randomly between 2 given directions.
  18082. */
  18083. export class PointParticleEmitter implements IParticleEmitterType {
  18084. /**
  18085. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18086. */
  18087. direction1: Vector3;
  18088. /**
  18089. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18090. */
  18091. direction2: Vector3;
  18092. /**
  18093. * Creates a new instance PointParticleEmitter
  18094. */
  18095. constructor();
  18096. /**
  18097. * Called by the particle System when the direction is computed for the created particle.
  18098. * @param worldMatrix is the world matrix of the particle system
  18099. * @param directionToUpdate is the direction vector to update with the result
  18100. * @param particle is the particle we are computed the direction for
  18101. */
  18102. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18103. /**
  18104. * Called by the particle System when the position is computed for the created particle.
  18105. * @param worldMatrix is the world matrix of the particle system
  18106. * @param positionToUpdate is the position vector to update with the result
  18107. * @param particle is the particle we are computed the position for
  18108. */
  18109. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18110. /**
  18111. * Clones the current emitter and returns a copy of it
  18112. * @returns the new emitter
  18113. */
  18114. clone(): PointParticleEmitter;
  18115. /**
  18116. * Called by the GPUParticleSystem to setup the update shader
  18117. * @param effect defines the update shader
  18118. */
  18119. applyToShader(effect: Effect): void;
  18120. /**
  18121. * Returns a string to use to update the GPU particles update shader
  18122. * @returns a string containng the defines string
  18123. */
  18124. getEffectDefines(): string;
  18125. /**
  18126. * Returns the string "PointParticleEmitter"
  18127. * @returns a string containing the class name
  18128. */
  18129. getClassName(): string;
  18130. /**
  18131. * Serializes the particle system to a JSON object.
  18132. * @returns the JSON object
  18133. */
  18134. serialize(): any;
  18135. /**
  18136. * Parse properties from a JSON object
  18137. * @param serializationObject defines the JSON object
  18138. */
  18139. parse(serializationObject: any): void;
  18140. }
  18141. }
  18142. declare module BABYLON {
  18143. /**
  18144. * Particle emitter emitting particles from the inside of a sphere.
  18145. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18146. */
  18147. export class SphereParticleEmitter implements IParticleEmitterType {
  18148. /**
  18149. * The radius of the emission sphere.
  18150. */
  18151. radius: number;
  18152. /**
  18153. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18154. */
  18155. radiusRange: number;
  18156. /**
  18157. * How much to randomize the particle direction [0-1].
  18158. */
  18159. directionRandomizer: number;
  18160. /**
  18161. * Creates a new instance SphereParticleEmitter
  18162. * @param radius the radius of the emission sphere (1 by default)
  18163. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18164. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18165. */
  18166. constructor(
  18167. /**
  18168. * The radius of the emission sphere.
  18169. */
  18170. radius?: number,
  18171. /**
  18172. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18173. */
  18174. radiusRange?: number,
  18175. /**
  18176. * How much to randomize the particle direction [0-1].
  18177. */
  18178. directionRandomizer?: number);
  18179. /**
  18180. * Called by the particle System when the direction is computed for the created particle.
  18181. * @param worldMatrix is the world matrix of the particle system
  18182. * @param directionToUpdate is the direction vector to update with the result
  18183. * @param particle is the particle we are computed the direction for
  18184. */
  18185. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18186. /**
  18187. * Called by the particle System when the position is computed for the created particle.
  18188. * @param worldMatrix is the world matrix of the particle system
  18189. * @param positionToUpdate is the position vector to update with the result
  18190. * @param particle is the particle we are computed the position for
  18191. */
  18192. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18193. /**
  18194. * Clones the current emitter and returns a copy of it
  18195. * @returns the new emitter
  18196. */
  18197. clone(): SphereParticleEmitter;
  18198. /**
  18199. * Called by the GPUParticleSystem to setup the update shader
  18200. * @param effect defines the update shader
  18201. */
  18202. applyToShader(effect: Effect): void;
  18203. /**
  18204. * Returns a string to use to update the GPU particles update shader
  18205. * @returns a string containng the defines string
  18206. */
  18207. getEffectDefines(): string;
  18208. /**
  18209. * Returns the string "SphereParticleEmitter"
  18210. * @returns a string containing the class name
  18211. */
  18212. getClassName(): string;
  18213. /**
  18214. * Serializes the particle system to a JSON object.
  18215. * @returns the JSON object
  18216. */
  18217. serialize(): any;
  18218. /**
  18219. * Parse properties from a JSON object
  18220. * @param serializationObject defines the JSON object
  18221. */
  18222. parse(serializationObject: any): void;
  18223. }
  18224. /**
  18225. * Particle emitter emitting particles from the inside of a sphere.
  18226. * It emits the particles randomly between two vectors.
  18227. */
  18228. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18229. /**
  18230. * The min limit of the emission direction.
  18231. */
  18232. direction1: Vector3;
  18233. /**
  18234. * The max limit of the emission direction.
  18235. */
  18236. direction2: Vector3;
  18237. /**
  18238. * Creates a new instance SphereDirectedParticleEmitter
  18239. * @param radius the radius of the emission sphere (1 by default)
  18240. * @param direction1 the min limit of the emission direction (up vector by default)
  18241. * @param direction2 the max limit of the emission direction (up vector by default)
  18242. */
  18243. constructor(radius?: number,
  18244. /**
  18245. * The min limit of the emission direction.
  18246. */
  18247. direction1?: Vector3,
  18248. /**
  18249. * The max limit of the emission direction.
  18250. */
  18251. direction2?: Vector3);
  18252. /**
  18253. * Called by the particle System when the direction is computed for the created particle.
  18254. * @param worldMatrix is the world matrix of the particle system
  18255. * @param directionToUpdate is the direction vector to update with the result
  18256. * @param particle is the particle we are computed the direction for
  18257. */
  18258. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18259. /**
  18260. * Clones the current emitter and returns a copy of it
  18261. * @returns the new emitter
  18262. */
  18263. clone(): SphereDirectedParticleEmitter;
  18264. /**
  18265. * Called by the GPUParticleSystem to setup the update shader
  18266. * @param effect defines the update shader
  18267. */
  18268. applyToShader(effect: Effect): void;
  18269. /**
  18270. * Returns a string to use to update the GPU particles update shader
  18271. * @returns a string containng the defines string
  18272. */
  18273. getEffectDefines(): string;
  18274. /**
  18275. * Returns the string "SphereDirectedParticleEmitter"
  18276. * @returns a string containing the class name
  18277. */
  18278. getClassName(): string;
  18279. /**
  18280. * Serializes the particle system to a JSON object.
  18281. * @returns the JSON object
  18282. */
  18283. serialize(): any;
  18284. /**
  18285. * Parse properties from a JSON object
  18286. * @param serializationObject defines the JSON object
  18287. */
  18288. parse(serializationObject: any): void;
  18289. }
  18290. }
  18291. declare module BABYLON {
  18292. /**
  18293. * Interface representing a particle system in Babylon.js.
  18294. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18295. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18296. */
  18297. export interface IParticleSystem {
  18298. /**
  18299. * List of animations used by the particle system.
  18300. */
  18301. animations: Animation[];
  18302. /**
  18303. * The id of the Particle system.
  18304. */
  18305. id: string;
  18306. /**
  18307. * The name of the Particle system.
  18308. */
  18309. name: string;
  18310. /**
  18311. * The emitter represents the Mesh or position we are attaching the particle system to.
  18312. */
  18313. emitter: Nullable<AbstractMesh | Vector3>;
  18314. /**
  18315. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18316. */
  18317. isBillboardBased: boolean;
  18318. /**
  18319. * The rendering group used by the Particle system to chose when to render.
  18320. */
  18321. renderingGroupId: number;
  18322. /**
  18323. * The layer mask we are rendering the particles through.
  18324. */
  18325. layerMask: number;
  18326. /**
  18327. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18328. */
  18329. updateSpeed: number;
  18330. /**
  18331. * The amount of time the particle system is running (depends of the overall update speed).
  18332. */
  18333. targetStopDuration: number;
  18334. /**
  18335. * The texture used to render each particle. (this can be a spritesheet)
  18336. */
  18337. particleTexture: Nullable<Texture>;
  18338. /**
  18339. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18340. */
  18341. blendMode: number;
  18342. /**
  18343. * Minimum life time of emitting particles.
  18344. */
  18345. minLifeTime: number;
  18346. /**
  18347. * Maximum life time of emitting particles.
  18348. */
  18349. maxLifeTime: number;
  18350. /**
  18351. * Minimum Size of emitting particles.
  18352. */
  18353. minSize: number;
  18354. /**
  18355. * Maximum Size of emitting particles.
  18356. */
  18357. maxSize: number;
  18358. /**
  18359. * Minimum scale of emitting particles on X axis.
  18360. */
  18361. minScaleX: number;
  18362. /**
  18363. * Maximum scale of emitting particles on X axis.
  18364. */
  18365. maxScaleX: number;
  18366. /**
  18367. * Minimum scale of emitting particles on Y axis.
  18368. */
  18369. minScaleY: number;
  18370. /**
  18371. * Maximum scale of emitting particles on Y axis.
  18372. */
  18373. maxScaleY: number;
  18374. /**
  18375. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18376. */
  18377. color1: Color4;
  18378. /**
  18379. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18380. */
  18381. color2: Color4;
  18382. /**
  18383. * Color the particle will have at the end of its lifetime.
  18384. */
  18385. colorDead: Color4;
  18386. /**
  18387. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18388. */
  18389. emitRate: number;
  18390. /**
  18391. * You can use gravity if you want to give an orientation to your particles.
  18392. */
  18393. gravity: Vector3;
  18394. /**
  18395. * Minimum power of emitting particles.
  18396. */
  18397. minEmitPower: number;
  18398. /**
  18399. * Maximum power of emitting particles.
  18400. */
  18401. maxEmitPower: number;
  18402. /**
  18403. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18404. */
  18405. minAngularSpeed: number;
  18406. /**
  18407. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18408. */
  18409. maxAngularSpeed: number;
  18410. /**
  18411. * Gets or sets the minimal initial rotation in radians.
  18412. */
  18413. minInitialRotation: number;
  18414. /**
  18415. * Gets or sets the maximal initial rotation in radians.
  18416. */
  18417. maxInitialRotation: number;
  18418. /**
  18419. * The particle emitter type defines the emitter used by the particle system.
  18420. * It can be for example box, sphere, or cone...
  18421. */
  18422. particleEmitterType: Nullable<IParticleEmitterType>;
  18423. /**
  18424. * Defines the delay in milliseconds before starting the system (0 by default)
  18425. */
  18426. startDelay: number;
  18427. /**
  18428. * 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
  18429. */
  18430. preWarmCycles: number;
  18431. /**
  18432. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18433. */
  18434. preWarmStepOffset: number;
  18435. /**
  18436. * 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)
  18437. */
  18438. spriteCellChangeSpeed: number;
  18439. /**
  18440. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18441. */
  18442. startSpriteCellID: number;
  18443. /**
  18444. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18445. */
  18446. endSpriteCellID: number;
  18447. /**
  18448. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18449. */
  18450. spriteCellWidth: number;
  18451. /**
  18452. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18453. */
  18454. spriteCellHeight: number;
  18455. /**
  18456. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18457. */
  18458. spriteRandomStartCell: boolean;
  18459. /**
  18460. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18461. */
  18462. isAnimationSheetEnabled: boolean;
  18463. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18464. translationPivot: Vector2;
  18465. /**
  18466. * Gets or sets a texture used to add random noise to particle positions
  18467. */
  18468. noiseTexture: Nullable<BaseTexture>;
  18469. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18470. noiseStrength: Vector3;
  18471. /**
  18472. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18473. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18474. */
  18475. billboardMode: number;
  18476. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18477. limitVelocityDamping: number;
  18478. /**
  18479. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18480. */
  18481. beginAnimationOnStart: boolean;
  18482. /**
  18483. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18484. */
  18485. beginAnimationFrom: number;
  18486. /**
  18487. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18488. */
  18489. beginAnimationTo: number;
  18490. /**
  18491. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18492. */
  18493. beginAnimationLoop: boolean;
  18494. /**
  18495. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18496. */
  18497. disposeOnStop: boolean;
  18498. /**
  18499. * Gets the maximum number of particles active at the same time.
  18500. * @returns The max number of active particles.
  18501. */
  18502. getCapacity(): number;
  18503. /**
  18504. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18505. * @returns True if it has been started, otherwise false.
  18506. */
  18507. isStarted(): boolean;
  18508. /**
  18509. * Animates the particle system for this frame.
  18510. */
  18511. animate(): void;
  18512. /**
  18513. * Renders the particle system in its current state.
  18514. * @returns the current number of particles
  18515. */
  18516. render(): number;
  18517. /**
  18518. * Dispose the particle system and frees its associated resources.
  18519. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18520. */
  18521. dispose(disposeTexture?: boolean): void;
  18522. /**
  18523. * Clones the particle system.
  18524. * @param name The name of the cloned object
  18525. * @param newEmitter The new emitter to use
  18526. * @returns the cloned particle system
  18527. */
  18528. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18529. /**
  18530. * Serializes the particle system to a JSON object.
  18531. * @returns the JSON object
  18532. */
  18533. serialize(): any;
  18534. /**
  18535. * Rebuild the particle system
  18536. */
  18537. rebuild(): void;
  18538. /**
  18539. * Starts the particle system and begins to emit
  18540. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18541. */
  18542. start(delay?: number): void;
  18543. /**
  18544. * Stops the particle system.
  18545. */
  18546. stop(): void;
  18547. /**
  18548. * Remove all active particles
  18549. */
  18550. reset(): void;
  18551. /**
  18552. * Is this system ready to be used/rendered
  18553. * @return true if the system is ready
  18554. */
  18555. isReady(): boolean;
  18556. /**
  18557. * Adds a new color gradient
  18558. * @param gradient defines the gradient to use (between 0 and 1)
  18559. * @param color1 defines the color to affect to the specified gradient
  18560. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18561. * @returns the current particle system
  18562. */
  18563. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18564. /**
  18565. * Remove a specific color gradient
  18566. * @param gradient defines the gradient to remove
  18567. * @returns the current particle system
  18568. */
  18569. removeColorGradient(gradient: number): IParticleSystem;
  18570. /**
  18571. * Adds a new size gradient
  18572. * @param gradient defines the gradient to use (between 0 and 1)
  18573. * @param factor defines the size factor to affect to the specified gradient
  18574. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18575. * @returns the current particle system
  18576. */
  18577. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18578. /**
  18579. * Remove a specific size gradient
  18580. * @param gradient defines the gradient to remove
  18581. * @returns the current particle system
  18582. */
  18583. removeSizeGradient(gradient: number): IParticleSystem;
  18584. /**
  18585. * Gets the current list of color gradients.
  18586. * You must use addColorGradient and removeColorGradient to udpate this list
  18587. * @returns the list of color gradients
  18588. */
  18589. getColorGradients(): Nullable<Array<ColorGradient>>;
  18590. /**
  18591. * Gets the current list of size gradients.
  18592. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18593. * @returns the list of size gradients
  18594. */
  18595. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18596. /**
  18597. * Gets the current list of angular speed gradients.
  18598. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18599. * @returns the list of angular speed gradients
  18600. */
  18601. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18602. /**
  18603. * Adds a new angular speed gradient
  18604. * @param gradient defines the gradient to use (between 0 and 1)
  18605. * @param factor defines the angular speed to affect to the specified gradient
  18606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18607. * @returns the current particle system
  18608. */
  18609. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18610. /**
  18611. * Remove a specific angular speed gradient
  18612. * @param gradient defines the gradient to remove
  18613. * @returns the current particle system
  18614. */
  18615. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18616. /**
  18617. * Gets the current list of velocity gradients.
  18618. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18619. * @returns the list of velocity gradients
  18620. */
  18621. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18622. /**
  18623. * Adds a new velocity gradient
  18624. * @param gradient defines the gradient to use (between 0 and 1)
  18625. * @param factor defines the velocity to affect to the specified gradient
  18626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18627. * @returns the current particle system
  18628. */
  18629. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18630. /**
  18631. * Remove a specific velocity gradient
  18632. * @param gradient defines the gradient to remove
  18633. * @returns the current particle system
  18634. */
  18635. removeVelocityGradient(gradient: number): IParticleSystem;
  18636. /**
  18637. * Gets the current list of limit velocity gradients.
  18638. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18639. * @returns the list of limit velocity gradients
  18640. */
  18641. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18642. /**
  18643. * Adds a new limit velocity gradient
  18644. * @param gradient defines the gradient to use (between 0 and 1)
  18645. * @param factor defines the limit velocity to affect to the specified gradient
  18646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18647. * @returns the current particle system
  18648. */
  18649. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18650. /**
  18651. * Remove a specific limit velocity gradient
  18652. * @param gradient defines the gradient to remove
  18653. * @returns the current particle system
  18654. */
  18655. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18656. /**
  18657. * Adds a new drag gradient
  18658. * @param gradient defines the gradient to use (between 0 and 1)
  18659. * @param factor defines the drag to affect to the specified gradient
  18660. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18661. * @returns the current particle system
  18662. */
  18663. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18664. /**
  18665. * Remove a specific drag gradient
  18666. * @param gradient defines the gradient to remove
  18667. * @returns the current particle system
  18668. */
  18669. removeDragGradient(gradient: number): IParticleSystem;
  18670. /**
  18671. * Gets the current list of drag gradients.
  18672. * You must use addDragGradient and removeDragGradient to udpate this list
  18673. * @returns the list of drag gradients
  18674. */
  18675. getDragGradients(): Nullable<Array<FactorGradient>>;
  18676. /**
  18677. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18678. * @param gradient defines the gradient to use (between 0 and 1)
  18679. * @param factor defines the emit rate to affect to the specified gradient
  18680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18681. * @returns the current particle system
  18682. */
  18683. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18684. /**
  18685. * Remove a specific emit rate gradient
  18686. * @param gradient defines the gradient to remove
  18687. * @returns the current particle system
  18688. */
  18689. removeEmitRateGradient(gradient: number): IParticleSystem;
  18690. /**
  18691. * Gets the current list of emit rate gradients.
  18692. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18693. * @returns the list of emit rate gradients
  18694. */
  18695. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18696. /**
  18697. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18698. * @param gradient defines the gradient to use (between 0 and 1)
  18699. * @param factor defines the start size to affect to the specified gradient
  18700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18701. * @returns the current particle system
  18702. */
  18703. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18704. /**
  18705. * Remove a specific start size gradient
  18706. * @param gradient defines the gradient to remove
  18707. * @returns the current particle system
  18708. */
  18709. removeStartSizeGradient(gradient: number): IParticleSystem;
  18710. /**
  18711. * Gets the current list of start size gradients.
  18712. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18713. * @returns the list of start size gradients
  18714. */
  18715. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18716. /**
  18717. * Adds a new life time gradient
  18718. * @param gradient defines the gradient to use (between 0 and 1)
  18719. * @param factor defines the life time factor to affect to the specified gradient
  18720. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18721. * @returns the current particle system
  18722. */
  18723. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18724. /**
  18725. * Remove a specific life time gradient
  18726. * @param gradient defines the gradient to remove
  18727. * @returns the current particle system
  18728. */
  18729. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18730. /**
  18731. * Gets the current list of life time gradients.
  18732. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18733. * @returns the list of life time gradients
  18734. */
  18735. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18736. /**
  18737. * Gets the current list of color gradients.
  18738. * You must use addColorGradient and removeColorGradient to udpate this list
  18739. * @returns the list of color gradients
  18740. */
  18741. getColorGradients(): Nullable<Array<ColorGradient>>;
  18742. /**
  18743. * Adds a new ramp gradient used to remap particle colors
  18744. * @param gradient defines the gradient to use (between 0 and 1)
  18745. * @param color defines the color to affect to the specified gradient
  18746. * @returns the current particle system
  18747. */
  18748. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18749. /**
  18750. * Gets the current list of ramp gradients.
  18751. * You must use addRampGradient and removeRampGradient to udpate this list
  18752. * @returns the list of ramp gradients
  18753. */
  18754. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18755. /** Gets or sets a boolean indicating that ramp gradients must be used
  18756. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18757. */
  18758. useRampGradients: boolean;
  18759. /**
  18760. * Adds a new color remap gradient
  18761. * @param gradient defines the gradient to use (between 0 and 1)
  18762. * @param min defines the color remap minimal range
  18763. * @param max defines the color remap maximal range
  18764. * @returns the current particle system
  18765. */
  18766. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18767. /**
  18768. * Gets the current list of color remap gradients.
  18769. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18770. * @returns the list of color remap gradients
  18771. */
  18772. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18773. /**
  18774. * Adds a new alpha remap gradient
  18775. * @param gradient defines the gradient to use (between 0 and 1)
  18776. * @param min defines the alpha remap minimal range
  18777. * @param max defines the alpha remap maximal range
  18778. * @returns the current particle system
  18779. */
  18780. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18781. /**
  18782. * Gets the current list of alpha remap gradients.
  18783. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18784. * @returns the list of alpha remap gradients
  18785. */
  18786. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18787. /**
  18788. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18789. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18790. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18791. * @returns the emitter
  18792. */
  18793. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18794. /**
  18795. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18796. * @param radius The radius of the hemisphere to emit from
  18797. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18798. * @returns the emitter
  18799. */
  18800. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18801. /**
  18802. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18803. * @param radius The radius of the sphere to emit from
  18804. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18805. * @returns the emitter
  18806. */
  18807. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18808. /**
  18809. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18810. * @param radius The radius of the sphere to emit from
  18811. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18812. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18813. * @returns the emitter
  18814. */
  18815. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18816. /**
  18817. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18818. * @param radius The radius of the emission cylinder
  18819. * @param height The height of the emission cylinder
  18820. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18821. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18822. * @returns the emitter
  18823. */
  18824. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18825. /**
  18826. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18827. * @param radius The radius of the cylinder to emit from
  18828. * @param height The height of the emission cylinder
  18829. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18830. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18831. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18832. * @returns the emitter
  18833. */
  18834. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18835. /**
  18836. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18837. * @param radius The radius of the cone to emit from
  18838. * @param angle The base angle of the cone
  18839. * @returns the emitter
  18840. */
  18841. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18842. /**
  18843. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18844. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18845. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18846. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18847. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18848. * @returns the emitter
  18849. */
  18850. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18851. /**
  18852. * Get hosting scene
  18853. * @returns the scene
  18854. */
  18855. getScene(): Scene;
  18856. }
  18857. }
  18858. declare module BABYLON {
  18859. /**
  18860. * Creates an instance based on a source mesh.
  18861. */
  18862. export class InstancedMesh extends AbstractMesh {
  18863. private _sourceMesh;
  18864. private _currentLOD;
  18865. /** @hidden */
  18866. _indexInSourceMeshInstanceArray: number;
  18867. constructor(name: string, source: Mesh);
  18868. /**
  18869. * Returns the string "InstancedMesh".
  18870. */
  18871. getClassName(): string;
  18872. /** Gets the list of lights affecting that mesh */
  18873. readonly lightSources: Light[];
  18874. _resyncLightSources(): void;
  18875. _resyncLighSource(light: Light): void;
  18876. _removeLightSource(light: Light, dispose: boolean): void;
  18877. /**
  18878. * If the source mesh receives shadows
  18879. */
  18880. readonly receiveShadows: boolean;
  18881. /**
  18882. * The material of the source mesh
  18883. */
  18884. readonly material: Nullable<Material>;
  18885. /**
  18886. * Visibility of the source mesh
  18887. */
  18888. readonly visibility: number;
  18889. /**
  18890. * Skeleton of the source mesh
  18891. */
  18892. readonly skeleton: Nullable<Skeleton>;
  18893. /**
  18894. * Rendering ground id of the source mesh
  18895. */
  18896. renderingGroupId: number;
  18897. /**
  18898. * Returns the total number of vertices (integer).
  18899. */
  18900. getTotalVertices(): number;
  18901. /**
  18902. * Returns a positive integer : the total number of indices in this mesh geometry.
  18903. * @returns the numner of indices or zero if the mesh has no geometry.
  18904. */
  18905. getTotalIndices(): number;
  18906. /**
  18907. * The source mesh of the instance
  18908. */
  18909. readonly sourceMesh: Mesh;
  18910. /**
  18911. * Is this node ready to be used/rendered
  18912. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18913. * @return {boolean} is it ready
  18914. */
  18915. isReady(completeCheck?: boolean): boolean;
  18916. /**
  18917. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18918. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18919. * @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.
  18920. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18921. */
  18922. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18923. /**
  18924. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18925. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18926. * The `data` are either a numeric array either a Float32Array.
  18927. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18928. * 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).
  18929. * Note that a new underlying VertexBuffer object is created each call.
  18930. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18931. *
  18932. * Possible `kind` values :
  18933. * - VertexBuffer.PositionKind
  18934. * - VertexBuffer.UVKind
  18935. * - VertexBuffer.UV2Kind
  18936. * - VertexBuffer.UV3Kind
  18937. * - VertexBuffer.UV4Kind
  18938. * - VertexBuffer.UV5Kind
  18939. * - VertexBuffer.UV6Kind
  18940. * - VertexBuffer.ColorKind
  18941. * - VertexBuffer.MatricesIndicesKind
  18942. * - VertexBuffer.MatricesIndicesExtraKind
  18943. * - VertexBuffer.MatricesWeightsKind
  18944. * - VertexBuffer.MatricesWeightsExtraKind
  18945. *
  18946. * Returns the Mesh.
  18947. */
  18948. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18949. /**
  18950. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18951. * If the mesh has no geometry, it is simply returned as it is.
  18952. * The `data` are either a numeric array either a Float32Array.
  18953. * No new underlying VertexBuffer object is created.
  18954. * 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.
  18955. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18956. *
  18957. * Possible `kind` values :
  18958. * - VertexBuffer.PositionKind
  18959. * - VertexBuffer.UVKind
  18960. * - VertexBuffer.UV2Kind
  18961. * - VertexBuffer.UV3Kind
  18962. * - VertexBuffer.UV4Kind
  18963. * - VertexBuffer.UV5Kind
  18964. * - VertexBuffer.UV6Kind
  18965. * - VertexBuffer.ColorKind
  18966. * - VertexBuffer.MatricesIndicesKind
  18967. * - VertexBuffer.MatricesIndicesExtraKind
  18968. * - VertexBuffer.MatricesWeightsKind
  18969. * - VertexBuffer.MatricesWeightsExtraKind
  18970. *
  18971. * Returns the Mesh.
  18972. */
  18973. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18974. /**
  18975. * Sets the mesh indices.
  18976. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18977. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18978. * This method creates a new index buffer each call.
  18979. * Returns the Mesh.
  18980. */
  18981. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18982. /**
  18983. * Boolean : True if the mesh owns the requested kind of data.
  18984. */
  18985. isVerticesDataPresent(kind: string): boolean;
  18986. /**
  18987. * Returns an array of indices (IndicesArray).
  18988. */
  18989. getIndices(): Nullable<IndicesArray>;
  18990. readonly _positions: Nullable<Vector3[]>;
  18991. /**
  18992. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18993. * This means the mesh underlying bounding box and sphere are recomputed.
  18994. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18995. * @returns the current mesh
  18996. */
  18997. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18998. /** @hidden */
  18999. _preActivate(): InstancedMesh;
  19000. /** @hidden */
  19001. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19002. /** @hidden */
  19003. _postActivate(): void;
  19004. getWorldMatrix(): Matrix;
  19005. readonly isAnInstance: boolean;
  19006. /**
  19007. * Returns the current associated LOD AbstractMesh.
  19008. */
  19009. getLOD(camera: Camera): AbstractMesh;
  19010. /** @hidden */
  19011. _syncSubMeshes(): InstancedMesh;
  19012. /** @hidden */
  19013. _generatePointsArray(): boolean;
  19014. /**
  19015. * Creates a new InstancedMesh from the current mesh.
  19016. * - name (string) : the cloned mesh name
  19017. * - newParent (optional Node) : the optional Node to parent the clone to.
  19018. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19019. *
  19020. * Returns the clone.
  19021. */
  19022. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19023. /**
  19024. * Disposes the InstancedMesh.
  19025. * Returns nothing.
  19026. */
  19027. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19028. }
  19029. }
  19030. declare module BABYLON {
  19031. /**
  19032. * Defines the options associated with the creation of a shader material.
  19033. */
  19034. export interface IShaderMaterialOptions {
  19035. /**
  19036. * Does the material work in alpha blend mode
  19037. */
  19038. needAlphaBlending: boolean;
  19039. /**
  19040. * Does the material work in alpha test mode
  19041. */
  19042. needAlphaTesting: boolean;
  19043. /**
  19044. * The list of attribute names used in the shader
  19045. */
  19046. attributes: string[];
  19047. /**
  19048. * The list of unifrom names used in the shader
  19049. */
  19050. uniforms: string[];
  19051. /**
  19052. * The list of UBO names used in the shader
  19053. */
  19054. uniformBuffers: string[];
  19055. /**
  19056. * The list of sampler names used in the shader
  19057. */
  19058. samplers: string[];
  19059. /**
  19060. * The list of defines used in the shader
  19061. */
  19062. defines: string[];
  19063. }
  19064. /**
  19065. * 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.
  19066. *
  19067. * This returned material effects how the mesh will look based on the code in the shaders.
  19068. *
  19069. * @see http://doc.babylonjs.com/how_to/shader_material
  19070. */
  19071. export class ShaderMaterial extends Material {
  19072. private _shaderPath;
  19073. private _options;
  19074. private _textures;
  19075. private _textureArrays;
  19076. private _floats;
  19077. private _ints;
  19078. private _floatsArrays;
  19079. private _colors3;
  19080. private _colors3Arrays;
  19081. private _colors4;
  19082. private _colors4Arrays;
  19083. private _vectors2;
  19084. private _vectors3;
  19085. private _vectors4;
  19086. private _matrices;
  19087. private _matrices3x3;
  19088. private _matrices2x2;
  19089. private _vectors2Arrays;
  19090. private _vectors3Arrays;
  19091. private _vectors4Arrays;
  19092. private _cachedWorldViewMatrix;
  19093. private _cachedWorldViewProjectionMatrix;
  19094. private _renderId;
  19095. /**
  19096. * Instantiate a new shader material.
  19097. * 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.
  19098. * This returned material effects how the mesh will look based on the code in the shaders.
  19099. * @see http://doc.babylonjs.com/how_to/shader_material
  19100. * @param name Define the name of the material in the scene
  19101. * @param scene Define the scene the material belongs to
  19102. * @param shaderPath Defines the route to the shader code in one of three ways:
  19103. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19104. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19105. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19106. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19107. * @param options Define the options used to create the shader
  19108. */
  19109. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19110. /**
  19111. * Gets the options used to compile the shader.
  19112. * They can be modified to trigger a new compilation
  19113. */
  19114. readonly options: IShaderMaterialOptions;
  19115. /**
  19116. * Gets the current class name of the material e.g. "ShaderMaterial"
  19117. * Mainly use in serialization.
  19118. * @returns the class name
  19119. */
  19120. getClassName(): string;
  19121. /**
  19122. * Specifies if the material will require alpha blending
  19123. * @returns a boolean specifying if alpha blending is needed
  19124. */
  19125. needAlphaBlending(): boolean;
  19126. /**
  19127. * Specifies if this material should be rendered in alpha test mode
  19128. * @returns a boolean specifying if an alpha test is needed.
  19129. */
  19130. needAlphaTesting(): boolean;
  19131. private _checkUniform;
  19132. /**
  19133. * Set a texture in the shader.
  19134. * @param name Define the name of the uniform samplers as defined in the shader
  19135. * @param texture Define the texture to bind to this sampler
  19136. * @return the material itself allowing "fluent" like uniform updates
  19137. */
  19138. setTexture(name: string, texture: Texture): ShaderMaterial;
  19139. /**
  19140. * Set a texture array in the shader.
  19141. * @param name Define the name of the uniform sampler array as defined in the shader
  19142. * @param textures Define the list of textures to bind to this sampler
  19143. * @return the material itself allowing "fluent" like uniform updates
  19144. */
  19145. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19146. /**
  19147. * Set a float in the shader.
  19148. * @param name Define the name of the uniform as defined in the shader
  19149. * @param value Define the value to give to the uniform
  19150. * @return the material itself allowing "fluent" like uniform updates
  19151. */
  19152. setFloat(name: string, value: number): ShaderMaterial;
  19153. /**
  19154. * Set a int in the shader.
  19155. * @param name Define the name of the uniform as defined in the shader
  19156. * @param value Define the value to give to the uniform
  19157. * @return the material itself allowing "fluent" like uniform updates
  19158. */
  19159. setInt(name: string, value: number): ShaderMaterial;
  19160. /**
  19161. * Set an array of floats in the shader.
  19162. * @param name Define the name of the uniform as defined in the shader
  19163. * @param value Define the value to give to the uniform
  19164. * @return the material itself allowing "fluent" like uniform updates
  19165. */
  19166. setFloats(name: string, value: number[]): ShaderMaterial;
  19167. /**
  19168. * Set a vec3 in the shader from a Color3.
  19169. * @param name Define the name of the uniform as defined in the shader
  19170. * @param value Define the value to give to the uniform
  19171. * @return the material itself allowing "fluent" like uniform updates
  19172. */
  19173. setColor3(name: string, value: Color3): ShaderMaterial;
  19174. /**
  19175. * Set a vec3 array in the shader from a Color3 array.
  19176. * @param name Define the name of the uniform as defined in the shader
  19177. * @param value Define the value to give to the uniform
  19178. * @return the material itself allowing "fluent" like uniform updates
  19179. */
  19180. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19181. /**
  19182. * Set a vec4 in the shader from a Color4.
  19183. * @param name Define the name of the uniform as defined in the shader
  19184. * @param value Define the value to give to the uniform
  19185. * @return the material itself allowing "fluent" like uniform updates
  19186. */
  19187. setColor4(name: string, value: Color4): ShaderMaterial;
  19188. /**
  19189. * Set a vec4 array in the shader from a Color4 array.
  19190. * @param name Define the name of the uniform as defined in the shader
  19191. * @param value Define the value to give to the uniform
  19192. * @return the material itself allowing "fluent" like uniform updates
  19193. */
  19194. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19195. /**
  19196. * Set a vec2 in the shader from a Vector2.
  19197. * @param name Define the name of the uniform as defined in the shader
  19198. * @param value Define the value to give to the uniform
  19199. * @return the material itself allowing "fluent" like uniform updates
  19200. */
  19201. setVector2(name: string, value: Vector2): ShaderMaterial;
  19202. /**
  19203. * Set a vec3 in the shader from a Vector3.
  19204. * @param name Define the name of the uniform as defined in the shader
  19205. * @param value Define the value to give to the uniform
  19206. * @return the material itself allowing "fluent" like uniform updates
  19207. */
  19208. setVector3(name: string, value: Vector3): ShaderMaterial;
  19209. /**
  19210. * Set a vec4 in the shader from a Vector4.
  19211. * @param name Define the name of the uniform as defined in the shader
  19212. * @param value Define the value to give to the uniform
  19213. * @return the material itself allowing "fluent" like uniform updates
  19214. */
  19215. setVector4(name: string, value: Vector4): ShaderMaterial;
  19216. /**
  19217. * Set a mat4 in the shader from a Matrix.
  19218. * @param name Define the name of the uniform as defined in the shader
  19219. * @param value Define the value to give to the uniform
  19220. * @return the material itself allowing "fluent" like uniform updates
  19221. */
  19222. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19223. /**
  19224. * Set a mat3 in the shader from a Float32Array.
  19225. * @param name Define the name of the uniform as defined in the shader
  19226. * @param value Define the value to give to the uniform
  19227. * @return the material itself allowing "fluent" like uniform updates
  19228. */
  19229. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19230. /**
  19231. * Set a mat2 in the shader from a Float32Array.
  19232. * @param name Define the name of the uniform as defined in the shader
  19233. * @param value Define the value to give to the uniform
  19234. * @return the material itself allowing "fluent" like uniform updates
  19235. */
  19236. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19237. /**
  19238. * Set a vec2 array in the shader from a number array.
  19239. * @param name Define the name of the uniform as defined in the shader
  19240. * @param value Define the value to give to the uniform
  19241. * @return the material itself allowing "fluent" like uniform updates
  19242. */
  19243. setArray2(name: string, value: number[]): ShaderMaterial;
  19244. /**
  19245. * Set a vec3 array in the shader from a number array.
  19246. * @param name Define the name of the uniform as defined in the shader
  19247. * @param value Define the value to give to the uniform
  19248. * @return the material itself allowing "fluent" like uniform updates
  19249. */
  19250. setArray3(name: string, value: number[]): ShaderMaterial;
  19251. /**
  19252. * Set a vec4 array in the shader from a number array.
  19253. * @param name Define the name of the uniform as defined in the shader
  19254. * @param value Define the value to give to the uniform
  19255. * @return the material itself allowing "fluent" like uniform updates
  19256. */
  19257. setArray4(name: string, value: number[]): ShaderMaterial;
  19258. private _checkCache;
  19259. /**
  19260. * Specifies that the submesh is ready to be used
  19261. * @param mesh defines the mesh to check
  19262. * @param subMesh defines which submesh to check
  19263. * @param useInstances specifies that instances should be used
  19264. * @returns a boolean indicating that the submesh is ready or not
  19265. */
  19266. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19267. /**
  19268. * Checks if the material is ready to render the requested mesh
  19269. * @param mesh Define the mesh to render
  19270. * @param useInstances Define whether or not the material is used with instances
  19271. * @returns true if ready, otherwise false
  19272. */
  19273. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19274. /**
  19275. * Binds the world matrix to the material
  19276. * @param world defines the world transformation matrix
  19277. */
  19278. bindOnlyWorldMatrix(world: Matrix): void;
  19279. /**
  19280. * Binds the material to the mesh
  19281. * @param world defines the world transformation matrix
  19282. * @param mesh defines the mesh to bind the material to
  19283. */
  19284. bind(world: Matrix, mesh?: Mesh): void;
  19285. /**
  19286. * Gets the active textures from the material
  19287. * @returns an array of textures
  19288. */
  19289. getActiveTextures(): BaseTexture[];
  19290. /**
  19291. * Specifies if the material uses a texture
  19292. * @param texture defines the texture to check against the material
  19293. * @returns a boolean specifying if the material uses the texture
  19294. */
  19295. hasTexture(texture: BaseTexture): boolean;
  19296. /**
  19297. * Makes a duplicate of the material, and gives it a new name
  19298. * @param name defines the new name for the duplicated material
  19299. * @returns the cloned material
  19300. */
  19301. clone(name: string): ShaderMaterial;
  19302. /**
  19303. * Disposes the material
  19304. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19305. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19306. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19307. */
  19308. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19309. /**
  19310. * Serializes this material in a JSON representation
  19311. * @returns the serialized material object
  19312. */
  19313. serialize(): any;
  19314. /**
  19315. * Creates a shader material from parsed shader material data
  19316. * @param source defines the JSON represnetation of the material
  19317. * @param scene defines the hosting scene
  19318. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19319. * @returns a new material
  19320. */
  19321. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19322. }
  19323. }
  19324. declare module BABYLON {
  19325. /** @hidden */
  19326. export var colorPixelShader: {
  19327. name: string;
  19328. shader: string;
  19329. };
  19330. }
  19331. declare module BABYLON {
  19332. /** @hidden */
  19333. export var colorVertexShader: {
  19334. name: string;
  19335. shader: string;
  19336. };
  19337. }
  19338. declare module BABYLON {
  19339. /**
  19340. * Line mesh
  19341. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19342. */
  19343. export class LinesMesh extends Mesh {
  19344. /**
  19345. * If vertex color should be applied to the mesh
  19346. */
  19347. readonly useVertexColor?: boolean | undefined;
  19348. /**
  19349. * If vertex alpha should be applied to the mesh
  19350. */
  19351. readonly useVertexAlpha?: boolean | undefined;
  19352. /**
  19353. * Color of the line (Default: White)
  19354. */
  19355. color: Color3;
  19356. /**
  19357. * Alpha of the line (Default: 1)
  19358. */
  19359. alpha: number;
  19360. /**
  19361. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19362. * This margin is expressed in world space coordinates, so its value may vary.
  19363. * Default value is 0.1
  19364. */
  19365. intersectionThreshold: number;
  19366. private _colorShader;
  19367. private color4;
  19368. /**
  19369. * Creates a new LinesMesh
  19370. * @param name defines the name
  19371. * @param scene defines the hosting scene
  19372. * @param parent defines the parent mesh if any
  19373. * @param source defines the optional source LinesMesh used to clone data from
  19374. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19375. * When false, achieved by calling a clone(), also passing False.
  19376. * This will make creation of children, recursive.
  19377. * @param useVertexColor defines if this LinesMesh supports vertex color
  19378. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19379. */
  19380. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19381. /**
  19382. * If vertex color should be applied to the mesh
  19383. */
  19384. useVertexColor?: boolean | undefined,
  19385. /**
  19386. * If vertex alpha should be applied to the mesh
  19387. */
  19388. useVertexAlpha?: boolean | undefined);
  19389. private _addClipPlaneDefine;
  19390. private _removeClipPlaneDefine;
  19391. isReady(): boolean;
  19392. /**
  19393. * Returns the string "LineMesh"
  19394. */
  19395. getClassName(): string;
  19396. /**
  19397. * @hidden
  19398. */
  19399. /**
  19400. * @hidden
  19401. */
  19402. material: Material;
  19403. /**
  19404. * @hidden
  19405. */
  19406. readonly checkCollisions: boolean;
  19407. /** @hidden */
  19408. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19409. /** @hidden */
  19410. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19411. /**
  19412. * Disposes of the line mesh
  19413. * @param doNotRecurse If children should be disposed
  19414. */
  19415. dispose(doNotRecurse?: boolean): void;
  19416. /**
  19417. * Returns a new LineMesh object cloned from the current one.
  19418. */
  19419. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19420. /**
  19421. * Creates a new InstancedLinesMesh object from the mesh model.
  19422. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19423. * @param name defines the name of the new instance
  19424. * @returns a new InstancedLinesMesh
  19425. */
  19426. createInstance(name: string): InstancedLinesMesh;
  19427. }
  19428. /**
  19429. * Creates an instance based on a source LinesMesh
  19430. */
  19431. export class InstancedLinesMesh extends InstancedMesh {
  19432. /**
  19433. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19434. * This margin is expressed in world space coordinates, so its value may vary.
  19435. * Initilized with the intersectionThreshold value of the source LinesMesh
  19436. */
  19437. intersectionThreshold: number;
  19438. constructor(name: string, source: LinesMesh);
  19439. /**
  19440. * Returns the string "InstancedLinesMesh".
  19441. */
  19442. getClassName(): string;
  19443. }
  19444. }
  19445. declare module BABYLON {
  19446. /** @hidden */
  19447. export var linePixelShader: {
  19448. name: string;
  19449. shader: string;
  19450. };
  19451. }
  19452. declare module BABYLON {
  19453. /** @hidden */
  19454. export var lineVertexShader: {
  19455. name: string;
  19456. shader: string;
  19457. };
  19458. }
  19459. declare module BABYLON {
  19460. interface AbstractMesh {
  19461. /**
  19462. * Gets the edgesRenderer associated with the mesh
  19463. */
  19464. edgesRenderer: Nullable<EdgesRenderer>;
  19465. }
  19466. interface LinesMesh {
  19467. /**
  19468. * Enables the edge rendering mode on the mesh.
  19469. * This mode makes the mesh edges visible
  19470. * @param epsilon defines the maximal distance between two angles to detect a face
  19471. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19472. * @returns the currentAbstractMesh
  19473. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19474. */
  19475. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19476. }
  19477. interface InstancedLinesMesh {
  19478. /**
  19479. * Enables the edge rendering mode on the mesh.
  19480. * This mode makes the mesh edges visible
  19481. * @param epsilon defines the maximal distance between two angles to detect a face
  19482. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19483. * @returns the current InstancedLinesMesh
  19484. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19485. */
  19486. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19487. }
  19488. /**
  19489. * Defines the minimum contract an Edges renderer should follow.
  19490. */
  19491. export interface IEdgesRenderer extends IDisposable {
  19492. /**
  19493. * Gets or sets a boolean indicating if the edgesRenderer is active
  19494. */
  19495. isEnabled: boolean;
  19496. /**
  19497. * Renders the edges of the attached mesh,
  19498. */
  19499. render(): void;
  19500. /**
  19501. * Checks wether or not the edges renderer is ready to render.
  19502. * @return true if ready, otherwise false.
  19503. */
  19504. isReady(): boolean;
  19505. }
  19506. /**
  19507. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19508. */
  19509. export class EdgesRenderer implements IEdgesRenderer {
  19510. /**
  19511. * Define the size of the edges with an orthographic camera
  19512. */
  19513. edgesWidthScalerForOrthographic: number;
  19514. /**
  19515. * Define the size of the edges with a perspective camera
  19516. */
  19517. edgesWidthScalerForPerspective: number;
  19518. protected _source: AbstractMesh;
  19519. protected _linesPositions: number[];
  19520. protected _linesNormals: number[];
  19521. protected _linesIndices: number[];
  19522. protected _epsilon: number;
  19523. protected _indicesCount: number;
  19524. protected _lineShader: ShaderMaterial;
  19525. protected _ib: DataBuffer;
  19526. protected _buffers: {
  19527. [key: string]: Nullable<VertexBuffer>;
  19528. };
  19529. protected _checkVerticesInsteadOfIndices: boolean;
  19530. private _meshRebuildObserver;
  19531. private _meshDisposeObserver;
  19532. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19533. isEnabled: boolean;
  19534. /**
  19535. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19536. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19537. * @param source Mesh used to create edges
  19538. * @param epsilon sum of angles in adjacency to check for edge
  19539. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19540. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19541. */
  19542. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19543. protected _prepareRessources(): void;
  19544. /** @hidden */
  19545. _rebuild(): void;
  19546. /**
  19547. * Releases the required resources for the edges renderer
  19548. */
  19549. dispose(): void;
  19550. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19551. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19552. /**
  19553. * Checks if the pair of p0 and p1 is en edge
  19554. * @param faceIndex
  19555. * @param edge
  19556. * @param faceNormals
  19557. * @param p0
  19558. * @param p1
  19559. * @private
  19560. */
  19561. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19562. /**
  19563. * push line into the position, normal and index buffer
  19564. * @protected
  19565. */
  19566. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19567. /**
  19568. * Generates lines edges from adjacencjes
  19569. * @private
  19570. */
  19571. _generateEdgesLines(): void;
  19572. /**
  19573. * Checks wether or not the edges renderer is ready to render.
  19574. * @return true if ready, otherwise false.
  19575. */
  19576. isReady(): boolean;
  19577. /**
  19578. * Renders the edges of the attached mesh,
  19579. */
  19580. render(): void;
  19581. }
  19582. /**
  19583. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19584. */
  19585. export class LineEdgesRenderer extends EdgesRenderer {
  19586. /**
  19587. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19588. * @param source LineMesh used to generate edges
  19589. * @param epsilon not important (specified angle for edge detection)
  19590. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19591. */
  19592. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19593. /**
  19594. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19595. */
  19596. _generateEdgesLines(): void;
  19597. }
  19598. }
  19599. declare module BABYLON {
  19600. /**
  19601. * This represents the object necessary to create a rendering group.
  19602. * This is exclusively used and created by the rendering manager.
  19603. * To modify the behavior, you use the available helpers in your scene or meshes.
  19604. * @hidden
  19605. */
  19606. export class RenderingGroup {
  19607. index: number;
  19608. private static _zeroVector;
  19609. private _scene;
  19610. private _opaqueSubMeshes;
  19611. private _transparentSubMeshes;
  19612. private _alphaTestSubMeshes;
  19613. private _depthOnlySubMeshes;
  19614. private _particleSystems;
  19615. private _spriteManagers;
  19616. private _opaqueSortCompareFn;
  19617. private _alphaTestSortCompareFn;
  19618. private _transparentSortCompareFn;
  19619. private _renderOpaque;
  19620. private _renderAlphaTest;
  19621. private _renderTransparent;
  19622. /** @hidden */
  19623. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19624. onBeforeTransparentRendering: () => void;
  19625. /**
  19626. * Set the opaque sort comparison function.
  19627. * If null the sub meshes will be render in the order they were created
  19628. */
  19629. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19630. /**
  19631. * Set the alpha test sort comparison function.
  19632. * If null the sub meshes will be render in the order they were created
  19633. */
  19634. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19635. /**
  19636. * Set the transparent sort comparison function.
  19637. * If null the sub meshes will be render in the order they were created
  19638. */
  19639. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19640. /**
  19641. * Creates a new rendering group.
  19642. * @param index The rendering group index
  19643. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19644. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19645. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19646. */
  19647. 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>);
  19648. /**
  19649. * Render all the sub meshes contained in the group.
  19650. * @param customRenderFunction Used to override the default render behaviour of the group.
  19651. * @returns true if rendered some submeshes.
  19652. */
  19653. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19654. /**
  19655. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19656. * @param subMeshes The submeshes to render
  19657. */
  19658. private renderOpaqueSorted;
  19659. /**
  19660. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19661. * @param subMeshes The submeshes to render
  19662. */
  19663. private renderAlphaTestSorted;
  19664. /**
  19665. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19666. * @param subMeshes The submeshes to render
  19667. */
  19668. private renderTransparentSorted;
  19669. /**
  19670. * Renders the submeshes in a specified order.
  19671. * @param subMeshes The submeshes to sort before render
  19672. * @param sortCompareFn The comparison function use to sort
  19673. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19674. * @param transparent Specifies to activate blending if true
  19675. */
  19676. private static renderSorted;
  19677. /**
  19678. * Renders the submeshes in the order they were dispatched (no sort applied).
  19679. * @param subMeshes The submeshes to render
  19680. */
  19681. private static renderUnsorted;
  19682. /**
  19683. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19684. * are rendered back to front if in the same alpha index.
  19685. *
  19686. * @param a The first submesh
  19687. * @param b The second submesh
  19688. * @returns The result of the comparison
  19689. */
  19690. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19691. /**
  19692. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19693. * are rendered back to front.
  19694. *
  19695. * @param a The first submesh
  19696. * @param b The second submesh
  19697. * @returns The result of the comparison
  19698. */
  19699. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19700. /**
  19701. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19702. * are rendered front to back (prevent overdraw).
  19703. *
  19704. * @param a The first submesh
  19705. * @param b The second submesh
  19706. * @returns The result of the comparison
  19707. */
  19708. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19709. /**
  19710. * Resets the different lists of submeshes to prepare a new frame.
  19711. */
  19712. prepare(): void;
  19713. dispose(): void;
  19714. /**
  19715. * Inserts the submesh in its correct queue depending on its material.
  19716. * @param subMesh The submesh to dispatch
  19717. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19718. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19719. */
  19720. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19721. dispatchSprites(spriteManager: ISpriteManager): void;
  19722. dispatchParticles(particleSystem: IParticleSystem): void;
  19723. private _renderParticles;
  19724. private _renderSprites;
  19725. }
  19726. }
  19727. declare module BABYLON {
  19728. /**
  19729. * Interface describing the different options available in the rendering manager
  19730. * regarding Auto Clear between groups.
  19731. */
  19732. export interface IRenderingManagerAutoClearSetup {
  19733. /**
  19734. * Defines whether or not autoclear is enable.
  19735. */
  19736. autoClear: boolean;
  19737. /**
  19738. * Defines whether or not to autoclear the depth buffer.
  19739. */
  19740. depth: boolean;
  19741. /**
  19742. * Defines whether or not to autoclear the stencil buffer.
  19743. */
  19744. stencil: boolean;
  19745. }
  19746. /**
  19747. * This class is used by the onRenderingGroupObservable
  19748. */
  19749. export class RenderingGroupInfo {
  19750. /**
  19751. * The Scene that being rendered
  19752. */
  19753. scene: Scene;
  19754. /**
  19755. * The camera currently used for the rendering pass
  19756. */
  19757. camera: Nullable<Camera>;
  19758. /**
  19759. * The ID of the renderingGroup being processed
  19760. */
  19761. renderingGroupId: number;
  19762. }
  19763. /**
  19764. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19765. * It is enable to manage the different groups as well as the different necessary sort functions.
  19766. * This should not be used directly aside of the few static configurations
  19767. */
  19768. export class RenderingManager {
  19769. /**
  19770. * The max id used for rendering groups (not included)
  19771. */
  19772. static MAX_RENDERINGGROUPS: number;
  19773. /**
  19774. * The min id used for rendering groups (included)
  19775. */
  19776. static MIN_RENDERINGGROUPS: number;
  19777. /**
  19778. * Used to globally prevent autoclearing scenes.
  19779. */
  19780. static AUTOCLEAR: boolean;
  19781. /**
  19782. * @hidden
  19783. */
  19784. _useSceneAutoClearSetup: boolean;
  19785. private _scene;
  19786. private _renderingGroups;
  19787. private _depthStencilBufferAlreadyCleaned;
  19788. private _autoClearDepthStencil;
  19789. private _customOpaqueSortCompareFn;
  19790. private _customAlphaTestSortCompareFn;
  19791. private _customTransparentSortCompareFn;
  19792. private _renderingGroupInfo;
  19793. /**
  19794. * Instantiates a new rendering group for a particular scene
  19795. * @param scene Defines the scene the groups belongs to
  19796. */
  19797. constructor(scene: Scene);
  19798. private _clearDepthStencilBuffer;
  19799. /**
  19800. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19801. * @hidden
  19802. */
  19803. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19804. /**
  19805. * Resets the different information of the group to prepare a new frame
  19806. * @hidden
  19807. */
  19808. reset(): void;
  19809. /**
  19810. * Dispose and release the group and its associated resources.
  19811. * @hidden
  19812. */
  19813. dispose(): void;
  19814. /**
  19815. * Clear the info related to rendering groups preventing retention points during dispose.
  19816. */
  19817. freeRenderingGroups(): void;
  19818. private _prepareRenderingGroup;
  19819. /**
  19820. * Add a sprite manager to the rendering manager in order to render it this frame.
  19821. * @param spriteManager Define the sprite manager to render
  19822. */
  19823. dispatchSprites(spriteManager: ISpriteManager): void;
  19824. /**
  19825. * Add a particle system to the rendering manager in order to render it this frame.
  19826. * @param particleSystem Define the particle system to render
  19827. */
  19828. dispatchParticles(particleSystem: IParticleSystem): void;
  19829. /**
  19830. * Add a submesh to the manager in order to render it this frame
  19831. * @param subMesh The submesh to dispatch
  19832. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19833. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19834. */
  19835. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19836. /**
  19837. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19838. * This allowed control for front to back rendering or reversly depending of the special needs.
  19839. *
  19840. * @param renderingGroupId The rendering group id corresponding to its index
  19841. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19842. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19843. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19844. */
  19845. 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;
  19846. /**
  19847. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19848. *
  19849. * @param renderingGroupId The rendering group id corresponding to its index
  19850. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19851. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19852. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19853. */
  19854. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19855. /**
  19856. * Gets the current auto clear configuration for one rendering group of the rendering
  19857. * manager.
  19858. * @param index the rendering group index to get the information for
  19859. * @returns The auto clear setup for the requested rendering group
  19860. */
  19861. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19862. }
  19863. }
  19864. declare module BABYLON {
  19865. /**
  19866. * This Helps creating a texture that will be created from a camera in your scene.
  19867. * It is basically a dynamic texture that could be used to create special effects for instance.
  19868. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19869. */
  19870. export class RenderTargetTexture extends Texture {
  19871. isCube: boolean;
  19872. /**
  19873. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19874. */
  19875. static readonly REFRESHRATE_RENDER_ONCE: number;
  19876. /**
  19877. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19878. */
  19879. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19880. /**
  19881. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19882. * the central point of your effect and can save a lot of performances.
  19883. */
  19884. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19885. /**
  19886. * Use this predicate to dynamically define the list of mesh you want to render.
  19887. * If set, the renderList property will be overwritten.
  19888. */
  19889. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19890. private _renderList;
  19891. /**
  19892. * Use this list to define the list of mesh you want to render.
  19893. */
  19894. renderList: Nullable<Array<AbstractMesh>>;
  19895. private _hookArray;
  19896. /**
  19897. * Define if particles should be rendered in your texture.
  19898. */
  19899. renderParticles: boolean;
  19900. /**
  19901. * Define if sprites should be rendered in your texture.
  19902. */
  19903. renderSprites: boolean;
  19904. /**
  19905. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19906. */
  19907. coordinatesMode: number;
  19908. /**
  19909. * Define the camera used to render the texture.
  19910. */
  19911. activeCamera: Nullable<Camera>;
  19912. /**
  19913. * Override the render function of the texture with your own one.
  19914. */
  19915. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19916. /**
  19917. * Define if camera post processes should be use while rendering the texture.
  19918. */
  19919. useCameraPostProcesses: boolean;
  19920. /**
  19921. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19922. */
  19923. ignoreCameraViewport: boolean;
  19924. private _postProcessManager;
  19925. private _postProcesses;
  19926. private _resizeObserver;
  19927. /**
  19928. * An event triggered when the texture is unbind.
  19929. */
  19930. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19931. /**
  19932. * An event triggered when the texture is unbind.
  19933. */
  19934. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19935. private _onAfterUnbindObserver;
  19936. /**
  19937. * Set a after unbind callback in the texture.
  19938. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19939. */
  19940. onAfterUnbind: () => void;
  19941. /**
  19942. * An event triggered before rendering the texture
  19943. */
  19944. onBeforeRenderObservable: Observable<number>;
  19945. private _onBeforeRenderObserver;
  19946. /**
  19947. * Set a before render callback in the texture.
  19948. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19949. */
  19950. onBeforeRender: (faceIndex: number) => void;
  19951. /**
  19952. * An event triggered after rendering the texture
  19953. */
  19954. onAfterRenderObservable: Observable<number>;
  19955. private _onAfterRenderObserver;
  19956. /**
  19957. * Set a after render callback in the texture.
  19958. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19959. */
  19960. onAfterRender: (faceIndex: number) => void;
  19961. /**
  19962. * An event triggered after the texture clear
  19963. */
  19964. onClearObservable: Observable<Engine>;
  19965. private _onClearObserver;
  19966. /**
  19967. * Set a clear callback in the texture.
  19968. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19969. */
  19970. onClear: (Engine: Engine) => void;
  19971. /**
  19972. * An event triggered when the texture is resized.
  19973. */
  19974. onResizeObservable: Observable<RenderTargetTexture>;
  19975. /**
  19976. * Define the clear color of the Render Target if it should be different from the scene.
  19977. */
  19978. clearColor: Color4;
  19979. protected _size: number | {
  19980. width: number;
  19981. height: number;
  19982. };
  19983. protected _initialSizeParameter: number | {
  19984. width: number;
  19985. height: number;
  19986. } | {
  19987. ratio: number;
  19988. };
  19989. protected _sizeRatio: Nullable<number>;
  19990. /** @hidden */
  19991. _generateMipMaps: boolean;
  19992. protected _renderingManager: RenderingManager;
  19993. /** @hidden */
  19994. _waitingRenderList: string[];
  19995. protected _doNotChangeAspectRatio: boolean;
  19996. protected _currentRefreshId: number;
  19997. protected _refreshRate: number;
  19998. protected _textureMatrix: Matrix;
  19999. protected _samples: number;
  20000. protected _renderTargetOptions: RenderTargetCreationOptions;
  20001. /**
  20002. * Gets render target creation options that were used.
  20003. */
  20004. readonly renderTargetOptions: RenderTargetCreationOptions;
  20005. protected _engine: Engine;
  20006. protected _onRatioRescale(): void;
  20007. /**
  20008. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20009. * It must define where the camera used to render the texture is set
  20010. */
  20011. boundingBoxPosition: Vector3;
  20012. private _boundingBoxSize;
  20013. /**
  20014. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20015. * When defined, the cubemap will switch to local mode
  20016. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20017. * @example https://www.babylonjs-playground.com/#RNASML
  20018. */
  20019. boundingBoxSize: Vector3;
  20020. /**
  20021. * In case the RTT has been created with a depth texture, get the associated
  20022. * depth texture.
  20023. * Otherwise, return null.
  20024. */
  20025. depthStencilTexture: Nullable<InternalTexture>;
  20026. /**
  20027. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20028. * or used a shadow, depth texture...
  20029. * @param name The friendly name of the texture
  20030. * @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)
  20031. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20032. * @param generateMipMaps True if mip maps need to be generated after render.
  20033. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20034. * @param type The type of the buffer in the RTT (int, half float, float...)
  20035. * @param isCube True if a cube texture needs to be created
  20036. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20037. * @param generateDepthBuffer True to generate a depth buffer
  20038. * @param generateStencilBuffer True to generate a stencil buffer
  20039. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20040. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20041. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20042. */
  20043. constructor(name: string, size: number | {
  20044. width: number;
  20045. height: number;
  20046. } | {
  20047. ratio: number;
  20048. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20049. /**
  20050. * Creates a depth stencil texture.
  20051. * This is only available in WebGL 2 or with the depth texture extension available.
  20052. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20053. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20054. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20055. */
  20056. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20057. private _processSizeParameter;
  20058. /**
  20059. * Define the number of samples to use in case of MSAA.
  20060. * It defaults to one meaning no MSAA has been enabled.
  20061. */
  20062. samples: number;
  20063. /**
  20064. * Resets the refresh counter of the texture and start bak from scratch.
  20065. * Could be useful to regenerate the texture if it is setup to render only once.
  20066. */
  20067. resetRefreshCounter(): void;
  20068. /**
  20069. * Define the refresh rate of the texture or the rendering frequency.
  20070. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20071. */
  20072. refreshRate: number;
  20073. /**
  20074. * Adds a post process to the render target rendering passes.
  20075. * @param postProcess define the post process to add
  20076. */
  20077. addPostProcess(postProcess: PostProcess): void;
  20078. /**
  20079. * Clear all the post processes attached to the render target
  20080. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20081. */
  20082. clearPostProcesses(dispose?: boolean): void;
  20083. /**
  20084. * Remove one of the post process from the list of attached post processes to the texture
  20085. * @param postProcess define the post process to remove from the list
  20086. */
  20087. removePostProcess(postProcess: PostProcess): void;
  20088. /** @hidden */
  20089. _shouldRender(): boolean;
  20090. /**
  20091. * Gets the actual render size of the texture.
  20092. * @returns the width of the render size
  20093. */
  20094. getRenderSize(): number;
  20095. /**
  20096. * Gets the actual render width of the texture.
  20097. * @returns the width of the render size
  20098. */
  20099. getRenderWidth(): number;
  20100. /**
  20101. * Gets the actual render height of the texture.
  20102. * @returns the height of the render size
  20103. */
  20104. getRenderHeight(): number;
  20105. /**
  20106. * Get if the texture can be rescaled or not.
  20107. */
  20108. readonly canRescale: boolean;
  20109. /**
  20110. * Resize the texture using a ratio.
  20111. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20112. */
  20113. scale(ratio: number): void;
  20114. /**
  20115. * Get the texture reflection matrix used to rotate/transform the reflection.
  20116. * @returns the reflection matrix
  20117. */
  20118. getReflectionTextureMatrix(): Matrix;
  20119. /**
  20120. * Resize the texture to a new desired size.
  20121. * Be carrefull as it will recreate all the data in the new texture.
  20122. * @param size Define the new size. It can be:
  20123. * - a number for squared texture,
  20124. * - an object containing { width: number, height: number }
  20125. * - or an object containing a ratio { ratio: number }
  20126. */
  20127. resize(size: number | {
  20128. width: number;
  20129. height: number;
  20130. } | {
  20131. ratio: number;
  20132. }): void;
  20133. /**
  20134. * Renders all the objects from the render list into the texture.
  20135. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20136. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20137. */
  20138. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20139. private _bestReflectionRenderTargetDimension;
  20140. /**
  20141. * @hidden
  20142. * @param faceIndex face index to bind to if this is a cubetexture
  20143. */
  20144. _bindFrameBuffer(faceIndex?: number): void;
  20145. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20146. private renderToTarget;
  20147. /**
  20148. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20149. * This allowed control for front to back rendering or reversly depending of the special needs.
  20150. *
  20151. * @param renderingGroupId The rendering group id corresponding to its index
  20152. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20153. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20154. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20155. */
  20156. 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;
  20157. /**
  20158. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20159. *
  20160. * @param renderingGroupId The rendering group id corresponding to its index
  20161. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20162. */
  20163. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20164. /**
  20165. * Clones the texture.
  20166. * @returns the cloned texture
  20167. */
  20168. clone(): RenderTargetTexture;
  20169. /**
  20170. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20171. * @returns The JSON representation of the texture
  20172. */
  20173. serialize(): any;
  20174. /**
  20175. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20176. */
  20177. disposeFramebufferObjects(): void;
  20178. /**
  20179. * Dispose the texture and release its associated resources.
  20180. */
  20181. dispose(): void;
  20182. /** @hidden */
  20183. _rebuild(): void;
  20184. /**
  20185. * Clear the info related to rendering groups preventing retention point in material dispose.
  20186. */
  20187. freeRenderingGroups(): void;
  20188. /**
  20189. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20190. * @returns the view count
  20191. */
  20192. getViewCount(): number;
  20193. }
  20194. }
  20195. declare module BABYLON {
  20196. /**
  20197. * Base class for the main features of a material in Babylon.js
  20198. */
  20199. export class Material implements IAnimatable {
  20200. /**
  20201. * Returns the triangle fill mode
  20202. */
  20203. static readonly TriangleFillMode: number;
  20204. /**
  20205. * Returns the wireframe mode
  20206. */
  20207. static readonly WireFrameFillMode: number;
  20208. /**
  20209. * Returns the point fill mode
  20210. */
  20211. static readonly PointFillMode: number;
  20212. /**
  20213. * Returns the point list draw mode
  20214. */
  20215. static readonly PointListDrawMode: number;
  20216. /**
  20217. * Returns the line list draw mode
  20218. */
  20219. static readonly LineListDrawMode: number;
  20220. /**
  20221. * Returns the line loop draw mode
  20222. */
  20223. static readonly LineLoopDrawMode: number;
  20224. /**
  20225. * Returns the line strip draw mode
  20226. */
  20227. static readonly LineStripDrawMode: number;
  20228. /**
  20229. * Returns the triangle strip draw mode
  20230. */
  20231. static readonly TriangleStripDrawMode: number;
  20232. /**
  20233. * Returns the triangle fan draw mode
  20234. */
  20235. static readonly TriangleFanDrawMode: number;
  20236. /**
  20237. * Stores the clock-wise side orientation
  20238. */
  20239. static readonly ClockWiseSideOrientation: number;
  20240. /**
  20241. * Stores the counter clock-wise side orientation
  20242. */
  20243. static readonly CounterClockWiseSideOrientation: number;
  20244. /**
  20245. * The dirty texture flag value
  20246. */
  20247. static readonly TextureDirtyFlag: number;
  20248. /**
  20249. * The dirty light flag value
  20250. */
  20251. static readonly LightDirtyFlag: number;
  20252. /**
  20253. * The dirty fresnel flag value
  20254. */
  20255. static readonly FresnelDirtyFlag: number;
  20256. /**
  20257. * The dirty attribute flag value
  20258. */
  20259. static readonly AttributesDirtyFlag: number;
  20260. /**
  20261. * The dirty misc flag value
  20262. */
  20263. static readonly MiscDirtyFlag: number;
  20264. /**
  20265. * The all dirty flag value
  20266. */
  20267. static readonly AllDirtyFlag: number;
  20268. /**
  20269. * The ID of the material
  20270. */
  20271. id: string;
  20272. /**
  20273. * Gets or sets the unique id of the material
  20274. */
  20275. uniqueId: number;
  20276. /**
  20277. * The name of the material
  20278. */
  20279. name: string;
  20280. /**
  20281. * Gets or sets user defined metadata
  20282. */
  20283. metadata: any;
  20284. /**
  20285. * For internal use only. Please do not use.
  20286. */
  20287. reservedDataStore: any;
  20288. /**
  20289. * Specifies if the ready state should be checked on each call
  20290. */
  20291. checkReadyOnEveryCall: boolean;
  20292. /**
  20293. * Specifies if the ready state should be checked once
  20294. */
  20295. checkReadyOnlyOnce: boolean;
  20296. /**
  20297. * The state of the material
  20298. */
  20299. state: string;
  20300. /**
  20301. * The alpha value of the material
  20302. */
  20303. protected _alpha: number;
  20304. /**
  20305. * List of inspectable custom properties (used by the Inspector)
  20306. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20307. */
  20308. inspectableCustomProperties: IInspectable[];
  20309. /**
  20310. * Sets the alpha value of the material
  20311. */
  20312. /**
  20313. * Gets the alpha value of the material
  20314. */
  20315. alpha: number;
  20316. /**
  20317. * Specifies if back face culling is enabled
  20318. */
  20319. protected _backFaceCulling: boolean;
  20320. /**
  20321. * Sets the back-face culling state
  20322. */
  20323. /**
  20324. * Gets the back-face culling state
  20325. */
  20326. backFaceCulling: boolean;
  20327. /**
  20328. * Stores the value for side orientation
  20329. */
  20330. sideOrientation: number;
  20331. /**
  20332. * Callback triggered when the material is compiled
  20333. */
  20334. onCompiled: Nullable<(effect: Effect) => void>;
  20335. /**
  20336. * Callback triggered when an error occurs
  20337. */
  20338. onError: Nullable<(effect: Effect, errors: string) => void>;
  20339. /**
  20340. * Callback triggered to get the render target textures
  20341. */
  20342. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20343. /**
  20344. * Gets a boolean indicating that current material needs to register RTT
  20345. */
  20346. readonly hasRenderTargetTextures: boolean;
  20347. /**
  20348. * Specifies if the material should be serialized
  20349. */
  20350. doNotSerialize: boolean;
  20351. /**
  20352. * @hidden
  20353. */
  20354. _storeEffectOnSubMeshes: boolean;
  20355. /**
  20356. * Stores the animations for the material
  20357. */
  20358. animations: Nullable<Array<Animation>>;
  20359. /**
  20360. * An event triggered when the material is disposed
  20361. */
  20362. onDisposeObservable: Observable<Material>;
  20363. /**
  20364. * An observer which watches for dispose events
  20365. */
  20366. private _onDisposeObserver;
  20367. private _onUnBindObservable;
  20368. /**
  20369. * Called during a dispose event
  20370. */
  20371. onDispose: () => void;
  20372. private _onBindObservable;
  20373. /**
  20374. * An event triggered when the material is bound
  20375. */
  20376. readonly onBindObservable: Observable<AbstractMesh>;
  20377. /**
  20378. * An observer which watches for bind events
  20379. */
  20380. private _onBindObserver;
  20381. /**
  20382. * Called during a bind event
  20383. */
  20384. onBind: (Mesh: AbstractMesh) => void;
  20385. /**
  20386. * An event triggered when the material is unbound
  20387. */
  20388. readonly onUnBindObservable: Observable<Material>;
  20389. /**
  20390. * Stores the value of the alpha mode
  20391. */
  20392. private _alphaMode;
  20393. /**
  20394. * Sets the value of the alpha mode.
  20395. *
  20396. * | Value | Type | Description |
  20397. * | --- | --- | --- |
  20398. * | 0 | ALPHA_DISABLE | |
  20399. * | 1 | ALPHA_ADD | |
  20400. * | 2 | ALPHA_COMBINE | |
  20401. * | 3 | ALPHA_SUBTRACT | |
  20402. * | 4 | ALPHA_MULTIPLY | |
  20403. * | 5 | ALPHA_MAXIMIZED | |
  20404. * | 6 | ALPHA_ONEONE | |
  20405. * | 7 | ALPHA_PREMULTIPLIED | |
  20406. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20407. * | 9 | ALPHA_INTERPOLATE | |
  20408. * | 10 | ALPHA_SCREENMODE | |
  20409. *
  20410. */
  20411. /**
  20412. * Gets the value of the alpha mode
  20413. */
  20414. alphaMode: number;
  20415. /**
  20416. * Stores the state of the need depth pre-pass value
  20417. */
  20418. private _needDepthPrePass;
  20419. /**
  20420. * Sets the need depth pre-pass value
  20421. */
  20422. /**
  20423. * Gets the depth pre-pass value
  20424. */
  20425. needDepthPrePass: boolean;
  20426. /**
  20427. * Specifies if depth writing should be disabled
  20428. */
  20429. disableDepthWrite: boolean;
  20430. /**
  20431. * Specifies if depth writing should be forced
  20432. */
  20433. forceDepthWrite: boolean;
  20434. /**
  20435. * Specifies if there should be a separate pass for culling
  20436. */
  20437. separateCullingPass: boolean;
  20438. /**
  20439. * Stores the state specifing if fog should be enabled
  20440. */
  20441. private _fogEnabled;
  20442. /**
  20443. * Sets the state for enabling fog
  20444. */
  20445. /**
  20446. * Gets the value of the fog enabled state
  20447. */
  20448. fogEnabled: boolean;
  20449. /**
  20450. * Stores the size of points
  20451. */
  20452. pointSize: number;
  20453. /**
  20454. * Stores the z offset value
  20455. */
  20456. zOffset: number;
  20457. /**
  20458. * Gets a value specifying if wireframe mode is enabled
  20459. */
  20460. /**
  20461. * Sets the state of wireframe mode
  20462. */
  20463. wireframe: boolean;
  20464. /**
  20465. * Gets the value specifying if point clouds are enabled
  20466. */
  20467. /**
  20468. * Sets the state of point cloud mode
  20469. */
  20470. pointsCloud: boolean;
  20471. /**
  20472. * Gets the material fill mode
  20473. */
  20474. /**
  20475. * Sets the material fill mode
  20476. */
  20477. fillMode: number;
  20478. /**
  20479. * @hidden
  20480. * Stores the effects for the material
  20481. */
  20482. _effect: Nullable<Effect>;
  20483. /**
  20484. * @hidden
  20485. * Specifies if the material was previously ready
  20486. */
  20487. _wasPreviouslyReady: boolean;
  20488. /**
  20489. * Specifies if uniform buffers should be used
  20490. */
  20491. private _useUBO;
  20492. /**
  20493. * Stores a reference to the scene
  20494. */
  20495. private _scene;
  20496. /**
  20497. * Stores the fill mode state
  20498. */
  20499. private _fillMode;
  20500. /**
  20501. * Specifies if the depth write state should be cached
  20502. */
  20503. private _cachedDepthWriteState;
  20504. /**
  20505. * Stores the uniform buffer
  20506. */
  20507. protected _uniformBuffer: UniformBuffer;
  20508. /** @hidden */
  20509. _indexInSceneMaterialArray: number;
  20510. /** @hidden */
  20511. meshMap: Nullable<{
  20512. [id: string]: AbstractMesh | undefined;
  20513. }>;
  20514. /**
  20515. * Creates a material instance
  20516. * @param name defines the name of the material
  20517. * @param scene defines the scene to reference
  20518. * @param doNotAdd specifies if the material should be added to the scene
  20519. */
  20520. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20521. /**
  20522. * Returns a string representation of the current material
  20523. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20524. * @returns a string with material information
  20525. */
  20526. toString(fullDetails?: boolean): string;
  20527. /**
  20528. * Gets the class name of the material
  20529. * @returns a string with the class name of the material
  20530. */
  20531. getClassName(): string;
  20532. /**
  20533. * Specifies if updates for the material been locked
  20534. */
  20535. readonly isFrozen: boolean;
  20536. /**
  20537. * Locks updates for the material
  20538. */
  20539. freeze(): void;
  20540. /**
  20541. * Unlocks updates for the material
  20542. */
  20543. unfreeze(): void;
  20544. /**
  20545. * Specifies if the material is ready to be used
  20546. * @param mesh defines the mesh to check
  20547. * @param useInstances specifies if instances should be used
  20548. * @returns a boolean indicating if the material is ready to be used
  20549. */
  20550. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20551. /**
  20552. * Specifies that the submesh is ready to be used
  20553. * @param mesh defines the mesh to check
  20554. * @param subMesh defines which submesh to check
  20555. * @param useInstances specifies that instances should be used
  20556. * @returns a boolean indicating that the submesh is ready or not
  20557. */
  20558. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20559. /**
  20560. * Returns the material effect
  20561. * @returns the effect associated with the material
  20562. */
  20563. getEffect(): Nullable<Effect>;
  20564. /**
  20565. * Returns the current scene
  20566. * @returns a Scene
  20567. */
  20568. getScene(): Scene;
  20569. /**
  20570. * Specifies if the material will require alpha blending
  20571. * @returns a boolean specifying if alpha blending is needed
  20572. */
  20573. needAlphaBlending(): boolean;
  20574. /**
  20575. * Specifies if the mesh will require alpha blending
  20576. * @param mesh defines the mesh to check
  20577. * @returns a boolean specifying if alpha blending is needed for the mesh
  20578. */
  20579. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20580. /**
  20581. * Specifies if this material should be rendered in alpha test mode
  20582. * @returns a boolean specifying if an alpha test is needed.
  20583. */
  20584. needAlphaTesting(): boolean;
  20585. /**
  20586. * Gets the texture used for the alpha test
  20587. * @returns the texture to use for alpha testing
  20588. */
  20589. getAlphaTestTexture(): Nullable<BaseTexture>;
  20590. /**
  20591. * Marks the material to indicate that it needs to be re-calculated
  20592. */
  20593. markDirty(): void;
  20594. /** @hidden */
  20595. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20596. /**
  20597. * Binds the material to the mesh
  20598. * @param world defines the world transformation matrix
  20599. * @param mesh defines the mesh to bind the material to
  20600. */
  20601. bind(world: Matrix, mesh?: Mesh): void;
  20602. /**
  20603. * Binds the submesh to the material
  20604. * @param world defines the world transformation matrix
  20605. * @param mesh defines the mesh containing the submesh
  20606. * @param subMesh defines the submesh to bind the material to
  20607. */
  20608. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20609. /**
  20610. * Binds the world matrix to the material
  20611. * @param world defines the world transformation matrix
  20612. */
  20613. bindOnlyWorldMatrix(world: Matrix): void;
  20614. /**
  20615. * Binds the scene's uniform buffer to the effect.
  20616. * @param effect defines the effect to bind to the scene uniform buffer
  20617. * @param sceneUbo defines the uniform buffer storing scene data
  20618. */
  20619. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20620. /**
  20621. * Binds the view matrix to the effect
  20622. * @param effect defines the effect to bind the view matrix to
  20623. */
  20624. bindView(effect: Effect): void;
  20625. /**
  20626. * Binds the view projection matrix to the effect
  20627. * @param effect defines the effect to bind the view projection matrix to
  20628. */
  20629. bindViewProjection(effect: Effect): void;
  20630. /**
  20631. * Specifies if material alpha testing should be turned on for the mesh
  20632. * @param mesh defines the mesh to check
  20633. */
  20634. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20635. /**
  20636. * Processes to execute after binding the material to a mesh
  20637. * @param mesh defines the rendered mesh
  20638. */
  20639. protected _afterBind(mesh?: Mesh): void;
  20640. /**
  20641. * Unbinds the material from the mesh
  20642. */
  20643. unbind(): void;
  20644. /**
  20645. * Gets the active textures from the material
  20646. * @returns an array of textures
  20647. */
  20648. getActiveTextures(): BaseTexture[];
  20649. /**
  20650. * Specifies if the material uses a texture
  20651. * @param texture defines the texture to check against the material
  20652. * @returns a boolean specifying if the material uses the texture
  20653. */
  20654. hasTexture(texture: BaseTexture): boolean;
  20655. /**
  20656. * Makes a duplicate of the material, and gives it a new name
  20657. * @param name defines the new name for the duplicated material
  20658. * @returns the cloned material
  20659. */
  20660. clone(name: string): Nullable<Material>;
  20661. /**
  20662. * Gets the meshes bound to the material
  20663. * @returns an array of meshes bound to the material
  20664. */
  20665. getBindedMeshes(): AbstractMesh[];
  20666. /**
  20667. * Force shader compilation
  20668. * @param mesh defines the mesh associated with this material
  20669. * @param onCompiled defines a function to execute once the material is compiled
  20670. * @param options defines the options to configure the compilation
  20671. */
  20672. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20673. clipPlane: boolean;
  20674. }>): void;
  20675. /**
  20676. * Force shader compilation
  20677. * @param mesh defines the mesh that will use this material
  20678. * @param options defines additional options for compiling the shaders
  20679. * @returns a promise that resolves when the compilation completes
  20680. */
  20681. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20682. clipPlane: boolean;
  20683. }>): Promise<void>;
  20684. private static readonly _AllDirtyCallBack;
  20685. private static readonly _ImageProcessingDirtyCallBack;
  20686. private static readonly _TextureDirtyCallBack;
  20687. private static readonly _FresnelDirtyCallBack;
  20688. private static readonly _MiscDirtyCallBack;
  20689. private static readonly _LightsDirtyCallBack;
  20690. private static readonly _AttributeDirtyCallBack;
  20691. private static _FresnelAndMiscDirtyCallBack;
  20692. private static _TextureAndMiscDirtyCallBack;
  20693. private static readonly _DirtyCallbackArray;
  20694. private static readonly _RunDirtyCallBacks;
  20695. /**
  20696. * Marks a define in the material to indicate that it needs to be re-computed
  20697. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20698. */
  20699. markAsDirty(flag: number): void;
  20700. /**
  20701. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20702. * @param func defines a function which checks material defines against the submeshes
  20703. */
  20704. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20705. /**
  20706. * Indicates that we need to re-calculated for all submeshes
  20707. */
  20708. protected _markAllSubMeshesAsAllDirty(): void;
  20709. /**
  20710. * Indicates that image processing needs to be re-calculated for all submeshes
  20711. */
  20712. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20713. /**
  20714. * Indicates that textures need to be re-calculated for all submeshes
  20715. */
  20716. protected _markAllSubMeshesAsTexturesDirty(): void;
  20717. /**
  20718. * Indicates that fresnel needs to be re-calculated for all submeshes
  20719. */
  20720. protected _markAllSubMeshesAsFresnelDirty(): void;
  20721. /**
  20722. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20723. */
  20724. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20725. /**
  20726. * Indicates that lights need to be re-calculated for all submeshes
  20727. */
  20728. protected _markAllSubMeshesAsLightsDirty(): void;
  20729. /**
  20730. * Indicates that attributes need to be re-calculated for all submeshes
  20731. */
  20732. protected _markAllSubMeshesAsAttributesDirty(): void;
  20733. /**
  20734. * Indicates that misc needs to be re-calculated for all submeshes
  20735. */
  20736. protected _markAllSubMeshesAsMiscDirty(): void;
  20737. /**
  20738. * Indicates that textures and misc need to be re-calculated for all submeshes
  20739. */
  20740. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20741. /**
  20742. * Disposes the material
  20743. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20744. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20745. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20746. */
  20747. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20748. /** @hidden */
  20749. private releaseVertexArrayObject;
  20750. /**
  20751. * Serializes this material
  20752. * @returns the serialized material object
  20753. */
  20754. serialize(): any;
  20755. /**
  20756. * Creates a material from parsed material data
  20757. * @param parsedMaterial defines parsed material data
  20758. * @param scene defines the hosting scene
  20759. * @param rootUrl defines the root URL to use to load textures
  20760. * @returns a new material
  20761. */
  20762. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20763. }
  20764. }
  20765. declare module BABYLON {
  20766. /**
  20767. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20768. * separate meshes. This can be use to improve performances.
  20769. * @see http://doc.babylonjs.com/how_to/multi_materials
  20770. */
  20771. export class MultiMaterial extends Material {
  20772. private _subMaterials;
  20773. /**
  20774. * Gets or Sets the list of Materials used within the multi material.
  20775. * They need to be ordered according to the submeshes order in the associated mesh
  20776. */
  20777. subMaterials: Nullable<Material>[];
  20778. /**
  20779. * Function used to align with Node.getChildren()
  20780. * @returns the list of Materials used within the multi material
  20781. */
  20782. getChildren(): Nullable<Material>[];
  20783. /**
  20784. * Instantiates a new Multi Material
  20785. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20786. * separate meshes. This can be use to improve performances.
  20787. * @see http://doc.babylonjs.com/how_to/multi_materials
  20788. * @param name Define the name in the scene
  20789. * @param scene Define the scene the material belongs to
  20790. */
  20791. constructor(name: string, scene: Scene);
  20792. private _hookArray;
  20793. /**
  20794. * Get one of the submaterial by its index in the submaterials array
  20795. * @param index The index to look the sub material at
  20796. * @returns The Material if the index has been defined
  20797. */
  20798. getSubMaterial(index: number): Nullable<Material>;
  20799. /**
  20800. * Get the list of active textures for the whole sub materials list.
  20801. * @returns All the textures that will be used during the rendering
  20802. */
  20803. getActiveTextures(): BaseTexture[];
  20804. /**
  20805. * Gets the current class name of the material e.g. "MultiMaterial"
  20806. * Mainly use in serialization.
  20807. * @returns the class name
  20808. */
  20809. getClassName(): string;
  20810. /**
  20811. * Checks if the material is ready to render the requested sub mesh
  20812. * @param mesh Define the mesh the submesh belongs to
  20813. * @param subMesh Define the sub mesh to look readyness for
  20814. * @param useInstances Define whether or not the material is used with instances
  20815. * @returns true if ready, otherwise false
  20816. */
  20817. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20818. /**
  20819. * Clones the current material and its related sub materials
  20820. * @param name Define the name of the newly cloned material
  20821. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20822. * @returns the cloned material
  20823. */
  20824. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20825. /**
  20826. * Serializes the materials into a JSON representation.
  20827. * @returns the JSON representation
  20828. */
  20829. serialize(): any;
  20830. /**
  20831. * Dispose the material and release its associated resources
  20832. * @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)
  20833. * @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)
  20834. * @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)
  20835. */
  20836. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20837. /**
  20838. * Creates a MultiMaterial from parsed MultiMaterial data.
  20839. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20840. * @param scene defines the hosting scene
  20841. * @returns a new MultiMaterial
  20842. */
  20843. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20844. }
  20845. }
  20846. declare module BABYLON {
  20847. /**
  20848. * Base class for submeshes
  20849. */
  20850. export class BaseSubMesh {
  20851. /** @hidden */
  20852. _materialDefines: Nullable<MaterialDefines>;
  20853. /** @hidden */
  20854. _materialEffect: Nullable<Effect>;
  20855. /**
  20856. * Gets associated effect
  20857. */
  20858. readonly effect: Nullable<Effect>;
  20859. /**
  20860. * Sets associated effect (effect used to render this submesh)
  20861. * @param effect defines the effect to associate with
  20862. * @param defines defines the set of defines used to compile this effect
  20863. */
  20864. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20865. }
  20866. /**
  20867. * Defines a subdivision inside a mesh
  20868. */
  20869. export class SubMesh extends BaseSubMesh implements ICullable {
  20870. /** the material index to use */
  20871. materialIndex: number;
  20872. /** vertex index start */
  20873. verticesStart: number;
  20874. /** vertices count */
  20875. verticesCount: number;
  20876. /** index start */
  20877. indexStart: number;
  20878. /** indices count */
  20879. indexCount: number;
  20880. /** @hidden */
  20881. _linesIndexCount: number;
  20882. private _mesh;
  20883. private _renderingMesh;
  20884. private _boundingInfo;
  20885. private _linesIndexBuffer;
  20886. /** @hidden */
  20887. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20888. /** @hidden */
  20889. _trianglePlanes: Plane[];
  20890. /** @hidden */
  20891. _lastColliderTransformMatrix: Nullable<Matrix>;
  20892. /** @hidden */
  20893. _renderId: number;
  20894. /** @hidden */
  20895. _alphaIndex: number;
  20896. /** @hidden */
  20897. _distanceToCamera: number;
  20898. /** @hidden */
  20899. _id: number;
  20900. private _currentMaterial;
  20901. /**
  20902. * Add a new submesh to a mesh
  20903. * @param materialIndex defines the material index to use
  20904. * @param verticesStart defines vertex index start
  20905. * @param verticesCount defines vertices count
  20906. * @param indexStart defines index start
  20907. * @param indexCount defines indices count
  20908. * @param mesh defines the parent mesh
  20909. * @param renderingMesh defines an optional rendering mesh
  20910. * @param createBoundingBox defines if bounding box should be created for this submesh
  20911. * @returns the new submesh
  20912. */
  20913. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20914. /**
  20915. * Creates a new submesh
  20916. * @param materialIndex defines the material index to use
  20917. * @param verticesStart defines vertex index start
  20918. * @param verticesCount defines vertices count
  20919. * @param indexStart defines index start
  20920. * @param indexCount defines indices count
  20921. * @param mesh defines the parent mesh
  20922. * @param renderingMesh defines an optional rendering mesh
  20923. * @param createBoundingBox defines if bounding box should be created for this submesh
  20924. */
  20925. constructor(
  20926. /** the material index to use */
  20927. materialIndex: number,
  20928. /** vertex index start */
  20929. verticesStart: number,
  20930. /** vertices count */
  20931. verticesCount: number,
  20932. /** index start */
  20933. indexStart: number,
  20934. /** indices count */
  20935. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20936. /**
  20937. * Returns true if this submesh covers the entire parent mesh
  20938. * @ignorenaming
  20939. */
  20940. readonly IsGlobal: boolean;
  20941. /**
  20942. * Returns the submesh BoudingInfo object
  20943. * @returns current bounding info (or mesh's one if the submesh is global)
  20944. */
  20945. getBoundingInfo(): BoundingInfo;
  20946. /**
  20947. * Sets the submesh BoundingInfo
  20948. * @param boundingInfo defines the new bounding info to use
  20949. * @returns the SubMesh
  20950. */
  20951. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20952. /**
  20953. * Returns the mesh of the current submesh
  20954. * @return the parent mesh
  20955. */
  20956. getMesh(): AbstractMesh;
  20957. /**
  20958. * Returns the rendering mesh of the submesh
  20959. * @returns the rendering mesh (could be different from parent mesh)
  20960. */
  20961. getRenderingMesh(): Mesh;
  20962. /**
  20963. * Returns the submesh material
  20964. * @returns null or the current material
  20965. */
  20966. getMaterial(): Nullable<Material>;
  20967. /**
  20968. * Sets a new updated BoundingInfo object to the submesh
  20969. * @param data defines an optional position array to use to determine the bounding info
  20970. * @returns the SubMesh
  20971. */
  20972. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20973. /** @hidden */
  20974. _checkCollision(collider: Collider): boolean;
  20975. /**
  20976. * Updates the submesh BoundingInfo
  20977. * @param world defines the world matrix to use to update the bounding info
  20978. * @returns the submesh
  20979. */
  20980. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20981. /**
  20982. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20983. * @param frustumPlanes defines the frustum planes
  20984. * @returns true if the submesh is intersecting with the frustum
  20985. */
  20986. isInFrustum(frustumPlanes: Plane[]): boolean;
  20987. /**
  20988. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20989. * @param frustumPlanes defines the frustum planes
  20990. * @returns true if the submesh is inside the frustum
  20991. */
  20992. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20993. /**
  20994. * Renders the submesh
  20995. * @param enableAlphaMode defines if alpha needs to be used
  20996. * @returns the submesh
  20997. */
  20998. render(enableAlphaMode: boolean): SubMesh;
  20999. /**
  21000. * @hidden
  21001. */
  21002. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21003. /**
  21004. * Checks if the submesh intersects with a ray
  21005. * @param ray defines the ray to test
  21006. * @returns true is the passed ray intersects the submesh bounding box
  21007. */
  21008. canIntersects(ray: Ray): boolean;
  21009. /**
  21010. * Intersects current submesh with a ray
  21011. * @param ray defines the ray to test
  21012. * @param positions defines mesh's positions array
  21013. * @param indices defines mesh's indices array
  21014. * @param fastCheck defines if only bounding info should be used
  21015. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21016. * @returns intersection info or null if no intersection
  21017. */
  21018. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21019. /** @hidden */
  21020. private _intersectLines;
  21021. /** @hidden */
  21022. private _intersectUnIndexedLines;
  21023. /** @hidden */
  21024. private _intersectTriangles;
  21025. /** @hidden */
  21026. private _intersectUnIndexedTriangles;
  21027. /** @hidden */
  21028. _rebuild(): void;
  21029. /**
  21030. * Creates a new submesh from the passed mesh
  21031. * @param newMesh defines the new hosting mesh
  21032. * @param newRenderingMesh defines an optional rendering mesh
  21033. * @returns the new submesh
  21034. */
  21035. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21036. /**
  21037. * Release associated resources
  21038. */
  21039. dispose(): void;
  21040. /**
  21041. * Gets the class name
  21042. * @returns the string "SubMesh".
  21043. */
  21044. getClassName(): string;
  21045. /**
  21046. * Creates a new submesh from indices data
  21047. * @param materialIndex the index of the main mesh material
  21048. * @param startIndex the index where to start the copy in the mesh indices array
  21049. * @param indexCount the number of indices to copy then from the startIndex
  21050. * @param mesh the main mesh to create the submesh from
  21051. * @param renderingMesh the optional rendering mesh
  21052. * @returns a new submesh
  21053. */
  21054. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21055. }
  21056. }
  21057. declare module BABYLON {
  21058. /**
  21059. * Class used to represent data loading progression
  21060. */
  21061. export class SceneLoaderFlags {
  21062. private static _ForceFullSceneLoadingForIncremental;
  21063. private static _ShowLoadingScreen;
  21064. private static _CleanBoneMatrixWeights;
  21065. private static _loggingLevel;
  21066. /**
  21067. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21068. */
  21069. static ForceFullSceneLoadingForIncremental: boolean;
  21070. /**
  21071. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21072. */
  21073. static ShowLoadingScreen: boolean;
  21074. /**
  21075. * Defines the current logging level (while loading the scene)
  21076. * @ignorenaming
  21077. */
  21078. static loggingLevel: number;
  21079. /**
  21080. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21081. */
  21082. static CleanBoneMatrixWeights: boolean;
  21083. }
  21084. }
  21085. declare module BABYLON {
  21086. /**
  21087. * Class used to store geometry data (vertex buffers + index buffer)
  21088. */
  21089. export class Geometry implements IGetSetVerticesData {
  21090. /**
  21091. * Gets or sets the ID of the geometry
  21092. */
  21093. id: string;
  21094. /**
  21095. * Gets or sets the unique ID of the geometry
  21096. */
  21097. uniqueId: number;
  21098. /**
  21099. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21100. */
  21101. delayLoadState: number;
  21102. /**
  21103. * Gets the file containing the data to load when running in delay load state
  21104. */
  21105. delayLoadingFile: Nullable<string>;
  21106. /**
  21107. * Callback called when the geometry is updated
  21108. */
  21109. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21110. private _scene;
  21111. private _engine;
  21112. private _meshes;
  21113. private _totalVertices;
  21114. /** @hidden */
  21115. _indices: IndicesArray;
  21116. /** @hidden */
  21117. _vertexBuffers: {
  21118. [key: string]: VertexBuffer;
  21119. };
  21120. private _isDisposed;
  21121. private _extend;
  21122. private _boundingBias;
  21123. /** @hidden */
  21124. _delayInfo: Array<string>;
  21125. private _indexBuffer;
  21126. private _indexBufferIsUpdatable;
  21127. /** @hidden */
  21128. _boundingInfo: Nullable<BoundingInfo>;
  21129. /** @hidden */
  21130. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21131. /** @hidden */
  21132. _softwareSkinningFrameId: number;
  21133. private _vertexArrayObjects;
  21134. private _updatable;
  21135. /** @hidden */
  21136. _positions: Nullable<Vector3[]>;
  21137. /**
  21138. * 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
  21139. */
  21140. /**
  21141. * 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
  21142. */
  21143. boundingBias: Vector2;
  21144. /**
  21145. * Static function used to attach a new empty geometry to a mesh
  21146. * @param mesh defines the mesh to attach the geometry to
  21147. * @returns the new Geometry
  21148. */
  21149. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21150. /**
  21151. * Creates a new geometry
  21152. * @param id defines the unique ID
  21153. * @param scene defines the hosting scene
  21154. * @param vertexData defines the VertexData used to get geometry data
  21155. * @param updatable defines if geometry must be updatable (false by default)
  21156. * @param mesh defines the mesh that will be associated with the geometry
  21157. */
  21158. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21159. /**
  21160. * Gets the current extend of the geometry
  21161. */
  21162. readonly extend: {
  21163. minimum: Vector3;
  21164. maximum: Vector3;
  21165. };
  21166. /**
  21167. * Gets the hosting scene
  21168. * @returns the hosting Scene
  21169. */
  21170. getScene(): Scene;
  21171. /**
  21172. * Gets the hosting engine
  21173. * @returns the hosting Engine
  21174. */
  21175. getEngine(): Engine;
  21176. /**
  21177. * Defines if the geometry is ready to use
  21178. * @returns true if the geometry is ready to be used
  21179. */
  21180. isReady(): boolean;
  21181. /**
  21182. * Gets a value indicating that the geometry should not be serialized
  21183. */
  21184. readonly doNotSerialize: boolean;
  21185. /** @hidden */
  21186. _rebuild(): void;
  21187. /**
  21188. * Affects all geometry data in one call
  21189. * @param vertexData defines the geometry data
  21190. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21191. */
  21192. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21193. /**
  21194. * Set specific vertex data
  21195. * @param kind defines the data kind (Position, normal, etc...)
  21196. * @param data defines the vertex data to use
  21197. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21198. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21199. */
  21200. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21201. /**
  21202. * Removes a specific vertex data
  21203. * @param kind defines the data kind (Position, normal, etc...)
  21204. */
  21205. removeVerticesData(kind: string): void;
  21206. /**
  21207. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21208. * @param buffer defines the vertex buffer to use
  21209. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21210. */
  21211. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21212. /**
  21213. * Update a specific vertex buffer
  21214. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21215. * It will do nothing if the buffer is not updatable
  21216. * @param kind defines the data kind (Position, normal, etc...)
  21217. * @param data defines the data to use
  21218. * @param offset defines the offset in the target buffer where to store the data
  21219. * @param useBytes set to true if the offset is in bytes
  21220. */
  21221. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21222. /**
  21223. * Update a specific vertex buffer
  21224. * This function will create a new buffer if the current one is not updatable
  21225. * @param kind defines the data kind (Position, normal, etc...)
  21226. * @param data defines the data to use
  21227. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21228. */
  21229. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21230. private _updateBoundingInfo;
  21231. /** @hidden */
  21232. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21233. /**
  21234. * Gets total number of vertices
  21235. * @returns the total number of vertices
  21236. */
  21237. getTotalVertices(): number;
  21238. /**
  21239. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21240. * @param kind defines the data kind (Position, normal, etc...)
  21241. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21242. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21243. * @returns a float array containing vertex data
  21244. */
  21245. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21246. /**
  21247. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21248. * @param kind defines the data kind (Position, normal, etc...)
  21249. * @returns true if the vertex buffer with the specified kind is updatable
  21250. */
  21251. isVertexBufferUpdatable(kind: string): boolean;
  21252. /**
  21253. * Gets a specific vertex buffer
  21254. * @param kind defines the data kind (Position, normal, etc...)
  21255. * @returns a VertexBuffer
  21256. */
  21257. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21258. /**
  21259. * Returns all vertex buffers
  21260. * @return an object holding all vertex buffers indexed by kind
  21261. */
  21262. getVertexBuffers(): Nullable<{
  21263. [key: string]: VertexBuffer;
  21264. }>;
  21265. /**
  21266. * Gets a boolean indicating if specific vertex buffer is present
  21267. * @param kind defines the data kind (Position, normal, etc...)
  21268. * @returns true if data is present
  21269. */
  21270. isVerticesDataPresent(kind: string): boolean;
  21271. /**
  21272. * Gets a list of all attached data kinds (Position, normal, etc...)
  21273. * @returns a list of string containing all kinds
  21274. */
  21275. getVerticesDataKinds(): string[];
  21276. /**
  21277. * Update index buffer
  21278. * @param indices defines the indices to store in the index buffer
  21279. * @param offset defines the offset in the target buffer where to store the data
  21280. * @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)
  21281. */
  21282. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21283. /**
  21284. * Creates a new index buffer
  21285. * @param indices defines the indices to store in the index buffer
  21286. * @param totalVertices defines the total number of vertices (could be null)
  21287. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21288. */
  21289. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21290. /**
  21291. * Return the total number of indices
  21292. * @returns the total number of indices
  21293. */
  21294. getTotalIndices(): number;
  21295. /**
  21296. * Gets the index buffer array
  21297. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21298. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21299. * @returns the index buffer array
  21300. */
  21301. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21302. /**
  21303. * Gets the index buffer
  21304. * @return the index buffer
  21305. */
  21306. getIndexBuffer(): Nullable<DataBuffer>;
  21307. /** @hidden */
  21308. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21309. /**
  21310. * Release the associated resources for a specific mesh
  21311. * @param mesh defines the source mesh
  21312. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21313. */
  21314. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21315. /**
  21316. * Apply current geometry to a given mesh
  21317. * @param mesh defines the mesh to apply geometry to
  21318. */
  21319. applyToMesh(mesh: Mesh): void;
  21320. private _updateExtend;
  21321. private _applyToMesh;
  21322. private notifyUpdate;
  21323. /**
  21324. * Load the geometry if it was flagged as delay loaded
  21325. * @param scene defines the hosting scene
  21326. * @param onLoaded defines a callback called when the geometry is loaded
  21327. */
  21328. load(scene: Scene, onLoaded?: () => void): void;
  21329. private _queueLoad;
  21330. /**
  21331. * Invert the geometry to move from a right handed system to a left handed one.
  21332. */
  21333. toLeftHanded(): void;
  21334. /** @hidden */
  21335. _resetPointsArrayCache(): void;
  21336. /** @hidden */
  21337. _generatePointsArray(): boolean;
  21338. /**
  21339. * Gets a value indicating if the geometry is disposed
  21340. * @returns true if the geometry was disposed
  21341. */
  21342. isDisposed(): boolean;
  21343. private _disposeVertexArrayObjects;
  21344. /**
  21345. * Free all associated resources
  21346. */
  21347. dispose(): void;
  21348. /**
  21349. * Clone the current geometry into a new geometry
  21350. * @param id defines the unique ID of the new geometry
  21351. * @returns a new geometry object
  21352. */
  21353. copy(id: string): Geometry;
  21354. /**
  21355. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21356. * @return a JSON representation of the current geometry data (without the vertices data)
  21357. */
  21358. serialize(): any;
  21359. private toNumberArray;
  21360. /**
  21361. * Serialize all vertices data into a JSON oject
  21362. * @returns a JSON representation of the current geometry data
  21363. */
  21364. serializeVerticeData(): any;
  21365. /**
  21366. * Extracts a clone of a mesh geometry
  21367. * @param mesh defines the source mesh
  21368. * @param id defines the unique ID of the new geometry object
  21369. * @returns the new geometry object
  21370. */
  21371. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21372. /**
  21373. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21374. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21375. * Be aware Math.random() could cause collisions, but:
  21376. * "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"
  21377. * @returns a string containing a new GUID
  21378. */
  21379. static RandomId(): string;
  21380. /** @hidden */
  21381. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21382. private static _CleanMatricesWeights;
  21383. /**
  21384. * Create a new geometry from persisted data (Using .babylon file format)
  21385. * @param parsedVertexData defines the persisted data
  21386. * @param scene defines the hosting scene
  21387. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21388. * @returns the new geometry object
  21389. */
  21390. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21391. }
  21392. }
  21393. declare module BABYLON {
  21394. /**
  21395. * Define an interface for all classes that will get and set the data on vertices
  21396. */
  21397. export interface IGetSetVerticesData {
  21398. /**
  21399. * Gets a boolean indicating if specific vertex data is present
  21400. * @param kind defines the vertex data kind to use
  21401. * @returns true is data kind is present
  21402. */
  21403. isVerticesDataPresent(kind: string): boolean;
  21404. /**
  21405. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21406. * @param kind defines the data kind (Position, normal, etc...)
  21407. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21408. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21409. * @returns a float array containing vertex data
  21410. */
  21411. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21412. /**
  21413. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21414. * @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.
  21415. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21416. * @returns the indices array or an empty array if the mesh has no geometry
  21417. */
  21418. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21419. /**
  21420. * Set specific vertex data
  21421. * @param kind defines the data kind (Position, normal, etc...)
  21422. * @param data defines the vertex data to use
  21423. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21424. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21425. */
  21426. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21427. /**
  21428. * Update a specific associated vertex buffer
  21429. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21430. * - VertexBuffer.PositionKind
  21431. * - VertexBuffer.UVKind
  21432. * - VertexBuffer.UV2Kind
  21433. * - VertexBuffer.UV3Kind
  21434. * - VertexBuffer.UV4Kind
  21435. * - VertexBuffer.UV5Kind
  21436. * - VertexBuffer.UV6Kind
  21437. * - VertexBuffer.ColorKind
  21438. * - VertexBuffer.MatricesIndicesKind
  21439. * - VertexBuffer.MatricesIndicesExtraKind
  21440. * - VertexBuffer.MatricesWeightsKind
  21441. * - VertexBuffer.MatricesWeightsExtraKind
  21442. * @param data defines the data source
  21443. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21444. * @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)
  21445. */
  21446. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21447. /**
  21448. * Creates a new index buffer
  21449. * @param indices defines the indices to store in the index buffer
  21450. * @param totalVertices defines the total number of vertices (could be null)
  21451. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21452. */
  21453. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21454. }
  21455. /**
  21456. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21457. */
  21458. export class VertexData {
  21459. /**
  21460. * Mesh side orientation : usually the external or front surface
  21461. */
  21462. static readonly FRONTSIDE: number;
  21463. /**
  21464. * Mesh side orientation : usually the internal or back surface
  21465. */
  21466. static readonly BACKSIDE: number;
  21467. /**
  21468. * Mesh side orientation : both internal and external or front and back surfaces
  21469. */
  21470. static readonly DOUBLESIDE: number;
  21471. /**
  21472. * Mesh side orientation : by default, `FRONTSIDE`
  21473. */
  21474. static readonly DEFAULTSIDE: number;
  21475. /**
  21476. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21477. */
  21478. positions: Nullable<FloatArray>;
  21479. /**
  21480. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21481. */
  21482. normals: Nullable<FloatArray>;
  21483. /**
  21484. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21485. */
  21486. tangents: Nullable<FloatArray>;
  21487. /**
  21488. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21489. */
  21490. uvs: Nullable<FloatArray>;
  21491. /**
  21492. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21493. */
  21494. uvs2: Nullable<FloatArray>;
  21495. /**
  21496. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21497. */
  21498. uvs3: Nullable<FloatArray>;
  21499. /**
  21500. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21501. */
  21502. uvs4: Nullable<FloatArray>;
  21503. /**
  21504. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21505. */
  21506. uvs5: Nullable<FloatArray>;
  21507. /**
  21508. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21509. */
  21510. uvs6: Nullable<FloatArray>;
  21511. /**
  21512. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21513. */
  21514. colors: Nullable<FloatArray>;
  21515. /**
  21516. * 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).
  21517. */
  21518. matricesIndices: Nullable<FloatArray>;
  21519. /**
  21520. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21521. */
  21522. matricesWeights: Nullable<FloatArray>;
  21523. /**
  21524. * An array extending the number of possible indices
  21525. */
  21526. matricesIndicesExtra: Nullable<FloatArray>;
  21527. /**
  21528. * An array extending the number of possible weights when the number of indices is extended
  21529. */
  21530. matricesWeightsExtra: Nullable<FloatArray>;
  21531. /**
  21532. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21533. */
  21534. indices: Nullable<IndicesArray>;
  21535. /**
  21536. * Uses the passed data array to set the set the values for the specified kind of data
  21537. * @param data a linear array of floating numbers
  21538. * @param kind the type of data that is being set, eg positions, colors etc
  21539. */
  21540. set(data: FloatArray, kind: string): void;
  21541. /**
  21542. * Associates the vertexData to the passed Mesh.
  21543. * Sets it as updatable or not (default `false`)
  21544. * @param mesh the mesh the vertexData is applied to
  21545. * @param updatable when used and having the value true allows new data to update the vertexData
  21546. * @returns the VertexData
  21547. */
  21548. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21549. /**
  21550. * Associates the vertexData to the passed Geometry.
  21551. * Sets it as updatable or not (default `false`)
  21552. * @param geometry the geometry the vertexData is applied to
  21553. * @param updatable when used and having the value true allows new data to update the vertexData
  21554. * @returns VertexData
  21555. */
  21556. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21557. /**
  21558. * Updates the associated mesh
  21559. * @param mesh the mesh to be updated
  21560. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21561. * @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
  21562. * @returns VertexData
  21563. */
  21564. updateMesh(mesh: Mesh): VertexData;
  21565. /**
  21566. * Updates the associated geometry
  21567. * @param geometry the geometry to be updated
  21568. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21569. * @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
  21570. * @returns VertexData.
  21571. */
  21572. updateGeometry(geometry: Geometry): VertexData;
  21573. private _applyTo;
  21574. private _update;
  21575. /**
  21576. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21577. * @param matrix the transforming matrix
  21578. * @returns the VertexData
  21579. */
  21580. transform(matrix: Matrix): VertexData;
  21581. /**
  21582. * Merges the passed VertexData into the current one
  21583. * @param other the VertexData to be merged into the current one
  21584. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21585. * @returns the modified VertexData
  21586. */
  21587. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21588. private _mergeElement;
  21589. private _validate;
  21590. /**
  21591. * Serializes the VertexData
  21592. * @returns a serialized object
  21593. */
  21594. serialize(): any;
  21595. /**
  21596. * Extracts the vertexData from a mesh
  21597. * @param mesh the mesh from which to extract the VertexData
  21598. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21599. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21600. * @returns the object VertexData associated to the passed mesh
  21601. */
  21602. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21603. /**
  21604. * Extracts the vertexData from the geometry
  21605. * @param geometry the geometry from which to extract the VertexData
  21606. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21607. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21608. * @returns the object VertexData associated to the passed mesh
  21609. */
  21610. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21611. private static _ExtractFrom;
  21612. /**
  21613. * Creates the VertexData for a Ribbon
  21614. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21615. * * pathArray array of paths, each of which an array of successive Vector3
  21616. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21617. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21618. * * 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
  21619. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21620. * * 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)
  21621. * * 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)
  21622. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21623. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21624. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21625. * @returns the VertexData of the ribbon
  21626. */
  21627. static CreateRibbon(options: {
  21628. pathArray: Vector3[][];
  21629. closeArray?: boolean;
  21630. closePath?: boolean;
  21631. offset?: number;
  21632. sideOrientation?: number;
  21633. frontUVs?: Vector4;
  21634. backUVs?: Vector4;
  21635. invertUV?: boolean;
  21636. uvs?: Vector2[];
  21637. colors?: Color4[];
  21638. }): VertexData;
  21639. /**
  21640. * Creates the VertexData for a box
  21641. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21642. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21643. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21644. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21645. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21646. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21647. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21648. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21649. * * 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)
  21650. * * 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)
  21651. * @returns the VertexData of the box
  21652. */
  21653. static CreateBox(options: {
  21654. size?: number;
  21655. width?: number;
  21656. height?: number;
  21657. depth?: number;
  21658. faceUV?: Vector4[];
  21659. faceColors?: Color4[];
  21660. sideOrientation?: number;
  21661. frontUVs?: Vector4;
  21662. backUVs?: Vector4;
  21663. }): VertexData;
  21664. /**
  21665. * Creates the VertexData for a tiled box
  21666. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21667. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21668. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21669. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21670. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21671. * @returns the VertexData of the box
  21672. */
  21673. static CreateTiledBox(options: {
  21674. pattern?: number;
  21675. width?: number;
  21676. height?: number;
  21677. depth?: number;
  21678. tileSize?: number;
  21679. tileWidth?: number;
  21680. tileHeight?: number;
  21681. alignHorizontal?: number;
  21682. alignVertical?: number;
  21683. faceUV?: Vector4[];
  21684. faceColors?: Color4[];
  21685. sideOrientation?: number;
  21686. }): VertexData;
  21687. /**
  21688. * Creates the VertexData for a tiled plane
  21689. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21690. * * pattern a limited pattern arrangement depending on the number
  21691. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21692. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21693. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21694. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21695. * * 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)
  21696. * * 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)
  21697. * @returns the VertexData of the tiled plane
  21698. */
  21699. static CreateTiledPlane(options: {
  21700. pattern?: number;
  21701. tileSize?: number;
  21702. tileWidth?: number;
  21703. tileHeight?: number;
  21704. size?: number;
  21705. width?: number;
  21706. height?: number;
  21707. alignHorizontal?: number;
  21708. alignVertical?: number;
  21709. sideOrientation?: number;
  21710. frontUVs?: Vector4;
  21711. backUVs?: Vector4;
  21712. }): VertexData;
  21713. /**
  21714. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21715. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21716. * * segments sets the number of horizontal strips optional, default 32
  21717. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21718. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21719. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21720. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21721. * * 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
  21722. * * 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
  21723. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21724. * * 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)
  21725. * * 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)
  21726. * @returns the VertexData of the ellipsoid
  21727. */
  21728. static CreateSphere(options: {
  21729. segments?: number;
  21730. diameter?: number;
  21731. diameterX?: number;
  21732. diameterY?: number;
  21733. diameterZ?: number;
  21734. arc?: number;
  21735. slice?: number;
  21736. sideOrientation?: number;
  21737. frontUVs?: Vector4;
  21738. backUVs?: Vector4;
  21739. }): VertexData;
  21740. /**
  21741. * Creates the VertexData for a cylinder, cone or prism
  21742. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21743. * * height sets the height (y direction) of the cylinder, optional, default 2
  21744. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21745. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21746. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21747. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21748. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21749. * * 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
  21750. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21751. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21752. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21753. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21754. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21755. * * 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)
  21756. * * 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)
  21757. * @returns the VertexData of the cylinder, cone or prism
  21758. */
  21759. static CreateCylinder(options: {
  21760. height?: number;
  21761. diameterTop?: number;
  21762. diameterBottom?: number;
  21763. diameter?: number;
  21764. tessellation?: number;
  21765. subdivisions?: number;
  21766. arc?: number;
  21767. faceColors?: Color4[];
  21768. faceUV?: Vector4[];
  21769. hasRings?: boolean;
  21770. enclose?: boolean;
  21771. sideOrientation?: number;
  21772. frontUVs?: Vector4;
  21773. backUVs?: Vector4;
  21774. }): VertexData;
  21775. /**
  21776. * Creates the VertexData for a torus
  21777. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21778. * * diameter the diameter of the torus, optional default 1
  21779. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21780. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21781. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21782. * * 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)
  21783. * * 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)
  21784. * @returns the VertexData of the torus
  21785. */
  21786. static CreateTorus(options: {
  21787. diameter?: number;
  21788. thickness?: number;
  21789. tessellation?: number;
  21790. sideOrientation?: number;
  21791. frontUVs?: Vector4;
  21792. backUVs?: Vector4;
  21793. }): VertexData;
  21794. /**
  21795. * Creates the VertexData of the LineSystem
  21796. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21797. * - lines an array of lines, each line being an array of successive Vector3
  21798. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21799. * @returns the VertexData of the LineSystem
  21800. */
  21801. static CreateLineSystem(options: {
  21802. lines: Vector3[][];
  21803. colors?: Nullable<Color4[][]>;
  21804. }): VertexData;
  21805. /**
  21806. * Create the VertexData for a DashedLines
  21807. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21808. * - points an array successive Vector3
  21809. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21810. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21811. * - dashNb the intended total number of dashes, optional, default 200
  21812. * @returns the VertexData for the DashedLines
  21813. */
  21814. static CreateDashedLines(options: {
  21815. points: Vector3[];
  21816. dashSize?: number;
  21817. gapSize?: number;
  21818. dashNb?: number;
  21819. }): VertexData;
  21820. /**
  21821. * Creates the VertexData for a Ground
  21822. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21823. * - width the width (x direction) of the ground, optional, default 1
  21824. * - height the height (z direction) of the ground, optional, default 1
  21825. * - subdivisions the number of subdivisions per side, optional, default 1
  21826. * @returns the VertexData of the Ground
  21827. */
  21828. static CreateGround(options: {
  21829. width?: number;
  21830. height?: number;
  21831. subdivisions?: number;
  21832. subdivisionsX?: number;
  21833. subdivisionsY?: number;
  21834. }): VertexData;
  21835. /**
  21836. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21837. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21838. * * xmin the ground minimum X coordinate, optional, default -1
  21839. * * zmin the ground minimum Z coordinate, optional, default -1
  21840. * * xmax the ground maximum X coordinate, optional, default 1
  21841. * * zmax the ground maximum Z coordinate, optional, default 1
  21842. * * 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}
  21843. * * 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}
  21844. * @returns the VertexData of the TiledGround
  21845. */
  21846. static CreateTiledGround(options: {
  21847. xmin: number;
  21848. zmin: number;
  21849. xmax: number;
  21850. zmax: number;
  21851. subdivisions?: {
  21852. w: number;
  21853. h: number;
  21854. };
  21855. precision?: {
  21856. w: number;
  21857. h: number;
  21858. };
  21859. }): VertexData;
  21860. /**
  21861. * Creates the VertexData of the Ground designed from a heightmap
  21862. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21863. * * width the width (x direction) of the ground
  21864. * * height the height (z direction) of the ground
  21865. * * subdivisions the number of subdivisions per side
  21866. * * minHeight the minimum altitude on the ground, optional, default 0
  21867. * * maxHeight the maximum altitude on the ground, optional default 1
  21868. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21869. * * buffer the array holding the image color data
  21870. * * bufferWidth the width of image
  21871. * * bufferHeight the height of image
  21872. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21873. * @returns the VertexData of the Ground designed from a heightmap
  21874. */
  21875. static CreateGroundFromHeightMap(options: {
  21876. width: number;
  21877. height: number;
  21878. subdivisions: number;
  21879. minHeight: number;
  21880. maxHeight: number;
  21881. colorFilter: Color3;
  21882. buffer: Uint8Array;
  21883. bufferWidth: number;
  21884. bufferHeight: number;
  21885. alphaFilter: number;
  21886. }): VertexData;
  21887. /**
  21888. * Creates the VertexData for a Plane
  21889. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21890. * * size sets the width and height of the plane to the value of size, optional default 1
  21891. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21892. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21893. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21894. * * 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)
  21895. * * 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)
  21896. * @returns the VertexData of the box
  21897. */
  21898. static CreatePlane(options: {
  21899. size?: number;
  21900. width?: number;
  21901. height?: number;
  21902. sideOrientation?: number;
  21903. frontUVs?: Vector4;
  21904. backUVs?: Vector4;
  21905. }): VertexData;
  21906. /**
  21907. * Creates the VertexData of the Disc or regular Polygon
  21908. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21909. * * radius the radius of the disc, optional default 0.5
  21910. * * tessellation the number of polygon sides, optional, default 64
  21911. * * 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
  21912. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21913. * * 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)
  21914. * * 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)
  21915. * @returns the VertexData of the box
  21916. */
  21917. static CreateDisc(options: {
  21918. radius?: number;
  21919. tessellation?: number;
  21920. arc?: number;
  21921. sideOrientation?: number;
  21922. frontUVs?: Vector4;
  21923. backUVs?: Vector4;
  21924. }): VertexData;
  21925. /**
  21926. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21927. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21928. * @param polygon a mesh built from polygonTriangulation.build()
  21929. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21930. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21931. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21932. * @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)
  21933. * @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)
  21934. * @returns the VertexData of the Polygon
  21935. */
  21936. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21937. /**
  21938. * Creates the VertexData of the IcoSphere
  21939. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21940. * * radius the radius of the IcoSphere, optional default 1
  21941. * * radiusX allows stretching in the x direction, optional, default radius
  21942. * * radiusY allows stretching in the y direction, optional, default radius
  21943. * * radiusZ allows stretching in the z direction, optional, default radius
  21944. * * flat when true creates a flat shaded mesh, optional, default true
  21945. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21946. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21947. * * 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)
  21948. * * 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)
  21949. * @returns the VertexData of the IcoSphere
  21950. */
  21951. static CreateIcoSphere(options: {
  21952. radius?: number;
  21953. radiusX?: number;
  21954. radiusY?: number;
  21955. radiusZ?: number;
  21956. flat?: boolean;
  21957. subdivisions?: number;
  21958. sideOrientation?: number;
  21959. frontUVs?: Vector4;
  21960. backUVs?: Vector4;
  21961. }): VertexData;
  21962. /**
  21963. * Creates the VertexData for a Polyhedron
  21964. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21965. * * type provided types are:
  21966. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21967. * * 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)
  21968. * * size the size of the IcoSphere, optional default 1
  21969. * * sizeX allows stretching in the x direction, optional, default size
  21970. * * sizeY allows stretching in the y direction, optional, default size
  21971. * * sizeZ allows stretching in the z direction, optional, default size
  21972. * * 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
  21973. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21974. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21975. * * flat when true creates a flat shaded mesh, optional, default true
  21976. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21978. * * 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)
  21979. * * 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)
  21980. * @returns the VertexData of the Polyhedron
  21981. */
  21982. static CreatePolyhedron(options: {
  21983. type?: number;
  21984. size?: number;
  21985. sizeX?: number;
  21986. sizeY?: number;
  21987. sizeZ?: number;
  21988. custom?: any;
  21989. faceUV?: Vector4[];
  21990. faceColors?: Color4[];
  21991. flat?: boolean;
  21992. sideOrientation?: number;
  21993. frontUVs?: Vector4;
  21994. backUVs?: Vector4;
  21995. }): VertexData;
  21996. /**
  21997. * Creates the VertexData for a TorusKnot
  21998. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21999. * * radius the radius of the torus knot, optional, default 2
  22000. * * tube the thickness of the tube, optional, default 0.5
  22001. * * radialSegments the number of sides on each tube segments, optional, default 32
  22002. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22003. * * p the number of windings around the z axis, optional, default 2
  22004. * * q the number of windings around the x axis, optional, default 3
  22005. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22006. * * 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)
  22007. * * 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)
  22008. * @returns the VertexData of the Torus Knot
  22009. */
  22010. static CreateTorusKnot(options: {
  22011. radius?: number;
  22012. tube?: number;
  22013. radialSegments?: number;
  22014. tubularSegments?: number;
  22015. p?: number;
  22016. q?: number;
  22017. sideOrientation?: number;
  22018. frontUVs?: Vector4;
  22019. backUVs?: Vector4;
  22020. }): VertexData;
  22021. /**
  22022. * Compute normals for given positions and indices
  22023. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22024. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22025. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22026. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22027. * * facetNormals : optional array of facet normals (vector3)
  22028. * * facetPositions : optional array of facet positions (vector3)
  22029. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22030. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22031. * * bInfo : optional bounding info, required for facetPartitioning computation
  22032. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22033. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22034. * * useRightHandedSystem: optional boolean to for right handed system computation
  22035. * * depthSort : optional boolean to enable the facet depth sort computation
  22036. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22037. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22038. */
  22039. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22040. facetNormals?: any;
  22041. facetPositions?: any;
  22042. facetPartitioning?: any;
  22043. ratio?: number;
  22044. bInfo?: any;
  22045. bbSize?: Vector3;
  22046. subDiv?: any;
  22047. useRightHandedSystem?: boolean;
  22048. depthSort?: boolean;
  22049. distanceTo?: Vector3;
  22050. depthSortedFacets?: any;
  22051. }): void;
  22052. /** @hidden */
  22053. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22054. /**
  22055. * Applies VertexData created from the imported parameters to the geometry
  22056. * @param parsedVertexData the parsed data from an imported file
  22057. * @param geometry the geometry to apply the VertexData to
  22058. */
  22059. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22060. }
  22061. }
  22062. declare module BABYLON {
  22063. /**
  22064. * Defines a target to use with MorphTargetManager
  22065. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22066. */
  22067. export class MorphTarget implements IAnimatable {
  22068. /** defines the name of the target */
  22069. name: string;
  22070. /**
  22071. * Gets or sets the list of animations
  22072. */
  22073. animations: Animation[];
  22074. private _scene;
  22075. private _positions;
  22076. private _normals;
  22077. private _tangents;
  22078. private _uvs;
  22079. private _influence;
  22080. /**
  22081. * Observable raised when the influence changes
  22082. */
  22083. onInfluenceChanged: Observable<boolean>;
  22084. /** @hidden */
  22085. _onDataLayoutChanged: Observable<void>;
  22086. /**
  22087. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22088. */
  22089. influence: number;
  22090. /**
  22091. * Gets or sets the id of the morph Target
  22092. */
  22093. id: string;
  22094. private _animationPropertiesOverride;
  22095. /**
  22096. * Gets or sets the animation properties override
  22097. */
  22098. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22099. /**
  22100. * Creates a new MorphTarget
  22101. * @param name defines the name of the target
  22102. * @param influence defines the influence to use
  22103. * @param scene defines the scene the morphtarget belongs to
  22104. */
  22105. constructor(
  22106. /** defines the name of the target */
  22107. name: string, influence?: number, scene?: Nullable<Scene>);
  22108. /**
  22109. * Gets a boolean defining if the target contains position data
  22110. */
  22111. readonly hasPositions: boolean;
  22112. /**
  22113. * Gets a boolean defining if the target contains normal data
  22114. */
  22115. readonly hasNormals: boolean;
  22116. /**
  22117. * Gets a boolean defining if the target contains tangent data
  22118. */
  22119. readonly hasTangents: boolean;
  22120. /**
  22121. * Gets a boolean defining if the target contains texture coordinates data
  22122. */
  22123. readonly hasUVs: boolean;
  22124. /**
  22125. * Affects position data to this target
  22126. * @param data defines the position data to use
  22127. */
  22128. setPositions(data: Nullable<FloatArray>): void;
  22129. /**
  22130. * Gets the position data stored in this target
  22131. * @returns a FloatArray containing the position data (or null if not present)
  22132. */
  22133. getPositions(): Nullable<FloatArray>;
  22134. /**
  22135. * Affects normal data to this target
  22136. * @param data defines the normal data to use
  22137. */
  22138. setNormals(data: Nullable<FloatArray>): void;
  22139. /**
  22140. * Gets the normal data stored in this target
  22141. * @returns a FloatArray containing the normal data (or null if not present)
  22142. */
  22143. getNormals(): Nullable<FloatArray>;
  22144. /**
  22145. * Affects tangent data to this target
  22146. * @param data defines the tangent data to use
  22147. */
  22148. setTangents(data: Nullable<FloatArray>): void;
  22149. /**
  22150. * Gets the tangent data stored in this target
  22151. * @returns a FloatArray containing the tangent data (or null if not present)
  22152. */
  22153. getTangents(): Nullable<FloatArray>;
  22154. /**
  22155. * Affects texture coordinates data to this target
  22156. * @param data defines the texture coordinates data to use
  22157. */
  22158. setUVs(data: Nullable<FloatArray>): void;
  22159. /**
  22160. * Gets the texture coordinates data stored in this target
  22161. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22162. */
  22163. getUVs(): Nullable<FloatArray>;
  22164. /**
  22165. * Serializes the current target into a Serialization object
  22166. * @returns the serialized object
  22167. */
  22168. serialize(): any;
  22169. /**
  22170. * Returns the string "MorphTarget"
  22171. * @returns "MorphTarget"
  22172. */
  22173. getClassName(): string;
  22174. /**
  22175. * Creates a new target from serialized data
  22176. * @param serializationObject defines the serialized data to use
  22177. * @returns a new MorphTarget
  22178. */
  22179. static Parse(serializationObject: any): MorphTarget;
  22180. /**
  22181. * Creates a MorphTarget from mesh data
  22182. * @param mesh defines the source mesh
  22183. * @param name defines the name to use for the new target
  22184. * @param influence defines the influence to attach to the target
  22185. * @returns a new MorphTarget
  22186. */
  22187. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22188. }
  22189. }
  22190. declare module BABYLON {
  22191. /**
  22192. * This class is used to deform meshes using morphing between different targets
  22193. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22194. */
  22195. export class MorphTargetManager {
  22196. private _targets;
  22197. private _targetInfluenceChangedObservers;
  22198. private _targetDataLayoutChangedObservers;
  22199. private _activeTargets;
  22200. private _scene;
  22201. private _influences;
  22202. private _supportsNormals;
  22203. private _supportsTangents;
  22204. private _supportsUVs;
  22205. private _vertexCount;
  22206. private _uniqueId;
  22207. private _tempInfluences;
  22208. /**
  22209. * Gets or sets a boolean indicating if normals must be morphed
  22210. */
  22211. enableNormalMorphing: boolean;
  22212. /**
  22213. * Gets or sets a boolean indicating if tangents must be morphed
  22214. */
  22215. enableTangentMorphing: boolean;
  22216. /**
  22217. * Gets or sets a boolean indicating if UV must be morphed
  22218. */
  22219. enableUVMorphing: boolean;
  22220. /**
  22221. * Creates a new MorphTargetManager
  22222. * @param scene defines the current scene
  22223. */
  22224. constructor(scene?: Nullable<Scene>);
  22225. /**
  22226. * Gets the unique ID of this manager
  22227. */
  22228. readonly uniqueId: number;
  22229. /**
  22230. * Gets the number of vertices handled by this manager
  22231. */
  22232. readonly vertexCount: number;
  22233. /**
  22234. * Gets a boolean indicating if this manager supports morphing of normals
  22235. */
  22236. readonly supportsNormals: boolean;
  22237. /**
  22238. * Gets a boolean indicating if this manager supports morphing of tangents
  22239. */
  22240. readonly supportsTangents: boolean;
  22241. /**
  22242. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22243. */
  22244. readonly supportsUVs: boolean;
  22245. /**
  22246. * Gets the number of targets stored in this manager
  22247. */
  22248. readonly numTargets: number;
  22249. /**
  22250. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22251. */
  22252. readonly numInfluencers: number;
  22253. /**
  22254. * Gets the list of influences (one per target)
  22255. */
  22256. readonly influences: Float32Array;
  22257. /**
  22258. * Gets the active target at specified index. An active target is a target with an influence > 0
  22259. * @param index defines the index to check
  22260. * @returns the requested target
  22261. */
  22262. getActiveTarget(index: number): MorphTarget;
  22263. /**
  22264. * Gets the target at specified index
  22265. * @param index defines the index to check
  22266. * @returns the requested target
  22267. */
  22268. getTarget(index: number): MorphTarget;
  22269. /**
  22270. * Add a new target to this manager
  22271. * @param target defines the target to add
  22272. */
  22273. addTarget(target: MorphTarget): void;
  22274. /**
  22275. * Removes a target from the manager
  22276. * @param target defines the target to remove
  22277. */
  22278. removeTarget(target: MorphTarget): void;
  22279. /**
  22280. * Serializes the current manager into a Serialization object
  22281. * @returns the serialized object
  22282. */
  22283. serialize(): any;
  22284. private _syncActiveTargets;
  22285. /**
  22286. * Syncrhonize the targets with all the meshes using this morph target manager
  22287. */
  22288. synchronize(): void;
  22289. /**
  22290. * Creates a new MorphTargetManager from serialized data
  22291. * @param serializationObject defines the serialized data
  22292. * @param scene defines the hosting scene
  22293. * @returns the new MorphTargetManager
  22294. */
  22295. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22296. }
  22297. }
  22298. declare module BABYLON {
  22299. /**
  22300. * Class used to represent a specific level of detail of a mesh
  22301. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22302. */
  22303. export class MeshLODLevel {
  22304. /** Defines the distance where this level should start being displayed */
  22305. distance: number;
  22306. /** Defines the mesh to use to render this level */
  22307. mesh: Nullable<Mesh>;
  22308. /**
  22309. * Creates a new LOD level
  22310. * @param distance defines the distance where this level should star being displayed
  22311. * @param mesh defines the mesh to use to render this level
  22312. */
  22313. constructor(
  22314. /** Defines the distance where this level should start being displayed */
  22315. distance: number,
  22316. /** Defines the mesh to use to render this level */
  22317. mesh: Nullable<Mesh>);
  22318. }
  22319. }
  22320. declare module BABYLON {
  22321. /**
  22322. * Mesh representing the gorund
  22323. */
  22324. export class GroundMesh extends Mesh {
  22325. /** If octree should be generated */
  22326. generateOctree: boolean;
  22327. private _heightQuads;
  22328. /** @hidden */
  22329. _subdivisionsX: number;
  22330. /** @hidden */
  22331. _subdivisionsY: number;
  22332. /** @hidden */
  22333. _width: number;
  22334. /** @hidden */
  22335. _height: number;
  22336. /** @hidden */
  22337. _minX: number;
  22338. /** @hidden */
  22339. _maxX: number;
  22340. /** @hidden */
  22341. _minZ: number;
  22342. /** @hidden */
  22343. _maxZ: number;
  22344. constructor(name: string, scene: Scene);
  22345. /**
  22346. * "GroundMesh"
  22347. * @returns "GroundMesh"
  22348. */
  22349. getClassName(): string;
  22350. /**
  22351. * The minimum of x and y subdivisions
  22352. */
  22353. readonly subdivisions: number;
  22354. /**
  22355. * X subdivisions
  22356. */
  22357. readonly subdivisionsX: number;
  22358. /**
  22359. * Y subdivisions
  22360. */
  22361. readonly subdivisionsY: number;
  22362. /**
  22363. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22364. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22365. * @param chunksCount the number of subdivisions for x and y
  22366. * @param octreeBlocksSize (Default: 32)
  22367. */
  22368. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22369. /**
  22370. * Returns a height (y) value in the Worl system :
  22371. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22372. * @param x x coordinate
  22373. * @param z z coordinate
  22374. * @returns the ground y position if (x, z) are outside the ground surface.
  22375. */
  22376. getHeightAtCoordinates(x: number, z: number): number;
  22377. /**
  22378. * Returns a normalized vector (Vector3) orthogonal to the ground
  22379. * at the ground coordinates (x, z) expressed in the World system.
  22380. * @param x x coordinate
  22381. * @param z z coordinate
  22382. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22383. */
  22384. getNormalAtCoordinates(x: number, z: number): Vector3;
  22385. /**
  22386. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22387. * at the ground coordinates (x, z) expressed in the World system.
  22388. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22389. * @param x x coordinate
  22390. * @param z z coordinate
  22391. * @param ref vector to store the result
  22392. * @returns the GroundMesh.
  22393. */
  22394. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22395. /**
  22396. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22397. * if the ground has been updated.
  22398. * This can be used in the render loop.
  22399. * @returns the GroundMesh.
  22400. */
  22401. updateCoordinateHeights(): GroundMesh;
  22402. private _getFacetAt;
  22403. private _initHeightQuads;
  22404. private _computeHeightQuads;
  22405. /**
  22406. * Serializes this ground mesh
  22407. * @param serializationObject object to write serialization to
  22408. */
  22409. serialize(serializationObject: any): void;
  22410. /**
  22411. * Parses a serialized ground mesh
  22412. * @param parsedMesh the serialized mesh
  22413. * @param scene the scene to create the ground mesh in
  22414. * @returns the created ground mesh
  22415. */
  22416. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22417. }
  22418. }
  22419. declare module BABYLON {
  22420. /**
  22421. * Interface for Physics-Joint data
  22422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22423. */
  22424. export interface PhysicsJointData {
  22425. /**
  22426. * The main pivot of the joint
  22427. */
  22428. mainPivot?: Vector3;
  22429. /**
  22430. * The connected pivot of the joint
  22431. */
  22432. connectedPivot?: Vector3;
  22433. /**
  22434. * The main axis of the joint
  22435. */
  22436. mainAxis?: Vector3;
  22437. /**
  22438. * The connected axis of the joint
  22439. */
  22440. connectedAxis?: Vector3;
  22441. /**
  22442. * The collision of the joint
  22443. */
  22444. collision?: boolean;
  22445. /**
  22446. * Native Oimo/Cannon/Energy data
  22447. */
  22448. nativeParams?: any;
  22449. }
  22450. /**
  22451. * This is a holder class for the physics joint created by the physics plugin
  22452. * It holds a set of functions to control the underlying joint
  22453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22454. */
  22455. export class PhysicsJoint {
  22456. /**
  22457. * The type of the physics joint
  22458. */
  22459. type: number;
  22460. /**
  22461. * The data for the physics joint
  22462. */
  22463. jointData: PhysicsJointData;
  22464. private _physicsJoint;
  22465. protected _physicsPlugin: IPhysicsEnginePlugin;
  22466. /**
  22467. * Initializes the physics joint
  22468. * @param type The type of the physics joint
  22469. * @param jointData The data for the physics joint
  22470. */
  22471. constructor(
  22472. /**
  22473. * The type of the physics joint
  22474. */
  22475. type: number,
  22476. /**
  22477. * The data for the physics joint
  22478. */
  22479. jointData: PhysicsJointData);
  22480. /**
  22481. * Gets the physics joint
  22482. */
  22483. /**
  22484. * Sets the physics joint
  22485. */
  22486. physicsJoint: any;
  22487. /**
  22488. * Sets the physics plugin
  22489. */
  22490. physicsPlugin: IPhysicsEnginePlugin;
  22491. /**
  22492. * Execute a function that is physics-plugin specific.
  22493. * @param {Function} func the function that will be executed.
  22494. * It accepts two parameters: the physics world and the physics joint
  22495. */
  22496. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22497. /**
  22498. * Distance-Joint type
  22499. */
  22500. static DistanceJoint: number;
  22501. /**
  22502. * Hinge-Joint type
  22503. */
  22504. static HingeJoint: number;
  22505. /**
  22506. * Ball-and-Socket joint type
  22507. */
  22508. static BallAndSocketJoint: number;
  22509. /**
  22510. * Wheel-Joint type
  22511. */
  22512. static WheelJoint: number;
  22513. /**
  22514. * Slider-Joint type
  22515. */
  22516. static SliderJoint: number;
  22517. /**
  22518. * Prismatic-Joint type
  22519. */
  22520. static PrismaticJoint: number;
  22521. /**
  22522. * Universal-Joint type
  22523. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22524. */
  22525. static UniversalJoint: number;
  22526. /**
  22527. * Hinge-Joint 2 type
  22528. */
  22529. static Hinge2Joint: number;
  22530. /**
  22531. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22532. */
  22533. static PointToPointJoint: number;
  22534. /**
  22535. * Spring-Joint type
  22536. */
  22537. static SpringJoint: number;
  22538. /**
  22539. * Lock-Joint type
  22540. */
  22541. static LockJoint: number;
  22542. }
  22543. /**
  22544. * A class representing a physics distance joint
  22545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22546. */
  22547. export class DistanceJoint extends PhysicsJoint {
  22548. /**
  22549. *
  22550. * @param jointData The data for the Distance-Joint
  22551. */
  22552. constructor(jointData: DistanceJointData);
  22553. /**
  22554. * Update the predefined distance.
  22555. * @param maxDistance The maximum preferred distance
  22556. * @param minDistance The minimum preferred distance
  22557. */
  22558. updateDistance(maxDistance: number, minDistance?: number): void;
  22559. }
  22560. /**
  22561. * Represents a Motor-Enabled Joint
  22562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22563. */
  22564. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22565. /**
  22566. * Initializes the Motor-Enabled Joint
  22567. * @param type The type of the joint
  22568. * @param jointData The physica joint data for the joint
  22569. */
  22570. constructor(type: number, jointData: PhysicsJointData);
  22571. /**
  22572. * Set the motor values.
  22573. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22574. * @param force the force to apply
  22575. * @param maxForce max force for this motor.
  22576. */
  22577. setMotor(force?: number, maxForce?: number): void;
  22578. /**
  22579. * Set the motor's limits.
  22580. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22581. * @param upperLimit The upper limit of the motor
  22582. * @param lowerLimit The lower limit of the motor
  22583. */
  22584. setLimit(upperLimit: number, lowerLimit?: number): void;
  22585. }
  22586. /**
  22587. * This class represents a single physics Hinge-Joint
  22588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22589. */
  22590. export class HingeJoint extends MotorEnabledJoint {
  22591. /**
  22592. * Initializes the Hinge-Joint
  22593. * @param jointData The joint data for the Hinge-Joint
  22594. */
  22595. constructor(jointData: PhysicsJointData);
  22596. /**
  22597. * Set the motor values.
  22598. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22599. * @param {number} force the force to apply
  22600. * @param {number} maxForce max force for this motor.
  22601. */
  22602. setMotor(force?: number, maxForce?: number): void;
  22603. /**
  22604. * Set the motor's limits.
  22605. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22606. * @param upperLimit The upper limit of the motor
  22607. * @param lowerLimit The lower limit of the motor
  22608. */
  22609. setLimit(upperLimit: number, lowerLimit?: number): void;
  22610. }
  22611. /**
  22612. * This class represents a dual hinge physics joint (same as wheel joint)
  22613. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22614. */
  22615. export class Hinge2Joint extends MotorEnabledJoint {
  22616. /**
  22617. * Initializes the Hinge2-Joint
  22618. * @param jointData The joint data for the Hinge2-Joint
  22619. */
  22620. constructor(jointData: PhysicsJointData);
  22621. /**
  22622. * Set the motor values.
  22623. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22624. * @param {number} targetSpeed the speed the motor is to reach
  22625. * @param {number} maxForce max force for this motor.
  22626. * @param {motorIndex} the motor's index, 0 or 1.
  22627. */
  22628. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22629. /**
  22630. * Set the motor limits.
  22631. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22632. * @param {number} upperLimit the upper limit
  22633. * @param {number} lowerLimit lower limit
  22634. * @param {motorIndex} the motor's index, 0 or 1.
  22635. */
  22636. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22637. }
  22638. /**
  22639. * Interface for a motor enabled joint
  22640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22641. */
  22642. export interface IMotorEnabledJoint {
  22643. /**
  22644. * Physics joint
  22645. */
  22646. physicsJoint: any;
  22647. /**
  22648. * Sets the motor of the motor-enabled joint
  22649. * @param force The force of the motor
  22650. * @param maxForce The maximum force of the motor
  22651. * @param motorIndex The index of the motor
  22652. */
  22653. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22654. /**
  22655. * Sets the limit of the motor
  22656. * @param upperLimit The upper limit of the motor
  22657. * @param lowerLimit The lower limit of the motor
  22658. * @param motorIndex The index of the motor
  22659. */
  22660. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22661. }
  22662. /**
  22663. * Joint data for a Distance-Joint
  22664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22665. */
  22666. export interface DistanceJointData extends PhysicsJointData {
  22667. /**
  22668. * Max distance the 2 joint objects can be apart
  22669. */
  22670. maxDistance: number;
  22671. }
  22672. /**
  22673. * Joint data from a spring joint
  22674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22675. */
  22676. export interface SpringJointData extends PhysicsJointData {
  22677. /**
  22678. * Length of the spring
  22679. */
  22680. length: number;
  22681. /**
  22682. * Stiffness of the spring
  22683. */
  22684. stiffness: number;
  22685. /**
  22686. * Damping of the spring
  22687. */
  22688. damping: number;
  22689. /** this callback will be called when applying the force to the impostors. */
  22690. forceApplicationCallback: () => void;
  22691. }
  22692. }
  22693. declare module BABYLON {
  22694. /**
  22695. * Holds the data for the raycast result
  22696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22697. */
  22698. export class PhysicsRaycastResult {
  22699. private _hasHit;
  22700. private _hitDistance;
  22701. private _hitNormalWorld;
  22702. private _hitPointWorld;
  22703. private _rayFromWorld;
  22704. private _rayToWorld;
  22705. /**
  22706. * Gets if there was a hit
  22707. */
  22708. readonly hasHit: boolean;
  22709. /**
  22710. * Gets the distance from the hit
  22711. */
  22712. readonly hitDistance: number;
  22713. /**
  22714. * Gets the hit normal/direction in the world
  22715. */
  22716. readonly hitNormalWorld: Vector3;
  22717. /**
  22718. * Gets the hit point in the world
  22719. */
  22720. readonly hitPointWorld: Vector3;
  22721. /**
  22722. * Gets the ray "start point" of the ray in the world
  22723. */
  22724. readonly rayFromWorld: Vector3;
  22725. /**
  22726. * Gets the ray "end point" of the ray in the world
  22727. */
  22728. readonly rayToWorld: Vector3;
  22729. /**
  22730. * Sets the hit data (normal & point in world space)
  22731. * @param hitNormalWorld defines the normal in world space
  22732. * @param hitPointWorld defines the point in world space
  22733. */
  22734. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22735. /**
  22736. * Sets the distance from the start point to the hit point
  22737. * @param distance
  22738. */
  22739. setHitDistance(distance: number): void;
  22740. /**
  22741. * Calculates the distance manually
  22742. */
  22743. calculateHitDistance(): void;
  22744. /**
  22745. * Resets all the values to default
  22746. * @param from The from point on world space
  22747. * @param to The to point on world space
  22748. */
  22749. reset(from?: Vector3, to?: Vector3): void;
  22750. }
  22751. /**
  22752. * Interface for the size containing width and height
  22753. */
  22754. interface IXYZ {
  22755. /**
  22756. * X
  22757. */
  22758. x: number;
  22759. /**
  22760. * Y
  22761. */
  22762. y: number;
  22763. /**
  22764. * Z
  22765. */
  22766. z: number;
  22767. }
  22768. }
  22769. declare module BABYLON {
  22770. /**
  22771. * Interface used to describe a physics joint
  22772. */
  22773. export interface PhysicsImpostorJoint {
  22774. /** Defines the main impostor to which the joint is linked */
  22775. mainImpostor: PhysicsImpostor;
  22776. /** Defines the impostor that is connected to the main impostor using this joint */
  22777. connectedImpostor: PhysicsImpostor;
  22778. /** Defines the joint itself */
  22779. joint: PhysicsJoint;
  22780. }
  22781. /** @hidden */
  22782. export interface IPhysicsEnginePlugin {
  22783. world: any;
  22784. name: string;
  22785. setGravity(gravity: Vector3): void;
  22786. setTimeStep(timeStep: number): void;
  22787. getTimeStep(): number;
  22788. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22789. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22790. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22791. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22792. removePhysicsBody(impostor: PhysicsImpostor): void;
  22793. generateJoint(joint: PhysicsImpostorJoint): void;
  22794. removeJoint(joint: PhysicsImpostorJoint): void;
  22795. isSupported(): boolean;
  22796. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22797. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22798. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22799. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22800. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22801. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22802. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22803. getBodyMass(impostor: PhysicsImpostor): number;
  22804. getBodyFriction(impostor: PhysicsImpostor): number;
  22805. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22806. getBodyRestitution(impostor: PhysicsImpostor): number;
  22807. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22808. getBodyPressure?(impostor: PhysicsImpostor): number;
  22809. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22810. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22811. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22812. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22813. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22814. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22815. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22816. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22817. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22818. sleepBody(impostor: PhysicsImpostor): void;
  22819. wakeUpBody(impostor: PhysicsImpostor): void;
  22820. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22821. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22822. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22823. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22824. getRadius(impostor: PhysicsImpostor): number;
  22825. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22826. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22827. dispose(): void;
  22828. }
  22829. /**
  22830. * Interface used to define a physics engine
  22831. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22832. */
  22833. export interface IPhysicsEngine {
  22834. /**
  22835. * Gets the gravity vector used by the simulation
  22836. */
  22837. gravity: Vector3;
  22838. /**
  22839. * Sets the gravity vector used by the simulation
  22840. * @param gravity defines the gravity vector to use
  22841. */
  22842. setGravity(gravity: Vector3): void;
  22843. /**
  22844. * Set the time step of the physics engine.
  22845. * Default is 1/60.
  22846. * To slow it down, enter 1/600 for example.
  22847. * To speed it up, 1/30
  22848. * @param newTimeStep the new timestep to apply to this world.
  22849. */
  22850. setTimeStep(newTimeStep: number): void;
  22851. /**
  22852. * Get the time step of the physics engine.
  22853. * @returns the current time step
  22854. */
  22855. getTimeStep(): number;
  22856. /**
  22857. * Release all resources
  22858. */
  22859. dispose(): void;
  22860. /**
  22861. * Gets the name of the current physics plugin
  22862. * @returns the name of the plugin
  22863. */
  22864. getPhysicsPluginName(): string;
  22865. /**
  22866. * Adding a new impostor for the impostor tracking.
  22867. * This will be done by the impostor itself.
  22868. * @param impostor the impostor to add
  22869. */
  22870. addImpostor(impostor: PhysicsImpostor): void;
  22871. /**
  22872. * Remove an impostor from the engine.
  22873. * This impostor and its mesh will not longer be updated by the physics engine.
  22874. * @param impostor the impostor to remove
  22875. */
  22876. removeImpostor(impostor: PhysicsImpostor): void;
  22877. /**
  22878. * Add a joint to the physics engine
  22879. * @param mainImpostor defines the main impostor to which the joint is added.
  22880. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22881. * @param joint defines the joint that will connect both impostors.
  22882. */
  22883. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22884. /**
  22885. * Removes a joint from the simulation
  22886. * @param mainImpostor defines the impostor used with the joint
  22887. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22888. * @param joint defines the joint to remove
  22889. */
  22890. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22891. /**
  22892. * Gets the current plugin used to run the simulation
  22893. * @returns current plugin
  22894. */
  22895. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22896. /**
  22897. * Gets the list of physic impostors
  22898. * @returns an array of PhysicsImpostor
  22899. */
  22900. getImpostors(): Array<PhysicsImpostor>;
  22901. /**
  22902. * Gets the impostor for a physics enabled object
  22903. * @param object defines the object impersonated by the impostor
  22904. * @returns the PhysicsImpostor or null if not found
  22905. */
  22906. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22907. /**
  22908. * Gets the impostor for a physics body object
  22909. * @param body defines physics body used by the impostor
  22910. * @returns the PhysicsImpostor or null if not found
  22911. */
  22912. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22913. /**
  22914. * Does a raycast in the physics world
  22915. * @param from when should the ray start?
  22916. * @param to when should the ray end?
  22917. * @returns PhysicsRaycastResult
  22918. */
  22919. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22920. /**
  22921. * Called by the scene. No need to call it.
  22922. * @param delta defines the timespam between frames
  22923. */
  22924. _step(delta: number): void;
  22925. }
  22926. }
  22927. declare module BABYLON {
  22928. /**
  22929. * The interface for the physics imposter parameters
  22930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22931. */
  22932. export interface PhysicsImpostorParameters {
  22933. /**
  22934. * The mass of the physics imposter
  22935. */
  22936. mass: number;
  22937. /**
  22938. * The friction of the physics imposter
  22939. */
  22940. friction?: number;
  22941. /**
  22942. * The coefficient of restitution of the physics imposter
  22943. */
  22944. restitution?: number;
  22945. /**
  22946. * The native options of the physics imposter
  22947. */
  22948. nativeOptions?: any;
  22949. /**
  22950. * Specifies if the parent should be ignored
  22951. */
  22952. ignoreParent?: boolean;
  22953. /**
  22954. * Specifies if bi-directional transformations should be disabled
  22955. */
  22956. disableBidirectionalTransformation?: boolean;
  22957. /**
  22958. * The pressure inside the physics imposter, soft object only
  22959. */
  22960. pressure?: number;
  22961. /**
  22962. * The stiffness the physics imposter, soft object only
  22963. */
  22964. stiffness?: number;
  22965. /**
  22966. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22967. */
  22968. velocityIterations?: number;
  22969. /**
  22970. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22971. */
  22972. positionIterations?: number;
  22973. /**
  22974. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22975. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22976. * Add to fix multiple points
  22977. */
  22978. fixedPoints?: number;
  22979. /**
  22980. * The collision margin around a soft object
  22981. */
  22982. margin?: number;
  22983. /**
  22984. * The collision margin around a soft object
  22985. */
  22986. damping?: number;
  22987. /**
  22988. * The path for a rope based on an extrusion
  22989. */
  22990. path?: any;
  22991. /**
  22992. * The shape of an extrusion used for a rope based on an extrusion
  22993. */
  22994. shape?: any;
  22995. }
  22996. /**
  22997. * Interface for a physics-enabled object
  22998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22999. */
  23000. export interface IPhysicsEnabledObject {
  23001. /**
  23002. * The position of the physics-enabled object
  23003. */
  23004. position: Vector3;
  23005. /**
  23006. * The rotation of the physics-enabled object
  23007. */
  23008. rotationQuaternion: Nullable<Quaternion>;
  23009. /**
  23010. * The scale of the physics-enabled object
  23011. */
  23012. scaling: Vector3;
  23013. /**
  23014. * The rotation of the physics-enabled object
  23015. */
  23016. rotation?: Vector3;
  23017. /**
  23018. * The parent of the physics-enabled object
  23019. */
  23020. parent?: any;
  23021. /**
  23022. * The bounding info of the physics-enabled object
  23023. * @returns The bounding info of the physics-enabled object
  23024. */
  23025. getBoundingInfo(): BoundingInfo;
  23026. /**
  23027. * Computes the world matrix
  23028. * @param force Specifies if the world matrix should be computed by force
  23029. * @returns A world matrix
  23030. */
  23031. computeWorldMatrix(force: boolean): Matrix;
  23032. /**
  23033. * Gets the world matrix
  23034. * @returns A world matrix
  23035. */
  23036. getWorldMatrix?(): Matrix;
  23037. /**
  23038. * Gets the child meshes
  23039. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23040. * @returns An array of abstract meshes
  23041. */
  23042. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23043. /**
  23044. * Gets the vertex data
  23045. * @param kind The type of vertex data
  23046. * @returns A nullable array of numbers, or a float32 array
  23047. */
  23048. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23049. /**
  23050. * Gets the indices from the mesh
  23051. * @returns A nullable array of index arrays
  23052. */
  23053. getIndices?(): Nullable<IndicesArray>;
  23054. /**
  23055. * Gets the scene from the mesh
  23056. * @returns the indices array or null
  23057. */
  23058. getScene?(): Scene;
  23059. /**
  23060. * Gets the absolute position from the mesh
  23061. * @returns the absolute position
  23062. */
  23063. getAbsolutePosition(): Vector3;
  23064. /**
  23065. * Gets the absolute pivot point from the mesh
  23066. * @returns the absolute pivot point
  23067. */
  23068. getAbsolutePivotPoint(): Vector3;
  23069. /**
  23070. * Rotates the mesh
  23071. * @param axis The axis of rotation
  23072. * @param amount The amount of rotation
  23073. * @param space The space of the rotation
  23074. * @returns The rotation transform node
  23075. */
  23076. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23077. /**
  23078. * Translates the mesh
  23079. * @param axis The axis of translation
  23080. * @param distance The distance of translation
  23081. * @param space The space of the translation
  23082. * @returns The transform node
  23083. */
  23084. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23085. /**
  23086. * Sets the absolute position of the mesh
  23087. * @param absolutePosition The absolute position of the mesh
  23088. * @returns The transform node
  23089. */
  23090. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23091. /**
  23092. * Gets the class name of the mesh
  23093. * @returns The class name
  23094. */
  23095. getClassName(): string;
  23096. }
  23097. /**
  23098. * Represents a physics imposter
  23099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23100. */
  23101. export class PhysicsImpostor {
  23102. /**
  23103. * The physics-enabled object used as the physics imposter
  23104. */
  23105. object: IPhysicsEnabledObject;
  23106. /**
  23107. * The type of the physics imposter
  23108. */
  23109. type: number;
  23110. private _options;
  23111. private _scene?;
  23112. /**
  23113. * The default object size of the imposter
  23114. */
  23115. static DEFAULT_OBJECT_SIZE: Vector3;
  23116. /**
  23117. * The identity quaternion of the imposter
  23118. */
  23119. static IDENTITY_QUATERNION: Quaternion;
  23120. /** @hidden */
  23121. _pluginData: any;
  23122. private _physicsEngine;
  23123. private _physicsBody;
  23124. private _bodyUpdateRequired;
  23125. private _onBeforePhysicsStepCallbacks;
  23126. private _onAfterPhysicsStepCallbacks;
  23127. /** @hidden */
  23128. _onPhysicsCollideCallbacks: Array<{
  23129. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23130. otherImpostors: Array<PhysicsImpostor>;
  23131. }>;
  23132. private _deltaPosition;
  23133. private _deltaRotation;
  23134. private _deltaRotationConjugated;
  23135. /** @hidden */
  23136. _isFromLine: boolean;
  23137. private _parent;
  23138. private _isDisposed;
  23139. private static _tmpVecs;
  23140. private static _tmpQuat;
  23141. /**
  23142. * Specifies if the physics imposter is disposed
  23143. */
  23144. readonly isDisposed: boolean;
  23145. /**
  23146. * Gets the mass of the physics imposter
  23147. */
  23148. mass: number;
  23149. /**
  23150. * Gets the coefficient of friction
  23151. */
  23152. /**
  23153. * Sets the coefficient of friction
  23154. */
  23155. friction: number;
  23156. /**
  23157. * Gets the coefficient of restitution
  23158. */
  23159. /**
  23160. * Sets the coefficient of restitution
  23161. */
  23162. restitution: number;
  23163. /**
  23164. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23165. */
  23166. /**
  23167. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23168. */
  23169. pressure: number;
  23170. /**
  23171. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23172. */
  23173. /**
  23174. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23175. */
  23176. stiffness: number;
  23177. /**
  23178. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23179. */
  23180. /**
  23181. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23182. */
  23183. velocityIterations: number;
  23184. /**
  23185. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23186. */
  23187. /**
  23188. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23189. */
  23190. positionIterations: number;
  23191. /**
  23192. * The unique id of the physics imposter
  23193. * set by the physics engine when adding this impostor to the array
  23194. */
  23195. uniqueId: number;
  23196. /**
  23197. * @hidden
  23198. */
  23199. soft: boolean;
  23200. /**
  23201. * @hidden
  23202. */
  23203. segments: number;
  23204. private _joints;
  23205. /**
  23206. * Initializes the physics imposter
  23207. * @param object The physics-enabled object used as the physics imposter
  23208. * @param type The type of the physics imposter
  23209. * @param _options The options for the physics imposter
  23210. * @param _scene The Babylon scene
  23211. */
  23212. constructor(
  23213. /**
  23214. * The physics-enabled object used as the physics imposter
  23215. */
  23216. object: IPhysicsEnabledObject,
  23217. /**
  23218. * The type of the physics imposter
  23219. */
  23220. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23221. /**
  23222. * This function will completly initialize this impostor.
  23223. * It will create a new body - but only if this mesh has no parent.
  23224. * If it has, this impostor will not be used other than to define the impostor
  23225. * of the child mesh.
  23226. * @hidden
  23227. */
  23228. _init(): void;
  23229. private _getPhysicsParent;
  23230. /**
  23231. * Should a new body be generated.
  23232. * @returns boolean specifying if body initialization is required
  23233. */
  23234. isBodyInitRequired(): boolean;
  23235. /**
  23236. * Sets the updated scaling
  23237. * @param updated Specifies if the scaling is updated
  23238. */
  23239. setScalingUpdated(): void;
  23240. /**
  23241. * Force a regeneration of this or the parent's impostor's body.
  23242. * Use under cautious - This will remove all joints already implemented.
  23243. */
  23244. forceUpdate(): void;
  23245. /**
  23246. * Gets the body that holds this impostor. Either its own, or its parent.
  23247. */
  23248. /**
  23249. * Set the physics body. Used mainly by the physics engine/plugin
  23250. */
  23251. physicsBody: any;
  23252. /**
  23253. * Get the parent of the physics imposter
  23254. * @returns Physics imposter or null
  23255. */
  23256. /**
  23257. * Sets the parent of the physics imposter
  23258. */
  23259. parent: Nullable<PhysicsImpostor>;
  23260. /**
  23261. * Resets the update flags
  23262. */
  23263. resetUpdateFlags(): void;
  23264. /**
  23265. * Gets the object extend size
  23266. * @returns the object extend size
  23267. */
  23268. getObjectExtendSize(): Vector3;
  23269. /**
  23270. * Gets the object center
  23271. * @returns The object center
  23272. */
  23273. getObjectCenter(): Vector3;
  23274. /**
  23275. * Get a specific parametes from the options parameter
  23276. * @param paramName The object parameter name
  23277. * @returns The object parameter
  23278. */
  23279. getParam(paramName: string): any;
  23280. /**
  23281. * Sets a specific parameter in the options given to the physics plugin
  23282. * @param paramName The parameter name
  23283. * @param value The value of the parameter
  23284. */
  23285. setParam(paramName: string, value: number): void;
  23286. /**
  23287. * Specifically change the body's mass option. Won't recreate the physics body object
  23288. * @param mass The mass of the physics imposter
  23289. */
  23290. setMass(mass: number): void;
  23291. /**
  23292. * Gets the linear velocity
  23293. * @returns linear velocity or null
  23294. */
  23295. getLinearVelocity(): Nullable<Vector3>;
  23296. /**
  23297. * Sets the linear velocity
  23298. * @param velocity linear velocity or null
  23299. */
  23300. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23301. /**
  23302. * Gets the angular velocity
  23303. * @returns angular velocity or null
  23304. */
  23305. getAngularVelocity(): Nullable<Vector3>;
  23306. /**
  23307. * Sets the angular velocity
  23308. * @param velocity The velocity or null
  23309. */
  23310. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23311. /**
  23312. * Execute a function with the physics plugin native code
  23313. * Provide a function the will have two variables - the world object and the physics body object
  23314. * @param func The function to execute with the physics plugin native code
  23315. */
  23316. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23317. /**
  23318. * Register a function that will be executed before the physics world is stepping forward
  23319. * @param func The function to execute before the physics world is stepped forward
  23320. */
  23321. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23322. /**
  23323. * Unregister a function that will be executed before the physics world is stepping forward
  23324. * @param func The function to execute before the physics world is stepped forward
  23325. */
  23326. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23327. /**
  23328. * Register a function that will be executed after the physics step
  23329. * @param func The function to execute after physics step
  23330. */
  23331. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23332. /**
  23333. * Unregisters a function that will be executed after the physics step
  23334. * @param func The function to execute after physics step
  23335. */
  23336. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23337. /**
  23338. * register a function that will be executed when this impostor collides against a different body
  23339. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23340. * @param func Callback that is executed on collision
  23341. */
  23342. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23343. /**
  23344. * Unregisters the physics imposter on contact
  23345. * @param collideAgainst The physics object to collide against
  23346. * @param func Callback to execute on collision
  23347. */
  23348. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23349. private _tmpQuat;
  23350. private _tmpQuat2;
  23351. /**
  23352. * Get the parent rotation
  23353. * @returns The parent rotation
  23354. */
  23355. getParentsRotation(): Quaternion;
  23356. /**
  23357. * this function is executed by the physics engine.
  23358. */
  23359. beforeStep: () => void;
  23360. /**
  23361. * this function is executed by the physics engine
  23362. */
  23363. afterStep: () => void;
  23364. /**
  23365. * Legacy collision detection event support
  23366. */
  23367. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23368. /**
  23369. * event and body object due to cannon's event-based architecture.
  23370. */
  23371. onCollide: (e: {
  23372. body: any;
  23373. }) => void;
  23374. /**
  23375. * Apply a force
  23376. * @param force The force to apply
  23377. * @param contactPoint The contact point for the force
  23378. * @returns The physics imposter
  23379. */
  23380. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23381. /**
  23382. * Apply an impulse
  23383. * @param force The impulse force
  23384. * @param contactPoint The contact point for the impulse force
  23385. * @returns The physics imposter
  23386. */
  23387. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23388. /**
  23389. * A help function to create a joint
  23390. * @param otherImpostor A physics imposter used to create a joint
  23391. * @param jointType The type of joint
  23392. * @param jointData The data for the joint
  23393. * @returns The physics imposter
  23394. */
  23395. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23396. /**
  23397. * Add a joint to this impostor with a different impostor
  23398. * @param otherImpostor A physics imposter used to add a joint
  23399. * @param joint The joint to add
  23400. * @returns The physics imposter
  23401. */
  23402. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23403. /**
  23404. * Add an anchor to a cloth impostor
  23405. * @param otherImpostor rigid impostor to anchor to
  23406. * @param width ratio across width from 0 to 1
  23407. * @param height ratio up height from 0 to 1
  23408. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23409. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23410. * @returns impostor the soft imposter
  23411. */
  23412. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23413. /**
  23414. * Add a hook to a rope impostor
  23415. * @param otherImpostor rigid impostor to anchor to
  23416. * @param length ratio across rope from 0 to 1
  23417. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23418. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23419. * @returns impostor the rope imposter
  23420. */
  23421. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23422. /**
  23423. * Will keep this body still, in a sleep mode.
  23424. * @returns the physics imposter
  23425. */
  23426. sleep(): PhysicsImpostor;
  23427. /**
  23428. * Wake the body up.
  23429. * @returns The physics imposter
  23430. */
  23431. wakeUp(): PhysicsImpostor;
  23432. /**
  23433. * Clones the physics imposter
  23434. * @param newObject The physics imposter clones to this physics-enabled object
  23435. * @returns A nullable physics imposter
  23436. */
  23437. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23438. /**
  23439. * Disposes the physics imposter
  23440. */
  23441. dispose(): void;
  23442. /**
  23443. * Sets the delta position
  23444. * @param position The delta position amount
  23445. */
  23446. setDeltaPosition(position: Vector3): void;
  23447. /**
  23448. * Sets the delta rotation
  23449. * @param rotation The delta rotation amount
  23450. */
  23451. setDeltaRotation(rotation: Quaternion): void;
  23452. /**
  23453. * Gets the box size of the physics imposter and stores the result in the input parameter
  23454. * @param result Stores the box size
  23455. * @returns The physics imposter
  23456. */
  23457. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23458. /**
  23459. * Gets the radius of the physics imposter
  23460. * @returns Radius of the physics imposter
  23461. */
  23462. getRadius(): number;
  23463. /**
  23464. * Sync a bone with this impostor
  23465. * @param bone The bone to sync to the impostor.
  23466. * @param boneMesh The mesh that the bone is influencing.
  23467. * @param jointPivot The pivot of the joint / bone in local space.
  23468. * @param distToJoint Optional distance from the impostor to the joint.
  23469. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23470. */
  23471. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23472. /**
  23473. * Sync impostor to a bone
  23474. * @param bone The bone that the impostor will be synced to.
  23475. * @param boneMesh The mesh that the bone is influencing.
  23476. * @param jointPivot The pivot of the joint / bone in local space.
  23477. * @param distToJoint Optional distance from the impostor to the joint.
  23478. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23479. * @param boneAxis Optional vector3 axis the bone is aligned with
  23480. */
  23481. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23482. /**
  23483. * No-Imposter type
  23484. */
  23485. static NoImpostor: number;
  23486. /**
  23487. * Sphere-Imposter type
  23488. */
  23489. static SphereImpostor: number;
  23490. /**
  23491. * Box-Imposter type
  23492. */
  23493. static BoxImpostor: number;
  23494. /**
  23495. * Plane-Imposter type
  23496. */
  23497. static PlaneImpostor: number;
  23498. /**
  23499. * Mesh-imposter type
  23500. */
  23501. static MeshImpostor: number;
  23502. /**
  23503. * Capsule-Impostor type (Ammo.js plugin only)
  23504. */
  23505. static CapsuleImpostor: number;
  23506. /**
  23507. * Cylinder-Imposter type
  23508. */
  23509. static CylinderImpostor: number;
  23510. /**
  23511. * Particle-Imposter type
  23512. */
  23513. static ParticleImpostor: number;
  23514. /**
  23515. * Heightmap-Imposter type
  23516. */
  23517. static HeightmapImpostor: number;
  23518. /**
  23519. * ConvexHull-Impostor type (Ammo.js plugin only)
  23520. */
  23521. static ConvexHullImpostor: number;
  23522. /**
  23523. * Rope-Imposter type
  23524. */
  23525. static RopeImpostor: number;
  23526. /**
  23527. * Cloth-Imposter type
  23528. */
  23529. static ClothImpostor: number;
  23530. /**
  23531. * Softbody-Imposter type
  23532. */
  23533. static SoftbodyImpostor: number;
  23534. }
  23535. }
  23536. declare module BABYLON {
  23537. /**
  23538. * @hidden
  23539. **/
  23540. export class _CreationDataStorage {
  23541. closePath?: boolean;
  23542. closeArray?: boolean;
  23543. idx: number[];
  23544. dashSize: number;
  23545. gapSize: number;
  23546. path3D: Path3D;
  23547. pathArray: Vector3[][];
  23548. arc: number;
  23549. radius: number;
  23550. cap: number;
  23551. tessellation: number;
  23552. }
  23553. /**
  23554. * @hidden
  23555. **/
  23556. class _InstanceDataStorage {
  23557. visibleInstances: any;
  23558. batchCache: _InstancesBatch;
  23559. instancesBufferSize: number;
  23560. instancesBuffer: Nullable<Buffer>;
  23561. instancesData: Float32Array;
  23562. overridenInstanceCount: number;
  23563. isFrozen: boolean;
  23564. previousBatch: Nullable<_InstancesBatch>;
  23565. hardwareInstancedRendering: boolean;
  23566. sideOrientation: number;
  23567. }
  23568. /**
  23569. * @hidden
  23570. **/
  23571. export class _InstancesBatch {
  23572. mustReturn: boolean;
  23573. visibleInstances: Nullable<InstancedMesh[]>[];
  23574. renderSelf: boolean[];
  23575. hardwareInstancedRendering: boolean[];
  23576. }
  23577. /**
  23578. * Class used to represent renderable models
  23579. */
  23580. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23581. /**
  23582. * Mesh side orientation : usually the external or front surface
  23583. */
  23584. static readonly FRONTSIDE: number;
  23585. /**
  23586. * Mesh side orientation : usually the internal or back surface
  23587. */
  23588. static readonly BACKSIDE: number;
  23589. /**
  23590. * Mesh side orientation : both internal and external or front and back surfaces
  23591. */
  23592. static readonly DOUBLESIDE: number;
  23593. /**
  23594. * Mesh side orientation : by default, `FRONTSIDE`
  23595. */
  23596. static readonly DEFAULTSIDE: number;
  23597. /**
  23598. * Mesh cap setting : no cap
  23599. */
  23600. static readonly NO_CAP: number;
  23601. /**
  23602. * Mesh cap setting : one cap at the beginning of the mesh
  23603. */
  23604. static readonly CAP_START: number;
  23605. /**
  23606. * Mesh cap setting : one cap at the end of the mesh
  23607. */
  23608. static readonly CAP_END: number;
  23609. /**
  23610. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23611. */
  23612. static readonly CAP_ALL: number;
  23613. /**
  23614. * Mesh pattern setting : no flip or rotate
  23615. */
  23616. static readonly NO_FLIP: number;
  23617. /**
  23618. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23619. */
  23620. static readonly FLIP_TILE: number;
  23621. /**
  23622. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23623. */
  23624. static readonly ROTATE_TILE: number;
  23625. /**
  23626. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23627. */
  23628. static readonly FLIP_ROW: number;
  23629. /**
  23630. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23631. */
  23632. static readonly ROTATE_ROW: number;
  23633. /**
  23634. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23635. */
  23636. static readonly FLIP_N_ROTATE_TILE: number;
  23637. /**
  23638. * Mesh pattern setting : rotate pattern and rotate
  23639. */
  23640. static readonly FLIP_N_ROTATE_ROW: number;
  23641. /**
  23642. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23643. */
  23644. static readonly CENTER: number;
  23645. /**
  23646. * Mesh tile positioning : part tiles on left
  23647. */
  23648. static readonly LEFT: number;
  23649. /**
  23650. * Mesh tile positioning : part tiles on right
  23651. */
  23652. static readonly RIGHT: number;
  23653. /**
  23654. * Mesh tile positioning : part tiles on top
  23655. */
  23656. static readonly TOP: number;
  23657. /**
  23658. * Mesh tile positioning : part tiles on bottom
  23659. */
  23660. static readonly BOTTOM: number;
  23661. /**
  23662. * Gets the default side orientation.
  23663. * @param orientation the orientation to value to attempt to get
  23664. * @returns the default orientation
  23665. * @hidden
  23666. */
  23667. static _GetDefaultSideOrientation(orientation?: number): number;
  23668. private _internalMeshDataInfo;
  23669. /**
  23670. * An event triggered before rendering the mesh
  23671. */
  23672. readonly onBeforeRenderObservable: Observable<Mesh>;
  23673. /**
  23674. * An event triggered before binding the mesh
  23675. */
  23676. readonly onBeforeBindObservable: Observable<Mesh>;
  23677. /**
  23678. * An event triggered after rendering the mesh
  23679. */
  23680. readonly onAfterRenderObservable: Observable<Mesh>;
  23681. /**
  23682. * An event triggered before drawing the mesh
  23683. */
  23684. readonly onBeforeDrawObservable: Observable<Mesh>;
  23685. private _onBeforeDrawObserver;
  23686. /**
  23687. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23688. */
  23689. onBeforeDraw: () => void;
  23690. readonly hasInstances: boolean;
  23691. /**
  23692. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23693. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23694. */
  23695. delayLoadState: number;
  23696. /**
  23697. * Gets the list of instances created from this mesh
  23698. * it is not supposed to be modified manually.
  23699. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23700. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23701. */
  23702. instances: InstancedMesh[];
  23703. /**
  23704. * Gets the file containing delay loading data for this mesh
  23705. */
  23706. delayLoadingFile: string;
  23707. /** @hidden */
  23708. _binaryInfo: any;
  23709. /**
  23710. * User defined function used to change how LOD level selection is done
  23711. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23712. */
  23713. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23714. /**
  23715. * Gets or sets the morph target manager
  23716. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23717. */
  23718. morphTargetManager: Nullable<MorphTargetManager>;
  23719. /** @hidden */
  23720. _creationDataStorage: Nullable<_CreationDataStorage>;
  23721. /** @hidden */
  23722. _geometry: Nullable<Geometry>;
  23723. /** @hidden */
  23724. _delayInfo: Array<string>;
  23725. /** @hidden */
  23726. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23727. /** @hidden */
  23728. _instanceDataStorage: _InstanceDataStorage;
  23729. private _effectiveMaterial;
  23730. /** @hidden */
  23731. _shouldGenerateFlatShading: boolean;
  23732. /** @hidden */
  23733. _originalBuilderSideOrientation: number;
  23734. /**
  23735. * Use this property to change the original side orientation defined at construction time
  23736. */
  23737. overrideMaterialSideOrientation: Nullable<number>;
  23738. /**
  23739. * Gets the source mesh (the one used to clone this one from)
  23740. */
  23741. readonly source: Nullable<Mesh>;
  23742. /**
  23743. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23744. */
  23745. isUnIndexed: boolean;
  23746. /**
  23747. * @constructor
  23748. * @param name The value used by scene.getMeshByName() to do a lookup.
  23749. * @param scene The scene to add this mesh to.
  23750. * @param parent The parent of this mesh, if it has one
  23751. * @param source An optional Mesh from which geometry is shared, cloned.
  23752. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23753. * When false, achieved by calling a clone(), also passing False.
  23754. * This will make creation of children, recursive.
  23755. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23756. */
  23757. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23758. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23759. /**
  23760. * Gets the class name
  23761. * @returns the string "Mesh".
  23762. */
  23763. getClassName(): string;
  23764. /** @hidden */
  23765. readonly _isMesh: boolean;
  23766. /**
  23767. * Returns a description of this mesh
  23768. * @param fullDetails define if full details about this mesh must be used
  23769. * @returns a descriptive string representing this mesh
  23770. */
  23771. toString(fullDetails?: boolean): string;
  23772. /** @hidden */
  23773. _unBindEffect(): void;
  23774. /**
  23775. * Gets a boolean indicating if this mesh has LOD
  23776. */
  23777. readonly hasLODLevels: boolean;
  23778. /**
  23779. * Gets the list of MeshLODLevel associated with the current mesh
  23780. * @returns an array of MeshLODLevel
  23781. */
  23782. getLODLevels(): MeshLODLevel[];
  23783. private _sortLODLevels;
  23784. /**
  23785. * Add a mesh as LOD level triggered at the given distance.
  23786. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23787. * @param distance The distance from the center of the object to show this level
  23788. * @param mesh The mesh to be added as LOD level (can be null)
  23789. * @return This mesh (for chaining)
  23790. */
  23791. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23792. /**
  23793. * Returns the LOD level mesh at the passed distance or null if not found.
  23794. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23795. * @param distance The distance from the center of the object to show this level
  23796. * @returns a Mesh or `null`
  23797. */
  23798. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23799. /**
  23800. * Remove a mesh from the LOD array
  23801. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23802. * @param mesh defines the mesh to be removed
  23803. * @return This mesh (for chaining)
  23804. */
  23805. removeLODLevel(mesh: Mesh): Mesh;
  23806. /**
  23807. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23808. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23809. * @param camera defines the camera to use to compute distance
  23810. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23811. * @return This mesh (for chaining)
  23812. */
  23813. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23814. /**
  23815. * Gets the mesh internal Geometry object
  23816. */
  23817. readonly geometry: Nullable<Geometry>;
  23818. /**
  23819. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23820. * @returns the total number of vertices
  23821. */
  23822. getTotalVertices(): number;
  23823. /**
  23824. * Returns the content of an associated vertex buffer
  23825. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23826. * - VertexBuffer.PositionKind
  23827. * - VertexBuffer.UVKind
  23828. * - VertexBuffer.UV2Kind
  23829. * - VertexBuffer.UV3Kind
  23830. * - VertexBuffer.UV4Kind
  23831. * - VertexBuffer.UV5Kind
  23832. * - VertexBuffer.UV6Kind
  23833. * - VertexBuffer.ColorKind
  23834. * - VertexBuffer.MatricesIndicesKind
  23835. * - VertexBuffer.MatricesIndicesExtraKind
  23836. * - VertexBuffer.MatricesWeightsKind
  23837. * - VertexBuffer.MatricesWeightsExtraKind
  23838. * @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
  23839. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23840. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23841. */
  23842. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23843. /**
  23844. * Returns the mesh VertexBuffer object from the requested `kind`
  23845. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23846. * - VertexBuffer.PositionKind
  23847. * - VertexBuffer.NormalKind
  23848. * - VertexBuffer.UVKind
  23849. * - VertexBuffer.UV2Kind
  23850. * - VertexBuffer.UV3Kind
  23851. * - VertexBuffer.UV4Kind
  23852. * - VertexBuffer.UV5Kind
  23853. * - VertexBuffer.UV6Kind
  23854. * - VertexBuffer.ColorKind
  23855. * - VertexBuffer.MatricesIndicesKind
  23856. * - VertexBuffer.MatricesIndicesExtraKind
  23857. * - VertexBuffer.MatricesWeightsKind
  23858. * - VertexBuffer.MatricesWeightsExtraKind
  23859. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23860. */
  23861. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23862. /**
  23863. * Tests if a specific vertex buffer is associated with this mesh
  23864. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23865. * - VertexBuffer.PositionKind
  23866. * - VertexBuffer.NormalKind
  23867. * - VertexBuffer.UVKind
  23868. * - VertexBuffer.UV2Kind
  23869. * - VertexBuffer.UV3Kind
  23870. * - VertexBuffer.UV4Kind
  23871. * - VertexBuffer.UV5Kind
  23872. * - VertexBuffer.UV6Kind
  23873. * - VertexBuffer.ColorKind
  23874. * - VertexBuffer.MatricesIndicesKind
  23875. * - VertexBuffer.MatricesIndicesExtraKind
  23876. * - VertexBuffer.MatricesWeightsKind
  23877. * - VertexBuffer.MatricesWeightsExtraKind
  23878. * @returns a boolean
  23879. */
  23880. isVerticesDataPresent(kind: string): boolean;
  23881. /**
  23882. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23883. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23884. * - VertexBuffer.PositionKind
  23885. * - VertexBuffer.UVKind
  23886. * - VertexBuffer.UV2Kind
  23887. * - VertexBuffer.UV3Kind
  23888. * - VertexBuffer.UV4Kind
  23889. * - VertexBuffer.UV5Kind
  23890. * - VertexBuffer.UV6Kind
  23891. * - VertexBuffer.ColorKind
  23892. * - VertexBuffer.MatricesIndicesKind
  23893. * - VertexBuffer.MatricesIndicesExtraKind
  23894. * - VertexBuffer.MatricesWeightsKind
  23895. * - VertexBuffer.MatricesWeightsExtraKind
  23896. * @returns a boolean
  23897. */
  23898. isVertexBufferUpdatable(kind: string): boolean;
  23899. /**
  23900. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23901. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23902. * - VertexBuffer.PositionKind
  23903. * - VertexBuffer.NormalKind
  23904. * - VertexBuffer.UVKind
  23905. * - VertexBuffer.UV2Kind
  23906. * - VertexBuffer.UV3Kind
  23907. * - VertexBuffer.UV4Kind
  23908. * - VertexBuffer.UV5Kind
  23909. * - VertexBuffer.UV6Kind
  23910. * - VertexBuffer.ColorKind
  23911. * - VertexBuffer.MatricesIndicesKind
  23912. * - VertexBuffer.MatricesIndicesExtraKind
  23913. * - VertexBuffer.MatricesWeightsKind
  23914. * - VertexBuffer.MatricesWeightsExtraKind
  23915. * @returns an array of strings
  23916. */
  23917. getVerticesDataKinds(): string[];
  23918. /**
  23919. * Returns a positive integer : the total number of indices in this mesh geometry.
  23920. * @returns the numner of indices or zero if the mesh has no geometry.
  23921. */
  23922. getTotalIndices(): number;
  23923. /**
  23924. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23925. * @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.
  23926. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23927. * @returns the indices array or an empty array if the mesh has no geometry
  23928. */
  23929. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23930. readonly isBlocked: boolean;
  23931. /**
  23932. * Determine if the current mesh is ready to be rendered
  23933. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23934. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23935. * @returns true if all associated assets are ready (material, textures, shaders)
  23936. */
  23937. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23938. /**
  23939. * 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.
  23940. */
  23941. readonly areNormalsFrozen: boolean;
  23942. /**
  23943. * 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.
  23944. * @returns the current mesh
  23945. */
  23946. freezeNormals(): Mesh;
  23947. /**
  23948. * 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
  23949. * @returns the current mesh
  23950. */
  23951. unfreezeNormals(): Mesh;
  23952. /**
  23953. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23954. */
  23955. overridenInstanceCount: number;
  23956. /** @hidden */
  23957. _preActivate(): Mesh;
  23958. /** @hidden */
  23959. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23960. /** @hidden */
  23961. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23962. /**
  23963. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23964. * This means the mesh underlying bounding box and sphere are recomputed.
  23965. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23966. * @returns the current mesh
  23967. */
  23968. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23969. /** @hidden */
  23970. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23971. /**
  23972. * This function will subdivide the mesh into multiple submeshes
  23973. * @param count defines the expected number of submeshes
  23974. */
  23975. subdivide(count: number): void;
  23976. /**
  23977. * Copy a FloatArray into a specific associated vertex buffer
  23978. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23979. * - VertexBuffer.PositionKind
  23980. * - VertexBuffer.UVKind
  23981. * - VertexBuffer.UV2Kind
  23982. * - VertexBuffer.UV3Kind
  23983. * - VertexBuffer.UV4Kind
  23984. * - VertexBuffer.UV5Kind
  23985. * - VertexBuffer.UV6Kind
  23986. * - VertexBuffer.ColorKind
  23987. * - VertexBuffer.MatricesIndicesKind
  23988. * - VertexBuffer.MatricesIndicesExtraKind
  23989. * - VertexBuffer.MatricesWeightsKind
  23990. * - VertexBuffer.MatricesWeightsExtraKind
  23991. * @param data defines the data source
  23992. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23993. * @param stride defines the data stride size (can be null)
  23994. * @returns the current mesh
  23995. */
  23996. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23997. /**
  23998. * Flags an associated vertex buffer as updatable
  23999. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24000. * - VertexBuffer.PositionKind
  24001. * - VertexBuffer.UVKind
  24002. * - VertexBuffer.UV2Kind
  24003. * - VertexBuffer.UV3Kind
  24004. * - VertexBuffer.UV4Kind
  24005. * - VertexBuffer.UV5Kind
  24006. * - VertexBuffer.UV6Kind
  24007. * - VertexBuffer.ColorKind
  24008. * - VertexBuffer.MatricesIndicesKind
  24009. * - VertexBuffer.MatricesIndicesExtraKind
  24010. * - VertexBuffer.MatricesWeightsKind
  24011. * - VertexBuffer.MatricesWeightsExtraKind
  24012. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24013. */
  24014. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24015. /**
  24016. * Sets the mesh global Vertex Buffer
  24017. * @param buffer defines the buffer to use
  24018. * @returns the current mesh
  24019. */
  24020. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24021. /**
  24022. * Update a specific associated vertex buffer
  24023. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24024. * - VertexBuffer.PositionKind
  24025. * - VertexBuffer.UVKind
  24026. * - VertexBuffer.UV2Kind
  24027. * - VertexBuffer.UV3Kind
  24028. * - VertexBuffer.UV4Kind
  24029. * - VertexBuffer.UV5Kind
  24030. * - VertexBuffer.UV6Kind
  24031. * - VertexBuffer.ColorKind
  24032. * - VertexBuffer.MatricesIndicesKind
  24033. * - VertexBuffer.MatricesIndicesExtraKind
  24034. * - VertexBuffer.MatricesWeightsKind
  24035. * - VertexBuffer.MatricesWeightsExtraKind
  24036. * @param data defines the data source
  24037. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24038. * @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)
  24039. * @returns the current mesh
  24040. */
  24041. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24042. /**
  24043. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24044. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24045. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24046. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24047. * @returns the current mesh
  24048. */
  24049. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24050. /**
  24051. * Creates a un-shared specific occurence of the geometry for the mesh.
  24052. * @returns the current mesh
  24053. */
  24054. makeGeometryUnique(): Mesh;
  24055. /**
  24056. * Set the index buffer of this mesh
  24057. * @param indices defines the source data
  24058. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24059. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24060. * @returns the current mesh
  24061. */
  24062. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24063. /**
  24064. * Update the current index buffer
  24065. * @param indices defines the source data
  24066. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24067. * @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)
  24068. * @returns the current mesh
  24069. */
  24070. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24071. /**
  24072. * Invert the geometry to move from a right handed system to a left handed one.
  24073. * @returns the current mesh
  24074. */
  24075. toLeftHanded(): Mesh;
  24076. /** @hidden */
  24077. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24078. /** @hidden */
  24079. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24080. /**
  24081. * Registers for this mesh a javascript function called just before the rendering process
  24082. * @param func defines the function to call before rendering this mesh
  24083. * @returns the current mesh
  24084. */
  24085. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24086. /**
  24087. * Disposes a previously registered javascript function called before the rendering
  24088. * @param func defines the function to remove
  24089. * @returns the current mesh
  24090. */
  24091. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24092. /**
  24093. * Registers for this mesh a javascript function called just after the rendering is complete
  24094. * @param func defines the function to call after rendering this mesh
  24095. * @returns the current mesh
  24096. */
  24097. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24098. /**
  24099. * Disposes a previously registered javascript function called after the rendering.
  24100. * @param func defines the function to remove
  24101. * @returns the current mesh
  24102. */
  24103. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24104. /** @hidden */
  24105. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24106. /** @hidden */
  24107. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24108. /** @hidden */
  24109. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24110. /** @hidden */
  24111. _rebuild(): void;
  24112. /** @hidden */
  24113. _freeze(): void;
  24114. /** @hidden */
  24115. _unFreeze(): void;
  24116. /**
  24117. * 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
  24118. * @param subMesh defines the subMesh to render
  24119. * @param enableAlphaMode defines if alpha mode can be changed
  24120. * @returns the current mesh
  24121. */
  24122. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24123. private _onBeforeDraw;
  24124. /**
  24125. * Renormalize the mesh and patch it up if there are no weights
  24126. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24127. * However in the case of zero weights then we set just a single influence to 1.
  24128. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24129. */
  24130. cleanMatrixWeights(): void;
  24131. private normalizeSkinFourWeights;
  24132. private normalizeSkinWeightsAndExtra;
  24133. /**
  24134. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24135. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24136. * the user know there was an issue with importing the mesh
  24137. * @returns a validation object with skinned, valid and report string
  24138. */
  24139. validateSkinning(): {
  24140. skinned: boolean;
  24141. valid: boolean;
  24142. report: string;
  24143. };
  24144. /** @hidden */
  24145. _checkDelayState(): Mesh;
  24146. private _queueLoad;
  24147. /**
  24148. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24149. * A mesh is in the frustum if its bounding box intersects the frustum
  24150. * @param frustumPlanes defines the frustum to test
  24151. * @returns true if the mesh is in the frustum planes
  24152. */
  24153. isInFrustum(frustumPlanes: Plane[]): boolean;
  24154. /**
  24155. * Sets the mesh material by the material or multiMaterial `id` property
  24156. * @param id is a string identifying the material or the multiMaterial
  24157. * @returns the current mesh
  24158. */
  24159. setMaterialByID(id: string): Mesh;
  24160. /**
  24161. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24162. * @returns an array of IAnimatable
  24163. */
  24164. getAnimatables(): IAnimatable[];
  24165. /**
  24166. * Modifies the mesh geometry according to the passed transformation matrix.
  24167. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24168. * The mesh normals are modified using the same transformation.
  24169. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24170. * @param transform defines the transform matrix to use
  24171. * @see http://doc.babylonjs.com/resources/baking_transformations
  24172. * @returns the current mesh
  24173. */
  24174. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24175. /**
  24176. * Modifies the mesh geometry according to its own current World Matrix.
  24177. * The mesh World Matrix is then reset.
  24178. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24179. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24180. * @see http://doc.babylonjs.com/resources/baking_transformations
  24181. * @returns the current mesh
  24182. */
  24183. bakeCurrentTransformIntoVertices(): Mesh;
  24184. /** @hidden */
  24185. readonly _positions: Nullable<Vector3[]>;
  24186. /** @hidden */
  24187. _resetPointsArrayCache(): Mesh;
  24188. /** @hidden */
  24189. _generatePointsArray(): boolean;
  24190. /**
  24191. * Returns a new Mesh object generated from the current mesh properties.
  24192. * This method must not get confused with createInstance()
  24193. * @param name is a string, the name given to the new mesh
  24194. * @param newParent can be any Node object (default `null`)
  24195. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24196. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24197. * @returns a new mesh
  24198. */
  24199. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24200. /**
  24201. * Releases resources associated with this mesh.
  24202. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24203. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24204. */
  24205. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24206. /**
  24207. * Modifies the mesh geometry according to a displacement map.
  24208. * 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.
  24209. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24210. * @param url is a string, the URL from the image file is to be downloaded.
  24211. * @param minHeight is the lower limit of the displacement.
  24212. * @param maxHeight is the upper limit of the displacement.
  24213. * @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.
  24214. * @param uvOffset is an optional vector2 used to offset UV.
  24215. * @param uvScale is an optional vector2 used to scale UV.
  24216. * @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.
  24217. * @returns the Mesh.
  24218. */
  24219. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24220. /**
  24221. * Modifies the mesh geometry according to a displacementMap buffer.
  24222. * 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.
  24223. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24224. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24225. * @param heightMapWidth is the width of the buffer image.
  24226. * @param heightMapHeight is the height of the buffer image.
  24227. * @param minHeight is the lower limit of the displacement.
  24228. * @param maxHeight is the upper limit of the displacement.
  24229. * @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.
  24230. * @param uvOffset is an optional vector2 used to offset UV.
  24231. * @param uvScale is an optional vector2 used to scale UV.
  24232. * @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.
  24233. * @returns the Mesh.
  24234. */
  24235. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24236. /**
  24237. * Modify the mesh to get a flat shading rendering.
  24238. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24239. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24240. * @returns current mesh
  24241. */
  24242. convertToFlatShadedMesh(): Mesh;
  24243. /**
  24244. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24245. * In other words, more vertices, no more indices and a single bigger VBO.
  24246. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24247. * @returns current mesh
  24248. */
  24249. convertToUnIndexedMesh(): Mesh;
  24250. /**
  24251. * Inverses facet orientations.
  24252. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24253. * @param flipNormals will also inverts the normals
  24254. * @returns current mesh
  24255. */
  24256. flipFaces(flipNormals?: boolean): Mesh;
  24257. /**
  24258. * Increase the number of facets and hence vertices in a mesh
  24259. * Vertex normals are interpolated from existing vertex normals
  24260. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24261. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24262. */
  24263. increaseVertices(numberPerEdge: number): void;
  24264. /**
  24265. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24266. * This will undo any application of covertToFlatShadedMesh
  24267. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24268. */
  24269. forceSharedVertices(): void;
  24270. /** @hidden */
  24271. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24272. /** @hidden */
  24273. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24274. /**
  24275. * Creates a new InstancedMesh object from the mesh model.
  24276. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24277. * @param name defines the name of the new instance
  24278. * @returns a new InstancedMesh
  24279. */
  24280. createInstance(name: string): InstancedMesh;
  24281. /**
  24282. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24283. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24284. * @returns the current mesh
  24285. */
  24286. synchronizeInstances(): Mesh;
  24287. /**
  24288. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24289. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24290. * This should be used together with the simplification to avoid disappearing triangles.
  24291. * @param successCallback an optional success callback to be called after the optimization finished.
  24292. * @returns the current mesh
  24293. */
  24294. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24295. /**
  24296. * Serialize current mesh
  24297. * @param serializationObject defines the object which will receive the serialization data
  24298. */
  24299. serialize(serializationObject: any): void;
  24300. /** @hidden */
  24301. _syncGeometryWithMorphTargetManager(): void;
  24302. /** @hidden */
  24303. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24304. /**
  24305. * Returns a new Mesh object parsed from the source provided.
  24306. * @param parsedMesh is the source
  24307. * @param scene defines the hosting scene
  24308. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24309. * @returns a new Mesh
  24310. */
  24311. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24312. /**
  24313. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24314. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24315. * @param name defines the name of the mesh to create
  24316. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24317. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24318. * @param closePath creates a seam between the first and the last points of each path of the path array
  24319. * @param offset is taken in account only if the `pathArray` is containing a single path
  24320. * @param scene defines the hosting scene
  24321. * @param updatable defines if the mesh must be flagged as updatable
  24322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24323. * @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)
  24324. * @returns a new Mesh
  24325. */
  24326. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24327. /**
  24328. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24329. * @param name defines the name of the mesh to create
  24330. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24331. * @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
  24332. * @param scene defines the hosting scene
  24333. * @param updatable defines if the mesh must be flagged as updatable
  24334. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24335. * @returns a new Mesh
  24336. */
  24337. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24338. /**
  24339. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24340. * @param name defines the name of the mesh to create
  24341. * @param size sets the size (float) of each box side (default 1)
  24342. * @param scene defines the hosting scene
  24343. * @param updatable defines if the mesh must be flagged as updatable
  24344. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24345. * @returns a new Mesh
  24346. */
  24347. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24348. /**
  24349. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24350. * @param name defines the name of the mesh to create
  24351. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24352. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24353. * @param scene defines the hosting scene
  24354. * @param updatable defines if the mesh must be flagged as updatable
  24355. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24356. * @returns a new Mesh
  24357. */
  24358. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24359. /**
  24360. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24361. * @param name defines the name of the mesh to create
  24362. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24363. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24364. * @param scene defines the hosting scene
  24365. * @returns a new Mesh
  24366. */
  24367. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24368. /**
  24369. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24370. * @param name defines the name of the mesh to create
  24371. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24372. * @param diameterTop set the top cap diameter (floats, default 1)
  24373. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24374. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24375. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24376. * @param scene defines the hosting scene
  24377. * @param updatable defines if the mesh must be flagged as updatable
  24378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24379. * @returns a new Mesh
  24380. */
  24381. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24382. /**
  24383. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24384. * @param name defines the name of the mesh to create
  24385. * @param diameter sets the diameter size (float) of the torus (default 1)
  24386. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24387. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24388. * @param scene defines the hosting scene
  24389. * @param updatable defines if the mesh must be flagged as updatable
  24390. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24391. * @returns a new Mesh
  24392. */
  24393. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24394. /**
  24395. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24396. * @param name defines the name of the mesh to create
  24397. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24398. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24399. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24400. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24401. * @param p the number of windings on X axis (positive integers, default 2)
  24402. * @param q the number of windings on Y axis (positive integers, default 3)
  24403. * @param scene defines the hosting scene
  24404. * @param updatable defines if the mesh must be flagged as updatable
  24405. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24406. * @returns a new Mesh
  24407. */
  24408. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24409. /**
  24410. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24411. * @param name defines the name of the mesh to create
  24412. * @param points is an array successive Vector3
  24413. * @param scene defines the hosting scene
  24414. * @param updatable defines if the mesh must be flagged as updatable
  24415. * @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).
  24416. * @returns a new Mesh
  24417. */
  24418. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24419. /**
  24420. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24421. * @param name defines the name of the mesh to create
  24422. * @param points is an array successive Vector3
  24423. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24424. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24425. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24426. * @param scene defines the hosting scene
  24427. * @param updatable defines if the mesh must be flagged as updatable
  24428. * @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)
  24429. * @returns a new Mesh
  24430. */
  24431. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24432. /**
  24433. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24434. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24435. * 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.
  24436. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24437. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24438. * Remember you can only change the shape positions, not their number when updating a polygon.
  24439. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24440. * @param name defines the name of the mesh to create
  24441. * @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
  24442. * @param scene defines the hosting scene
  24443. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24444. * @param updatable defines if the mesh must be flagged as updatable
  24445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24446. * @param earcutInjection can be used to inject your own earcut reference
  24447. * @returns a new Mesh
  24448. */
  24449. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24450. /**
  24451. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24452. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24453. * @param name defines the name of the mesh to create
  24454. * @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
  24455. * @param depth defines the height of extrusion
  24456. * @param scene defines the hosting scene
  24457. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24458. * @param updatable defines if the mesh must be flagged as updatable
  24459. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24460. * @param earcutInjection can be used to inject your own earcut reference
  24461. * @returns a new Mesh
  24462. */
  24463. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24464. /**
  24465. * Creates an extruded shape mesh.
  24466. * 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
  24467. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24468. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24469. * @param name defines the name of the mesh to create
  24470. * @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
  24471. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24472. * @param scale is the value to scale the shape
  24473. * @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
  24474. * @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
  24475. * @param scene defines the hosting scene
  24476. * @param updatable defines if the mesh must be flagged as updatable
  24477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24478. * @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)
  24479. * @returns a new Mesh
  24480. */
  24481. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24482. /**
  24483. * Creates an custom extruded shape mesh.
  24484. * The custom extrusion is a parametric shape.
  24485. * It has no predefined shape. Its final shape will depend on the input parameters.
  24486. * Please consider using the same method from the MeshBuilder class instead
  24487. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24488. * @param name defines the name of the mesh to create
  24489. * @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
  24490. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24491. * @param scaleFunction is a custom Javascript function called on each path point
  24492. * @param rotationFunction is a custom Javascript function called on each path point
  24493. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24494. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24495. * @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
  24496. * @param scene defines the hosting scene
  24497. * @param updatable defines if the mesh must be flagged as updatable
  24498. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24499. * @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)
  24500. * @returns a new Mesh
  24501. */
  24502. 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;
  24503. /**
  24504. * Creates lathe mesh.
  24505. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24506. * Please consider using the same method from the MeshBuilder class instead
  24507. * @param name defines the name of the mesh to create
  24508. * @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
  24509. * @param radius is the radius value of the lathe
  24510. * @param tessellation is the side number of the lathe.
  24511. * @param scene defines the hosting scene
  24512. * @param updatable defines if the mesh must be flagged as updatable
  24513. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24514. * @returns a new Mesh
  24515. */
  24516. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24517. /**
  24518. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24519. * @param name defines the name of the mesh to create
  24520. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24521. * @param scene defines the hosting scene
  24522. * @param updatable defines if the mesh must be flagged as updatable
  24523. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24524. * @returns a new Mesh
  24525. */
  24526. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24527. /**
  24528. * Creates a ground mesh.
  24529. * Please consider using the same method from the MeshBuilder class instead
  24530. * @param name defines the name of the mesh to create
  24531. * @param width set the width of the ground
  24532. * @param height set the height of the ground
  24533. * @param subdivisions sets the number of subdivisions per side
  24534. * @param scene defines the hosting scene
  24535. * @param updatable defines if the mesh must be flagged as updatable
  24536. * @returns a new Mesh
  24537. */
  24538. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24539. /**
  24540. * Creates a tiled ground mesh.
  24541. * Please consider using the same method from the MeshBuilder class instead
  24542. * @param name defines the name of the mesh to create
  24543. * @param xmin set the ground minimum X coordinate
  24544. * @param zmin set the ground minimum Y coordinate
  24545. * @param xmax set the ground maximum X coordinate
  24546. * @param zmax set the ground maximum Z coordinate
  24547. * @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
  24548. * @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
  24549. * @param scene defines the hosting scene
  24550. * @param updatable defines if the mesh must be flagged as updatable
  24551. * @returns a new Mesh
  24552. */
  24553. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24554. w: number;
  24555. h: number;
  24556. }, precision: {
  24557. w: number;
  24558. h: number;
  24559. }, scene: Scene, updatable?: boolean): Mesh;
  24560. /**
  24561. * Creates a ground mesh from a height map.
  24562. * Please consider using the same method from the MeshBuilder class instead
  24563. * @see http://doc.babylonjs.com/babylon101/height_map
  24564. * @param name defines the name of the mesh to create
  24565. * @param url sets the URL of the height map image resource
  24566. * @param width set the ground width size
  24567. * @param height set the ground height size
  24568. * @param subdivisions sets the number of subdivision per side
  24569. * @param minHeight is the minimum altitude on the ground
  24570. * @param maxHeight is the maximum altitude on the ground
  24571. * @param scene defines the hosting scene
  24572. * @param updatable defines if the mesh must be flagged as updatable
  24573. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24574. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24575. * @returns a new Mesh
  24576. */
  24577. 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;
  24578. /**
  24579. * Creates a tube mesh.
  24580. * The tube is a parametric shape.
  24581. * It has no predefined shape. Its final shape will depend on the input parameters.
  24582. * Please consider using the same method from the MeshBuilder class instead
  24583. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24584. * @param name defines the name of the mesh to create
  24585. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24586. * @param radius sets the tube radius size
  24587. * @param tessellation is the number of sides on the tubular surface
  24588. * @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
  24589. * @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
  24590. * @param scene defines the hosting scene
  24591. * @param updatable defines if the mesh must be flagged as updatable
  24592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24593. * @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)
  24594. * @returns a new Mesh
  24595. */
  24596. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24597. (i: number, distance: number): number;
  24598. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24599. /**
  24600. * Creates a polyhedron mesh.
  24601. * Please consider using the same method from the MeshBuilder class instead.
  24602. * * 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
  24603. * * The parameter `size` (positive float, default 1) sets the polygon size
  24604. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24605. * * 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`
  24606. * * 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
  24607. * * 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)`)
  24608. * * 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
  24609. * * 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
  24610. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24611. * * 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
  24612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24613. * @param name defines the name of the mesh to create
  24614. * @param options defines the options used to create the mesh
  24615. * @param scene defines the hosting scene
  24616. * @returns a new Mesh
  24617. */
  24618. static CreatePolyhedron(name: string, options: {
  24619. type?: number;
  24620. size?: number;
  24621. sizeX?: number;
  24622. sizeY?: number;
  24623. sizeZ?: number;
  24624. custom?: any;
  24625. faceUV?: Vector4[];
  24626. faceColors?: Color4[];
  24627. updatable?: boolean;
  24628. sideOrientation?: number;
  24629. }, scene: Scene): Mesh;
  24630. /**
  24631. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24632. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24633. * * 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`)
  24634. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24635. * * 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
  24636. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24637. * * 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
  24638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24639. * @param name defines the name of the mesh
  24640. * @param options defines the options used to create the mesh
  24641. * @param scene defines the hosting scene
  24642. * @returns a new Mesh
  24643. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24644. */
  24645. static CreateIcoSphere(name: string, options: {
  24646. radius?: number;
  24647. flat?: boolean;
  24648. subdivisions?: number;
  24649. sideOrientation?: number;
  24650. updatable?: boolean;
  24651. }, scene: Scene): Mesh;
  24652. /**
  24653. * Creates a decal mesh.
  24654. * Please consider using the same method from the MeshBuilder class instead.
  24655. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24656. * @param name defines the name of the mesh
  24657. * @param sourceMesh defines the mesh receiving the decal
  24658. * @param position sets the position of the decal in world coordinates
  24659. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24660. * @param size sets the decal scaling
  24661. * @param angle sets the angle to rotate the decal
  24662. * @returns a new Mesh
  24663. */
  24664. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24665. /**
  24666. * Prepare internal position array for software CPU skinning
  24667. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24668. */
  24669. setPositionsForCPUSkinning(): Float32Array;
  24670. /**
  24671. * Prepare internal normal array for software CPU skinning
  24672. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24673. */
  24674. setNormalsForCPUSkinning(): Float32Array;
  24675. /**
  24676. * Updates the vertex buffer by applying transformation from the bones
  24677. * @param skeleton defines the skeleton to apply to current mesh
  24678. * @returns the current mesh
  24679. */
  24680. applySkeleton(skeleton: Skeleton): Mesh;
  24681. /**
  24682. * 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
  24683. * @param meshes defines the list of meshes to scan
  24684. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24685. */
  24686. static MinMax(meshes: AbstractMesh[]): {
  24687. min: Vector3;
  24688. max: Vector3;
  24689. };
  24690. /**
  24691. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24692. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24693. * @returns a vector3
  24694. */
  24695. static Center(meshesOrMinMaxVector: {
  24696. min: Vector3;
  24697. max: Vector3;
  24698. } | AbstractMesh[]): Vector3;
  24699. /**
  24700. * Merge the array of meshes into a single mesh for performance reasons.
  24701. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24702. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24703. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24704. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24705. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24706. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24707. * @returns a new mesh
  24708. */
  24709. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24710. /** @hidden */
  24711. addInstance(instance: InstancedMesh): void;
  24712. /** @hidden */
  24713. removeInstance(instance: InstancedMesh): void;
  24714. }
  24715. }
  24716. declare module BABYLON {
  24717. /**
  24718. * This is the base class of all the camera used in the application.
  24719. * @see http://doc.babylonjs.com/features/cameras
  24720. */
  24721. export class Camera extends Node {
  24722. /** @hidden */
  24723. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24724. /**
  24725. * This is the default projection mode used by the cameras.
  24726. * It helps recreating a feeling of perspective and better appreciate depth.
  24727. * This is the best way to simulate real life cameras.
  24728. */
  24729. static readonly PERSPECTIVE_CAMERA: number;
  24730. /**
  24731. * This helps creating camera with an orthographic mode.
  24732. * 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.
  24733. */
  24734. static readonly ORTHOGRAPHIC_CAMERA: number;
  24735. /**
  24736. * This is the default FOV mode for perspective cameras.
  24737. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24738. */
  24739. static readonly FOVMODE_VERTICAL_FIXED: number;
  24740. /**
  24741. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24742. */
  24743. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24744. /**
  24745. * This specifies ther is no need for a camera rig.
  24746. * Basically only one eye is rendered corresponding to the camera.
  24747. */
  24748. static readonly RIG_MODE_NONE: number;
  24749. /**
  24750. * Simulates a camera Rig with one blue eye and one red eye.
  24751. * This can be use with 3d blue and red glasses.
  24752. */
  24753. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24754. /**
  24755. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24756. */
  24757. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24758. /**
  24759. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24760. */
  24761. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24762. /**
  24763. * Defines that both eyes of the camera will be rendered over under each other.
  24764. */
  24765. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24766. /**
  24767. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24768. */
  24769. static readonly RIG_MODE_VR: number;
  24770. /**
  24771. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24772. */
  24773. static readonly RIG_MODE_WEBVR: number;
  24774. /**
  24775. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24776. */
  24777. static readonly RIG_MODE_CUSTOM: number;
  24778. /**
  24779. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24780. */
  24781. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24782. /**
  24783. * Define the input manager associated with the camera.
  24784. */
  24785. inputs: CameraInputsManager<Camera>;
  24786. /** @hidden */
  24787. _position: Vector3;
  24788. /**
  24789. * Define the current local position of the camera in the scene
  24790. */
  24791. position: Vector3;
  24792. /**
  24793. * The vector the camera should consider as up.
  24794. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24795. */
  24796. upVector: Vector3;
  24797. /**
  24798. * Define the current limit on the left side for an orthographic camera
  24799. * In scene unit
  24800. */
  24801. orthoLeft: Nullable<number>;
  24802. /**
  24803. * Define the current limit on the right side for an orthographic camera
  24804. * In scene unit
  24805. */
  24806. orthoRight: Nullable<number>;
  24807. /**
  24808. * Define the current limit on the bottom side for an orthographic camera
  24809. * In scene unit
  24810. */
  24811. orthoBottom: Nullable<number>;
  24812. /**
  24813. * Define the current limit on the top side for an orthographic camera
  24814. * In scene unit
  24815. */
  24816. orthoTop: Nullable<number>;
  24817. /**
  24818. * Field Of View is set in Radians. (default is 0.8)
  24819. */
  24820. fov: number;
  24821. /**
  24822. * Define the minimum distance the camera can see from.
  24823. * This is important to note that the depth buffer are not infinite and the closer it starts
  24824. * the more your scene might encounter depth fighting issue.
  24825. */
  24826. minZ: number;
  24827. /**
  24828. * Define the maximum distance the camera can see to.
  24829. * This is important to note that the depth buffer are not infinite and the further it end
  24830. * the more your scene might encounter depth fighting issue.
  24831. */
  24832. maxZ: number;
  24833. /**
  24834. * Define the default inertia of the camera.
  24835. * This helps giving a smooth feeling to the camera movement.
  24836. */
  24837. inertia: number;
  24838. /**
  24839. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24840. */
  24841. mode: number;
  24842. /**
  24843. * Define wether the camera is intermediate.
  24844. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24845. */
  24846. isIntermediate: boolean;
  24847. /**
  24848. * Define the viewport of the camera.
  24849. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24850. */
  24851. viewport: Viewport;
  24852. /**
  24853. * Restricts the camera to viewing objects with the same layerMask.
  24854. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24855. */
  24856. layerMask: number;
  24857. /**
  24858. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24859. */
  24860. fovMode: number;
  24861. /**
  24862. * Rig mode of the camera.
  24863. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24864. * This is normally controlled byt the camera themselves as internal use.
  24865. */
  24866. cameraRigMode: number;
  24867. /**
  24868. * Defines the distance between both "eyes" in case of a RIG
  24869. */
  24870. interaxialDistance: number;
  24871. /**
  24872. * Defines if stereoscopic rendering is done side by side or over under.
  24873. */
  24874. isStereoscopicSideBySide: boolean;
  24875. /**
  24876. * 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
  24877. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24878. * else in the scene. (Eg. security camera)
  24879. *
  24880. * 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)
  24881. */
  24882. customRenderTargets: RenderTargetTexture[];
  24883. /**
  24884. * When set, the camera will render to this render target instead of the default canvas
  24885. *
  24886. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24887. */
  24888. outputRenderTarget: Nullable<RenderTargetTexture>;
  24889. /**
  24890. * Observable triggered when the camera view matrix has changed.
  24891. */
  24892. onViewMatrixChangedObservable: Observable<Camera>;
  24893. /**
  24894. * Observable triggered when the camera Projection matrix has changed.
  24895. */
  24896. onProjectionMatrixChangedObservable: Observable<Camera>;
  24897. /**
  24898. * Observable triggered when the inputs have been processed.
  24899. */
  24900. onAfterCheckInputsObservable: Observable<Camera>;
  24901. /**
  24902. * Observable triggered when reset has been called and applied to the camera.
  24903. */
  24904. onRestoreStateObservable: Observable<Camera>;
  24905. /** @hidden */
  24906. _cameraRigParams: any;
  24907. /** @hidden */
  24908. _rigCameras: Camera[];
  24909. /** @hidden */
  24910. _rigPostProcess: Nullable<PostProcess>;
  24911. protected _webvrViewMatrix: Matrix;
  24912. /** @hidden */
  24913. _skipRendering: boolean;
  24914. /** @hidden */
  24915. _projectionMatrix: Matrix;
  24916. /** @hidden */
  24917. _postProcesses: Nullable<PostProcess>[];
  24918. /** @hidden */
  24919. _activeMeshes: SmartArray<AbstractMesh>;
  24920. protected _globalPosition: Vector3;
  24921. /** @hidden */
  24922. _computedViewMatrix: Matrix;
  24923. private _doNotComputeProjectionMatrix;
  24924. private _transformMatrix;
  24925. private _frustumPlanes;
  24926. private _refreshFrustumPlanes;
  24927. private _storedFov;
  24928. private _stateStored;
  24929. /**
  24930. * Instantiates a new camera object.
  24931. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24932. * @see http://doc.babylonjs.com/features/cameras
  24933. * @param name Defines the name of the camera in the scene
  24934. * @param position Defines the position of the camera
  24935. * @param scene Defines the scene the camera belongs too
  24936. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24937. */
  24938. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24939. /**
  24940. * Store current camera state (fov, position, etc..)
  24941. * @returns the camera
  24942. */
  24943. storeState(): Camera;
  24944. /**
  24945. * Restores the camera state values if it has been stored. You must call storeState() first
  24946. */
  24947. protected _restoreStateValues(): boolean;
  24948. /**
  24949. * Restored camera state. You must call storeState() first.
  24950. * @returns true if restored and false otherwise
  24951. */
  24952. restoreState(): boolean;
  24953. /**
  24954. * Gets the class name of the camera.
  24955. * @returns the class name
  24956. */
  24957. getClassName(): string;
  24958. /** @hidden */
  24959. readonly _isCamera: boolean;
  24960. /**
  24961. * Gets a string representation of the camera useful for debug purpose.
  24962. * @param fullDetails Defines that a more verboe level of logging is required
  24963. * @returns the string representation
  24964. */
  24965. toString(fullDetails?: boolean): string;
  24966. /**
  24967. * Gets the current world space position of the camera.
  24968. */
  24969. readonly globalPosition: Vector3;
  24970. /**
  24971. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24972. * @returns the active meshe list
  24973. */
  24974. getActiveMeshes(): SmartArray<AbstractMesh>;
  24975. /**
  24976. * Check wether a mesh is part of the current active mesh list of the camera
  24977. * @param mesh Defines the mesh to check
  24978. * @returns true if active, false otherwise
  24979. */
  24980. isActiveMesh(mesh: Mesh): boolean;
  24981. /**
  24982. * Is this camera ready to be used/rendered
  24983. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24984. * @return true if the camera is ready
  24985. */
  24986. isReady(completeCheck?: boolean): boolean;
  24987. /** @hidden */
  24988. _initCache(): void;
  24989. /** @hidden */
  24990. _updateCache(ignoreParentClass?: boolean): void;
  24991. /** @hidden */
  24992. _isSynchronized(): boolean;
  24993. /** @hidden */
  24994. _isSynchronizedViewMatrix(): boolean;
  24995. /** @hidden */
  24996. _isSynchronizedProjectionMatrix(): boolean;
  24997. /**
  24998. * Attach the input controls to a specific dom element to get the input from.
  24999. * @param element Defines the element the controls should be listened from
  25000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25001. */
  25002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25003. /**
  25004. * Detach the current controls from the specified dom element.
  25005. * @param element Defines the element to stop listening the inputs from
  25006. */
  25007. detachControl(element: HTMLElement): void;
  25008. /**
  25009. * Update the camera state according to the different inputs gathered during the frame.
  25010. */
  25011. update(): void;
  25012. /** @hidden */
  25013. _checkInputs(): void;
  25014. /** @hidden */
  25015. readonly rigCameras: Camera[];
  25016. /**
  25017. * Gets the post process used by the rig cameras
  25018. */
  25019. readonly rigPostProcess: Nullable<PostProcess>;
  25020. /**
  25021. * Internal, gets the first post proces.
  25022. * @returns the first post process to be run on this camera.
  25023. */
  25024. _getFirstPostProcess(): Nullable<PostProcess>;
  25025. private _cascadePostProcessesToRigCams;
  25026. /**
  25027. * Attach a post process to the camera.
  25028. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25029. * @param postProcess The post process to attach to the camera
  25030. * @param insertAt The position of the post process in case several of them are in use in the scene
  25031. * @returns the position the post process has been inserted at
  25032. */
  25033. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25034. /**
  25035. * Detach a post process to the camera.
  25036. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25037. * @param postProcess The post process to detach from the camera
  25038. */
  25039. detachPostProcess(postProcess: PostProcess): void;
  25040. /**
  25041. * Gets the current world matrix of the camera
  25042. */
  25043. getWorldMatrix(): Matrix;
  25044. /** @hidden */
  25045. _getViewMatrix(): Matrix;
  25046. /**
  25047. * Gets the current view matrix of the camera.
  25048. * @param force forces the camera to recompute the matrix without looking at the cached state
  25049. * @returns the view matrix
  25050. */
  25051. getViewMatrix(force?: boolean): Matrix;
  25052. /**
  25053. * Freeze the projection matrix.
  25054. * It will prevent the cache check of the camera projection compute and can speed up perf
  25055. * if no parameter of the camera are meant to change
  25056. * @param projection Defines manually a projection if necessary
  25057. */
  25058. freezeProjectionMatrix(projection?: Matrix): void;
  25059. /**
  25060. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25061. */
  25062. unfreezeProjectionMatrix(): void;
  25063. /**
  25064. * Gets the current projection matrix of the camera.
  25065. * @param force forces the camera to recompute the matrix without looking at the cached state
  25066. * @returns the projection matrix
  25067. */
  25068. getProjectionMatrix(force?: boolean): Matrix;
  25069. /**
  25070. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25071. * @returns a Matrix
  25072. */
  25073. getTransformationMatrix(): Matrix;
  25074. private _updateFrustumPlanes;
  25075. /**
  25076. * Checks if a cullable object (mesh...) is in the camera frustum
  25077. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25078. * @param target The object to check
  25079. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25080. * @returns true if the object is in frustum otherwise false
  25081. */
  25082. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25083. /**
  25084. * Checks if a cullable object (mesh...) is in the camera frustum
  25085. * Unlike isInFrustum this cheks the full bounding box
  25086. * @param target The object to check
  25087. * @returns true if the object is in frustum otherwise false
  25088. */
  25089. isCompletelyInFrustum(target: ICullable): boolean;
  25090. /**
  25091. * Gets a ray in the forward direction from the camera.
  25092. * @param length Defines the length of the ray to create
  25093. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25094. * @param origin Defines the start point of the ray which defaults to the camera position
  25095. * @returns the forward ray
  25096. */
  25097. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25098. /**
  25099. * Releases resources associated with this node.
  25100. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25101. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25102. */
  25103. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25104. /** @hidden */
  25105. _isLeftCamera: boolean;
  25106. /**
  25107. * Gets the left camera of a rig setup in case of Rigged Camera
  25108. */
  25109. readonly isLeftCamera: boolean;
  25110. /** @hidden */
  25111. _isRightCamera: boolean;
  25112. /**
  25113. * Gets the right camera of a rig setup in case of Rigged Camera
  25114. */
  25115. readonly isRightCamera: boolean;
  25116. /**
  25117. * Gets the left camera of a rig setup in case of Rigged Camera
  25118. */
  25119. readonly leftCamera: Nullable<FreeCamera>;
  25120. /**
  25121. * Gets the right camera of a rig setup in case of Rigged Camera
  25122. */
  25123. readonly rightCamera: Nullable<FreeCamera>;
  25124. /**
  25125. * Gets the left camera target of a rig setup in case of Rigged Camera
  25126. * @returns the target position
  25127. */
  25128. getLeftTarget(): Nullable<Vector3>;
  25129. /**
  25130. * Gets the right camera target of a rig setup in case of Rigged Camera
  25131. * @returns the target position
  25132. */
  25133. getRightTarget(): Nullable<Vector3>;
  25134. /**
  25135. * @hidden
  25136. */
  25137. setCameraRigMode(mode: number, rigParams: any): void;
  25138. /** @hidden */
  25139. static _setStereoscopicRigMode(camera: Camera): void;
  25140. /** @hidden */
  25141. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25142. /** @hidden */
  25143. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25144. /** @hidden */
  25145. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25146. /** @hidden */
  25147. _getVRProjectionMatrix(): Matrix;
  25148. protected _updateCameraRotationMatrix(): void;
  25149. protected _updateWebVRCameraRotationMatrix(): void;
  25150. /**
  25151. * This function MUST be overwritten by the different WebVR cameras available.
  25152. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25153. * @hidden
  25154. */
  25155. _getWebVRProjectionMatrix(): Matrix;
  25156. /**
  25157. * This function MUST be overwritten by the different WebVR cameras available.
  25158. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25159. * @hidden
  25160. */
  25161. _getWebVRViewMatrix(): Matrix;
  25162. /** @hidden */
  25163. setCameraRigParameter(name: string, value: any): void;
  25164. /**
  25165. * needs to be overridden by children so sub has required properties to be copied
  25166. * @hidden
  25167. */
  25168. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25169. /**
  25170. * May need to be overridden by children
  25171. * @hidden
  25172. */
  25173. _updateRigCameras(): void;
  25174. /** @hidden */
  25175. _setupInputs(): void;
  25176. /**
  25177. * Serialiaze the camera setup to a json represention
  25178. * @returns the JSON representation
  25179. */
  25180. serialize(): any;
  25181. /**
  25182. * Clones the current camera.
  25183. * @param name The cloned camera name
  25184. * @returns the cloned camera
  25185. */
  25186. clone(name: string): Camera;
  25187. /**
  25188. * Gets the direction of the camera relative to a given local axis.
  25189. * @param localAxis Defines the reference axis to provide a relative direction.
  25190. * @return the direction
  25191. */
  25192. getDirection(localAxis: Vector3): Vector3;
  25193. /**
  25194. * Returns the current camera absolute rotation
  25195. */
  25196. readonly absoluteRotation: Quaternion;
  25197. /**
  25198. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25199. * @param localAxis Defines the reference axis to provide a relative direction.
  25200. * @param result Defines the vector to store the result in
  25201. */
  25202. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25203. /**
  25204. * Gets a camera constructor for a given camera type
  25205. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25206. * @param name The name of the camera the result will be able to instantiate
  25207. * @param scene The scene the result will construct the camera in
  25208. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25209. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25210. * @returns a factory method to construc the camera
  25211. */
  25212. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25213. /**
  25214. * Compute the world matrix of the camera.
  25215. * @returns the camera workd matrix
  25216. */
  25217. computeWorldMatrix(): Matrix;
  25218. /**
  25219. * Parse a JSON and creates the camera from the parsed information
  25220. * @param parsedCamera The JSON to parse
  25221. * @param scene The scene to instantiate the camera in
  25222. * @returns the newly constructed camera
  25223. */
  25224. static Parse(parsedCamera: any, scene: Scene): Camera;
  25225. }
  25226. }
  25227. declare module BABYLON {
  25228. /**
  25229. * Class containing static functions to help procedurally build meshes
  25230. */
  25231. export class DiscBuilder {
  25232. /**
  25233. * Creates a plane polygonal mesh. By default, this is a disc
  25234. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25235. * * 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
  25236. * * 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
  25237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25238. * * 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
  25239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25240. * @param name defines the name of the mesh
  25241. * @param options defines the options used to create the mesh
  25242. * @param scene defines the hosting scene
  25243. * @returns the plane polygonal mesh
  25244. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25245. */
  25246. static CreateDisc(name: string, options: {
  25247. radius?: number;
  25248. tessellation?: number;
  25249. arc?: number;
  25250. updatable?: boolean;
  25251. sideOrientation?: number;
  25252. frontUVs?: Vector4;
  25253. backUVs?: Vector4;
  25254. }, scene?: Nullable<Scene>): Mesh;
  25255. }
  25256. }
  25257. declare module BABYLON {
  25258. /**
  25259. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25260. *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.
  25261. * The SPS is also a particle system. It provides some methods to manage the particles.
  25262. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25263. *
  25264. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25265. */
  25266. export class SolidParticleSystem implements IDisposable {
  25267. /**
  25268. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25269. * Example : var p = SPS.particles[i];
  25270. */
  25271. particles: SolidParticle[];
  25272. /**
  25273. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25274. */
  25275. nbParticles: number;
  25276. /**
  25277. * If the particles must ever face the camera (default false). Useful for planar particles.
  25278. */
  25279. billboard: boolean;
  25280. /**
  25281. * Recompute normals when adding a shape
  25282. */
  25283. recomputeNormals: boolean;
  25284. /**
  25285. * This a counter ofr your own usage. It's not set by any SPS functions.
  25286. */
  25287. counter: number;
  25288. /**
  25289. * The SPS name. This name is also given to the underlying mesh.
  25290. */
  25291. name: string;
  25292. /**
  25293. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25294. */
  25295. mesh: Mesh;
  25296. /**
  25297. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25298. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25299. */
  25300. vars: any;
  25301. /**
  25302. * This array is populated when the SPS is set as 'pickable'.
  25303. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25304. * Each element of this array is an object `{idx: int, faceId: int}`.
  25305. * `idx` is the picked particle index in the `SPS.particles` array
  25306. * `faceId` is the picked face index counted within this particle.
  25307. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25308. */
  25309. pickedParticles: {
  25310. idx: number;
  25311. faceId: number;
  25312. }[];
  25313. /**
  25314. * This array is populated when `enableDepthSort` is set to true.
  25315. * Each element of this array is an instance of the class DepthSortedParticle.
  25316. */
  25317. depthSortedParticles: DepthSortedParticle[];
  25318. /**
  25319. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25320. * @hidden
  25321. */
  25322. _bSphereOnly: boolean;
  25323. /**
  25324. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25325. * @hidden
  25326. */
  25327. _bSphereRadiusFactor: number;
  25328. private _scene;
  25329. private _positions;
  25330. private _indices;
  25331. private _normals;
  25332. private _colors;
  25333. private _uvs;
  25334. private _indices32;
  25335. private _positions32;
  25336. private _normals32;
  25337. private _fixedNormal32;
  25338. private _colors32;
  25339. private _uvs32;
  25340. private _index;
  25341. private _updatable;
  25342. private _pickable;
  25343. private _isVisibilityBoxLocked;
  25344. private _alwaysVisible;
  25345. private _depthSort;
  25346. private _shapeCounter;
  25347. private _copy;
  25348. private _color;
  25349. private _computeParticleColor;
  25350. private _computeParticleTexture;
  25351. private _computeParticleRotation;
  25352. private _computeParticleVertex;
  25353. private _computeBoundingBox;
  25354. private _depthSortParticles;
  25355. private _camera;
  25356. private _mustUnrotateFixedNormals;
  25357. private _particlesIntersect;
  25358. private _needs32Bits;
  25359. /**
  25360. * Creates a SPS (Solid Particle System) object.
  25361. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25362. * @param scene (Scene) is the scene in which the SPS is added.
  25363. * @param options defines the options of the sps e.g.
  25364. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25365. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25366. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25367. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25368. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25369. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25370. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25371. */
  25372. constructor(name: string, scene: Scene, options?: {
  25373. updatable?: boolean;
  25374. isPickable?: boolean;
  25375. enableDepthSort?: boolean;
  25376. particleIntersection?: boolean;
  25377. boundingSphereOnly?: boolean;
  25378. bSphereRadiusFactor?: number;
  25379. });
  25380. /**
  25381. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25382. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25383. * @returns the created mesh
  25384. */
  25385. buildMesh(): Mesh;
  25386. /**
  25387. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25388. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25389. * Thus the particles generated from `digest()` have their property `position` set yet.
  25390. * @param mesh ( Mesh ) is the mesh to be digested
  25391. * @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
  25392. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25393. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25394. * @returns the current SPS
  25395. */
  25396. digest(mesh: Mesh, options?: {
  25397. facetNb?: number;
  25398. number?: number;
  25399. delta?: number;
  25400. }): SolidParticleSystem;
  25401. private _unrotateFixedNormals;
  25402. private _resetCopy;
  25403. private _meshBuilder;
  25404. private _posToShape;
  25405. private _uvsToShapeUV;
  25406. private _addParticle;
  25407. /**
  25408. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25409. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25410. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25411. * @param nb (positive integer) the number of particles to be created from this model
  25412. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25413. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25414. * @returns the number of shapes in the system
  25415. */
  25416. addShape(mesh: Mesh, nb: number, options?: {
  25417. positionFunction?: any;
  25418. vertexFunction?: any;
  25419. }): number;
  25420. private _rebuildParticle;
  25421. /**
  25422. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25423. * @returns the SPS.
  25424. */
  25425. rebuildMesh(): SolidParticleSystem;
  25426. /**
  25427. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25428. * This method calls `updateParticle()` for each particle of the SPS.
  25429. * For an animated SPS, it is usually called within the render loop.
  25430. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25431. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25432. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25433. * @returns the SPS.
  25434. */
  25435. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25436. /**
  25437. * Disposes the SPS.
  25438. */
  25439. dispose(): void;
  25440. /**
  25441. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25442. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25443. * @returns the SPS.
  25444. */
  25445. refreshVisibleSize(): SolidParticleSystem;
  25446. /**
  25447. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25448. * @param size the size (float) of the visibility box
  25449. * note : this doesn't lock the SPS mesh bounding box.
  25450. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25451. */
  25452. setVisibilityBox(size: number): void;
  25453. /**
  25454. * Gets whether the SPS as always visible or not
  25455. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25456. */
  25457. /**
  25458. * Sets the SPS as always visible or not
  25459. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25460. */
  25461. isAlwaysVisible: boolean;
  25462. /**
  25463. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25464. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25465. */
  25466. /**
  25467. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25468. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25469. */
  25470. isVisibilityBoxLocked: boolean;
  25471. /**
  25472. * Tells to `setParticles()` to compute the particle rotations or not.
  25473. * Default value : true. The SPS is faster when it's set to false.
  25474. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25475. */
  25476. /**
  25477. * Gets if `setParticles()` computes the particle rotations or not.
  25478. * Default value : true. The SPS is faster when it's set to false.
  25479. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25480. */
  25481. computeParticleRotation: boolean;
  25482. /**
  25483. * Tells to `setParticles()` to compute the particle colors or not.
  25484. * Default value : true. The SPS is faster when it's set to false.
  25485. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25486. */
  25487. /**
  25488. * Gets if `setParticles()` computes the particle colors or not.
  25489. * Default value : true. The SPS is faster when it's set to false.
  25490. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25491. */
  25492. computeParticleColor: boolean;
  25493. /**
  25494. * Gets if `setParticles()` computes the particle textures or not.
  25495. * Default value : true. The SPS is faster when it's set to false.
  25496. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25497. */
  25498. computeParticleTexture: boolean;
  25499. /**
  25500. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25501. * Default value : false. The SPS is faster when it's set to false.
  25502. * Note : the particle custom vertex positions aren't stored values.
  25503. */
  25504. /**
  25505. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25506. * Default value : false. The SPS is faster when it's set to false.
  25507. * Note : the particle custom vertex positions aren't stored values.
  25508. */
  25509. computeParticleVertex: boolean;
  25510. /**
  25511. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25512. */
  25513. /**
  25514. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25515. */
  25516. computeBoundingBox: boolean;
  25517. /**
  25518. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25519. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25520. * Default : `true`
  25521. */
  25522. /**
  25523. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25524. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25525. * Default : `true`
  25526. */
  25527. depthSortParticles: boolean;
  25528. /**
  25529. * This function does nothing. It may be overwritten to set all the particle first values.
  25530. * The SPS doesn't call this function, you may have to call it by your own.
  25531. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25532. */
  25533. initParticles(): void;
  25534. /**
  25535. * This function does nothing. It may be overwritten to recycle a particle.
  25536. * The SPS doesn't call this function, you may have to call it by your own.
  25537. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25538. * @param particle The particle to recycle
  25539. * @returns the recycled particle
  25540. */
  25541. recycleParticle(particle: SolidParticle): SolidParticle;
  25542. /**
  25543. * Updates a particle : this function should be overwritten by the user.
  25544. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25545. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25546. * @example : just set a particle position or velocity and recycle conditions
  25547. * @param particle The particle to update
  25548. * @returns the updated particle
  25549. */
  25550. updateParticle(particle: SolidParticle): SolidParticle;
  25551. /**
  25552. * Updates a vertex of a particle : it can be overwritten by the user.
  25553. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25554. * @param particle the current particle
  25555. * @param vertex the current index of the current particle
  25556. * @param pt the index of the current vertex in the particle shape
  25557. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25558. * @example : just set a vertex particle position
  25559. * @returns the updated vertex
  25560. */
  25561. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25562. /**
  25563. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25564. * This does nothing and may be overwritten by the user.
  25565. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25566. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25567. * @param update the boolean update value actually passed to setParticles()
  25568. */
  25569. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25570. /**
  25571. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25572. * This will be passed three parameters.
  25573. * This does nothing and may be overwritten by the user.
  25574. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25575. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25576. * @param update the boolean update value actually passed to setParticles()
  25577. */
  25578. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25579. }
  25580. }
  25581. declare module BABYLON {
  25582. /**
  25583. * Represents one particle of a solid particle system.
  25584. */
  25585. export class SolidParticle {
  25586. /**
  25587. * particle global index
  25588. */
  25589. idx: number;
  25590. /**
  25591. * The color of the particle
  25592. */
  25593. color: Nullable<Color4>;
  25594. /**
  25595. * The world space position of the particle.
  25596. */
  25597. position: Vector3;
  25598. /**
  25599. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25600. */
  25601. rotation: Vector3;
  25602. /**
  25603. * The world space rotation quaternion of the particle.
  25604. */
  25605. rotationQuaternion: Nullable<Quaternion>;
  25606. /**
  25607. * The scaling of the particle.
  25608. */
  25609. scaling: Vector3;
  25610. /**
  25611. * The uvs of the particle.
  25612. */
  25613. uvs: Vector4;
  25614. /**
  25615. * The current speed of the particle.
  25616. */
  25617. velocity: Vector3;
  25618. /**
  25619. * The pivot point in the particle local space.
  25620. */
  25621. pivot: Vector3;
  25622. /**
  25623. * Must the particle be translated from its pivot point in its local space ?
  25624. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25625. * Default : false
  25626. */
  25627. translateFromPivot: boolean;
  25628. /**
  25629. * Is the particle active or not ?
  25630. */
  25631. alive: boolean;
  25632. /**
  25633. * Is the particle visible or not ?
  25634. */
  25635. isVisible: boolean;
  25636. /**
  25637. * Index of this particle in the global "positions" array (Internal use)
  25638. * @hidden
  25639. */
  25640. _pos: number;
  25641. /**
  25642. * @hidden Index of this particle in the global "indices" array (Internal use)
  25643. */
  25644. _ind: number;
  25645. /**
  25646. * @hidden ModelShape of this particle (Internal use)
  25647. */
  25648. _model: ModelShape;
  25649. /**
  25650. * ModelShape id of this particle
  25651. */
  25652. shapeId: number;
  25653. /**
  25654. * Index of the particle in its shape id
  25655. */
  25656. idxInShape: number;
  25657. /**
  25658. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25659. */
  25660. _modelBoundingInfo: BoundingInfo;
  25661. /**
  25662. * @hidden Particle BoundingInfo object (Internal use)
  25663. */
  25664. _boundingInfo: BoundingInfo;
  25665. /**
  25666. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25667. */
  25668. _sps: SolidParticleSystem;
  25669. /**
  25670. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25671. */
  25672. _stillInvisible: boolean;
  25673. /**
  25674. * @hidden Last computed particle rotation matrix
  25675. */
  25676. _rotationMatrix: number[];
  25677. /**
  25678. * Parent particle Id, if any.
  25679. * Default null.
  25680. */
  25681. parentId: Nullable<number>;
  25682. /**
  25683. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25684. * The possible values are :
  25685. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25686. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25687. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25688. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25689. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25690. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25691. * */
  25692. cullingStrategy: number;
  25693. /**
  25694. * @hidden Internal global position in the SPS.
  25695. */
  25696. _globalPosition: Vector3;
  25697. /**
  25698. * Creates a Solid Particle object.
  25699. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25700. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25701. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25702. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25703. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25704. * @param shapeId (integer) is the model shape identifier in the SPS.
  25705. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25706. * @param sps defines the sps it is associated to
  25707. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25708. */
  25709. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25710. /**
  25711. * Legacy support, changed scale to scaling
  25712. */
  25713. /**
  25714. * Legacy support, changed scale to scaling
  25715. */
  25716. scale: Vector3;
  25717. /**
  25718. * Legacy support, changed quaternion to rotationQuaternion
  25719. */
  25720. /**
  25721. * Legacy support, changed quaternion to rotationQuaternion
  25722. */
  25723. quaternion: Nullable<Quaternion>;
  25724. /**
  25725. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25726. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25727. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25728. * @returns true if it intersects
  25729. */
  25730. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25731. /**
  25732. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25733. * A particle is in the frustum if its bounding box intersects the frustum
  25734. * @param frustumPlanes defines the frustum to test
  25735. * @returns true if the particle is in the frustum planes
  25736. */
  25737. isInFrustum(frustumPlanes: Plane[]): boolean;
  25738. /**
  25739. * get the rotation matrix of the particle
  25740. * @hidden
  25741. */
  25742. getRotationMatrix(m: Matrix): void;
  25743. }
  25744. /**
  25745. * Represents the shape of the model used by one particle of a solid particle system.
  25746. * SPS internal tool, don't use it manually.
  25747. */
  25748. export class ModelShape {
  25749. /**
  25750. * The shape id
  25751. * @hidden
  25752. */
  25753. shapeID: number;
  25754. /**
  25755. * flat array of model positions (internal use)
  25756. * @hidden
  25757. */
  25758. _shape: Vector3[];
  25759. /**
  25760. * flat array of model UVs (internal use)
  25761. * @hidden
  25762. */
  25763. _shapeUV: number[];
  25764. /**
  25765. * length of the shape in the model indices array (internal use)
  25766. * @hidden
  25767. */
  25768. _indicesLength: number;
  25769. /**
  25770. * Custom position function (internal use)
  25771. * @hidden
  25772. */
  25773. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25774. /**
  25775. * Custom vertex function (internal use)
  25776. * @hidden
  25777. */
  25778. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25779. /**
  25780. * 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.
  25781. * SPS internal tool, don't use it manually.
  25782. * @hidden
  25783. */
  25784. 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>);
  25785. }
  25786. /**
  25787. * Represents a Depth Sorted Particle in the solid particle system.
  25788. */
  25789. export class DepthSortedParticle {
  25790. /**
  25791. * Index of the particle in the "indices" array
  25792. */
  25793. ind: number;
  25794. /**
  25795. * Length of the particle shape in the "indices" array
  25796. */
  25797. indicesLength: number;
  25798. /**
  25799. * Squared distance from the particle to the camera
  25800. */
  25801. sqDistance: number;
  25802. }
  25803. }
  25804. declare module BABYLON {
  25805. /**
  25806. * @hidden
  25807. */
  25808. export class _MeshCollisionData {
  25809. _checkCollisions: boolean;
  25810. _collisionMask: number;
  25811. _collisionGroup: number;
  25812. _collider: Nullable<Collider>;
  25813. _oldPositionForCollisions: Vector3;
  25814. _diffPositionForCollisions: Vector3;
  25815. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25816. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25817. }
  25818. }
  25819. declare module BABYLON {
  25820. /** @hidden */
  25821. class _FacetDataStorage {
  25822. facetPositions: Vector3[];
  25823. facetNormals: Vector3[];
  25824. facetPartitioning: number[][];
  25825. facetNb: number;
  25826. partitioningSubdivisions: number;
  25827. partitioningBBoxRatio: number;
  25828. facetDataEnabled: boolean;
  25829. facetParameters: any;
  25830. bbSize: Vector3;
  25831. subDiv: {
  25832. max: number;
  25833. X: number;
  25834. Y: number;
  25835. Z: number;
  25836. };
  25837. facetDepthSort: boolean;
  25838. facetDepthSortEnabled: boolean;
  25839. depthSortedIndices: IndicesArray;
  25840. depthSortedFacets: {
  25841. ind: number;
  25842. sqDistance: number;
  25843. }[];
  25844. facetDepthSortFunction: (f1: {
  25845. ind: number;
  25846. sqDistance: number;
  25847. }, f2: {
  25848. ind: number;
  25849. sqDistance: number;
  25850. }) => number;
  25851. facetDepthSortFrom: Vector3;
  25852. facetDepthSortOrigin: Vector3;
  25853. invertedMatrix: Matrix;
  25854. }
  25855. /**
  25856. * @hidden
  25857. **/
  25858. class _InternalAbstractMeshDataInfo {
  25859. _hasVertexAlpha: boolean;
  25860. _useVertexColors: boolean;
  25861. _numBoneInfluencers: number;
  25862. _applyFog: boolean;
  25863. _receiveShadows: boolean;
  25864. _facetData: _FacetDataStorage;
  25865. _visibility: number;
  25866. _skeleton: Nullable<Skeleton>;
  25867. _layerMask: number;
  25868. _computeBonesUsingShaders: boolean;
  25869. _isActive: boolean;
  25870. _onlyForInstances: boolean;
  25871. _isActiveIntermediate: boolean;
  25872. _onlyForInstancesIntermediate: boolean;
  25873. }
  25874. /**
  25875. * Class used to store all common mesh properties
  25876. */
  25877. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25878. /** No occlusion */
  25879. static OCCLUSION_TYPE_NONE: number;
  25880. /** Occlusion set to optimisitic */
  25881. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25882. /** Occlusion set to strict */
  25883. static OCCLUSION_TYPE_STRICT: number;
  25884. /** Use an accurante occlusion algorithm */
  25885. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25886. /** Use a conservative occlusion algorithm */
  25887. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25888. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25889. * Test order :
  25890. * Is the bounding sphere outside the frustum ?
  25891. * If not, are the bounding box vertices outside the frustum ?
  25892. * It not, then the cullable object is in the frustum.
  25893. */
  25894. static readonly CULLINGSTRATEGY_STANDARD: number;
  25895. /** Culling strategy : Bounding Sphere Only.
  25896. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25897. * It's also less accurate than the standard because some not visible objects can still be selected.
  25898. * Test : is the bounding sphere outside the frustum ?
  25899. * If not, then the cullable object is in the frustum.
  25900. */
  25901. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25902. /** Culling strategy : Optimistic Inclusion.
  25903. * This in an inclusion test first, then the standard exclusion test.
  25904. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25905. * 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.
  25906. * Anyway, it's as accurate as the standard strategy.
  25907. * Test :
  25908. * Is the cullable object bounding sphere center in the frustum ?
  25909. * If not, apply the default culling strategy.
  25910. */
  25911. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25912. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25913. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25914. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25915. * 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.
  25916. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25917. * Test :
  25918. * Is the cullable object bounding sphere center in the frustum ?
  25919. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25920. */
  25921. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25922. /**
  25923. * No billboard
  25924. */
  25925. static readonly BILLBOARDMODE_NONE: number;
  25926. /** Billboard on X axis */
  25927. static readonly BILLBOARDMODE_X: number;
  25928. /** Billboard on Y axis */
  25929. static readonly BILLBOARDMODE_Y: number;
  25930. /** Billboard on Z axis */
  25931. static readonly BILLBOARDMODE_Z: number;
  25932. /** Billboard on all axes */
  25933. static readonly BILLBOARDMODE_ALL: number;
  25934. /** Billboard on using position instead of orientation */
  25935. static readonly BILLBOARDMODE_USE_POSITION: number;
  25936. /** @hidden */
  25937. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25938. /**
  25939. * The culling strategy to use to check whether the mesh must be rendered or not.
  25940. * This value can be changed at any time and will be used on the next render mesh selection.
  25941. * The possible values are :
  25942. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25943. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25944. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25945. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25946. * Please read each static variable documentation to get details about the culling process.
  25947. * */
  25948. cullingStrategy: number;
  25949. /**
  25950. * Gets the number of facets in the mesh
  25951. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25952. */
  25953. readonly facetNb: number;
  25954. /**
  25955. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25956. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25957. */
  25958. partitioningSubdivisions: number;
  25959. /**
  25960. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25961. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25962. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25963. */
  25964. partitioningBBoxRatio: number;
  25965. /**
  25966. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25967. * Works only for updatable meshes.
  25968. * Doesn't work with multi-materials
  25969. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25970. */
  25971. mustDepthSortFacets: boolean;
  25972. /**
  25973. * The location (Vector3) where the facet depth sort must be computed from.
  25974. * By default, the active camera position.
  25975. * Used only when facet depth sort is enabled
  25976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25977. */
  25978. facetDepthSortFrom: Vector3;
  25979. /**
  25980. * gets a boolean indicating if facetData is enabled
  25981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25982. */
  25983. readonly isFacetDataEnabled: boolean;
  25984. /** @hidden */
  25985. _updateNonUniformScalingState(value: boolean): boolean;
  25986. /**
  25987. * An event triggered when this mesh collides with another one
  25988. */
  25989. onCollideObservable: Observable<AbstractMesh>;
  25990. /** Set a function to call when this mesh collides with another one */
  25991. onCollide: () => void;
  25992. /**
  25993. * An event triggered when the collision's position changes
  25994. */
  25995. onCollisionPositionChangeObservable: Observable<Vector3>;
  25996. /** Set a function to call when the collision's position changes */
  25997. onCollisionPositionChange: () => void;
  25998. /**
  25999. * An event triggered when material is changed
  26000. */
  26001. onMaterialChangedObservable: Observable<AbstractMesh>;
  26002. /**
  26003. * Gets or sets the orientation for POV movement & rotation
  26004. */
  26005. definedFacingForward: boolean;
  26006. /** @hidden */
  26007. _occlusionQuery: Nullable<WebGLQuery>;
  26008. /** @hidden */
  26009. _renderingGroup: Nullable<RenderingGroup>;
  26010. /**
  26011. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26012. */
  26013. /**
  26014. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26015. */
  26016. visibility: number;
  26017. /** Gets or sets the alpha index used to sort transparent meshes
  26018. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26019. */
  26020. alphaIndex: number;
  26021. /**
  26022. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26023. */
  26024. isVisible: boolean;
  26025. /**
  26026. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26027. */
  26028. isPickable: boolean;
  26029. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26030. showSubMeshesBoundingBox: boolean;
  26031. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26032. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26033. */
  26034. isBlocker: boolean;
  26035. /**
  26036. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26037. */
  26038. enablePointerMoveEvents: boolean;
  26039. /**
  26040. * Specifies the rendering group id for this mesh (0 by default)
  26041. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26042. */
  26043. renderingGroupId: number;
  26044. private _material;
  26045. /** Gets or sets current material */
  26046. material: Nullable<Material>;
  26047. /**
  26048. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26049. * @see http://doc.babylonjs.com/babylon101/shadows
  26050. */
  26051. receiveShadows: boolean;
  26052. /** Defines color to use when rendering outline */
  26053. outlineColor: Color3;
  26054. /** Define width to use when rendering outline */
  26055. outlineWidth: number;
  26056. /** Defines color to use when rendering overlay */
  26057. overlayColor: Color3;
  26058. /** Defines alpha to use when rendering overlay */
  26059. overlayAlpha: number;
  26060. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26061. hasVertexAlpha: boolean;
  26062. /** 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) */
  26063. useVertexColors: boolean;
  26064. /**
  26065. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26066. */
  26067. computeBonesUsingShaders: boolean;
  26068. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26069. numBoneInfluencers: number;
  26070. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26071. applyFog: boolean;
  26072. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26073. useOctreeForRenderingSelection: boolean;
  26074. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26075. useOctreeForPicking: boolean;
  26076. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26077. useOctreeForCollisions: boolean;
  26078. /**
  26079. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26080. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26081. */
  26082. layerMask: number;
  26083. /**
  26084. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26085. */
  26086. alwaysSelectAsActiveMesh: boolean;
  26087. /**
  26088. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26089. */
  26090. doNotSyncBoundingInfo: boolean;
  26091. /**
  26092. * Gets or sets the current action manager
  26093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26094. */
  26095. actionManager: Nullable<AbstractActionManager>;
  26096. private _meshCollisionData;
  26097. /**
  26098. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26099. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26100. */
  26101. ellipsoid: Vector3;
  26102. /**
  26103. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26104. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26105. */
  26106. ellipsoidOffset: Vector3;
  26107. /**
  26108. * Gets or sets a collision mask used to mask collisions (default is -1).
  26109. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26110. */
  26111. collisionMask: number;
  26112. /**
  26113. * Gets or sets the current collision group mask (-1 by default).
  26114. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26115. */
  26116. collisionGroup: number;
  26117. /**
  26118. * Defines edge width used when edgesRenderer is enabled
  26119. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26120. */
  26121. edgesWidth: number;
  26122. /**
  26123. * Defines edge color used when edgesRenderer is enabled
  26124. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26125. */
  26126. edgesColor: Color4;
  26127. /** @hidden */
  26128. _edgesRenderer: Nullable<IEdgesRenderer>;
  26129. /** @hidden */
  26130. _masterMesh: Nullable<AbstractMesh>;
  26131. /** @hidden */
  26132. _boundingInfo: Nullable<BoundingInfo>;
  26133. /** @hidden */
  26134. _renderId: number;
  26135. /**
  26136. * Gets or sets the list of subMeshes
  26137. * @see http://doc.babylonjs.com/how_to/multi_materials
  26138. */
  26139. subMeshes: SubMesh[];
  26140. /** @hidden */
  26141. _intersectionsInProgress: AbstractMesh[];
  26142. /** @hidden */
  26143. _unIndexed: boolean;
  26144. /** @hidden */
  26145. _lightSources: Light[];
  26146. /** Gets the list of lights affecting that mesh */
  26147. readonly lightSources: Light[];
  26148. /** @hidden */
  26149. readonly _positions: Nullable<Vector3[]>;
  26150. /** @hidden */
  26151. _waitingData: {
  26152. lods: Nullable<any>;
  26153. actions: Nullable<any>;
  26154. freezeWorldMatrix: Nullable<boolean>;
  26155. };
  26156. /** @hidden */
  26157. _bonesTransformMatrices: Nullable<Float32Array>;
  26158. /** @hidden */
  26159. _transformMatrixTexture: Nullable<RawTexture>;
  26160. /**
  26161. * Gets or sets a skeleton to apply skining transformations
  26162. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26163. */
  26164. skeleton: Nullable<Skeleton>;
  26165. /**
  26166. * An event triggered when the mesh is rebuilt.
  26167. */
  26168. onRebuildObservable: Observable<AbstractMesh>;
  26169. /**
  26170. * Creates a new AbstractMesh
  26171. * @param name defines the name of the mesh
  26172. * @param scene defines the hosting scene
  26173. */
  26174. constructor(name: string, scene?: Nullable<Scene>);
  26175. /**
  26176. * Returns the string "AbstractMesh"
  26177. * @returns "AbstractMesh"
  26178. */
  26179. getClassName(): string;
  26180. /**
  26181. * Gets a string representation of the current mesh
  26182. * @param fullDetails defines a boolean indicating if full details must be included
  26183. * @returns a string representation of the current mesh
  26184. */
  26185. toString(fullDetails?: boolean): string;
  26186. /**
  26187. * @hidden
  26188. */
  26189. protected _getEffectiveParent(): Nullable<Node>;
  26190. /** @hidden */
  26191. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26192. /** @hidden */
  26193. _rebuild(): void;
  26194. /** @hidden */
  26195. _resyncLightSources(): void;
  26196. /** @hidden */
  26197. _resyncLighSource(light: Light): void;
  26198. /** @hidden */
  26199. _unBindEffect(): void;
  26200. /** @hidden */
  26201. _removeLightSource(light: Light, dispose: boolean): void;
  26202. private _markSubMeshesAsDirty;
  26203. /** @hidden */
  26204. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26205. /** @hidden */
  26206. _markSubMeshesAsAttributesDirty(): void;
  26207. /** @hidden */
  26208. _markSubMeshesAsMiscDirty(): void;
  26209. /**
  26210. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26211. */
  26212. scaling: Vector3;
  26213. /**
  26214. * Returns true if the mesh is blocked. Implemented by child classes
  26215. */
  26216. readonly isBlocked: boolean;
  26217. /**
  26218. * Returns the mesh itself by default. Implemented by child classes
  26219. * @param camera defines the camera to use to pick the right LOD level
  26220. * @returns the currentAbstractMesh
  26221. */
  26222. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26223. /**
  26224. * Returns 0 by default. Implemented by child classes
  26225. * @returns an integer
  26226. */
  26227. getTotalVertices(): number;
  26228. /**
  26229. * Returns a positive integer : the total number of indices in this mesh geometry.
  26230. * @returns the numner of indices or zero if the mesh has no geometry.
  26231. */
  26232. getTotalIndices(): number;
  26233. /**
  26234. * Returns null by default. Implemented by child classes
  26235. * @returns null
  26236. */
  26237. getIndices(): Nullable<IndicesArray>;
  26238. /**
  26239. * Returns the array of the requested vertex data kind. Implemented by child classes
  26240. * @param kind defines the vertex data kind to use
  26241. * @returns null
  26242. */
  26243. getVerticesData(kind: string): Nullable<FloatArray>;
  26244. /**
  26245. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26246. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26247. * Note that a new underlying VertexBuffer object is created each call.
  26248. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26249. * @param kind defines vertex data kind:
  26250. * * VertexBuffer.PositionKind
  26251. * * VertexBuffer.UVKind
  26252. * * VertexBuffer.UV2Kind
  26253. * * VertexBuffer.UV3Kind
  26254. * * VertexBuffer.UV4Kind
  26255. * * VertexBuffer.UV5Kind
  26256. * * VertexBuffer.UV6Kind
  26257. * * VertexBuffer.ColorKind
  26258. * * VertexBuffer.MatricesIndicesKind
  26259. * * VertexBuffer.MatricesIndicesExtraKind
  26260. * * VertexBuffer.MatricesWeightsKind
  26261. * * VertexBuffer.MatricesWeightsExtraKind
  26262. * @param data defines the data source
  26263. * @param updatable defines if the data must be flagged as updatable (or static)
  26264. * @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
  26265. * @returns the current mesh
  26266. */
  26267. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26268. /**
  26269. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26270. * If the mesh has no geometry, it is simply returned as it is.
  26271. * @param kind defines vertex data kind:
  26272. * * VertexBuffer.PositionKind
  26273. * * VertexBuffer.UVKind
  26274. * * VertexBuffer.UV2Kind
  26275. * * VertexBuffer.UV3Kind
  26276. * * VertexBuffer.UV4Kind
  26277. * * VertexBuffer.UV5Kind
  26278. * * VertexBuffer.UV6Kind
  26279. * * VertexBuffer.ColorKind
  26280. * * VertexBuffer.MatricesIndicesKind
  26281. * * VertexBuffer.MatricesIndicesExtraKind
  26282. * * VertexBuffer.MatricesWeightsKind
  26283. * * VertexBuffer.MatricesWeightsExtraKind
  26284. * @param data defines the data source
  26285. * @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
  26286. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26287. * @returns the current mesh
  26288. */
  26289. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26290. /**
  26291. * Sets the mesh indices,
  26292. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26293. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26294. * @param totalVertices Defines the total number of vertices
  26295. * @returns the current mesh
  26296. */
  26297. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26298. /**
  26299. * Gets a boolean indicating if specific vertex data is present
  26300. * @param kind defines the vertex data kind to use
  26301. * @returns true is data kind is present
  26302. */
  26303. isVerticesDataPresent(kind: string): boolean;
  26304. /**
  26305. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26306. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26307. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26308. * @returns a BoundingInfo
  26309. */
  26310. getBoundingInfo(): BoundingInfo;
  26311. /**
  26312. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26313. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26314. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26315. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26316. * @returns the current mesh
  26317. */
  26318. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26319. /**
  26320. * Overwrite the current bounding info
  26321. * @param boundingInfo defines the new bounding info
  26322. * @returns the current mesh
  26323. */
  26324. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26325. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26326. readonly useBones: boolean;
  26327. /** @hidden */
  26328. _preActivate(): void;
  26329. /** @hidden */
  26330. _preActivateForIntermediateRendering(renderId: number): void;
  26331. /** @hidden */
  26332. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26333. /** @hidden */
  26334. _postActivate(): void;
  26335. /** @hidden */
  26336. _freeze(): void;
  26337. /** @hidden */
  26338. _unFreeze(): void;
  26339. /**
  26340. * Gets the current world matrix
  26341. * @returns a Matrix
  26342. */
  26343. getWorldMatrix(): Matrix;
  26344. /** @hidden */
  26345. _getWorldMatrixDeterminant(): number;
  26346. /**
  26347. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26348. */
  26349. readonly isAnInstance: boolean;
  26350. /**
  26351. * Gets a boolean indicating if this mesh has instances
  26352. */
  26353. readonly hasInstances: boolean;
  26354. /**
  26355. * Perform relative position change from the point of view of behind the front of the mesh.
  26356. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26357. * Supports definition of mesh facing forward or backward
  26358. * @param amountRight defines the distance on the right axis
  26359. * @param amountUp defines the distance on the up axis
  26360. * @param amountForward defines the distance on the forward axis
  26361. * @returns the current mesh
  26362. */
  26363. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26364. /**
  26365. * Calculate relative position change from the point of view of behind the front of the mesh.
  26366. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26367. * Supports definition of mesh facing forward or backward
  26368. * @param amountRight defines the distance on the right axis
  26369. * @param amountUp defines the distance on the up axis
  26370. * @param amountForward defines the distance on the forward axis
  26371. * @returns the new displacement vector
  26372. */
  26373. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26374. /**
  26375. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26376. * Supports definition of mesh facing forward or backward
  26377. * @param flipBack defines the flip
  26378. * @param twirlClockwise defines the twirl
  26379. * @param tiltRight defines the tilt
  26380. * @returns the current mesh
  26381. */
  26382. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26383. /**
  26384. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26385. * Supports definition of mesh facing forward or backward.
  26386. * @param flipBack defines the flip
  26387. * @param twirlClockwise defines the twirl
  26388. * @param tiltRight defines the tilt
  26389. * @returns the new rotation vector
  26390. */
  26391. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26392. /**
  26393. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26394. * This means the mesh underlying bounding box and sphere are recomputed.
  26395. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26396. * @returns the current mesh
  26397. */
  26398. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26399. /** @hidden */
  26400. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26401. /** @hidden */
  26402. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26403. /** @hidden */
  26404. _updateBoundingInfo(): AbstractMesh;
  26405. /** @hidden */
  26406. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26407. /** @hidden */
  26408. protected _afterComputeWorldMatrix(): void;
  26409. /** @hidden */
  26410. readonly _effectiveMesh: AbstractMesh;
  26411. /**
  26412. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26413. * A mesh is in the frustum if its bounding box intersects the frustum
  26414. * @param frustumPlanes defines the frustum to test
  26415. * @returns true if the mesh is in the frustum planes
  26416. */
  26417. isInFrustum(frustumPlanes: Plane[]): boolean;
  26418. /**
  26419. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26420. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26421. * @param frustumPlanes defines the frustum to test
  26422. * @returns true if the mesh is completely in the frustum planes
  26423. */
  26424. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26425. /**
  26426. * True if the mesh intersects another mesh or a SolidParticle object
  26427. * @param mesh defines a target mesh or SolidParticle to test
  26428. * @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)
  26429. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26430. * @returns true if there is an intersection
  26431. */
  26432. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26433. /**
  26434. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26435. * @param point defines the point to test
  26436. * @returns true if there is an intersection
  26437. */
  26438. intersectsPoint(point: Vector3): boolean;
  26439. /**
  26440. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26441. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26442. */
  26443. checkCollisions: boolean;
  26444. /**
  26445. * Gets Collider object used to compute collisions (not physics)
  26446. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26447. */
  26448. readonly collider: Nullable<Collider>;
  26449. /**
  26450. * Move the mesh using collision engine
  26451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26452. * @param displacement defines the requested displacement vector
  26453. * @returns the current mesh
  26454. */
  26455. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26456. private _onCollisionPositionChange;
  26457. /** @hidden */
  26458. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26459. /** @hidden */
  26460. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26461. /** @hidden */
  26462. _checkCollision(collider: Collider): AbstractMesh;
  26463. /** @hidden */
  26464. _generatePointsArray(): boolean;
  26465. /**
  26466. * Checks if the passed Ray intersects with the mesh
  26467. * @param ray defines the ray to use
  26468. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26469. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26470. * @returns the picking info
  26471. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26472. */
  26473. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26474. /**
  26475. * Clones the current mesh
  26476. * @param name defines the mesh name
  26477. * @param newParent defines the new mesh parent
  26478. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26479. * @returns the new mesh
  26480. */
  26481. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26482. /**
  26483. * Disposes all the submeshes of the current meshnp
  26484. * @returns the current mesh
  26485. */
  26486. releaseSubMeshes(): AbstractMesh;
  26487. /**
  26488. * Releases resources associated with this abstract mesh.
  26489. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26490. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26491. */
  26492. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26493. /**
  26494. * Adds the passed mesh as a child to the current mesh
  26495. * @param mesh defines the child mesh
  26496. * @returns the current mesh
  26497. */
  26498. addChild(mesh: AbstractMesh): AbstractMesh;
  26499. /**
  26500. * Removes the passed mesh from the current mesh children list
  26501. * @param mesh defines the child mesh
  26502. * @returns the current mesh
  26503. */
  26504. removeChild(mesh: AbstractMesh): AbstractMesh;
  26505. /** @hidden */
  26506. private _initFacetData;
  26507. /**
  26508. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26509. * This method can be called within the render loop.
  26510. * 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
  26511. * @returns the current mesh
  26512. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26513. */
  26514. updateFacetData(): AbstractMesh;
  26515. /**
  26516. * Returns the facetLocalNormals array.
  26517. * The normals are expressed in the mesh local spac
  26518. * @returns an array of Vector3
  26519. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26520. */
  26521. getFacetLocalNormals(): Vector3[];
  26522. /**
  26523. * Returns the facetLocalPositions array.
  26524. * The facet positions are expressed in the mesh local space
  26525. * @returns an array of Vector3
  26526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26527. */
  26528. getFacetLocalPositions(): Vector3[];
  26529. /**
  26530. * Returns the facetLocalPartioning array
  26531. * @returns an array of array of numbers
  26532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26533. */
  26534. getFacetLocalPartitioning(): number[][];
  26535. /**
  26536. * Returns the i-th facet position in the world system.
  26537. * This method allocates a new Vector3 per call
  26538. * @param i defines the facet index
  26539. * @returns a new Vector3
  26540. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26541. */
  26542. getFacetPosition(i: number): Vector3;
  26543. /**
  26544. * Sets the reference Vector3 with the i-th facet position in the world system
  26545. * @param i defines the facet index
  26546. * @param ref defines the target vector
  26547. * @returns the current mesh
  26548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26549. */
  26550. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26551. /**
  26552. * Returns the i-th facet normal in the world system.
  26553. * This method allocates a new Vector3 per call
  26554. * @param i defines the facet index
  26555. * @returns a new Vector3
  26556. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26557. */
  26558. getFacetNormal(i: number): Vector3;
  26559. /**
  26560. * Sets the reference Vector3 with the i-th facet normal in the world system
  26561. * @param i defines the facet index
  26562. * @param ref defines the target vector
  26563. * @returns the current mesh
  26564. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26565. */
  26566. getFacetNormalToRef(i: number, ref: Vector3): this;
  26567. /**
  26568. * 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)
  26569. * @param x defines x coordinate
  26570. * @param y defines y coordinate
  26571. * @param z defines z coordinate
  26572. * @returns the array of facet indexes
  26573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26574. */
  26575. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26576. /**
  26577. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26578. * @param projected sets as the (x,y,z) world projection on the facet
  26579. * @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
  26580. * @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
  26581. * @param x defines x coordinate
  26582. * @param y defines y coordinate
  26583. * @param z defines z coordinate
  26584. * @returns the face index if found (or null instead)
  26585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26586. */
  26587. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26588. /**
  26589. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26590. * @param projected sets as the (x,y,z) local projection on the facet
  26591. * @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
  26592. * @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
  26593. * @param x defines x coordinate
  26594. * @param y defines y coordinate
  26595. * @param z defines z coordinate
  26596. * @returns the face index if found (or null instead)
  26597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26598. */
  26599. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26600. /**
  26601. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26602. * @returns the parameters
  26603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26604. */
  26605. getFacetDataParameters(): any;
  26606. /**
  26607. * Disables the feature FacetData and frees the related memory
  26608. * @returns the current mesh
  26609. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26610. */
  26611. disableFacetData(): AbstractMesh;
  26612. /**
  26613. * Updates the AbstractMesh indices array
  26614. * @param indices defines the data source
  26615. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26616. * @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)
  26617. * @returns the current mesh
  26618. */
  26619. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26620. /**
  26621. * Creates new normals data for the mesh
  26622. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26623. * @returns the current mesh
  26624. */
  26625. createNormals(updatable: boolean): AbstractMesh;
  26626. /**
  26627. * Align the mesh with a normal
  26628. * @param normal defines the normal to use
  26629. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26630. * @returns the current mesh
  26631. */
  26632. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26633. /** @hidden */
  26634. _checkOcclusionQuery(): boolean;
  26635. /**
  26636. * Disables the mesh edge rendering mode
  26637. * @returns the currentAbstractMesh
  26638. */
  26639. disableEdgesRendering(): AbstractMesh;
  26640. /**
  26641. * Enables the edge rendering mode on the mesh.
  26642. * This mode makes the mesh edges visible
  26643. * @param epsilon defines the maximal distance between two angles to detect a face
  26644. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26645. * @returns the currentAbstractMesh
  26646. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26647. */
  26648. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26649. }
  26650. }
  26651. declare module BABYLON {
  26652. /**
  26653. * Interface used to define ActionEvent
  26654. */
  26655. export interface IActionEvent {
  26656. /** The mesh or sprite that triggered the action */
  26657. source: any;
  26658. /** The X mouse cursor position at the time of the event */
  26659. pointerX: number;
  26660. /** The Y mouse cursor position at the time of the event */
  26661. pointerY: number;
  26662. /** The mesh that is currently pointed at (can be null) */
  26663. meshUnderPointer: Nullable<AbstractMesh>;
  26664. /** the original (browser) event that triggered the ActionEvent */
  26665. sourceEvent?: any;
  26666. /** additional data for the event */
  26667. additionalData?: any;
  26668. }
  26669. /**
  26670. * ActionEvent is the event being sent when an action is triggered.
  26671. */
  26672. export class ActionEvent implements IActionEvent {
  26673. /** The mesh or sprite that triggered the action */
  26674. source: any;
  26675. /** The X mouse cursor position at the time of the event */
  26676. pointerX: number;
  26677. /** The Y mouse cursor position at the time of the event */
  26678. pointerY: number;
  26679. /** The mesh that is currently pointed at (can be null) */
  26680. meshUnderPointer: Nullable<AbstractMesh>;
  26681. /** the original (browser) event that triggered the ActionEvent */
  26682. sourceEvent?: any;
  26683. /** additional data for the event */
  26684. additionalData?: any;
  26685. /**
  26686. * Creates a new ActionEvent
  26687. * @param source The mesh or sprite that triggered the action
  26688. * @param pointerX The X mouse cursor position at the time of the event
  26689. * @param pointerY The Y mouse cursor position at the time of the event
  26690. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26691. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26692. * @param additionalData additional data for the event
  26693. */
  26694. constructor(
  26695. /** The mesh or sprite that triggered the action */
  26696. source: any,
  26697. /** The X mouse cursor position at the time of the event */
  26698. pointerX: number,
  26699. /** The Y mouse cursor position at the time of the event */
  26700. pointerY: number,
  26701. /** The mesh that is currently pointed at (can be null) */
  26702. meshUnderPointer: Nullable<AbstractMesh>,
  26703. /** the original (browser) event that triggered the ActionEvent */
  26704. sourceEvent?: any,
  26705. /** additional data for the event */
  26706. additionalData?: any);
  26707. /**
  26708. * Helper function to auto-create an ActionEvent from a source mesh.
  26709. * @param source The source mesh that triggered the event
  26710. * @param evt The original (browser) event
  26711. * @param additionalData additional data for the event
  26712. * @returns the new ActionEvent
  26713. */
  26714. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26715. /**
  26716. * Helper function to auto-create an ActionEvent from a source sprite
  26717. * @param source The source sprite that triggered the event
  26718. * @param scene Scene associated with the sprite
  26719. * @param evt The original (browser) event
  26720. * @param additionalData additional data for the event
  26721. * @returns the new ActionEvent
  26722. */
  26723. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26724. /**
  26725. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26726. * @param scene the scene where the event occurred
  26727. * @param evt The original (browser) event
  26728. * @returns the new ActionEvent
  26729. */
  26730. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26731. /**
  26732. * Helper function to auto-create an ActionEvent from a primitive
  26733. * @param prim defines the target primitive
  26734. * @param pointerPos defines the pointer position
  26735. * @param evt The original (browser) event
  26736. * @param additionalData additional data for the event
  26737. * @returns the new ActionEvent
  26738. */
  26739. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26740. }
  26741. }
  26742. declare module BABYLON {
  26743. /**
  26744. * Abstract class used to decouple action Manager from scene and meshes.
  26745. * Do not instantiate.
  26746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26747. */
  26748. export abstract class AbstractActionManager implements IDisposable {
  26749. /** Gets the list of active triggers */
  26750. static Triggers: {
  26751. [key: string]: number;
  26752. };
  26753. /** Gets the cursor to use when hovering items */
  26754. hoverCursor: string;
  26755. /** Gets the list of actions */
  26756. actions: IAction[];
  26757. /**
  26758. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26759. */
  26760. isRecursive: boolean;
  26761. /**
  26762. * Releases all associated resources
  26763. */
  26764. abstract dispose(): void;
  26765. /**
  26766. * Does this action manager has pointer triggers
  26767. */
  26768. abstract readonly hasPointerTriggers: boolean;
  26769. /**
  26770. * Does this action manager has pick triggers
  26771. */
  26772. abstract readonly hasPickTriggers: boolean;
  26773. /**
  26774. * Process a specific trigger
  26775. * @param trigger defines the trigger to process
  26776. * @param evt defines the event details to be processed
  26777. */
  26778. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26779. /**
  26780. * Does this action manager handles actions of any of the given triggers
  26781. * @param triggers defines the triggers to be tested
  26782. * @return a boolean indicating whether one (or more) of the triggers is handled
  26783. */
  26784. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26785. /**
  26786. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26787. * speed.
  26788. * @param triggerA defines the trigger to be tested
  26789. * @param triggerB defines the trigger to be tested
  26790. * @return a boolean indicating whether one (or more) of the triggers is handled
  26791. */
  26792. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26793. /**
  26794. * Does this action manager handles actions of a given trigger
  26795. * @param trigger defines the trigger to be tested
  26796. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26797. * @return whether the trigger is handled
  26798. */
  26799. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26800. /**
  26801. * Serialize this manager to a JSON object
  26802. * @param name defines the property name to store this manager
  26803. * @returns a JSON representation of this manager
  26804. */
  26805. abstract serialize(name: string): any;
  26806. /**
  26807. * Registers an action to this action manager
  26808. * @param action defines the action to be registered
  26809. * @return the action amended (prepared) after registration
  26810. */
  26811. abstract registerAction(action: IAction): Nullable<IAction>;
  26812. /**
  26813. * Unregisters an action to this action manager
  26814. * @param action defines the action to be unregistered
  26815. * @return a boolean indicating whether the action has been unregistered
  26816. */
  26817. abstract unregisterAction(action: IAction): Boolean;
  26818. /**
  26819. * Does exist one action manager with at least one trigger
  26820. **/
  26821. static readonly HasTriggers: boolean;
  26822. /**
  26823. * Does exist one action manager with at least one pick trigger
  26824. **/
  26825. static readonly HasPickTriggers: boolean;
  26826. /**
  26827. * Does exist one action manager that handles actions of a given trigger
  26828. * @param trigger defines the trigger to be tested
  26829. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26830. **/
  26831. static HasSpecificTrigger(trigger: number): boolean;
  26832. }
  26833. }
  26834. declare module BABYLON {
  26835. /**
  26836. * Defines how a node can be built from a string name.
  26837. */
  26838. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26839. /**
  26840. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26841. */
  26842. export class Node implements IBehaviorAware<Node> {
  26843. /** @hidden */
  26844. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26845. private static _NodeConstructors;
  26846. /**
  26847. * Add a new node constructor
  26848. * @param type defines the type name of the node to construct
  26849. * @param constructorFunc defines the constructor function
  26850. */
  26851. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26852. /**
  26853. * Returns a node constructor based on type name
  26854. * @param type defines the type name
  26855. * @param name defines the new node name
  26856. * @param scene defines the hosting scene
  26857. * @param options defines optional options to transmit to constructors
  26858. * @returns the new constructor or null
  26859. */
  26860. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26861. /**
  26862. * Gets or sets the name of the node
  26863. */
  26864. name: string;
  26865. /**
  26866. * Gets or sets the id of the node
  26867. */
  26868. id: string;
  26869. /**
  26870. * Gets or sets the unique id of the node
  26871. */
  26872. uniqueId: number;
  26873. /**
  26874. * Gets or sets a string used to store user defined state for the node
  26875. */
  26876. state: string;
  26877. /**
  26878. * Gets or sets an object used to store user defined information for the node
  26879. */
  26880. metadata: any;
  26881. /**
  26882. * For internal use only. Please do not use.
  26883. */
  26884. reservedDataStore: any;
  26885. /**
  26886. * List of inspectable custom properties (used by the Inspector)
  26887. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26888. */
  26889. inspectableCustomProperties: IInspectable[];
  26890. private _doNotSerialize;
  26891. /**
  26892. * Gets or sets a boolean used to define if the node must be serialized
  26893. */
  26894. doNotSerialize: boolean;
  26895. /** @hidden */
  26896. _isDisposed: boolean;
  26897. /**
  26898. * Gets a list of Animations associated with the node
  26899. */
  26900. animations: Animation[];
  26901. protected _ranges: {
  26902. [name: string]: Nullable<AnimationRange>;
  26903. };
  26904. /**
  26905. * Callback raised when the node is ready to be used
  26906. */
  26907. onReady: Nullable<(node: Node) => void>;
  26908. private _isEnabled;
  26909. private _isParentEnabled;
  26910. private _isReady;
  26911. /** @hidden */
  26912. _currentRenderId: number;
  26913. private _parentUpdateId;
  26914. /** @hidden */
  26915. _childUpdateId: number;
  26916. /** @hidden */
  26917. _waitingParentId: Nullable<string>;
  26918. /** @hidden */
  26919. _scene: Scene;
  26920. /** @hidden */
  26921. _cache: any;
  26922. private _parentNode;
  26923. private _children;
  26924. /** @hidden */
  26925. _worldMatrix: Matrix;
  26926. /** @hidden */
  26927. _worldMatrixDeterminant: number;
  26928. /** @hidden */
  26929. _worldMatrixDeterminantIsDirty: boolean;
  26930. /** @hidden */
  26931. private _sceneRootNodesIndex;
  26932. /**
  26933. * Gets a boolean indicating if the node has been disposed
  26934. * @returns true if the node was disposed
  26935. */
  26936. isDisposed(): boolean;
  26937. /**
  26938. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26939. * @see https://doc.babylonjs.com/how_to/parenting
  26940. */
  26941. parent: Nullable<Node>;
  26942. private addToSceneRootNodes;
  26943. private removeFromSceneRootNodes;
  26944. private _animationPropertiesOverride;
  26945. /**
  26946. * Gets or sets the animation properties override
  26947. */
  26948. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26949. /**
  26950. * Gets a string idenfifying the name of the class
  26951. * @returns "Node" string
  26952. */
  26953. getClassName(): string;
  26954. /** @hidden */
  26955. readonly _isNode: boolean;
  26956. /**
  26957. * An event triggered when the mesh is disposed
  26958. */
  26959. onDisposeObservable: Observable<Node>;
  26960. private _onDisposeObserver;
  26961. /**
  26962. * Sets a callback that will be raised when the node will be disposed
  26963. */
  26964. onDispose: () => void;
  26965. /**
  26966. * Creates a new Node
  26967. * @param name the name and id to be given to this node
  26968. * @param scene the scene this node will be added to
  26969. * @param addToRootNodes the node will be added to scene.rootNodes
  26970. */
  26971. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26972. /**
  26973. * Gets the scene of the node
  26974. * @returns a scene
  26975. */
  26976. getScene(): Scene;
  26977. /**
  26978. * Gets the engine of the node
  26979. * @returns a Engine
  26980. */
  26981. getEngine(): Engine;
  26982. private _behaviors;
  26983. /**
  26984. * Attach a behavior to the node
  26985. * @see http://doc.babylonjs.com/features/behaviour
  26986. * @param behavior defines the behavior to attach
  26987. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26988. * @returns the current Node
  26989. */
  26990. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26991. /**
  26992. * Remove an attached behavior
  26993. * @see http://doc.babylonjs.com/features/behaviour
  26994. * @param behavior defines the behavior to attach
  26995. * @returns the current Node
  26996. */
  26997. removeBehavior(behavior: Behavior<Node>): Node;
  26998. /**
  26999. * Gets the list of attached behaviors
  27000. * @see http://doc.babylonjs.com/features/behaviour
  27001. */
  27002. readonly behaviors: Behavior<Node>[];
  27003. /**
  27004. * Gets an attached behavior by name
  27005. * @param name defines the name of the behavior to look for
  27006. * @see http://doc.babylonjs.com/features/behaviour
  27007. * @returns null if behavior was not found else the requested behavior
  27008. */
  27009. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27010. /**
  27011. * Returns the latest update of the World matrix
  27012. * @returns a Matrix
  27013. */
  27014. getWorldMatrix(): Matrix;
  27015. /** @hidden */
  27016. _getWorldMatrixDeterminant(): number;
  27017. /**
  27018. * Returns directly the latest state of the mesh World matrix.
  27019. * A Matrix is returned.
  27020. */
  27021. readonly worldMatrixFromCache: Matrix;
  27022. /** @hidden */
  27023. _initCache(): void;
  27024. /** @hidden */
  27025. updateCache(force?: boolean): void;
  27026. /** @hidden */
  27027. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27028. /** @hidden */
  27029. _updateCache(ignoreParentClass?: boolean): void;
  27030. /** @hidden */
  27031. _isSynchronized(): boolean;
  27032. /** @hidden */
  27033. _markSyncedWithParent(): void;
  27034. /** @hidden */
  27035. isSynchronizedWithParent(): boolean;
  27036. /** @hidden */
  27037. isSynchronized(): boolean;
  27038. /**
  27039. * Is this node ready to be used/rendered
  27040. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27041. * @return true if the node is ready
  27042. */
  27043. isReady(completeCheck?: boolean): boolean;
  27044. /**
  27045. * Is this node enabled?
  27046. * 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
  27047. * @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
  27048. * @return whether this node (and its parent) is enabled
  27049. */
  27050. isEnabled(checkAncestors?: boolean): boolean;
  27051. /** @hidden */
  27052. protected _syncParentEnabledState(): void;
  27053. /**
  27054. * Set the enabled state of this node
  27055. * @param value defines the new enabled state
  27056. */
  27057. setEnabled(value: boolean): void;
  27058. /**
  27059. * Is this node a descendant of the given node?
  27060. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27061. * @param ancestor defines the parent node to inspect
  27062. * @returns a boolean indicating if this node is a descendant of the given node
  27063. */
  27064. isDescendantOf(ancestor: Node): boolean;
  27065. /** @hidden */
  27066. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27067. /**
  27068. * Will return all nodes that have this node as ascendant
  27069. * @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
  27070. * @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
  27071. * @return all children nodes of all types
  27072. */
  27073. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27074. /**
  27075. * Get all child-meshes of this node
  27076. * @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)
  27077. * @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
  27078. * @returns an array of AbstractMesh
  27079. */
  27080. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27081. /**
  27082. * Get all direct children of this node
  27083. * @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
  27084. * @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)
  27085. * @returns an array of Node
  27086. */
  27087. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27088. /** @hidden */
  27089. _setReady(state: boolean): void;
  27090. /**
  27091. * Get an animation by name
  27092. * @param name defines the name of the animation to look for
  27093. * @returns null if not found else the requested animation
  27094. */
  27095. getAnimationByName(name: string): Nullable<Animation>;
  27096. /**
  27097. * Creates an animation range for this node
  27098. * @param name defines the name of the range
  27099. * @param from defines the starting key
  27100. * @param to defines the end key
  27101. */
  27102. createAnimationRange(name: string, from: number, to: number): void;
  27103. /**
  27104. * Delete a specific animation range
  27105. * @param name defines the name of the range to delete
  27106. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27107. */
  27108. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27109. /**
  27110. * Get an animation range by name
  27111. * @param name defines the name of the animation range to look for
  27112. * @returns null if not found else the requested animation range
  27113. */
  27114. getAnimationRange(name: string): Nullable<AnimationRange>;
  27115. /**
  27116. * Gets the list of all animation ranges defined on this node
  27117. * @returns an array
  27118. */
  27119. getAnimationRanges(): Nullable<AnimationRange>[];
  27120. /**
  27121. * Will start the animation sequence
  27122. * @param name defines the range frames for animation sequence
  27123. * @param loop defines if the animation should loop (false by default)
  27124. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27125. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27126. * @returns the object created for this animation. If range does not exist, it will return null
  27127. */
  27128. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27129. /**
  27130. * Serialize animation ranges into a JSON compatible object
  27131. * @returns serialization object
  27132. */
  27133. serializeAnimationRanges(): any;
  27134. /**
  27135. * Computes the world matrix of the node
  27136. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27137. * @returns the world matrix
  27138. */
  27139. computeWorldMatrix(force?: boolean): Matrix;
  27140. /**
  27141. * Releases resources associated with this node.
  27142. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27143. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27144. */
  27145. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27146. /**
  27147. * Parse animation range data from a serialization object and store them into a given node
  27148. * @param node defines where to store the animation ranges
  27149. * @param parsedNode defines the serialization object to read data from
  27150. * @param scene defines the hosting scene
  27151. */
  27152. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27153. /**
  27154. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27155. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27156. * @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
  27157. * @returns the new bounding vectors
  27158. */
  27159. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27160. min: Vector3;
  27161. max: Vector3;
  27162. };
  27163. }
  27164. }
  27165. declare module BABYLON {
  27166. /**
  27167. * @hidden
  27168. */
  27169. export class _IAnimationState {
  27170. key: number;
  27171. repeatCount: number;
  27172. workValue?: any;
  27173. loopMode?: number;
  27174. offsetValue?: any;
  27175. highLimitValue?: any;
  27176. }
  27177. /**
  27178. * Class used to store any kind of animation
  27179. */
  27180. export class Animation {
  27181. /**Name of the animation */
  27182. name: string;
  27183. /**Property to animate */
  27184. targetProperty: string;
  27185. /**The frames per second of the animation */
  27186. framePerSecond: number;
  27187. /**The data type of the animation */
  27188. dataType: number;
  27189. /**The loop mode of the animation */
  27190. loopMode?: number | undefined;
  27191. /**Specifies if blending should be enabled */
  27192. enableBlending?: boolean | undefined;
  27193. /**
  27194. * Use matrix interpolation instead of using direct key value when animating matrices
  27195. */
  27196. static AllowMatricesInterpolation: boolean;
  27197. /**
  27198. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27199. */
  27200. static AllowMatrixDecomposeForInterpolation: boolean;
  27201. /**
  27202. * Stores the key frames of the animation
  27203. */
  27204. private _keys;
  27205. /**
  27206. * Stores the easing function of the animation
  27207. */
  27208. private _easingFunction;
  27209. /**
  27210. * @hidden Internal use only
  27211. */
  27212. _runtimeAnimations: RuntimeAnimation[];
  27213. /**
  27214. * The set of event that will be linked to this animation
  27215. */
  27216. private _events;
  27217. /**
  27218. * Stores an array of target property paths
  27219. */
  27220. targetPropertyPath: string[];
  27221. /**
  27222. * Stores the blending speed of the animation
  27223. */
  27224. blendingSpeed: number;
  27225. /**
  27226. * Stores the animation ranges for the animation
  27227. */
  27228. private _ranges;
  27229. /**
  27230. * @hidden Internal use
  27231. */
  27232. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27233. /**
  27234. * Sets up an animation
  27235. * @param property The property to animate
  27236. * @param animationType The animation type to apply
  27237. * @param framePerSecond The frames per second of the animation
  27238. * @param easingFunction The easing function used in the animation
  27239. * @returns The created animation
  27240. */
  27241. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27242. /**
  27243. * Create and start an animation on a node
  27244. * @param name defines the name of the global animation that will be run on all nodes
  27245. * @param node defines the root node where the animation will take place
  27246. * @param targetProperty defines property to animate
  27247. * @param framePerSecond defines the number of frame per second yo use
  27248. * @param totalFrame defines the number of frames in total
  27249. * @param from defines the initial value
  27250. * @param to defines the final value
  27251. * @param loopMode defines which loop mode you want to use (off by default)
  27252. * @param easingFunction defines the easing function to use (linear by default)
  27253. * @param onAnimationEnd defines the callback to call when animation end
  27254. * @returns the animatable created for this animation
  27255. */
  27256. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27257. /**
  27258. * Create and start an animation on a node and its descendants
  27259. * @param name defines the name of the global animation that will be run on all nodes
  27260. * @param node defines the root node where the animation will take place
  27261. * @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
  27262. * @param targetProperty defines property to animate
  27263. * @param framePerSecond defines the number of frame per second to use
  27264. * @param totalFrame defines the number of frames in total
  27265. * @param from defines the initial value
  27266. * @param to defines the final value
  27267. * @param loopMode defines which loop mode you want to use (off by default)
  27268. * @param easingFunction defines the easing function to use (linear by default)
  27269. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27270. * @returns the list of animatables created for all nodes
  27271. * @example https://www.babylonjs-playground.com/#MH0VLI
  27272. */
  27273. 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[]>;
  27274. /**
  27275. * Creates a new animation, merges it with the existing animations and starts it
  27276. * @param name Name of the animation
  27277. * @param node Node which contains the scene that begins the animations
  27278. * @param targetProperty Specifies which property to animate
  27279. * @param framePerSecond The frames per second of the animation
  27280. * @param totalFrame The total number of frames
  27281. * @param from The frame at the beginning of the animation
  27282. * @param to The frame at the end of the animation
  27283. * @param loopMode Specifies the loop mode of the animation
  27284. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27285. * @param onAnimationEnd Callback to run once the animation is complete
  27286. * @returns Nullable animation
  27287. */
  27288. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27289. /**
  27290. * Transition property of an host to the target Value
  27291. * @param property The property to transition
  27292. * @param targetValue The target Value of the property
  27293. * @param host The object where the property to animate belongs
  27294. * @param scene Scene used to run the animation
  27295. * @param frameRate Framerate (in frame/s) to use
  27296. * @param transition The transition type we want to use
  27297. * @param duration The duration of the animation, in milliseconds
  27298. * @param onAnimationEnd Callback trigger at the end of the animation
  27299. * @returns Nullable animation
  27300. */
  27301. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27302. /**
  27303. * Return the array of runtime animations currently using this animation
  27304. */
  27305. readonly runtimeAnimations: RuntimeAnimation[];
  27306. /**
  27307. * Specifies if any of the runtime animations are currently running
  27308. */
  27309. readonly hasRunningRuntimeAnimations: boolean;
  27310. /**
  27311. * Initializes the animation
  27312. * @param name Name of the animation
  27313. * @param targetProperty Property to animate
  27314. * @param framePerSecond The frames per second of the animation
  27315. * @param dataType The data type of the animation
  27316. * @param loopMode The loop mode of the animation
  27317. * @param enableBlending Specifies if blending should be enabled
  27318. */
  27319. constructor(
  27320. /**Name of the animation */
  27321. name: string,
  27322. /**Property to animate */
  27323. targetProperty: string,
  27324. /**The frames per second of the animation */
  27325. framePerSecond: number,
  27326. /**The data type of the animation */
  27327. dataType: number,
  27328. /**The loop mode of the animation */
  27329. loopMode?: number | undefined,
  27330. /**Specifies if blending should be enabled */
  27331. enableBlending?: boolean | undefined);
  27332. /**
  27333. * Converts the animation to a string
  27334. * @param fullDetails support for multiple levels of logging within scene loading
  27335. * @returns String form of the animation
  27336. */
  27337. toString(fullDetails?: boolean): string;
  27338. /**
  27339. * Add an event to this animation
  27340. * @param event Event to add
  27341. */
  27342. addEvent(event: AnimationEvent): void;
  27343. /**
  27344. * Remove all events found at the given frame
  27345. * @param frame The frame to remove events from
  27346. */
  27347. removeEvents(frame: number): void;
  27348. /**
  27349. * Retrieves all the events from the animation
  27350. * @returns Events from the animation
  27351. */
  27352. getEvents(): AnimationEvent[];
  27353. /**
  27354. * Creates an animation range
  27355. * @param name Name of the animation range
  27356. * @param from Starting frame of the animation range
  27357. * @param to Ending frame of the animation
  27358. */
  27359. createRange(name: string, from: number, to: number): void;
  27360. /**
  27361. * Deletes an animation range by name
  27362. * @param name Name of the animation range to delete
  27363. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27364. */
  27365. deleteRange(name: string, deleteFrames?: boolean): void;
  27366. /**
  27367. * Gets the animation range by name, or null if not defined
  27368. * @param name Name of the animation range
  27369. * @returns Nullable animation range
  27370. */
  27371. getRange(name: string): Nullable<AnimationRange>;
  27372. /**
  27373. * Gets the key frames from the animation
  27374. * @returns The key frames of the animation
  27375. */
  27376. getKeys(): Array<IAnimationKey>;
  27377. /**
  27378. * Gets the highest frame rate of the animation
  27379. * @returns Highest frame rate of the animation
  27380. */
  27381. getHighestFrame(): number;
  27382. /**
  27383. * Gets the easing function of the animation
  27384. * @returns Easing function of the animation
  27385. */
  27386. getEasingFunction(): IEasingFunction;
  27387. /**
  27388. * Sets the easing function of the animation
  27389. * @param easingFunction A custom mathematical formula for animation
  27390. */
  27391. setEasingFunction(easingFunction: EasingFunction): void;
  27392. /**
  27393. * Interpolates a scalar linearly
  27394. * @param startValue Start value of the animation curve
  27395. * @param endValue End value of the animation curve
  27396. * @param gradient Scalar amount to interpolate
  27397. * @returns Interpolated scalar value
  27398. */
  27399. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27400. /**
  27401. * Interpolates a scalar cubically
  27402. * @param startValue Start value of the animation curve
  27403. * @param outTangent End tangent of the animation
  27404. * @param endValue End value of the animation curve
  27405. * @param inTangent Start tangent of the animation curve
  27406. * @param gradient Scalar amount to interpolate
  27407. * @returns Interpolated scalar value
  27408. */
  27409. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27410. /**
  27411. * Interpolates a quaternion using a spherical linear interpolation
  27412. * @param startValue Start value of the animation curve
  27413. * @param endValue End value of the animation curve
  27414. * @param gradient Scalar amount to interpolate
  27415. * @returns Interpolated quaternion value
  27416. */
  27417. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27418. /**
  27419. * Interpolates a quaternion cubically
  27420. * @param startValue Start value of the animation curve
  27421. * @param outTangent End tangent of the animation curve
  27422. * @param endValue End value of the animation curve
  27423. * @param inTangent Start tangent of the animation curve
  27424. * @param gradient Scalar amount to interpolate
  27425. * @returns Interpolated quaternion value
  27426. */
  27427. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27428. /**
  27429. * Interpolates a Vector3 linearl
  27430. * @param startValue Start value of the animation curve
  27431. * @param endValue End value of the animation curve
  27432. * @param gradient Scalar amount to interpolate
  27433. * @returns Interpolated scalar value
  27434. */
  27435. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27436. /**
  27437. * Interpolates a Vector3 cubically
  27438. * @param startValue Start value of the animation curve
  27439. * @param outTangent End tangent of the animation
  27440. * @param endValue End value of the animation curve
  27441. * @param inTangent Start tangent of the animation curve
  27442. * @param gradient Scalar amount to interpolate
  27443. * @returns InterpolatedVector3 value
  27444. */
  27445. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27446. /**
  27447. * Interpolates a Vector2 linearly
  27448. * @param startValue Start value of the animation curve
  27449. * @param endValue End value of the animation curve
  27450. * @param gradient Scalar amount to interpolate
  27451. * @returns Interpolated Vector2 value
  27452. */
  27453. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27454. /**
  27455. * Interpolates a Vector2 cubically
  27456. * @param startValue Start value of the animation curve
  27457. * @param outTangent End tangent of the animation
  27458. * @param endValue End value of the animation curve
  27459. * @param inTangent Start tangent of the animation curve
  27460. * @param gradient Scalar amount to interpolate
  27461. * @returns Interpolated Vector2 value
  27462. */
  27463. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27464. /**
  27465. * Interpolates a size linearly
  27466. * @param startValue Start value of the animation curve
  27467. * @param endValue End value of the animation curve
  27468. * @param gradient Scalar amount to interpolate
  27469. * @returns Interpolated Size value
  27470. */
  27471. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27472. /**
  27473. * Interpolates a Color3 linearly
  27474. * @param startValue Start value of the animation curve
  27475. * @param endValue End value of the animation curve
  27476. * @param gradient Scalar amount to interpolate
  27477. * @returns Interpolated Color3 value
  27478. */
  27479. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27480. /**
  27481. * @hidden Internal use only
  27482. */
  27483. _getKeyValue(value: any): any;
  27484. /**
  27485. * @hidden Internal use only
  27486. */
  27487. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27488. /**
  27489. * Defines the function to use to interpolate matrices
  27490. * @param startValue defines the start matrix
  27491. * @param endValue defines the end matrix
  27492. * @param gradient defines the gradient between both matrices
  27493. * @param result defines an optional target matrix where to store the interpolation
  27494. * @returns the interpolated matrix
  27495. */
  27496. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27497. /**
  27498. * Makes a copy of the animation
  27499. * @returns Cloned animation
  27500. */
  27501. clone(): Animation;
  27502. /**
  27503. * Sets the key frames of the animation
  27504. * @param values The animation key frames to set
  27505. */
  27506. setKeys(values: Array<IAnimationKey>): void;
  27507. /**
  27508. * Serializes the animation to an object
  27509. * @returns Serialized object
  27510. */
  27511. serialize(): any;
  27512. /**
  27513. * Float animation type
  27514. */
  27515. private static _ANIMATIONTYPE_FLOAT;
  27516. /**
  27517. * Vector3 animation type
  27518. */
  27519. private static _ANIMATIONTYPE_VECTOR3;
  27520. /**
  27521. * Quaternion animation type
  27522. */
  27523. private static _ANIMATIONTYPE_QUATERNION;
  27524. /**
  27525. * Matrix animation type
  27526. */
  27527. private static _ANIMATIONTYPE_MATRIX;
  27528. /**
  27529. * Color3 animation type
  27530. */
  27531. private static _ANIMATIONTYPE_COLOR3;
  27532. /**
  27533. * Vector2 animation type
  27534. */
  27535. private static _ANIMATIONTYPE_VECTOR2;
  27536. /**
  27537. * Size animation type
  27538. */
  27539. private static _ANIMATIONTYPE_SIZE;
  27540. /**
  27541. * Relative Loop Mode
  27542. */
  27543. private static _ANIMATIONLOOPMODE_RELATIVE;
  27544. /**
  27545. * Cycle Loop Mode
  27546. */
  27547. private static _ANIMATIONLOOPMODE_CYCLE;
  27548. /**
  27549. * Constant Loop Mode
  27550. */
  27551. private static _ANIMATIONLOOPMODE_CONSTANT;
  27552. /**
  27553. * Get the float animation type
  27554. */
  27555. static readonly ANIMATIONTYPE_FLOAT: number;
  27556. /**
  27557. * Get the Vector3 animation type
  27558. */
  27559. static readonly ANIMATIONTYPE_VECTOR3: number;
  27560. /**
  27561. * Get the Vector2 animation type
  27562. */
  27563. static readonly ANIMATIONTYPE_VECTOR2: number;
  27564. /**
  27565. * Get the Size animation type
  27566. */
  27567. static readonly ANIMATIONTYPE_SIZE: number;
  27568. /**
  27569. * Get the Quaternion animation type
  27570. */
  27571. static readonly ANIMATIONTYPE_QUATERNION: number;
  27572. /**
  27573. * Get the Matrix animation type
  27574. */
  27575. static readonly ANIMATIONTYPE_MATRIX: number;
  27576. /**
  27577. * Get the Color3 animation type
  27578. */
  27579. static readonly ANIMATIONTYPE_COLOR3: number;
  27580. /**
  27581. * Get the Relative Loop Mode
  27582. */
  27583. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27584. /**
  27585. * Get the Cycle Loop Mode
  27586. */
  27587. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27588. /**
  27589. * Get the Constant Loop Mode
  27590. */
  27591. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27592. /** @hidden */
  27593. static _UniversalLerp(left: any, right: any, amount: number): any;
  27594. /**
  27595. * Parses an animation object and creates an animation
  27596. * @param parsedAnimation Parsed animation object
  27597. * @returns Animation object
  27598. */
  27599. static Parse(parsedAnimation: any): Animation;
  27600. /**
  27601. * Appends the serialized animations from the source animations
  27602. * @param source Source containing the animations
  27603. * @param destination Target to store the animations
  27604. */
  27605. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27606. }
  27607. }
  27608. declare module BABYLON {
  27609. /**
  27610. * Interface containing an array of animations
  27611. */
  27612. export interface IAnimatable {
  27613. /**
  27614. * Array of animations
  27615. */
  27616. animations: Nullable<Array<Animation>>;
  27617. }
  27618. }
  27619. declare module BABYLON {
  27620. /**
  27621. * This represents all the required information to add a fresnel effect on a material:
  27622. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27623. */
  27624. export class FresnelParameters {
  27625. private _isEnabled;
  27626. /**
  27627. * Define if the fresnel effect is enable or not.
  27628. */
  27629. isEnabled: boolean;
  27630. /**
  27631. * Define the color used on edges (grazing angle)
  27632. */
  27633. leftColor: Color3;
  27634. /**
  27635. * Define the color used on center
  27636. */
  27637. rightColor: Color3;
  27638. /**
  27639. * Define bias applied to computed fresnel term
  27640. */
  27641. bias: number;
  27642. /**
  27643. * Defined the power exponent applied to fresnel term
  27644. */
  27645. power: number;
  27646. /**
  27647. * Clones the current fresnel and its valuues
  27648. * @returns a clone fresnel configuration
  27649. */
  27650. clone(): FresnelParameters;
  27651. /**
  27652. * Serializes the current fresnel parameters to a JSON representation.
  27653. * @return the JSON serialization
  27654. */
  27655. serialize(): any;
  27656. /**
  27657. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27658. * @param parsedFresnelParameters Define the JSON representation
  27659. * @returns the parsed parameters
  27660. */
  27661. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27662. }
  27663. }
  27664. declare module BABYLON {
  27665. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27666. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27667. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27668. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27669. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27670. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27671. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27672. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27673. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27674. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27675. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27676. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27677. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27678. /**
  27679. * Decorator used to define property that can be serialized as reference to a camera
  27680. * @param sourceName defines the name of the property to decorate
  27681. */
  27682. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27683. /**
  27684. * Class used to help serialization objects
  27685. */
  27686. export class SerializationHelper {
  27687. /** @hidden */
  27688. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27689. /** @hidden */
  27690. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27691. /** @hidden */
  27692. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27693. /** @hidden */
  27694. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27695. /**
  27696. * Appends the serialized animations from the source animations
  27697. * @param source Source containing the animations
  27698. * @param destination Target to store the animations
  27699. */
  27700. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27701. /**
  27702. * Static function used to serialized a specific entity
  27703. * @param entity defines the entity to serialize
  27704. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27705. * @returns a JSON compatible object representing the serialization of the entity
  27706. */
  27707. static Serialize<T>(entity: T, serializationObject?: any): any;
  27708. /**
  27709. * Creates a new entity from a serialization data object
  27710. * @param creationFunction defines a function used to instanciated the new entity
  27711. * @param source defines the source serialization data
  27712. * @param scene defines the hosting scene
  27713. * @param rootUrl defines the root url for resources
  27714. * @returns a new entity
  27715. */
  27716. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27717. /**
  27718. * Clones an object
  27719. * @param creationFunction defines the function used to instanciate the new object
  27720. * @param source defines the source object
  27721. * @returns the cloned object
  27722. */
  27723. static Clone<T>(creationFunction: () => T, source: T): T;
  27724. /**
  27725. * Instanciates a new object based on a source one (some data will be shared between both object)
  27726. * @param creationFunction defines the function used to instanciate the new object
  27727. * @param source defines the source object
  27728. * @returns the new object
  27729. */
  27730. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27731. }
  27732. }
  27733. declare module BABYLON {
  27734. /**
  27735. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27736. */
  27737. export interface CubeMapInfo {
  27738. /**
  27739. * The pixel array for the front face.
  27740. * This is stored in format, left to right, up to down format.
  27741. */
  27742. front: Nullable<ArrayBufferView>;
  27743. /**
  27744. * The pixel array for the back face.
  27745. * This is stored in format, left to right, up to down format.
  27746. */
  27747. back: Nullable<ArrayBufferView>;
  27748. /**
  27749. * The pixel array for the left face.
  27750. * This is stored in format, left to right, up to down format.
  27751. */
  27752. left: Nullable<ArrayBufferView>;
  27753. /**
  27754. * The pixel array for the right face.
  27755. * This is stored in format, left to right, up to down format.
  27756. */
  27757. right: Nullable<ArrayBufferView>;
  27758. /**
  27759. * The pixel array for the up face.
  27760. * This is stored in format, left to right, up to down format.
  27761. */
  27762. up: Nullable<ArrayBufferView>;
  27763. /**
  27764. * The pixel array for the down face.
  27765. * This is stored in format, left to right, up to down format.
  27766. */
  27767. down: Nullable<ArrayBufferView>;
  27768. /**
  27769. * The size of the cubemap stored.
  27770. *
  27771. * Each faces will be size * size pixels.
  27772. */
  27773. size: number;
  27774. /**
  27775. * The format of the texture.
  27776. *
  27777. * RGBA, RGB.
  27778. */
  27779. format: number;
  27780. /**
  27781. * The type of the texture data.
  27782. *
  27783. * UNSIGNED_INT, FLOAT.
  27784. */
  27785. type: number;
  27786. /**
  27787. * Specifies whether the texture is in gamma space.
  27788. */
  27789. gammaSpace: boolean;
  27790. }
  27791. /**
  27792. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27793. */
  27794. export class PanoramaToCubeMapTools {
  27795. private static FACE_FRONT;
  27796. private static FACE_BACK;
  27797. private static FACE_RIGHT;
  27798. private static FACE_LEFT;
  27799. private static FACE_DOWN;
  27800. private static FACE_UP;
  27801. /**
  27802. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27803. *
  27804. * @param float32Array The source data.
  27805. * @param inputWidth The width of the input panorama.
  27806. * @param inputHeight The height of the input panorama.
  27807. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27808. * @return The cubemap data
  27809. */
  27810. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27811. private static CreateCubemapTexture;
  27812. private static CalcProjectionSpherical;
  27813. }
  27814. }
  27815. declare module BABYLON {
  27816. /**
  27817. * Helper class dealing with the extraction of spherical polynomial dataArray
  27818. * from a cube map.
  27819. */
  27820. export class CubeMapToSphericalPolynomialTools {
  27821. private static FileFaces;
  27822. /**
  27823. * Converts a texture to the according Spherical Polynomial data.
  27824. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27825. *
  27826. * @param texture The texture to extract the information from.
  27827. * @return The Spherical Polynomial data.
  27828. */
  27829. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27830. /**
  27831. * Converts a cubemap to the according Spherical Polynomial data.
  27832. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27833. *
  27834. * @param cubeInfo The Cube map to extract the information from.
  27835. * @return The Spherical Polynomial data.
  27836. */
  27837. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27838. }
  27839. }
  27840. declare module BABYLON {
  27841. /**
  27842. * Class used to manipulate GUIDs
  27843. */
  27844. export class GUID {
  27845. /**
  27846. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27847. * Be aware Math.random() could cause collisions, but:
  27848. * "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"
  27849. * @returns a pseudo random id
  27850. */
  27851. static RandomId(): string;
  27852. }
  27853. }
  27854. declare module BABYLON {
  27855. /**
  27856. * Base class of all the textures in babylon.
  27857. * It groups all the common properties the materials, post process, lights... might need
  27858. * in order to make a correct use of the texture.
  27859. */
  27860. export class BaseTexture implements IAnimatable {
  27861. /**
  27862. * Default anisotropic filtering level for the application.
  27863. * It is set to 4 as a good tradeoff between perf and quality.
  27864. */
  27865. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27866. /**
  27867. * Gets or sets the unique id of the texture
  27868. */
  27869. uniqueId: number;
  27870. /**
  27871. * Define the name of the texture.
  27872. */
  27873. name: string;
  27874. /**
  27875. * Gets or sets an object used to store user defined information.
  27876. */
  27877. metadata: any;
  27878. /**
  27879. * For internal use only. Please do not use.
  27880. */
  27881. reservedDataStore: any;
  27882. private _hasAlpha;
  27883. /**
  27884. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27885. */
  27886. hasAlpha: boolean;
  27887. /**
  27888. * Defines if the alpha value should be determined via the rgb values.
  27889. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27890. */
  27891. getAlphaFromRGB: boolean;
  27892. /**
  27893. * Intensity or strength of the texture.
  27894. * It is commonly used by materials to fine tune the intensity of the texture
  27895. */
  27896. level: number;
  27897. /**
  27898. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27899. * This is part of the texture as textures usually maps to one uv set.
  27900. */
  27901. coordinatesIndex: number;
  27902. private _coordinatesMode;
  27903. /**
  27904. * How a texture is mapped.
  27905. *
  27906. * | Value | Type | Description |
  27907. * | ----- | ----------------------------------- | ----------- |
  27908. * | 0 | EXPLICIT_MODE | |
  27909. * | 1 | SPHERICAL_MODE | |
  27910. * | 2 | PLANAR_MODE | |
  27911. * | 3 | CUBIC_MODE | |
  27912. * | 4 | PROJECTION_MODE | |
  27913. * | 5 | SKYBOX_MODE | |
  27914. * | 6 | INVCUBIC_MODE | |
  27915. * | 7 | EQUIRECTANGULAR_MODE | |
  27916. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27917. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27918. */
  27919. coordinatesMode: number;
  27920. /**
  27921. * | Value | Type | Description |
  27922. * | ----- | ------------------ | ----------- |
  27923. * | 0 | CLAMP_ADDRESSMODE | |
  27924. * | 1 | WRAP_ADDRESSMODE | |
  27925. * | 2 | MIRROR_ADDRESSMODE | |
  27926. */
  27927. wrapU: number;
  27928. /**
  27929. * | Value | Type | Description |
  27930. * | ----- | ------------------ | ----------- |
  27931. * | 0 | CLAMP_ADDRESSMODE | |
  27932. * | 1 | WRAP_ADDRESSMODE | |
  27933. * | 2 | MIRROR_ADDRESSMODE | |
  27934. */
  27935. wrapV: number;
  27936. /**
  27937. * | Value | Type | Description |
  27938. * | ----- | ------------------ | ----------- |
  27939. * | 0 | CLAMP_ADDRESSMODE | |
  27940. * | 1 | WRAP_ADDRESSMODE | |
  27941. * | 2 | MIRROR_ADDRESSMODE | |
  27942. */
  27943. wrapR: number;
  27944. /**
  27945. * With compliant hardware and browser (supporting anisotropic filtering)
  27946. * this defines the level of anisotropic filtering in the texture.
  27947. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27948. */
  27949. anisotropicFilteringLevel: number;
  27950. /**
  27951. * Define if the texture is a cube texture or if false a 2d texture.
  27952. */
  27953. isCube: boolean;
  27954. /**
  27955. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27956. */
  27957. is3D: boolean;
  27958. /**
  27959. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27960. * HDR texture are usually stored in linear space.
  27961. * This only impacts the PBR and Background materials
  27962. */
  27963. gammaSpace: boolean;
  27964. /**
  27965. * Gets or sets whether or not the texture contains RGBD data.
  27966. */
  27967. isRGBD: boolean;
  27968. /**
  27969. * Is Z inverted in the texture (useful in a cube texture).
  27970. */
  27971. invertZ: boolean;
  27972. /**
  27973. * Are mip maps generated for this texture or not.
  27974. */
  27975. readonly noMipmap: boolean;
  27976. /**
  27977. * @hidden
  27978. */
  27979. lodLevelInAlpha: boolean;
  27980. /**
  27981. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27982. */
  27983. lodGenerationOffset: number;
  27984. /**
  27985. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27986. */
  27987. lodGenerationScale: number;
  27988. /**
  27989. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27990. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27991. * average roughness values.
  27992. */
  27993. linearSpecularLOD: boolean;
  27994. /**
  27995. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27996. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27997. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27998. */
  27999. irradianceTexture: Nullable<BaseTexture>;
  28000. /**
  28001. * Define if the texture is a render target.
  28002. */
  28003. isRenderTarget: boolean;
  28004. /**
  28005. * Define the unique id of the texture in the scene.
  28006. */
  28007. readonly uid: string;
  28008. /**
  28009. * Return a string representation of the texture.
  28010. * @returns the texture as a string
  28011. */
  28012. toString(): string;
  28013. /**
  28014. * Get the class name of the texture.
  28015. * @returns "BaseTexture"
  28016. */
  28017. getClassName(): string;
  28018. /**
  28019. * Define the list of animation attached to the texture.
  28020. */
  28021. animations: Animation[];
  28022. /**
  28023. * An event triggered when the texture is disposed.
  28024. */
  28025. onDisposeObservable: Observable<BaseTexture>;
  28026. private _onDisposeObserver;
  28027. /**
  28028. * Callback triggered when the texture has been disposed.
  28029. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28030. */
  28031. onDispose: () => void;
  28032. /**
  28033. * Define the current state of the loading sequence when in delayed load mode.
  28034. */
  28035. delayLoadState: number;
  28036. private _scene;
  28037. /** @hidden */
  28038. _texture: Nullable<InternalTexture>;
  28039. private _uid;
  28040. /**
  28041. * Define if the texture is preventinga material to render or not.
  28042. * If not and the texture is not ready, the engine will use a default black texture instead.
  28043. */
  28044. readonly isBlocking: boolean;
  28045. /**
  28046. * Instantiates a new BaseTexture.
  28047. * Base class of all the textures in babylon.
  28048. * It groups all the common properties the materials, post process, lights... might need
  28049. * in order to make a correct use of the texture.
  28050. * @param scene Define the scene the texture blongs to
  28051. */
  28052. constructor(scene: Nullable<Scene>);
  28053. /**
  28054. * Get the scene the texture belongs to.
  28055. * @returns the scene or null if undefined
  28056. */
  28057. getScene(): Nullable<Scene>;
  28058. /**
  28059. * Get the texture transform matrix used to offset tile the texture for istance.
  28060. * @returns the transformation matrix
  28061. */
  28062. getTextureMatrix(): Matrix;
  28063. /**
  28064. * Get the texture reflection matrix used to rotate/transform the reflection.
  28065. * @returns the reflection matrix
  28066. */
  28067. getReflectionTextureMatrix(): Matrix;
  28068. /**
  28069. * Get the underlying lower level texture from Babylon.
  28070. * @returns the insternal texture
  28071. */
  28072. getInternalTexture(): Nullable<InternalTexture>;
  28073. /**
  28074. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28075. * @returns true if ready or not blocking
  28076. */
  28077. isReadyOrNotBlocking(): boolean;
  28078. /**
  28079. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28080. * @returns true if fully ready
  28081. */
  28082. isReady(): boolean;
  28083. private _cachedSize;
  28084. /**
  28085. * Get the size of the texture.
  28086. * @returns the texture size.
  28087. */
  28088. getSize(): ISize;
  28089. /**
  28090. * Get the base size of the texture.
  28091. * It can be different from the size if the texture has been resized for POT for instance
  28092. * @returns the base size
  28093. */
  28094. getBaseSize(): ISize;
  28095. /**
  28096. * Update the sampling mode of the texture.
  28097. * Default is Trilinear mode.
  28098. *
  28099. * | Value | Type | Description |
  28100. * | ----- | ------------------ | ----------- |
  28101. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28102. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28103. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28104. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28105. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28106. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28107. * | 7 | NEAREST_LINEAR | |
  28108. * | 8 | NEAREST_NEAREST | |
  28109. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28110. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28111. * | 11 | LINEAR_LINEAR | |
  28112. * | 12 | LINEAR_NEAREST | |
  28113. *
  28114. * > _mag_: magnification filter (close to the viewer)
  28115. * > _min_: minification filter (far from the viewer)
  28116. * > _mip_: filter used between mip map levels
  28117. *@param samplingMode Define the new sampling mode of the texture
  28118. */
  28119. updateSamplingMode(samplingMode: number): void;
  28120. /**
  28121. * Scales the texture if is `canRescale()`
  28122. * @param ratio the resize factor we want to use to rescale
  28123. */
  28124. scale(ratio: number): void;
  28125. /**
  28126. * Get if the texture can rescale.
  28127. */
  28128. readonly canRescale: boolean;
  28129. /** @hidden */
  28130. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28131. /** @hidden */
  28132. _rebuild(): void;
  28133. /**
  28134. * Triggers the load sequence in delayed load mode.
  28135. */
  28136. delayLoad(): void;
  28137. /**
  28138. * Clones the texture.
  28139. * @returns the cloned texture
  28140. */
  28141. clone(): Nullable<BaseTexture>;
  28142. /**
  28143. * Get the texture underlying type (INT, FLOAT...)
  28144. */
  28145. readonly textureType: number;
  28146. /**
  28147. * Get the texture underlying format (RGB, RGBA...)
  28148. */
  28149. readonly textureFormat: number;
  28150. /**
  28151. * Indicates that textures need to be re-calculated for all materials
  28152. */
  28153. protected _markAllSubMeshesAsTexturesDirty(): void;
  28154. /**
  28155. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28156. * This will returns an RGBA array buffer containing either in values (0-255) or
  28157. * float values (0-1) depending of the underlying buffer type.
  28158. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28159. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28160. * @param buffer defines a user defined buffer to fill with data (can be null)
  28161. * @returns The Array buffer containing the pixels data.
  28162. */
  28163. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28164. /**
  28165. * Release and destroy the underlying lower level texture aka internalTexture.
  28166. */
  28167. releaseInternalTexture(): void;
  28168. /**
  28169. * Get the polynomial representation of the texture data.
  28170. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28171. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28172. */
  28173. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28174. /** @hidden */
  28175. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28176. /** @hidden */
  28177. readonly _lodTextureMid: Nullable<BaseTexture>;
  28178. /** @hidden */
  28179. readonly _lodTextureLow: Nullable<BaseTexture>;
  28180. /**
  28181. * Dispose the texture and release its associated resources.
  28182. */
  28183. dispose(): void;
  28184. /**
  28185. * Serialize the texture into a JSON representation that can be parsed later on.
  28186. * @returns the JSON representation of the texture
  28187. */
  28188. serialize(): any;
  28189. /**
  28190. * Helper function to be called back once a list of texture contains only ready textures.
  28191. * @param textures Define the list of textures to wait for
  28192. * @param callback Define the callback triggered once the entire list will be ready
  28193. */
  28194. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28195. }
  28196. }
  28197. declare module BABYLON {
  28198. /**
  28199. * Options to be used when creating an effect.
  28200. */
  28201. export class EffectCreationOptions {
  28202. /**
  28203. * Atrributes that will be used in the shader.
  28204. */
  28205. attributes: string[];
  28206. /**
  28207. * Uniform varible names that will be set in the shader.
  28208. */
  28209. uniformsNames: string[];
  28210. /**
  28211. * Uniform buffer varible names that will be set in the shader.
  28212. */
  28213. uniformBuffersNames: string[];
  28214. /**
  28215. * Sampler texture variable names that will be set in the shader.
  28216. */
  28217. samplers: string[];
  28218. /**
  28219. * Define statements that will be set in the shader.
  28220. */
  28221. defines: any;
  28222. /**
  28223. * Possible fallbacks for this effect to improve performance when needed.
  28224. */
  28225. fallbacks: Nullable<IEffectFallbacks>;
  28226. /**
  28227. * Callback that will be called when the shader is compiled.
  28228. */
  28229. onCompiled: Nullable<(effect: Effect) => void>;
  28230. /**
  28231. * Callback that will be called if an error occurs during shader compilation.
  28232. */
  28233. onError: Nullable<(effect: Effect, errors: string) => void>;
  28234. /**
  28235. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28236. */
  28237. indexParameters?: any;
  28238. /**
  28239. * Max number of lights that can be used in the shader.
  28240. */
  28241. maxSimultaneousLights?: number;
  28242. /**
  28243. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28244. */
  28245. transformFeedbackVaryings?: Nullable<string[]>;
  28246. }
  28247. /**
  28248. * Effect containing vertex and fragment shader that can be executed on an object.
  28249. */
  28250. export class Effect implements IDisposable {
  28251. /**
  28252. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28253. */
  28254. static ShadersRepository: string;
  28255. /**
  28256. * Name of the effect.
  28257. */
  28258. name: any;
  28259. /**
  28260. * String container all the define statements that should be set on the shader.
  28261. */
  28262. defines: string;
  28263. /**
  28264. * Callback that will be called when the shader is compiled.
  28265. */
  28266. onCompiled: Nullable<(effect: Effect) => void>;
  28267. /**
  28268. * Callback that will be called if an error occurs during shader compilation.
  28269. */
  28270. onError: Nullable<(effect: Effect, errors: string) => void>;
  28271. /**
  28272. * Callback that will be called when effect is bound.
  28273. */
  28274. onBind: Nullable<(effect: Effect) => void>;
  28275. /**
  28276. * Unique ID of the effect.
  28277. */
  28278. uniqueId: number;
  28279. /**
  28280. * Observable that will be called when the shader is compiled.
  28281. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28282. */
  28283. onCompileObservable: Observable<Effect>;
  28284. /**
  28285. * Observable that will be called if an error occurs during shader compilation.
  28286. */
  28287. onErrorObservable: Observable<Effect>;
  28288. /** @hidden */
  28289. _onBindObservable: Nullable<Observable<Effect>>;
  28290. /**
  28291. * Observable that will be called when effect is bound.
  28292. */
  28293. readonly onBindObservable: Observable<Effect>;
  28294. /** @hidden */
  28295. _bonesComputationForcedToCPU: boolean;
  28296. private static _uniqueIdSeed;
  28297. private _engine;
  28298. private _uniformBuffersNames;
  28299. private _uniformsNames;
  28300. private _samplerList;
  28301. private _samplers;
  28302. private _isReady;
  28303. private _compilationError;
  28304. private _attributesNames;
  28305. private _attributes;
  28306. private _uniforms;
  28307. /**
  28308. * Key for the effect.
  28309. * @hidden
  28310. */
  28311. _key: string;
  28312. private _indexParameters;
  28313. private _fallbacks;
  28314. private _vertexSourceCode;
  28315. private _fragmentSourceCode;
  28316. private _vertexSourceCodeOverride;
  28317. private _fragmentSourceCodeOverride;
  28318. private _transformFeedbackVaryings;
  28319. /**
  28320. * Compiled shader to webGL program.
  28321. * @hidden
  28322. */
  28323. _pipelineContext: Nullable<IPipelineContext>;
  28324. private _valueCache;
  28325. private static _baseCache;
  28326. /**
  28327. * Instantiates an effect.
  28328. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28329. * @param baseName Name of the effect.
  28330. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28331. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28332. * @param samplers List of sampler variables that will be passed to the shader.
  28333. * @param engine Engine to be used to render the effect
  28334. * @param defines Define statements to be added to the shader.
  28335. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28336. * @param onCompiled Callback that will be called when the shader is compiled.
  28337. * @param onError Callback that will be called if an error occurs during shader compilation.
  28338. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28339. */
  28340. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, 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);
  28341. private _useFinalCode;
  28342. /**
  28343. * Unique key for this effect
  28344. */
  28345. readonly key: string;
  28346. /**
  28347. * If the effect has been compiled and prepared.
  28348. * @returns if the effect is compiled and prepared.
  28349. */
  28350. isReady(): boolean;
  28351. private _isReadyInternal;
  28352. /**
  28353. * The engine the effect was initialized with.
  28354. * @returns the engine.
  28355. */
  28356. getEngine(): Engine;
  28357. /**
  28358. * The pipeline context for this effect
  28359. * @returns the associated pipeline context
  28360. */
  28361. getPipelineContext(): Nullable<IPipelineContext>;
  28362. /**
  28363. * The set of names of attribute variables for the shader.
  28364. * @returns An array of attribute names.
  28365. */
  28366. getAttributesNames(): string[];
  28367. /**
  28368. * Returns the attribute at the given index.
  28369. * @param index The index of the attribute.
  28370. * @returns The location of the attribute.
  28371. */
  28372. getAttributeLocation(index: number): number;
  28373. /**
  28374. * Returns the attribute based on the name of the variable.
  28375. * @param name of the attribute to look up.
  28376. * @returns the attribute location.
  28377. */
  28378. getAttributeLocationByName(name: string): number;
  28379. /**
  28380. * The number of attributes.
  28381. * @returns the numnber of attributes.
  28382. */
  28383. getAttributesCount(): number;
  28384. /**
  28385. * Gets the index of a uniform variable.
  28386. * @param uniformName of the uniform to look up.
  28387. * @returns the index.
  28388. */
  28389. getUniformIndex(uniformName: string): number;
  28390. /**
  28391. * Returns the attribute based on the name of the variable.
  28392. * @param uniformName of the uniform to look up.
  28393. * @returns the location of the uniform.
  28394. */
  28395. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28396. /**
  28397. * Returns an array of sampler variable names
  28398. * @returns The array of sampler variable neames.
  28399. */
  28400. getSamplers(): string[];
  28401. /**
  28402. * The error from the last compilation.
  28403. * @returns the error string.
  28404. */
  28405. getCompilationError(): string;
  28406. /**
  28407. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28408. * @param func The callback to be used.
  28409. */
  28410. executeWhenCompiled(func: (effect: Effect) => void): void;
  28411. private _checkIsReady;
  28412. /** @hidden */
  28413. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28414. /** @hidden */
  28415. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28416. /** @hidden */
  28417. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28418. /**
  28419. * Recompiles the webGL program
  28420. * @param vertexSourceCode The source code for the vertex shader.
  28421. * @param fragmentSourceCode The source code for the fragment shader.
  28422. * @param onCompiled Callback called when completed.
  28423. * @param onError Callback called on error.
  28424. * @hidden
  28425. */
  28426. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28427. /**
  28428. * Prepares the effect
  28429. * @hidden
  28430. */
  28431. _prepareEffect(): void;
  28432. private _processCompilationErrors;
  28433. /**
  28434. * Checks if the effect is supported. (Must be called after compilation)
  28435. */
  28436. readonly isSupported: boolean;
  28437. /**
  28438. * Binds a texture to the engine to be used as output of the shader.
  28439. * @param channel Name of the output variable.
  28440. * @param texture Texture to bind.
  28441. * @hidden
  28442. */
  28443. _bindTexture(channel: string, texture: InternalTexture): void;
  28444. /**
  28445. * Sets a texture on the engine to be used in the shader.
  28446. * @param channel Name of the sampler variable.
  28447. * @param texture Texture to set.
  28448. */
  28449. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28450. /**
  28451. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28452. * @param channel Name of the sampler variable.
  28453. * @param texture Texture to set.
  28454. */
  28455. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28456. /**
  28457. * Sets an array of textures on the engine to be used in the shader.
  28458. * @param channel Name of the variable.
  28459. * @param textures Textures to set.
  28460. */
  28461. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28462. /**
  28463. * 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)
  28464. * @param channel Name of the sampler variable.
  28465. * @param postProcess Post process to get the input texture from.
  28466. */
  28467. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28468. /**
  28469. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28470. * 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)
  28471. * @param channel Name of the sampler variable.
  28472. * @param postProcess Post process to get the output texture from.
  28473. */
  28474. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28475. /** @hidden */
  28476. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28477. /** @hidden */
  28478. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28479. /** @hidden */
  28480. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28481. /** @hidden */
  28482. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28483. /**
  28484. * Binds a buffer to a uniform.
  28485. * @param buffer Buffer to bind.
  28486. * @param name Name of the uniform variable to bind to.
  28487. */
  28488. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28489. /**
  28490. * Binds block to a uniform.
  28491. * @param blockName Name of the block to bind.
  28492. * @param index Index to bind.
  28493. */
  28494. bindUniformBlock(blockName: string, index: number): void;
  28495. /**
  28496. * Sets an interger value on a uniform variable.
  28497. * @param uniformName Name of the variable.
  28498. * @param value Value to be set.
  28499. * @returns this effect.
  28500. */
  28501. setInt(uniformName: string, value: number): Effect;
  28502. /**
  28503. * Sets an int array on a uniform variable.
  28504. * @param uniformName Name of the variable.
  28505. * @param array array to be set.
  28506. * @returns this effect.
  28507. */
  28508. setIntArray(uniformName: string, array: Int32Array): Effect;
  28509. /**
  28510. * 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)
  28511. * @param uniformName Name of the variable.
  28512. * @param array array to be set.
  28513. * @returns this effect.
  28514. */
  28515. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28516. /**
  28517. * 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)
  28518. * @param uniformName Name of the variable.
  28519. * @param array array to be set.
  28520. * @returns this effect.
  28521. */
  28522. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28523. /**
  28524. * 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)
  28525. * @param uniformName Name of the variable.
  28526. * @param array array to be set.
  28527. * @returns this effect.
  28528. */
  28529. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28530. /**
  28531. * Sets an float array on a uniform variable.
  28532. * @param uniformName Name of the variable.
  28533. * @param array array to be set.
  28534. * @returns this effect.
  28535. */
  28536. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28537. /**
  28538. * 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)
  28539. * @param uniformName Name of the variable.
  28540. * @param array array to be set.
  28541. * @returns this effect.
  28542. */
  28543. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28544. /**
  28545. * 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)
  28546. * @param uniformName Name of the variable.
  28547. * @param array array to be set.
  28548. * @returns this effect.
  28549. */
  28550. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28551. /**
  28552. * 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)
  28553. * @param uniformName Name of the variable.
  28554. * @param array array to be set.
  28555. * @returns this effect.
  28556. */
  28557. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28558. /**
  28559. * Sets an array on a uniform variable.
  28560. * @param uniformName Name of the variable.
  28561. * @param array array to be set.
  28562. * @returns this effect.
  28563. */
  28564. setArray(uniformName: string, array: number[]): Effect;
  28565. /**
  28566. * 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)
  28567. * @param uniformName Name of the variable.
  28568. * @param array array to be set.
  28569. * @returns this effect.
  28570. */
  28571. setArray2(uniformName: string, array: number[]): Effect;
  28572. /**
  28573. * 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)
  28574. * @param uniformName Name of the variable.
  28575. * @param array array to be set.
  28576. * @returns this effect.
  28577. */
  28578. setArray3(uniformName: string, array: number[]): Effect;
  28579. /**
  28580. * 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)
  28581. * @param uniformName Name of the variable.
  28582. * @param array array to be set.
  28583. * @returns this effect.
  28584. */
  28585. setArray4(uniformName: string, array: number[]): Effect;
  28586. /**
  28587. * Sets matrices on a uniform variable.
  28588. * @param uniformName Name of the variable.
  28589. * @param matrices matrices to be set.
  28590. * @returns this effect.
  28591. */
  28592. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28593. /**
  28594. * Sets matrix on a uniform variable.
  28595. * @param uniformName Name of the variable.
  28596. * @param matrix matrix to be set.
  28597. * @returns this effect.
  28598. */
  28599. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28600. /**
  28601. * 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)
  28602. * @param uniformName Name of the variable.
  28603. * @param matrix matrix to be set.
  28604. * @returns this effect.
  28605. */
  28606. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28607. /**
  28608. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28609. * @param uniformName Name of the variable.
  28610. * @param matrix matrix to be set.
  28611. * @returns this effect.
  28612. */
  28613. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28614. /**
  28615. * Sets a float on a uniform variable.
  28616. * @param uniformName Name of the variable.
  28617. * @param value value to be set.
  28618. * @returns this effect.
  28619. */
  28620. setFloat(uniformName: string, value: number): Effect;
  28621. /**
  28622. * Sets a boolean on a uniform variable.
  28623. * @param uniformName Name of the variable.
  28624. * @param bool value to be set.
  28625. * @returns this effect.
  28626. */
  28627. setBool(uniformName: string, bool: boolean): Effect;
  28628. /**
  28629. * Sets a Vector2 on a uniform variable.
  28630. * @param uniformName Name of the variable.
  28631. * @param vector2 vector2 to be set.
  28632. * @returns this effect.
  28633. */
  28634. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28635. /**
  28636. * Sets a float2 on a uniform variable.
  28637. * @param uniformName Name of the variable.
  28638. * @param x First float in float2.
  28639. * @param y Second float in float2.
  28640. * @returns this effect.
  28641. */
  28642. setFloat2(uniformName: string, x: number, y: number): Effect;
  28643. /**
  28644. * Sets a Vector3 on a uniform variable.
  28645. * @param uniformName Name of the variable.
  28646. * @param vector3 Value to be set.
  28647. * @returns this effect.
  28648. */
  28649. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28650. /**
  28651. * Sets a float3 on a uniform variable.
  28652. * @param uniformName Name of the variable.
  28653. * @param x First float in float3.
  28654. * @param y Second float in float3.
  28655. * @param z Third float in float3.
  28656. * @returns this effect.
  28657. */
  28658. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28659. /**
  28660. * Sets a Vector4 on a uniform variable.
  28661. * @param uniformName Name of the variable.
  28662. * @param vector4 Value to be set.
  28663. * @returns this effect.
  28664. */
  28665. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28666. /**
  28667. * Sets a float4 on a uniform variable.
  28668. * @param uniformName Name of the variable.
  28669. * @param x First float in float4.
  28670. * @param y Second float in float4.
  28671. * @param z Third float in float4.
  28672. * @param w Fourth float in float4.
  28673. * @returns this effect.
  28674. */
  28675. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28676. /**
  28677. * Sets a Color3 on a uniform variable.
  28678. * @param uniformName Name of the variable.
  28679. * @param color3 Value to be set.
  28680. * @returns this effect.
  28681. */
  28682. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28683. /**
  28684. * Sets a Color4 on a uniform variable.
  28685. * @param uniformName Name of the variable.
  28686. * @param color3 Value to be set.
  28687. * @param alpha Alpha value to be set.
  28688. * @returns this effect.
  28689. */
  28690. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28691. /**
  28692. * Sets a Color4 on a uniform variable
  28693. * @param uniformName defines the name of the variable
  28694. * @param color4 defines the value to be set
  28695. * @returns this effect.
  28696. */
  28697. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28698. /** Release all associated resources */
  28699. dispose(): void;
  28700. /**
  28701. * This function will add a new shader to the shader store
  28702. * @param name the name of the shader
  28703. * @param pixelShader optional pixel shader content
  28704. * @param vertexShader optional vertex shader content
  28705. */
  28706. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28707. /**
  28708. * Store of each shader (The can be looked up using effect.key)
  28709. */
  28710. static ShadersStore: {
  28711. [key: string]: string;
  28712. };
  28713. /**
  28714. * Store of each included file for a shader (The can be looked up using effect.key)
  28715. */
  28716. static IncludesShadersStore: {
  28717. [key: string]: string;
  28718. };
  28719. /**
  28720. * Resets the cache of effects.
  28721. */
  28722. static ResetCache(): void;
  28723. }
  28724. }
  28725. declare module BABYLON {
  28726. /**
  28727. * Class used to describe the capabilities of the engine relatively to the current browser
  28728. */
  28729. export class EngineCapabilities {
  28730. /** Maximum textures units per fragment shader */
  28731. maxTexturesImageUnits: number;
  28732. /** Maximum texture units per vertex shader */
  28733. maxVertexTextureImageUnits: number;
  28734. /** Maximum textures units in the entire pipeline */
  28735. maxCombinedTexturesImageUnits: number;
  28736. /** Maximum texture size */
  28737. maxTextureSize: number;
  28738. /** Maximum cube texture size */
  28739. maxCubemapTextureSize: number;
  28740. /** Maximum render texture size */
  28741. maxRenderTextureSize: number;
  28742. /** Maximum number of vertex attributes */
  28743. maxVertexAttribs: number;
  28744. /** Maximum number of varyings */
  28745. maxVaryingVectors: number;
  28746. /** Maximum number of uniforms per vertex shader */
  28747. maxVertexUniformVectors: number;
  28748. /** Maximum number of uniforms per fragment shader */
  28749. maxFragmentUniformVectors: number;
  28750. /** Defines if standard derivates (dx/dy) are supported */
  28751. standardDerivatives: boolean;
  28752. /** Defines if s3tc texture compression is supported */
  28753. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28754. /** Defines if pvrtc texture compression is supported */
  28755. pvrtc: any;
  28756. /** Defines if etc1 texture compression is supported */
  28757. etc1: any;
  28758. /** Defines if etc2 texture compression is supported */
  28759. etc2: any;
  28760. /** Defines if astc texture compression is supported */
  28761. astc: any;
  28762. /** Defines if float textures are supported */
  28763. textureFloat: boolean;
  28764. /** Defines if vertex array objects are supported */
  28765. vertexArrayObject: boolean;
  28766. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28767. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28768. /** Gets the maximum level of anisotropy supported */
  28769. maxAnisotropy: number;
  28770. /** Defines if instancing is supported */
  28771. instancedArrays: boolean;
  28772. /** Defines if 32 bits indices are supported */
  28773. uintIndices: boolean;
  28774. /** Defines if high precision shaders are supported */
  28775. highPrecisionShaderSupported: boolean;
  28776. /** Defines if depth reading in the fragment shader is supported */
  28777. fragmentDepthSupported: boolean;
  28778. /** Defines if float texture linear filtering is supported*/
  28779. textureFloatLinearFiltering: boolean;
  28780. /** Defines if rendering to float textures is supported */
  28781. textureFloatRender: boolean;
  28782. /** Defines if half float textures are supported*/
  28783. textureHalfFloat: boolean;
  28784. /** Defines if half float texture linear filtering is supported*/
  28785. textureHalfFloatLinearFiltering: boolean;
  28786. /** Defines if rendering to half float textures is supported */
  28787. textureHalfFloatRender: boolean;
  28788. /** Defines if textureLOD shader command is supported */
  28789. textureLOD: boolean;
  28790. /** Defines if draw buffers extension is supported */
  28791. drawBuffersExtension: boolean;
  28792. /** Defines if depth textures are supported */
  28793. depthTextureExtension: boolean;
  28794. /** Defines if float color buffer are supported */
  28795. colorBufferFloat: boolean;
  28796. /** Gets disjoint timer query extension (null if not supported) */
  28797. timerQuery: EXT_disjoint_timer_query;
  28798. /** Defines if timestamp can be used with timer query */
  28799. canUseTimestampForTimerQuery: boolean;
  28800. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28801. multiview: any;
  28802. /** Function used to let the system compiles shaders in background */
  28803. parallelShaderCompile: {
  28804. COMPLETION_STATUS_KHR: number;
  28805. };
  28806. /** Max number of texture samples for MSAA */
  28807. maxMSAASamples: number;
  28808. /** Defines if the blend min max extension is supported */
  28809. blendMinMax: boolean;
  28810. }
  28811. }
  28812. declare module BABYLON {
  28813. /**
  28814. * This class is used to track a performance counter which is number based.
  28815. * The user has access to many properties which give statistics of different nature.
  28816. *
  28817. * The implementer can track two kinds of Performance Counter: time and count.
  28818. * 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.
  28819. * 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.
  28820. */
  28821. export class PerfCounter {
  28822. /**
  28823. * Gets or sets a global boolean to turn on and off all the counters
  28824. */
  28825. static Enabled: boolean;
  28826. /**
  28827. * Returns the smallest value ever
  28828. */
  28829. readonly min: number;
  28830. /**
  28831. * Returns the biggest value ever
  28832. */
  28833. readonly max: number;
  28834. /**
  28835. * Returns the average value since the performance counter is running
  28836. */
  28837. readonly average: number;
  28838. /**
  28839. * Returns the average value of the last second the counter was monitored
  28840. */
  28841. readonly lastSecAverage: number;
  28842. /**
  28843. * Returns the current value
  28844. */
  28845. readonly current: number;
  28846. /**
  28847. * Gets the accumulated total
  28848. */
  28849. readonly total: number;
  28850. /**
  28851. * Gets the total value count
  28852. */
  28853. readonly count: number;
  28854. /**
  28855. * Creates a new counter
  28856. */
  28857. constructor();
  28858. /**
  28859. * Call this method to start monitoring a new frame.
  28860. * 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.
  28861. */
  28862. fetchNewFrame(): void;
  28863. /**
  28864. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28865. * @param newCount the count value to add to the monitored count
  28866. * @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.
  28867. */
  28868. addCount(newCount: number, fetchResult: boolean): void;
  28869. /**
  28870. * Start monitoring this performance counter
  28871. */
  28872. beginMonitoring(): void;
  28873. /**
  28874. * Compute the time lapsed since the previous beginMonitoring() call.
  28875. * @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
  28876. */
  28877. endMonitoring(newFrame?: boolean): void;
  28878. private _fetchResult;
  28879. private _startMonitoringTime;
  28880. private _min;
  28881. private _max;
  28882. private _average;
  28883. private _current;
  28884. private _totalValueCount;
  28885. private _totalAccumulated;
  28886. private _lastSecAverage;
  28887. private _lastSecAccumulated;
  28888. private _lastSecTime;
  28889. private _lastSecValueCount;
  28890. }
  28891. }
  28892. declare module BABYLON {
  28893. /**
  28894. * @hidden
  28895. **/
  28896. export class DepthCullingState {
  28897. private _isDepthTestDirty;
  28898. private _isDepthMaskDirty;
  28899. private _isDepthFuncDirty;
  28900. private _isCullFaceDirty;
  28901. private _isCullDirty;
  28902. private _isZOffsetDirty;
  28903. private _isFrontFaceDirty;
  28904. private _depthTest;
  28905. private _depthMask;
  28906. private _depthFunc;
  28907. private _cull;
  28908. private _cullFace;
  28909. private _zOffset;
  28910. private _frontFace;
  28911. /**
  28912. * Initializes the state.
  28913. */
  28914. constructor();
  28915. readonly isDirty: boolean;
  28916. zOffset: number;
  28917. cullFace: Nullable<number>;
  28918. cull: Nullable<boolean>;
  28919. depthFunc: Nullable<number>;
  28920. depthMask: boolean;
  28921. depthTest: boolean;
  28922. frontFace: Nullable<number>;
  28923. reset(): void;
  28924. apply(gl: WebGLRenderingContext): void;
  28925. }
  28926. }
  28927. declare module BABYLON {
  28928. /**
  28929. * @hidden
  28930. **/
  28931. export class StencilState {
  28932. /** 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 */
  28933. static readonly ALWAYS: number;
  28934. /** Passed to stencilOperation to specify that stencil value must be kept */
  28935. static readonly KEEP: number;
  28936. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28937. static readonly REPLACE: number;
  28938. private _isStencilTestDirty;
  28939. private _isStencilMaskDirty;
  28940. private _isStencilFuncDirty;
  28941. private _isStencilOpDirty;
  28942. private _stencilTest;
  28943. private _stencilMask;
  28944. private _stencilFunc;
  28945. private _stencilFuncRef;
  28946. private _stencilFuncMask;
  28947. private _stencilOpStencilFail;
  28948. private _stencilOpDepthFail;
  28949. private _stencilOpStencilDepthPass;
  28950. readonly isDirty: boolean;
  28951. stencilFunc: number;
  28952. stencilFuncRef: number;
  28953. stencilFuncMask: number;
  28954. stencilOpStencilFail: number;
  28955. stencilOpDepthFail: number;
  28956. stencilOpStencilDepthPass: number;
  28957. stencilMask: number;
  28958. stencilTest: boolean;
  28959. constructor();
  28960. reset(): void;
  28961. apply(gl: WebGLRenderingContext): void;
  28962. }
  28963. }
  28964. declare module BABYLON {
  28965. /**
  28966. * @hidden
  28967. **/
  28968. export class AlphaState {
  28969. private _isAlphaBlendDirty;
  28970. private _isBlendFunctionParametersDirty;
  28971. private _isBlendEquationParametersDirty;
  28972. private _isBlendConstantsDirty;
  28973. private _alphaBlend;
  28974. private _blendFunctionParameters;
  28975. private _blendEquationParameters;
  28976. private _blendConstants;
  28977. /**
  28978. * Initializes the state.
  28979. */
  28980. constructor();
  28981. readonly isDirty: boolean;
  28982. alphaBlend: boolean;
  28983. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28984. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28985. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28986. reset(): void;
  28987. apply(gl: WebGLRenderingContext): void;
  28988. }
  28989. }
  28990. declare module BABYLON {
  28991. /** @hidden */
  28992. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28993. attributeProcessor(attribute: string): string;
  28994. varyingProcessor(varying: string, isFragment: boolean): string;
  28995. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28996. }
  28997. }
  28998. declare module BABYLON {
  28999. /**
  29000. * Interface for attribute information associated with buffer instanciation
  29001. */
  29002. export class InstancingAttributeInfo {
  29003. /**
  29004. * Index/offset of the attribute in the vertex shader
  29005. */
  29006. index: number;
  29007. /**
  29008. * size of the attribute, 1, 2, 3 or 4
  29009. */
  29010. attributeSize: number;
  29011. /**
  29012. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29013. * default is FLOAT
  29014. */
  29015. attribyteType: number;
  29016. /**
  29017. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29018. */
  29019. normalized: boolean;
  29020. /**
  29021. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29022. */
  29023. offset: number;
  29024. /**
  29025. * Name of the GLSL attribute, for debugging purpose only
  29026. */
  29027. attributeName: string;
  29028. }
  29029. }
  29030. declare module BABYLON {
  29031. interface ThinEngine {
  29032. /**
  29033. * Update a video texture
  29034. * @param texture defines the texture to update
  29035. * @param video defines the video element to use
  29036. * @param invertY defines if data must be stored with Y axis inverted
  29037. */
  29038. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29039. }
  29040. }
  29041. declare module BABYLON {
  29042. /**
  29043. * Settings for finer control over video usage
  29044. */
  29045. export interface VideoTextureSettings {
  29046. /**
  29047. * Applies `autoplay` to video, if specified
  29048. */
  29049. autoPlay?: boolean;
  29050. /**
  29051. * Applies `loop` to video, if specified
  29052. */
  29053. loop?: boolean;
  29054. /**
  29055. * Automatically updates internal texture from video at every frame in the render loop
  29056. */
  29057. autoUpdateTexture: boolean;
  29058. /**
  29059. * Image src displayed during the video loading or until the user interacts with the video.
  29060. */
  29061. poster?: string;
  29062. }
  29063. /**
  29064. * If you want to display a video in your scene, this is the special texture for that.
  29065. * This special texture works similar to other textures, with the exception of a few parameters.
  29066. * @see https://doc.babylonjs.com/how_to/video_texture
  29067. */
  29068. export class VideoTexture extends Texture {
  29069. /**
  29070. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29071. */
  29072. readonly autoUpdateTexture: boolean;
  29073. /**
  29074. * The video instance used by the texture internally
  29075. */
  29076. readonly video: HTMLVideoElement;
  29077. private _onUserActionRequestedObservable;
  29078. /**
  29079. * Event triggerd when a dom action is required by the user to play the video.
  29080. * This happens due to recent changes in browser policies preventing video to auto start.
  29081. */
  29082. readonly onUserActionRequestedObservable: Observable<Texture>;
  29083. private _generateMipMaps;
  29084. private _engine;
  29085. private _stillImageCaptured;
  29086. private _displayingPosterTexture;
  29087. private _settings;
  29088. private _createInternalTextureOnEvent;
  29089. private _frameId;
  29090. /**
  29091. * Creates a video texture.
  29092. * If you want to display a video in your scene, this is the special texture for that.
  29093. * This special texture works similar to other textures, with the exception of a few parameters.
  29094. * @see https://doc.babylonjs.com/how_to/video_texture
  29095. * @param name optional name, will detect from video source, if not defined
  29096. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29097. * @param scene is obviously the current scene.
  29098. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29099. * @param invertY is false by default but can be used to invert video on Y axis
  29100. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29101. * @param settings allows finer control over video usage
  29102. */
  29103. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29104. private _getName;
  29105. private _getVideo;
  29106. private _createInternalTexture;
  29107. private reset;
  29108. /**
  29109. * @hidden Internal method to initiate `update`.
  29110. */
  29111. _rebuild(): void;
  29112. /**
  29113. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29114. */
  29115. update(): void;
  29116. /**
  29117. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29118. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29119. */
  29120. updateTexture(isVisible: boolean): void;
  29121. protected _updateInternalTexture: () => void;
  29122. /**
  29123. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29124. * @param url New url.
  29125. */
  29126. updateURL(url: string): void;
  29127. /**
  29128. * Dispose the texture and release its associated resources.
  29129. */
  29130. dispose(): void;
  29131. /**
  29132. * Creates a video texture straight from a stream.
  29133. * @param scene Define the scene the texture should be created in
  29134. * @param stream Define the stream the texture should be created from
  29135. * @returns The created video texture as a promise
  29136. */
  29137. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29138. /**
  29139. * Creates a video texture straight from your WebCam video feed.
  29140. * @param scene Define the scene the texture should be created in
  29141. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29142. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29143. * @returns The created video texture as a promise
  29144. */
  29145. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29146. minWidth: number;
  29147. maxWidth: number;
  29148. minHeight: number;
  29149. maxHeight: number;
  29150. deviceId: string;
  29151. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29152. /**
  29153. * Creates a video texture straight from your WebCam video feed.
  29154. * @param scene Define the scene the texture should be created in
  29155. * @param onReady Define a callback to triggered once the texture will be ready
  29156. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29157. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29158. */
  29159. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29160. minWidth: number;
  29161. maxWidth: number;
  29162. minHeight: number;
  29163. maxHeight: number;
  29164. deviceId: string;
  29165. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29166. }
  29167. }
  29168. declare module BABYLON {
  29169. /**
  29170. * Defines the interface used by objects working like Scene
  29171. * @hidden
  29172. */
  29173. interface ISceneLike {
  29174. _addPendingData(data: any): void;
  29175. _removePendingData(data: any): void;
  29176. offlineProvider: IOfflineProvider;
  29177. }
  29178. /** Interface defining initialization parameters for Engine class */
  29179. export interface EngineOptions extends WebGLContextAttributes {
  29180. /**
  29181. * Defines if the engine should no exceed a specified device ratio
  29182. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29183. */
  29184. limitDeviceRatio?: number;
  29185. /**
  29186. * Defines if webvr should be enabled automatically
  29187. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29188. */
  29189. autoEnableWebVR?: boolean;
  29190. /**
  29191. * Defines if webgl2 should be turned off even if supported
  29192. * @see http://doc.babylonjs.com/features/webgl2
  29193. */
  29194. disableWebGL2Support?: boolean;
  29195. /**
  29196. * Defines if webaudio should be initialized as well
  29197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29198. */
  29199. audioEngine?: boolean;
  29200. /**
  29201. * Defines if animations should run using a deterministic lock step
  29202. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29203. */
  29204. deterministicLockstep?: boolean;
  29205. /** Defines the maximum steps to use with deterministic lock step mode */
  29206. lockstepMaxSteps?: number;
  29207. /**
  29208. * Defines that engine should ignore context lost events
  29209. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29210. */
  29211. doNotHandleContextLost?: boolean;
  29212. /**
  29213. * Defines that engine should ignore modifying touch action attribute and style
  29214. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29215. */
  29216. doNotHandleTouchAction?: boolean;
  29217. /**
  29218. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29219. */
  29220. useHighPrecisionFloats?: boolean;
  29221. }
  29222. /**
  29223. * The base engine class (root of all engines)
  29224. */
  29225. export class ThinEngine {
  29226. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29227. static ExceptionList: ({
  29228. key: string;
  29229. capture: string;
  29230. captureConstraint: number;
  29231. targets: string[];
  29232. } | {
  29233. key: string;
  29234. capture: null;
  29235. captureConstraint: null;
  29236. targets: string[];
  29237. })[];
  29238. /** @hidden */
  29239. static _TextureLoaders: IInternalTextureLoader[];
  29240. /**
  29241. * Returns the current npm package of the sdk
  29242. */
  29243. static readonly NpmPackage: string;
  29244. /**
  29245. * Returns the current version of the framework
  29246. */
  29247. static readonly Version: string;
  29248. /**
  29249. * Returns a string describing the current engine
  29250. */
  29251. readonly description: string;
  29252. /**
  29253. * Gets or sets the epsilon value used by collision engine
  29254. */
  29255. static CollisionsEpsilon: number;
  29256. /**
  29257. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29258. */
  29259. static ShadersRepository: string;
  29260. /** @hidden */
  29261. _shaderProcessor: IShaderProcessor;
  29262. /**
  29263. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29264. */
  29265. forcePOTTextures: boolean;
  29266. /**
  29267. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29268. */
  29269. isFullscreen: boolean;
  29270. /**
  29271. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29272. */
  29273. cullBackFaces: boolean;
  29274. /**
  29275. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29276. */
  29277. renderEvenInBackground: boolean;
  29278. /**
  29279. * Gets or sets a boolean indicating that cache can be kept between frames
  29280. */
  29281. preventCacheWipeBetweenFrames: boolean;
  29282. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29283. validateShaderPrograms: boolean;
  29284. /**
  29285. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29286. */
  29287. disableUniformBuffers: boolean;
  29288. /** @hidden */
  29289. _uniformBuffers: UniformBuffer[];
  29290. /**
  29291. * Gets a boolean indicating that the engine supports uniform buffers
  29292. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29293. */
  29294. readonly supportsUniformBuffers: boolean;
  29295. /** @hidden */
  29296. _gl: WebGLRenderingContext;
  29297. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29298. protected _windowIsBackground: boolean;
  29299. protected _webGLVersion: number;
  29300. protected _highPrecisionShadersAllowed: boolean;
  29301. /** @hidden */
  29302. readonly _shouldUseHighPrecisionShader: boolean;
  29303. /**
  29304. * Gets a boolean indicating that only power of 2 textures are supported
  29305. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29306. */
  29307. readonly needPOTTextures: boolean;
  29308. /** @hidden */
  29309. _badOS: boolean;
  29310. /** @hidden */
  29311. _badDesktopOS: boolean;
  29312. private _hardwareScalingLevel;
  29313. /** @hidden */
  29314. _caps: EngineCapabilities;
  29315. private _isStencilEnable;
  29316. protected _colorWrite: boolean;
  29317. /** @hidden */
  29318. _drawCalls: PerfCounter;
  29319. private _glVersion;
  29320. private _glRenderer;
  29321. private _glVendor;
  29322. /** @hidden */
  29323. _videoTextureSupported: boolean;
  29324. protected _renderingQueueLaunched: boolean;
  29325. protected _activeRenderLoops: (() => void)[];
  29326. /**
  29327. * Observable signaled when a context lost event is raised
  29328. */
  29329. onContextLostObservable: Observable<ThinEngine>;
  29330. /**
  29331. * Observable signaled when a context restored event is raised
  29332. */
  29333. onContextRestoredObservable: Observable<ThinEngine>;
  29334. private _onContextLost;
  29335. private _onContextRestored;
  29336. protected _contextWasLost: boolean;
  29337. /** @hidden */
  29338. _doNotHandleContextLost: boolean;
  29339. /**
  29340. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29341. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29342. */
  29343. doNotHandleContextLost: boolean;
  29344. /**
  29345. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29346. */
  29347. disableVertexArrayObjects: boolean;
  29348. /** @hidden */
  29349. protected _depthCullingState: DepthCullingState;
  29350. /** @hidden */
  29351. protected _stencilState: StencilState;
  29352. /** @hidden */
  29353. protected _alphaState: AlphaState;
  29354. /** @hidden */
  29355. _internalTexturesCache: InternalTexture[];
  29356. /** @hidden */
  29357. protected _activeChannel: number;
  29358. private _currentTextureChannel;
  29359. /** @hidden */
  29360. protected _boundTexturesCache: {
  29361. [key: string]: Nullable<InternalTexture>;
  29362. };
  29363. /** @hidden */
  29364. protected _currentEffect: Nullable<Effect>;
  29365. /** @hidden */
  29366. protected _currentProgram: Nullable<WebGLProgram>;
  29367. private _compiledEffects;
  29368. private _vertexAttribArraysEnabled;
  29369. /** @hidden */
  29370. protected _cachedViewport: Nullable<IViewportLike>;
  29371. private _cachedVertexArrayObject;
  29372. /** @hidden */
  29373. protected _cachedVertexBuffers: any;
  29374. /** @hidden */
  29375. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29376. /** @hidden */
  29377. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29378. /** @hidden */
  29379. _currentRenderTarget: Nullable<InternalTexture>;
  29380. private _uintIndicesCurrentlySet;
  29381. private _currentBoundBuffer;
  29382. /** @hidden */
  29383. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29384. private _currentBufferPointers;
  29385. private _currentInstanceLocations;
  29386. private _currentInstanceBuffers;
  29387. private _textureUnits;
  29388. /** @hidden */
  29389. _workingCanvas: Nullable<HTMLCanvasElement>;
  29390. /** @hidden */
  29391. _workingContext: Nullable<CanvasRenderingContext2D>;
  29392. /** @hidden */
  29393. _bindedRenderFunction: any;
  29394. private _vaoRecordInProgress;
  29395. private _mustWipeVertexAttributes;
  29396. private _emptyTexture;
  29397. private _emptyCubeTexture;
  29398. private _emptyTexture3D;
  29399. /** @hidden */
  29400. _frameHandler: number;
  29401. private _nextFreeTextureSlots;
  29402. private _maxSimultaneousTextures;
  29403. private _activeRequests;
  29404. protected _texturesSupported: string[];
  29405. /** @hidden */
  29406. _textureFormatInUse: Nullable<string>;
  29407. protected readonly _supportsHardwareTextureRescaling: boolean;
  29408. /**
  29409. * Gets the list of texture formats supported
  29410. */
  29411. readonly texturesSupported: Array<string>;
  29412. /**
  29413. * Gets the list of texture formats in use
  29414. */
  29415. readonly textureFormatInUse: Nullable<string>;
  29416. /**
  29417. * Gets the current viewport
  29418. */
  29419. readonly currentViewport: Nullable<IViewportLike>;
  29420. /**
  29421. * Gets the default empty texture
  29422. */
  29423. readonly emptyTexture: InternalTexture;
  29424. /**
  29425. * Gets the default empty 3D texture
  29426. */
  29427. readonly emptyTexture3D: InternalTexture;
  29428. /**
  29429. * Gets the default empty cube texture
  29430. */
  29431. readonly emptyCubeTexture: InternalTexture;
  29432. /**
  29433. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29434. */
  29435. readonly premultipliedAlpha: boolean;
  29436. /**
  29437. * Creates a new engine
  29438. * @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
  29439. * @param antialias defines enable antialiasing (default: false)
  29440. * @param options defines further options to be sent to the getContext() function
  29441. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29442. */
  29443. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29444. private _rebuildInternalTextures;
  29445. private _rebuildEffects;
  29446. /**
  29447. * Gets a boolean indicating if all created effects are ready
  29448. * @returns true if all effects are ready
  29449. */
  29450. areAllEffectsReady(): boolean;
  29451. protected _rebuildBuffers(): void;
  29452. private _initGLContext;
  29453. /**
  29454. * Gets version of the current webGL context
  29455. */
  29456. readonly webGLVersion: number;
  29457. /**
  29458. * Gets a string idenfifying the name of the class
  29459. * @returns "Engine" string
  29460. */
  29461. getClassName(): string;
  29462. /**
  29463. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29464. */
  29465. readonly isStencilEnable: boolean;
  29466. /** @hidden */
  29467. _prepareWorkingCanvas(): void;
  29468. /**
  29469. * Reset the texture cache to empty state
  29470. */
  29471. resetTextureCache(): void;
  29472. /**
  29473. * Gets an object containing information about the current webGL context
  29474. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29475. */
  29476. getGlInfo(): {
  29477. vendor: string;
  29478. renderer: string;
  29479. version: string;
  29480. };
  29481. /**
  29482. * Defines the hardware scaling level.
  29483. * By default the hardware scaling level is computed from the window device ratio.
  29484. * 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.
  29485. * @param level defines the level to use
  29486. */
  29487. setHardwareScalingLevel(level: number): void;
  29488. /**
  29489. * Gets the current hardware scaling level.
  29490. * By default the hardware scaling level is computed from the window device ratio.
  29491. * 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.
  29492. * @returns a number indicating the current hardware scaling level
  29493. */
  29494. getHardwareScalingLevel(): number;
  29495. /**
  29496. * Gets the list of loaded textures
  29497. * @returns an array containing all loaded textures
  29498. */
  29499. getLoadedTexturesCache(): InternalTexture[];
  29500. /**
  29501. * Gets the object containing all engine capabilities
  29502. * @returns the EngineCapabilities object
  29503. */
  29504. getCaps(): EngineCapabilities;
  29505. /**
  29506. * stop executing a render loop function and remove it from the execution array
  29507. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29508. */
  29509. stopRenderLoop(renderFunction?: () => void): void;
  29510. /** @hidden */
  29511. _renderLoop(): void;
  29512. /**
  29513. * Gets the HTML canvas attached with the current webGL context
  29514. * @returns a HTML canvas
  29515. */
  29516. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29517. /**
  29518. * Gets host window
  29519. * @returns the host window object
  29520. */
  29521. getHostWindow(): Window;
  29522. /**
  29523. * Gets the current render width
  29524. * @param useScreen defines if screen size must be used (or the current render target if any)
  29525. * @returns a number defining the current render width
  29526. */
  29527. getRenderWidth(useScreen?: boolean): number;
  29528. /**
  29529. * Gets the current render height
  29530. * @param useScreen defines if screen size must be used (or the current render target if any)
  29531. * @returns a number defining the current render height
  29532. */
  29533. getRenderHeight(useScreen?: boolean): number;
  29534. /**
  29535. * Can be used to override the current requestAnimationFrame requester.
  29536. * @hidden
  29537. */
  29538. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29539. /**
  29540. * Register and execute a render loop. The engine can have more than one render function
  29541. * @param renderFunction defines the function to continuously execute
  29542. */
  29543. runRenderLoop(renderFunction: () => void): void;
  29544. /**
  29545. * Clear the current render buffer or the current render target (if any is set up)
  29546. * @param color defines the color to use
  29547. * @param backBuffer defines if the back buffer must be cleared
  29548. * @param depth defines if the depth buffer must be cleared
  29549. * @param stencil defines if the stencil buffer must be cleared
  29550. */
  29551. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29552. private _viewportCached;
  29553. /** @hidden */
  29554. _viewport(x: number, y: number, width: number, height: number): void;
  29555. /**
  29556. * Set the WebGL's viewport
  29557. * @param viewport defines the viewport element to be used
  29558. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29559. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29560. */
  29561. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29562. /**
  29563. * Begin a new frame
  29564. */
  29565. beginFrame(): void;
  29566. /**
  29567. * Enf the current frame
  29568. */
  29569. endFrame(): void;
  29570. /**
  29571. * Resize the view according to the canvas' size
  29572. */
  29573. resize(): void;
  29574. /**
  29575. * Force a specific size of the canvas
  29576. * @param width defines the new canvas' width
  29577. * @param height defines the new canvas' height
  29578. */
  29579. setSize(width: number, height: number): void;
  29580. /**
  29581. * Binds the frame buffer to the specified texture.
  29582. * @param texture The texture to render to or null for the default canvas
  29583. * @param faceIndex The face of the texture to render to in case of cube texture
  29584. * @param requiredWidth The width of the target to render to
  29585. * @param requiredHeight The height of the target to render to
  29586. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29587. * @param depthStencilTexture The depth stencil texture to use to render
  29588. * @param lodLevel defines le lod level to bind to the frame buffer
  29589. */
  29590. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29591. /** @hidden */
  29592. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29593. /**
  29594. * Unbind the current render target texture from the webGL context
  29595. * @param texture defines the render target texture to unbind
  29596. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29597. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29598. */
  29599. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29600. /**
  29601. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29602. */
  29603. flushFramebuffer(): void;
  29604. /**
  29605. * Unbind the current render target and bind the default framebuffer
  29606. */
  29607. restoreDefaultFramebuffer(): void;
  29608. private _resetVertexBufferBinding;
  29609. /**
  29610. * Creates a vertex buffer
  29611. * @param data the data for the vertex buffer
  29612. * @returns the new WebGL static buffer
  29613. */
  29614. createVertexBuffer(data: DataArray): DataBuffer;
  29615. private _createVertexBuffer;
  29616. /**
  29617. * Creates a dynamic vertex buffer
  29618. * @param data the data for the dynamic vertex buffer
  29619. * @returns the new WebGL dynamic buffer
  29620. */
  29621. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29622. /**
  29623. * Update a dynamic index buffer
  29624. * @param indexBuffer defines the target index buffer
  29625. * @param indices defines the data to update
  29626. * @param offset defines the offset in the target index buffer where update should start
  29627. */
  29628. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29629. /**
  29630. * Updates a dynamic vertex buffer.
  29631. * @param vertexBuffer the vertex buffer to update
  29632. * @param data the data used to update the vertex buffer
  29633. * @param byteOffset the byte offset of the data
  29634. * @param byteLength the byte length of the data
  29635. */
  29636. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29637. private _resetIndexBufferBinding;
  29638. /**
  29639. * Creates a new index buffer
  29640. * @param indices defines the content of the index buffer
  29641. * @param updatable defines if the index buffer must be updatable
  29642. * @returns a new webGL buffer
  29643. */
  29644. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29645. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29646. /**
  29647. * Bind a webGL buffer to the webGL context
  29648. * @param buffer defines the buffer to bind
  29649. */
  29650. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29651. private bindIndexBuffer;
  29652. private bindBuffer;
  29653. /**
  29654. * update the bound buffer with the given data
  29655. * @param data defines the data to update
  29656. */
  29657. updateArrayBuffer(data: Float32Array): void;
  29658. private _vertexAttribPointer;
  29659. private _bindIndexBufferWithCache;
  29660. private _bindVertexBuffersAttributes;
  29661. /**
  29662. * Records a vertex array object
  29663. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29664. * @param vertexBuffers defines the list of vertex buffers to store
  29665. * @param indexBuffer defines the index buffer to store
  29666. * @param effect defines the effect to store
  29667. * @returns the new vertex array object
  29668. */
  29669. recordVertexArrayObject(vertexBuffers: {
  29670. [key: string]: VertexBuffer;
  29671. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29672. /**
  29673. * Bind a specific vertex array object
  29674. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29675. * @param vertexArrayObject defines the vertex array object to bind
  29676. * @param indexBuffer defines the index buffer to bind
  29677. */
  29678. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29679. /**
  29680. * Bind webGl buffers directly to the webGL context
  29681. * @param vertexBuffer defines the vertex buffer to bind
  29682. * @param indexBuffer defines the index buffer to bind
  29683. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29684. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29685. * @param effect defines the effect associated with the vertex buffer
  29686. */
  29687. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29688. private _unbindVertexArrayObject;
  29689. /**
  29690. * Bind a list of vertex buffers to the webGL context
  29691. * @param vertexBuffers defines the list of vertex buffers to bind
  29692. * @param indexBuffer defines the index buffer to bind
  29693. * @param effect defines the effect associated with the vertex buffers
  29694. */
  29695. bindBuffers(vertexBuffers: {
  29696. [key: string]: Nullable<VertexBuffer>;
  29697. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29698. /**
  29699. * Unbind all instance attributes
  29700. */
  29701. unbindInstanceAttributes(): void;
  29702. /**
  29703. * Release and free the memory of a vertex array object
  29704. * @param vao defines the vertex array object to delete
  29705. */
  29706. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29707. /** @hidden */
  29708. _releaseBuffer(buffer: DataBuffer): boolean;
  29709. protected _deleteBuffer(buffer: DataBuffer): void;
  29710. /**
  29711. * Creates a webGL buffer to use with instanciation
  29712. * @param capacity defines the size of the buffer
  29713. * @returns the webGL buffer
  29714. */
  29715. createInstancesBuffer(capacity: number): DataBuffer;
  29716. /**
  29717. * Delete a webGL buffer used with instanciation
  29718. * @param buffer defines the webGL buffer to delete
  29719. */
  29720. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29721. /**
  29722. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29723. * @param instancesBuffer defines the webGL buffer to update and bind
  29724. * @param data defines the data to store in the buffer
  29725. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29726. */
  29727. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29728. /**
  29729. * Apply all cached states (depth, culling, stencil and alpha)
  29730. */
  29731. applyStates(): void;
  29732. /**
  29733. * Send a draw order
  29734. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29735. * @param indexStart defines the starting index
  29736. * @param indexCount defines the number of index to draw
  29737. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29738. */
  29739. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29740. /**
  29741. * Draw a list of points
  29742. * @param verticesStart defines the index of first vertex to draw
  29743. * @param verticesCount defines the count of vertices to draw
  29744. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29745. */
  29746. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29747. /**
  29748. * Draw a list of unindexed primitives
  29749. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29750. * @param verticesStart defines the index of first vertex to draw
  29751. * @param verticesCount defines the count of vertices to draw
  29752. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29753. */
  29754. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29755. /**
  29756. * Draw a list of indexed primitives
  29757. * @param fillMode defines the primitive to use
  29758. * @param indexStart defines the starting index
  29759. * @param indexCount defines the number of index to draw
  29760. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29761. */
  29762. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29763. /**
  29764. * Draw a list of unindexed primitives
  29765. * @param fillMode defines the primitive to use
  29766. * @param verticesStart defines the index of first vertex to draw
  29767. * @param verticesCount defines the count of vertices to draw
  29768. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29769. */
  29770. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29771. private _drawMode;
  29772. /** @hidden */
  29773. _releaseEffect(effect: Effect): void;
  29774. /** @hidden */
  29775. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29776. /**
  29777. * Create a new effect (used to store vertex/fragment shaders)
  29778. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29779. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29780. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29781. * @param samplers defines an array of string used to represent textures
  29782. * @param defines defines the string containing the defines to use to compile the shaders
  29783. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29784. * @param onCompiled defines a function to call when the effect creation is successful
  29785. * @param onError defines a function to call when the effect creation has failed
  29786. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29787. * @returns the new Effect
  29788. */
  29789. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29790. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29791. private _compileShader;
  29792. private _compileRawShader;
  29793. /**
  29794. * Directly creates a webGL program
  29795. * @param pipelineContext defines the pipeline context to attach to
  29796. * @param vertexCode defines the vertex shader code to use
  29797. * @param fragmentCode defines the fragment shader code to use
  29798. * @param context defines the webGL context to use (if not set, the current one will be used)
  29799. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29800. * @returns the new webGL program
  29801. */
  29802. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29803. /**
  29804. * Creates a webGL program
  29805. * @param pipelineContext defines the pipeline context to attach to
  29806. * @param vertexCode defines the vertex shader code to use
  29807. * @param fragmentCode defines the fragment shader code to use
  29808. * @param defines defines the string containing the defines to use to compile the shaders
  29809. * @param context defines the webGL context to use (if not set, the current one will be used)
  29810. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29811. * @returns the new webGL program
  29812. */
  29813. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29814. /**
  29815. * Creates a new pipeline context
  29816. * @returns the new pipeline
  29817. */
  29818. createPipelineContext(): IPipelineContext;
  29819. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29820. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29821. /** @hidden */
  29822. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29823. /** @hidden */
  29824. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29825. /** @hidden */
  29826. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29827. /**
  29828. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29829. * @param pipelineContext defines the pipeline context to use
  29830. * @param uniformsNames defines the list of uniform names
  29831. * @returns an array of webGL uniform locations
  29832. */
  29833. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29834. /**
  29835. * Gets the lsit of active attributes for a given webGL program
  29836. * @param pipelineContext defines the pipeline context to use
  29837. * @param attributesNames defines the list of attribute names to get
  29838. * @returns an array of indices indicating the offset of each attribute
  29839. */
  29840. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29841. /**
  29842. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29843. * @param effect defines the effect to activate
  29844. */
  29845. enableEffect(effect: Nullable<Effect>): void;
  29846. /**
  29847. * Set the value of an uniform to an array of int32
  29848. * @param uniform defines the webGL uniform location where to store the value
  29849. * @param array defines the array of int32 to store
  29850. */
  29851. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29852. /**
  29853. * Set the value of an uniform to an array of int32 (stored as vec2)
  29854. * @param uniform defines the webGL uniform location where to store the value
  29855. * @param array defines the array of int32 to store
  29856. */
  29857. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29858. /**
  29859. * Set the value of an uniform to an array of int32 (stored as vec3)
  29860. * @param uniform defines the webGL uniform location where to store the value
  29861. * @param array defines the array of int32 to store
  29862. */
  29863. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29864. /**
  29865. * Set the value of an uniform to an array of int32 (stored as vec4)
  29866. * @param uniform defines the webGL uniform location where to store the value
  29867. * @param array defines the array of int32 to store
  29868. */
  29869. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29870. /**
  29871. * Set the value of an uniform to an array of float32
  29872. * @param uniform defines the webGL uniform location where to store the value
  29873. * @param array defines the array of float32 to store
  29874. */
  29875. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29876. /**
  29877. * Set the value of an uniform to an array of float32 (stored as vec2)
  29878. * @param uniform defines the webGL uniform location where to store the value
  29879. * @param array defines the array of float32 to store
  29880. */
  29881. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29882. /**
  29883. * Set the value of an uniform to an array of float32 (stored as vec3)
  29884. * @param uniform defines the webGL uniform location where to store the value
  29885. * @param array defines the array of float32 to store
  29886. */
  29887. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29888. /**
  29889. * Set the value of an uniform to an array of float32 (stored as vec4)
  29890. * @param uniform defines the webGL uniform location where to store the value
  29891. * @param array defines the array of float32 to store
  29892. */
  29893. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29894. /**
  29895. * Set the value of an uniform to an array of number
  29896. * @param uniform defines the webGL uniform location where to store the value
  29897. * @param array defines the array of number to store
  29898. */
  29899. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29900. /**
  29901. * Set the value of an uniform to an array of number (stored as vec2)
  29902. * @param uniform defines the webGL uniform location where to store the value
  29903. * @param array defines the array of number to store
  29904. */
  29905. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29906. /**
  29907. * Set the value of an uniform to an array of number (stored as vec3)
  29908. * @param uniform defines the webGL uniform location where to store the value
  29909. * @param array defines the array of number to store
  29910. */
  29911. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29912. /**
  29913. * Set the value of an uniform to an array of number (stored as vec4)
  29914. * @param uniform defines the webGL uniform location where to store the value
  29915. * @param array defines the array of number to store
  29916. */
  29917. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29918. /**
  29919. * Set the value of an uniform to an array of float32 (stored as matrices)
  29920. * @param uniform defines the webGL uniform location where to store the value
  29921. * @param matrices defines the array of float32 to store
  29922. */
  29923. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29924. /**
  29925. * Set the value of an uniform to a matrix (3x3)
  29926. * @param uniform defines the webGL uniform location where to store the value
  29927. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29928. */
  29929. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29930. /**
  29931. * Set the value of an uniform to a matrix (2x2)
  29932. * @param uniform defines the webGL uniform location where to store the value
  29933. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29934. */
  29935. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29936. /**
  29937. * Set the value of an uniform to a number (int)
  29938. * @param uniform defines the webGL uniform location where to store the value
  29939. * @param value defines the int number to store
  29940. */
  29941. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29942. /**
  29943. * Set the value of an uniform to a number (float)
  29944. * @param uniform defines the webGL uniform location where to store the value
  29945. * @param value defines the float number to store
  29946. */
  29947. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29948. /**
  29949. * Set the value of an uniform to a vec2
  29950. * @param uniform defines the webGL uniform location where to store the value
  29951. * @param x defines the 1st component of the value
  29952. * @param y defines the 2nd component of the value
  29953. */
  29954. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29955. /**
  29956. * Set the value of an uniform to a vec3
  29957. * @param uniform defines the webGL uniform location where to store the value
  29958. * @param x defines the 1st component of the value
  29959. * @param y defines the 2nd component of the value
  29960. * @param z defines the 3rd component of the value
  29961. */
  29962. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29963. /**
  29964. * Set the value of an uniform to a boolean
  29965. * @param uniform defines the webGL uniform location where to store the value
  29966. * @param bool defines the boolean to store
  29967. */
  29968. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29969. /**
  29970. * Set the value of an uniform to a vec4
  29971. * @param uniform defines the webGL uniform location where to store the value
  29972. * @param x defines the 1st component of the value
  29973. * @param y defines the 2nd component of the value
  29974. * @param z defines the 3rd component of the value
  29975. * @param w defines the 4th component of the value
  29976. */
  29977. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29978. /**
  29979. * Sets a Color4 on a uniform variable
  29980. * @param uniform defines the uniform location
  29981. * @param color4 defines the value to be set
  29982. */
  29983. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29984. /**
  29985. * Gets the depth culling state manager
  29986. */
  29987. readonly depthCullingState: DepthCullingState;
  29988. /**
  29989. * Gets the alpha state manager
  29990. */
  29991. readonly alphaState: AlphaState;
  29992. /**
  29993. * Gets the stencil state manager
  29994. */
  29995. readonly stencilState: StencilState;
  29996. /**
  29997. * Clears the list of texture accessible through engine.
  29998. * This can help preventing texture load conflict due to name collision.
  29999. */
  30000. clearInternalTexturesCache(): void;
  30001. /**
  30002. * Force the entire cache to be cleared
  30003. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30004. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30005. */
  30006. wipeCaches(bruteForce?: boolean): void;
  30007. /** @hidden */
  30008. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30009. min: number;
  30010. mag: number;
  30011. };
  30012. /** @hidden */
  30013. _createTexture(): WebGLTexture;
  30014. /**
  30015. * Usually called from Texture.ts.
  30016. * Passed information to create a WebGLTexture
  30017. * @param urlArg defines a value which contains one of the following:
  30018. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30019. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30020. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30021. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30022. * @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)
  30023. * @param scene needed for loading to the correct scene
  30024. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30025. * @param onLoad optional callback to be called upon successful completion
  30026. * @param onError optional callback to be called upon failure
  30027. * @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
  30028. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30029. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30030. * @param forcedExtension defines the extension to use to pick the right loader
  30031. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30032. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30033. */
  30034. 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>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30035. /**
  30036. * @hidden
  30037. */
  30038. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30039. /**
  30040. * Creates a raw texture
  30041. * @param data defines the data to store in the texture
  30042. * @param width defines the width of the texture
  30043. * @param height defines the height of the texture
  30044. * @param format defines the format of the data
  30045. * @param generateMipMaps defines if the engine should generate the mip levels
  30046. * @param invertY defines if data must be stored with Y axis inverted
  30047. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30048. * @param compression defines the compression used (null by default)
  30049. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30050. * @returns the raw texture inside an InternalTexture
  30051. */
  30052. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30053. /**
  30054. * Creates a new raw cube texture
  30055. * @param data defines the array of data to use to create each face
  30056. * @param size defines the size of the textures
  30057. * @param format defines the format of the data
  30058. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30059. * @param generateMipMaps defines if the engine should generate the mip levels
  30060. * @param invertY defines if data must be stored with Y axis inverted
  30061. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30062. * @param compression defines the compression used (null by default)
  30063. * @returns the cube texture as an InternalTexture
  30064. */
  30065. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30066. /**
  30067. * Creates a new raw 3D texture
  30068. * @param data defines the data used to create the texture
  30069. * @param width defines the width of the texture
  30070. * @param height defines the height of the texture
  30071. * @param depth defines the depth of the texture
  30072. * @param format defines the format of the texture
  30073. * @param generateMipMaps defines if the engine must generate mip levels
  30074. * @param invertY defines if data must be stored with Y axis inverted
  30075. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30076. * @param compression defines the compressed used (can be null)
  30077. * @param textureType defines the compressed used (can be null)
  30078. * @returns a new raw 3D texture (stored in an InternalTexture)
  30079. */
  30080. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30081. private _unpackFlipYCached;
  30082. /**
  30083. * In case you are sharing the context with other applications, it might
  30084. * be interested to not cache the unpack flip y state to ensure a consistent
  30085. * value would be set.
  30086. */
  30087. enableUnpackFlipYCached: boolean;
  30088. /** @hidden */
  30089. _unpackFlipY(value: boolean): void;
  30090. /** @hidden */
  30091. _getUnpackAlignement(): number;
  30092. /**
  30093. * Update the sampling mode of a given texture
  30094. * @param samplingMode defines the required sampling mode
  30095. * @param texture defines the texture to update
  30096. */
  30097. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30098. /**
  30099. * Updates a depth texture Comparison Mode and Function.
  30100. * If the comparison Function is equal to 0, the mode will be set to none.
  30101. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30102. * @param texture The texture to set the comparison function for
  30103. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30104. */
  30105. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30106. /** @hidden */
  30107. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30108. width: number;
  30109. height: number;
  30110. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30111. /**
  30112. * Creates a depth stencil texture.
  30113. * This is only available in WebGL 2 or with the depth texture extension available.
  30114. * @param size The size of face edge in the texture.
  30115. * @param options The options defining the texture.
  30116. * @returns The texture
  30117. */
  30118. createDepthStencilTexture(size: number | {
  30119. width: number;
  30120. height: number;
  30121. }, options: DepthTextureCreationOptions): InternalTexture;
  30122. /**
  30123. * Creates a depth stencil texture.
  30124. * This is only available in WebGL 2 or with the depth texture extension available.
  30125. * @param size The size of face edge in the texture.
  30126. * @param options The options defining the texture.
  30127. * @returns The texture
  30128. */
  30129. private _createDepthStencilTexture;
  30130. /**
  30131. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30132. * @param renderTarget The render target to set the frame buffer for
  30133. */
  30134. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  30135. /** @hidden */
  30136. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30137. /** @hidden */
  30138. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30139. /** @hidden */
  30140. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30141. /** @hidden */
  30142. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30143. /** @hidden */
  30144. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30145. /**
  30146. * @hidden
  30147. */
  30148. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30149. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30150. private _prepareWebGLTexture;
  30151. /** @hidden */
  30152. _releaseFramebufferObjects(texture: InternalTexture): void;
  30153. /** @hidden */
  30154. _releaseTexture(texture: InternalTexture): void;
  30155. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30156. protected _setProgram(program: WebGLProgram): void;
  30157. protected _boundUniforms: {
  30158. [key: number]: WebGLUniformLocation;
  30159. };
  30160. /**
  30161. * Binds an effect to the webGL context
  30162. * @param effect defines the effect to bind
  30163. */
  30164. bindSamplers(effect: Effect): void;
  30165. private _activateCurrentTexture;
  30166. /** @hidden */
  30167. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30168. /** @hidden */
  30169. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30170. /**
  30171. * Unbind all textures from the webGL context
  30172. */
  30173. unbindAllTextures(): void;
  30174. /**
  30175. * Sets a texture to the according uniform.
  30176. * @param channel The texture channel
  30177. * @param uniform The uniform to set
  30178. * @param texture The texture to apply
  30179. */
  30180. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30181. private _bindSamplerUniformToChannel;
  30182. private _getTextureWrapMode;
  30183. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30184. /**
  30185. * Sets an array of texture to the webGL context
  30186. * @param channel defines the channel where the texture array must be set
  30187. * @param uniform defines the associated uniform location
  30188. * @param textures defines the array of textures to bind
  30189. */
  30190. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30191. /** @hidden */
  30192. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30193. private _setTextureParameterFloat;
  30194. private _setTextureParameterInteger;
  30195. /**
  30196. * Unbind all vertex attributes from the webGL context
  30197. */
  30198. unbindAllAttributes(): void;
  30199. /**
  30200. * 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
  30201. */
  30202. releaseEffects(): void;
  30203. /**
  30204. * Dispose and release all associated resources
  30205. */
  30206. dispose(): void;
  30207. /**
  30208. * Attach a new callback raised when context lost event is fired
  30209. * @param callback defines the callback to call
  30210. */
  30211. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30212. /**
  30213. * Attach a new callback raised when context restored event is fired
  30214. * @param callback defines the callback to call
  30215. */
  30216. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30217. /**
  30218. * Get the current error code of the webGL context
  30219. * @returns the error code
  30220. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30221. */
  30222. getError(): number;
  30223. private _canRenderToFloatFramebuffer;
  30224. private _canRenderToHalfFloatFramebuffer;
  30225. private _canRenderToFramebuffer;
  30226. /** @hidden */
  30227. _getWebGLTextureType(type: number): number;
  30228. /** @hidden */
  30229. _getInternalFormat(format: number): number;
  30230. /** @hidden */
  30231. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30232. /** @hidden */
  30233. _getRGBAMultiSampleBufferFormat(type: number): number;
  30234. /** @hidden */
  30235. _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;
  30236. /**
  30237. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30238. * @returns true if the engine can be created
  30239. * @ignorenaming
  30240. */
  30241. static isSupported(): boolean;
  30242. /**
  30243. * Find the next highest power of two.
  30244. * @param x Number to start search from.
  30245. * @return Next highest power of two.
  30246. */
  30247. static CeilingPOT(x: number): number;
  30248. /**
  30249. * Find the next lowest power of two.
  30250. * @param x Number to start search from.
  30251. * @return Next lowest power of two.
  30252. */
  30253. static FloorPOT(x: number): number;
  30254. /**
  30255. * Find the nearest power of two.
  30256. * @param x Number to start search from.
  30257. * @return Next nearest power of two.
  30258. */
  30259. static NearestPOT(x: number): number;
  30260. /**
  30261. * Get the closest exponent of two
  30262. * @param value defines the value to approximate
  30263. * @param max defines the maximum value to return
  30264. * @param mode defines how to define the closest value
  30265. * @returns closest exponent of two of the given value
  30266. */
  30267. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30268. /**
  30269. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30270. * @param func - the function to be called
  30271. * @param requester - the object that will request the next frame. Falls back to window.
  30272. * @returns frame number
  30273. */
  30274. static QueueNewFrame(func: () => void, requester?: any): number;
  30275. }
  30276. }
  30277. declare module BABYLON {
  30278. /**
  30279. * Class used to store data associated with WebGL texture data for the engine
  30280. * This class should not be used directly
  30281. */
  30282. export class InternalTexture {
  30283. /** @hidden */
  30284. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30285. /**
  30286. * The source of the texture data is unknown
  30287. */
  30288. static DATASOURCE_UNKNOWN: number;
  30289. /**
  30290. * Texture data comes from an URL
  30291. */
  30292. static DATASOURCE_URL: number;
  30293. /**
  30294. * Texture data is only used for temporary storage
  30295. */
  30296. static DATASOURCE_TEMP: number;
  30297. /**
  30298. * Texture data comes from raw data (ArrayBuffer)
  30299. */
  30300. static DATASOURCE_RAW: number;
  30301. /**
  30302. * Texture content is dynamic (video or dynamic texture)
  30303. */
  30304. static DATASOURCE_DYNAMIC: number;
  30305. /**
  30306. * Texture content is generated by rendering to it
  30307. */
  30308. static DATASOURCE_RENDERTARGET: number;
  30309. /**
  30310. * Texture content is part of a multi render target process
  30311. */
  30312. static DATASOURCE_MULTIRENDERTARGET: number;
  30313. /**
  30314. * Texture data comes from a cube data file
  30315. */
  30316. static DATASOURCE_CUBE: number;
  30317. /**
  30318. * Texture data comes from a raw cube data
  30319. */
  30320. static DATASOURCE_CUBERAW: number;
  30321. /**
  30322. * Texture data come from a prefiltered cube data file
  30323. */
  30324. static DATASOURCE_CUBEPREFILTERED: number;
  30325. /**
  30326. * Texture content is raw 3D data
  30327. */
  30328. static DATASOURCE_RAW3D: number;
  30329. /**
  30330. * Texture content is a depth texture
  30331. */
  30332. static DATASOURCE_DEPTHTEXTURE: number;
  30333. /**
  30334. * Texture data comes from a raw cube data encoded with RGBD
  30335. */
  30336. static DATASOURCE_CUBERAW_RGBD: number;
  30337. /**
  30338. * Defines if the texture is ready
  30339. */
  30340. isReady: boolean;
  30341. /**
  30342. * Defines if the texture is a cube texture
  30343. */
  30344. isCube: boolean;
  30345. /**
  30346. * Defines if the texture contains 3D data
  30347. */
  30348. is3D: boolean;
  30349. /**
  30350. * Defines if the texture contains multiview data
  30351. */
  30352. isMultiview: boolean;
  30353. /**
  30354. * Gets the URL used to load this texture
  30355. */
  30356. url: string;
  30357. /**
  30358. * Gets the sampling mode of the texture
  30359. */
  30360. samplingMode: number;
  30361. /**
  30362. * Gets a boolean indicating if the texture needs mipmaps generation
  30363. */
  30364. generateMipMaps: boolean;
  30365. /**
  30366. * Gets the number of samples used by the texture (WebGL2+ only)
  30367. */
  30368. samples: number;
  30369. /**
  30370. * Gets the type of the texture (int, float...)
  30371. */
  30372. type: number;
  30373. /**
  30374. * Gets the format of the texture (RGB, RGBA...)
  30375. */
  30376. format: number;
  30377. /**
  30378. * Observable called when the texture is loaded
  30379. */
  30380. onLoadedObservable: Observable<InternalTexture>;
  30381. /**
  30382. * Gets the width of the texture
  30383. */
  30384. width: number;
  30385. /**
  30386. * Gets the height of the texture
  30387. */
  30388. height: number;
  30389. /**
  30390. * Gets the depth of the texture
  30391. */
  30392. depth: number;
  30393. /**
  30394. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30395. */
  30396. baseWidth: number;
  30397. /**
  30398. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30399. */
  30400. baseHeight: number;
  30401. /**
  30402. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30403. */
  30404. baseDepth: number;
  30405. /**
  30406. * Gets a boolean indicating if the texture is inverted on Y axis
  30407. */
  30408. invertY: boolean;
  30409. /** @hidden */
  30410. _invertVScale: boolean;
  30411. /** @hidden */
  30412. _associatedChannel: number;
  30413. /** @hidden */
  30414. _dataSource: number;
  30415. /** @hidden */
  30416. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  30417. /** @hidden */
  30418. _bufferView: Nullable<ArrayBufferView>;
  30419. /** @hidden */
  30420. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30421. /** @hidden */
  30422. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30423. /** @hidden */
  30424. _size: number;
  30425. /** @hidden */
  30426. _extension: string;
  30427. /** @hidden */
  30428. _files: Nullable<string[]>;
  30429. /** @hidden */
  30430. _workingCanvas: Nullable<HTMLCanvasElement>;
  30431. /** @hidden */
  30432. _workingContext: Nullable<CanvasRenderingContext2D>;
  30433. /** @hidden */
  30434. _framebuffer: Nullable<WebGLFramebuffer>;
  30435. /** @hidden */
  30436. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30437. /** @hidden */
  30438. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30439. /** @hidden */
  30440. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30441. /** @hidden */
  30442. _attachments: Nullable<number[]>;
  30443. /** @hidden */
  30444. _cachedCoordinatesMode: Nullable<number>;
  30445. /** @hidden */
  30446. _cachedWrapU: Nullable<number>;
  30447. /** @hidden */
  30448. _cachedWrapV: Nullable<number>;
  30449. /** @hidden */
  30450. _cachedWrapR: Nullable<number>;
  30451. /** @hidden */
  30452. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30453. /** @hidden */
  30454. _isDisabled: boolean;
  30455. /** @hidden */
  30456. _compression: Nullable<string>;
  30457. /** @hidden */
  30458. _generateStencilBuffer: boolean;
  30459. /** @hidden */
  30460. _generateDepthBuffer: boolean;
  30461. /** @hidden */
  30462. _comparisonFunction: number;
  30463. /** @hidden */
  30464. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30465. /** @hidden */
  30466. _lodGenerationScale: number;
  30467. /** @hidden */
  30468. _lodGenerationOffset: number;
  30469. /** @hidden */
  30470. _colorTextureArray: Nullable<WebGLTexture>;
  30471. /** @hidden */
  30472. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30473. /** @hidden */
  30474. _lodTextureHigh: Nullable<BaseTexture>;
  30475. /** @hidden */
  30476. _lodTextureMid: Nullable<BaseTexture>;
  30477. /** @hidden */
  30478. _lodTextureLow: Nullable<BaseTexture>;
  30479. /** @hidden */
  30480. _isRGBD: boolean;
  30481. /** @hidden */
  30482. _linearSpecularLOD: boolean;
  30483. /** @hidden */
  30484. _irradianceTexture: Nullable<BaseTexture>;
  30485. /** @hidden */
  30486. _webGLTexture: Nullable<WebGLTexture>;
  30487. /** @hidden */
  30488. _references: number;
  30489. private _engine;
  30490. /**
  30491. * Gets the Engine the texture belongs to.
  30492. * @returns The babylon engine
  30493. */
  30494. getEngine(): ThinEngine;
  30495. /**
  30496. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  30497. */
  30498. readonly dataSource: number;
  30499. /**
  30500. * Creates a new InternalTexture
  30501. * @param engine defines the engine to use
  30502. * @param dataSource defines the type of data that will be used
  30503. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30504. */
  30505. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  30506. /**
  30507. * Increments the number of references (ie. the number of Texture that point to it)
  30508. */
  30509. incrementReferences(): void;
  30510. /**
  30511. * Change the size of the texture (not the size of the content)
  30512. * @param width defines the new width
  30513. * @param height defines the new height
  30514. * @param depth defines the new depth (1 by default)
  30515. */
  30516. updateSize(width: int, height: int, depth?: int): void;
  30517. /** @hidden */
  30518. _rebuild(): void;
  30519. /** @hidden */
  30520. _swapAndDie(target: InternalTexture): void;
  30521. /**
  30522. * Dispose the current allocated resources
  30523. */
  30524. dispose(): void;
  30525. }
  30526. }
  30527. declare module BABYLON {
  30528. /**
  30529. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30531. */
  30532. export class Analyser {
  30533. /**
  30534. * Gets or sets the smoothing
  30535. * @ignorenaming
  30536. */
  30537. SMOOTHING: number;
  30538. /**
  30539. * Gets or sets the FFT table size
  30540. * @ignorenaming
  30541. */
  30542. FFT_SIZE: number;
  30543. /**
  30544. * Gets or sets the bar graph amplitude
  30545. * @ignorenaming
  30546. */
  30547. BARGRAPHAMPLITUDE: number;
  30548. /**
  30549. * Gets or sets the position of the debug canvas
  30550. * @ignorenaming
  30551. */
  30552. DEBUGCANVASPOS: {
  30553. x: number;
  30554. y: number;
  30555. };
  30556. /**
  30557. * Gets or sets the debug canvas size
  30558. * @ignorenaming
  30559. */
  30560. DEBUGCANVASSIZE: {
  30561. width: number;
  30562. height: number;
  30563. };
  30564. private _byteFreqs;
  30565. private _byteTime;
  30566. private _floatFreqs;
  30567. private _webAudioAnalyser;
  30568. private _debugCanvas;
  30569. private _debugCanvasContext;
  30570. private _scene;
  30571. private _registerFunc;
  30572. private _audioEngine;
  30573. /**
  30574. * Creates a new analyser
  30575. * @param scene defines hosting scene
  30576. */
  30577. constructor(scene: Scene);
  30578. /**
  30579. * Get the number of data values you will have to play with for the visualization
  30580. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30581. * @returns a number
  30582. */
  30583. getFrequencyBinCount(): number;
  30584. /**
  30585. * Gets the current frequency data as a byte array
  30586. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30587. * @returns a Uint8Array
  30588. */
  30589. getByteFrequencyData(): Uint8Array;
  30590. /**
  30591. * Gets the current waveform as a byte array
  30592. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30593. * @returns a Uint8Array
  30594. */
  30595. getByteTimeDomainData(): Uint8Array;
  30596. /**
  30597. * Gets the current frequency data as a float array
  30598. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30599. * @returns a Float32Array
  30600. */
  30601. getFloatFrequencyData(): Float32Array;
  30602. /**
  30603. * Renders the debug canvas
  30604. */
  30605. drawDebugCanvas(): void;
  30606. /**
  30607. * Stops rendering the debug canvas and removes it
  30608. */
  30609. stopDebugCanvas(): void;
  30610. /**
  30611. * Connects two audio nodes
  30612. * @param inputAudioNode defines first node to connect
  30613. * @param outputAudioNode defines second node to connect
  30614. */
  30615. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30616. /**
  30617. * Releases all associated resources
  30618. */
  30619. dispose(): void;
  30620. }
  30621. }
  30622. declare module BABYLON {
  30623. /**
  30624. * This represents an audio engine and it is responsible
  30625. * to play, synchronize and analyse sounds throughout the application.
  30626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30627. */
  30628. export interface IAudioEngine extends IDisposable {
  30629. /**
  30630. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30631. */
  30632. readonly canUseWebAudio: boolean;
  30633. /**
  30634. * Gets the current AudioContext if available.
  30635. */
  30636. readonly audioContext: Nullable<AudioContext>;
  30637. /**
  30638. * The master gain node defines the global audio volume of your audio engine.
  30639. */
  30640. readonly masterGain: GainNode;
  30641. /**
  30642. * Gets whether or not mp3 are supported by your browser.
  30643. */
  30644. readonly isMP3supported: boolean;
  30645. /**
  30646. * Gets whether or not ogg are supported by your browser.
  30647. */
  30648. readonly isOGGsupported: boolean;
  30649. /**
  30650. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30651. * @ignoreNaming
  30652. */
  30653. WarnedWebAudioUnsupported: boolean;
  30654. /**
  30655. * Defines if the audio engine relies on a custom unlocked button.
  30656. * In this case, the embedded button will not be displayed.
  30657. */
  30658. useCustomUnlockedButton: boolean;
  30659. /**
  30660. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30661. */
  30662. readonly unlocked: boolean;
  30663. /**
  30664. * Event raised when audio has been unlocked on the browser.
  30665. */
  30666. onAudioUnlockedObservable: Observable<AudioEngine>;
  30667. /**
  30668. * Event raised when audio has been locked on the browser.
  30669. */
  30670. onAudioLockedObservable: Observable<AudioEngine>;
  30671. /**
  30672. * Flags the audio engine in Locked state.
  30673. * This happens due to new browser policies preventing audio to autoplay.
  30674. */
  30675. lock(): void;
  30676. /**
  30677. * Unlocks the audio engine once a user action has been done on the dom.
  30678. * This is helpful to resume play once browser policies have been satisfied.
  30679. */
  30680. unlock(): void;
  30681. }
  30682. /**
  30683. * This represents the default audio engine used in babylon.
  30684. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30686. */
  30687. export class AudioEngine implements IAudioEngine {
  30688. private _audioContext;
  30689. private _audioContextInitialized;
  30690. private _muteButton;
  30691. private _hostElement;
  30692. /**
  30693. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30694. */
  30695. canUseWebAudio: boolean;
  30696. /**
  30697. * The master gain node defines the global audio volume of your audio engine.
  30698. */
  30699. masterGain: GainNode;
  30700. /**
  30701. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30702. * @ignoreNaming
  30703. */
  30704. WarnedWebAudioUnsupported: boolean;
  30705. /**
  30706. * Gets whether or not mp3 are supported by your browser.
  30707. */
  30708. isMP3supported: boolean;
  30709. /**
  30710. * Gets whether or not ogg are supported by your browser.
  30711. */
  30712. isOGGsupported: boolean;
  30713. /**
  30714. * Gets whether audio has been unlocked on the device.
  30715. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30716. * a user interaction has happened.
  30717. */
  30718. unlocked: boolean;
  30719. /**
  30720. * Defines if the audio engine relies on a custom unlocked button.
  30721. * In this case, the embedded button will not be displayed.
  30722. */
  30723. useCustomUnlockedButton: boolean;
  30724. /**
  30725. * Event raised when audio has been unlocked on the browser.
  30726. */
  30727. onAudioUnlockedObservable: Observable<AudioEngine>;
  30728. /**
  30729. * Event raised when audio has been locked on the browser.
  30730. */
  30731. onAudioLockedObservable: Observable<AudioEngine>;
  30732. /**
  30733. * Gets the current AudioContext if available.
  30734. */
  30735. readonly audioContext: Nullable<AudioContext>;
  30736. private _connectedAnalyser;
  30737. /**
  30738. * Instantiates a new audio engine.
  30739. *
  30740. * There should be only one per page as some browsers restrict the number
  30741. * of audio contexts you can create.
  30742. * @param hostElement defines the host element where to display the mute icon if necessary
  30743. */
  30744. constructor(hostElement?: Nullable<HTMLElement>);
  30745. /**
  30746. * Flags the audio engine in Locked state.
  30747. * This happens due to new browser policies preventing audio to autoplay.
  30748. */
  30749. lock(): void;
  30750. /**
  30751. * Unlocks the audio engine once a user action has been done on the dom.
  30752. * This is helpful to resume play once browser policies have been satisfied.
  30753. */
  30754. unlock(): void;
  30755. private _resumeAudioContext;
  30756. private _initializeAudioContext;
  30757. private _tryToRun;
  30758. private _triggerRunningState;
  30759. private _triggerSuspendedState;
  30760. private _displayMuteButton;
  30761. private _moveButtonToTopLeft;
  30762. private _onResize;
  30763. private _hideMuteButton;
  30764. /**
  30765. * Destroy and release the resources associated with the audio ccontext.
  30766. */
  30767. dispose(): void;
  30768. /**
  30769. * Gets the global volume sets on the master gain.
  30770. * @returns the global volume if set or -1 otherwise
  30771. */
  30772. getGlobalVolume(): number;
  30773. /**
  30774. * Sets the global volume of your experience (sets on the master gain).
  30775. * @param newVolume Defines the new global volume of the application
  30776. */
  30777. setGlobalVolume(newVolume: number): void;
  30778. /**
  30779. * Connect the audio engine to an audio analyser allowing some amazing
  30780. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30782. * @param analyser The analyser to connect to the engine
  30783. */
  30784. connectToAnalyser(analyser: Analyser): void;
  30785. }
  30786. }
  30787. declare module BABYLON {
  30788. /**
  30789. * Interface used to present a loading screen while loading a scene
  30790. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30791. */
  30792. export interface ILoadingScreen {
  30793. /**
  30794. * Function called to display the loading screen
  30795. */
  30796. displayLoadingUI: () => void;
  30797. /**
  30798. * Function called to hide the loading screen
  30799. */
  30800. hideLoadingUI: () => void;
  30801. /**
  30802. * Gets or sets the color to use for the background
  30803. */
  30804. loadingUIBackgroundColor: string;
  30805. /**
  30806. * Gets or sets the text to display while loading
  30807. */
  30808. loadingUIText: string;
  30809. }
  30810. /**
  30811. * Class used for the default loading screen
  30812. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30813. */
  30814. export class DefaultLoadingScreen implements ILoadingScreen {
  30815. private _renderingCanvas;
  30816. private _loadingText;
  30817. private _loadingDivBackgroundColor;
  30818. private _loadingDiv;
  30819. private _loadingTextDiv;
  30820. /** Gets or sets the logo url to use for the default loading screen */
  30821. static DefaultLogoUrl: string;
  30822. /** Gets or sets the spinner url to use for the default loading screen */
  30823. static DefaultSpinnerUrl: string;
  30824. /**
  30825. * Creates a new default loading screen
  30826. * @param _renderingCanvas defines the canvas used to render the scene
  30827. * @param _loadingText defines the default text to display
  30828. * @param _loadingDivBackgroundColor defines the default background color
  30829. */
  30830. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30831. /**
  30832. * Function called to display the loading screen
  30833. */
  30834. displayLoadingUI(): void;
  30835. /**
  30836. * Function called to hide the loading screen
  30837. */
  30838. hideLoadingUI(): void;
  30839. /**
  30840. * Gets or sets the text to display while loading
  30841. */
  30842. loadingUIText: string;
  30843. /**
  30844. * Gets or sets the color to use for the background
  30845. */
  30846. loadingUIBackgroundColor: string;
  30847. private _resizeLoadingUI;
  30848. }
  30849. }
  30850. declare module BABYLON {
  30851. /**
  30852. * Interface for any object that can request an animation frame
  30853. */
  30854. export interface ICustomAnimationFrameRequester {
  30855. /**
  30856. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30857. */
  30858. renderFunction?: Function;
  30859. /**
  30860. * Called to request the next frame to render to
  30861. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30862. */
  30863. requestAnimationFrame: Function;
  30864. /**
  30865. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30866. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30867. */
  30868. requestID?: number;
  30869. }
  30870. }
  30871. declare module BABYLON {
  30872. /**
  30873. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30874. */
  30875. export class PerformanceMonitor {
  30876. private _enabled;
  30877. private _rollingFrameTime;
  30878. private _lastFrameTimeMs;
  30879. /**
  30880. * constructor
  30881. * @param frameSampleSize The number of samples required to saturate the sliding window
  30882. */
  30883. constructor(frameSampleSize?: number);
  30884. /**
  30885. * Samples current frame
  30886. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30887. */
  30888. sampleFrame(timeMs?: number): void;
  30889. /**
  30890. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30891. */
  30892. readonly averageFrameTime: number;
  30893. /**
  30894. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30895. */
  30896. readonly averageFrameTimeVariance: number;
  30897. /**
  30898. * Returns the frame time of the most recent frame
  30899. */
  30900. readonly instantaneousFrameTime: number;
  30901. /**
  30902. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30903. */
  30904. readonly averageFPS: number;
  30905. /**
  30906. * Returns the average framerate in frames per second using the most recent frame time
  30907. */
  30908. readonly instantaneousFPS: number;
  30909. /**
  30910. * Returns true if enough samples have been taken to completely fill the sliding window
  30911. */
  30912. readonly isSaturated: boolean;
  30913. /**
  30914. * Enables contributions to the sliding window sample set
  30915. */
  30916. enable(): void;
  30917. /**
  30918. * Disables contributions to the sliding window sample set
  30919. * Samples will not be interpolated over the disabled period
  30920. */
  30921. disable(): void;
  30922. /**
  30923. * Returns true if sampling is enabled
  30924. */
  30925. readonly isEnabled: boolean;
  30926. /**
  30927. * Resets performance monitor
  30928. */
  30929. reset(): void;
  30930. }
  30931. /**
  30932. * RollingAverage
  30933. *
  30934. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30935. */
  30936. export class RollingAverage {
  30937. /**
  30938. * Current average
  30939. */
  30940. average: number;
  30941. /**
  30942. * Current variance
  30943. */
  30944. variance: number;
  30945. protected _samples: Array<number>;
  30946. protected _sampleCount: number;
  30947. protected _pos: number;
  30948. protected _m2: number;
  30949. /**
  30950. * constructor
  30951. * @param length The number of samples required to saturate the sliding window
  30952. */
  30953. constructor(length: number);
  30954. /**
  30955. * Adds a sample to the sample set
  30956. * @param v The sample value
  30957. */
  30958. add(v: number): void;
  30959. /**
  30960. * Returns previously added values or null if outside of history or outside the sliding window domain
  30961. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30962. * @return Value previously recorded with add() or null if outside of range
  30963. */
  30964. history(i: number): number;
  30965. /**
  30966. * Returns true if enough samples have been taken to completely fill the sliding window
  30967. * @return true if sample-set saturated
  30968. */
  30969. isSaturated(): boolean;
  30970. /**
  30971. * Resets the rolling average (equivalent to 0 samples taken so far)
  30972. */
  30973. reset(): void;
  30974. /**
  30975. * Wraps a value around the sample range boundaries
  30976. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30977. * @return Wrapped position in sample range
  30978. */
  30979. protected _wrapPosition(i: number): number;
  30980. }
  30981. }
  30982. declare module BABYLON {
  30983. /**
  30984. * Defines the interface used by display changed events
  30985. */
  30986. export interface IDisplayChangedEventArgs {
  30987. /** Gets the vrDisplay object (if any) */
  30988. vrDisplay: Nullable<any>;
  30989. /** Gets a boolean indicating if webVR is supported */
  30990. vrSupported: boolean;
  30991. }
  30992. /**
  30993. * Defines the interface used by objects containing a viewport (like a camera)
  30994. */
  30995. interface IViewportOwnerLike {
  30996. /**
  30997. * Gets or sets the viewport
  30998. */
  30999. viewport: IViewportLike;
  31000. }
  31001. /**
  31002. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31003. */
  31004. export class Engine extends ThinEngine {
  31005. /** Defines that alpha blending is disabled */
  31006. static readonly ALPHA_DISABLE: number;
  31007. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31008. static readonly ALPHA_ADD: number;
  31009. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31010. static readonly ALPHA_COMBINE: number;
  31011. /** Defines that alpha blending to DEST - SRC * DEST */
  31012. static readonly ALPHA_SUBTRACT: number;
  31013. /** Defines that alpha blending to SRC * DEST */
  31014. static readonly ALPHA_MULTIPLY: number;
  31015. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31016. static readonly ALPHA_MAXIMIZED: number;
  31017. /** Defines that alpha blending to SRC + DEST */
  31018. static readonly ALPHA_ONEONE: number;
  31019. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31020. static readonly ALPHA_PREMULTIPLIED: number;
  31021. /**
  31022. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31023. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31024. */
  31025. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31026. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31027. static readonly ALPHA_INTERPOLATE: number;
  31028. /**
  31029. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31030. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31031. */
  31032. static readonly ALPHA_SCREENMODE: number;
  31033. /** Defines that the ressource is not delayed*/
  31034. static readonly DELAYLOADSTATE_NONE: number;
  31035. /** Defines that the ressource was successfully delay loaded */
  31036. static readonly DELAYLOADSTATE_LOADED: number;
  31037. /** Defines that the ressource is currently delay loading */
  31038. static readonly DELAYLOADSTATE_LOADING: number;
  31039. /** Defines that the ressource is delayed and has not started loading */
  31040. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31041. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31042. static readonly NEVER: number;
  31043. /** 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 */
  31044. static readonly ALWAYS: number;
  31045. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31046. static readonly LESS: number;
  31047. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31048. static readonly EQUAL: number;
  31049. /** 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 */
  31050. static readonly LEQUAL: number;
  31051. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31052. static readonly GREATER: number;
  31053. /** 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 */
  31054. static readonly GEQUAL: number;
  31055. /** 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 */
  31056. static readonly NOTEQUAL: number;
  31057. /** Passed to stencilOperation to specify that stencil value must be kept */
  31058. static readonly KEEP: number;
  31059. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31060. static readonly REPLACE: number;
  31061. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31062. static readonly INCR: number;
  31063. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31064. static readonly DECR: number;
  31065. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31066. static readonly INVERT: number;
  31067. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31068. static readonly INCR_WRAP: number;
  31069. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31070. static readonly DECR_WRAP: number;
  31071. /** Texture is not repeating outside of 0..1 UVs */
  31072. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31073. /** Texture is repeating outside of 0..1 UVs */
  31074. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31075. /** Texture is repeating and mirrored */
  31076. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31077. /** ALPHA */
  31078. static readonly TEXTUREFORMAT_ALPHA: number;
  31079. /** LUMINANCE */
  31080. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31081. /** LUMINANCE_ALPHA */
  31082. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31083. /** RGB */
  31084. static readonly TEXTUREFORMAT_RGB: number;
  31085. /** RGBA */
  31086. static readonly TEXTUREFORMAT_RGBA: number;
  31087. /** RED */
  31088. static readonly TEXTUREFORMAT_RED: number;
  31089. /** RED (2nd reference) */
  31090. static readonly TEXTUREFORMAT_R: number;
  31091. /** RG */
  31092. static readonly TEXTUREFORMAT_RG: number;
  31093. /** RED_INTEGER */
  31094. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31095. /** RED_INTEGER (2nd reference) */
  31096. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31097. /** RG_INTEGER */
  31098. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31099. /** RGB_INTEGER */
  31100. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31101. /** RGBA_INTEGER */
  31102. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31103. /** UNSIGNED_BYTE */
  31104. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31105. /** UNSIGNED_BYTE (2nd reference) */
  31106. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31107. /** FLOAT */
  31108. static readonly TEXTURETYPE_FLOAT: number;
  31109. /** HALF_FLOAT */
  31110. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31111. /** BYTE */
  31112. static readonly TEXTURETYPE_BYTE: number;
  31113. /** SHORT */
  31114. static readonly TEXTURETYPE_SHORT: number;
  31115. /** UNSIGNED_SHORT */
  31116. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31117. /** INT */
  31118. static readonly TEXTURETYPE_INT: number;
  31119. /** UNSIGNED_INT */
  31120. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31121. /** UNSIGNED_SHORT_4_4_4_4 */
  31122. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31123. /** UNSIGNED_SHORT_5_5_5_1 */
  31124. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31125. /** UNSIGNED_SHORT_5_6_5 */
  31126. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31127. /** UNSIGNED_INT_2_10_10_10_REV */
  31128. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31129. /** UNSIGNED_INT_24_8 */
  31130. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31131. /** UNSIGNED_INT_10F_11F_11F_REV */
  31132. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31133. /** UNSIGNED_INT_5_9_9_9_REV */
  31134. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31135. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31136. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31137. /** nearest is mag = nearest and min = nearest and mip = linear */
  31138. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31139. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31140. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31141. /** Trilinear is mag = linear and min = linear and mip = linear */
  31142. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31143. /** nearest is mag = nearest and min = nearest and mip = linear */
  31144. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31145. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31146. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31147. /** Trilinear is mag = linear and min = linear and mip = linear */
  31148. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31149. /** mag = nearest and min = nearest and mip = nearest */
  31150. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31151. /** mag = nearest and min = linear and mip = nearest */
  31152. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31153. /** mag = nearest and min = linear and mip = linear */
  31154. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31155. /** mag = nearest and min = linear and mip = none */
  31156. static readonly TEXTURE_NEAREST_LINEAR: number;
  31157. /** mag = nearest and min = nearest and mip = none */
  31158. static readonly TEXTURE_NEAREST_NEAREST: number;
  31159. /** mag = linear and min = nearest and mip = nearest */
  31160. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31161. /** mag = linear and min = nearest and mip = linear */
  31162. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31163. /** mag = linear and min = linear and mip = none */
  31164. static readonly TEXTURE_LINEAR_LINEAR: number;
  31165. /** mag = linear and min = nearest and mip = none */
  31166. static readonly TEXTURE_LINEAR_NEAREST: number;
  31167. /** Explicit coordinates mode */
  31168. static readonly TEXTURE_EXPLICIT_MODE: number;
  31169. /** Spherical coordinates mode */
  31170. static readonly TEXTURE_SPHERICAL_MODE: number;
  31171. /** Planar coordinates mode */
  31172. static readonly TEXTURE_PLANAR_MODE: number;
  31173. /** Cubic coordinates mode */
  31174. static readonly TEXTURE_CUBIC_MODE: number;
  31175. /** Projection coordinates mode */
  31176. static readonly TEXTURE_PROJECTION_MODE: number;
  31177. /** Skybox coordinates mode */
  31178. static readonly TEXTURE_SKYBOX_MODE: number;
  31179. /** Inverse Cubic coordinates mode */
  31180. static readonly TEXTURE_INVCUBIC_MODE: number;
  31181. /** Equirectangular coordinates mode */
  31182. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31183. /** Equirectangular Fixed coordinates mode */
  31184. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31185. /** Equirectangular Fixed Mirrored coordinates mode */
  31186. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31187. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31188. static readonly SCALEMODE_FLOOR: number;
  31189. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31190. static readonly SCALEMODE_NEAREST: number;
  31191. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31192. static readonly SCALEMODE_CEILING: number;
  31193. /**
  31194. * Returns the current npm package of the sdk
  31195. */
  31196. static readonly NpmPackage: string;
  31197. /**
  31198. * Returns the current version of the framework
  31199. */
  31200. static readonly Version: string;
  31201. /** Gets the list of created engines */
  31202. static readonly Instances: Engine[];
  31203. /**
  31204. * Gets the latest created engine
  31205. */
  31206. static readonly LastCreatedEngine: Nullable<Engine>;
  31207. /**
  31208. * Gets the latest created scene
  31209. */
  31210. static readonly LastCreatedScene: Nullable<Scene>;
  31211. /**
  31212. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31213. * @param flag defines which part of the materials must be marked as dirty
  31214. * @param predicate defines a predicate used to filter which materials should be affected
  31215. */
  31216. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31217. /**
  31218. * Method called to create the default loading screen.
  31219. * This can be overriden in your own app.
  31220. * @param canvas The rendering canvas element
  31221. * @returns The loading screen
  31222. */
  31223. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31224. /**
  31225. * Method called to create the default rescale post process on each engine.
  31226. */
  31227. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31228. /**
  31229. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31230. **/
  31231. enableOfflineSupport: boolean;
  31232. /**
  31233. * 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)
  31234. **/
  31235. disableManifestCheck: boolean;
  31236. /**
  31237. * Gets the list of created scenes
  31238. */
  31239. scenes: Scene[];
  31240. /**
  31241. * Event raised when a new scene is created
  31242. */
  31243. onNewSceneAddedObservable: Observable<Scene>;
  31244. /**
  31245. * Gets the list of created postprocesses
  31246. */
  31247. postProcesses: PostProcess[];
  31248. /**
  31249. * Gets a boolean indicating if the pointer is currently locked
  31250. */
  31251. isPointerLock: boolean;
  31252. /**
  31253. * Observable event triggered each time the rendering canvas is resized
  31254. */
  31255. onResizeObservable: Observable<Engine>;
  31256. /**
  31257. * Observable event triggered each time the canvas loses focus
  31258. */
  31259. onCanvasBlurObservable: Observable<Engine>;
  31260. /**
  31261. * Observable event triggered each time the canvas gains focus
  31262. */
  31263. onCanvasFocusObservable: Observable<Engine>;
  31264. /**
  31265. * Observable event triggered each time the canvas receives pointerout event
  31266. */
  31267. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31268. /**
  31269. * Observable event triggered before each texture is initialized
  31270. */
  31271. onBeforeTextureInitObservable: Observable<Texture>;
  31272. /**
  31273. * Observable raised when the engine begins a new frame
  31274. */
  31275. onBeginFrameObservable: Observable<Engine>;
  31276. /**
  31277. * If set, will be used to request the next animation frame for the render loop
  31278. */
  31279. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31280. /**
  31281. * Observable raised when the engine ends the current frame
  31282. */
  31283. onEndFrameObservable: Observable<Engine>;
  31284. /**
  31285. * Observable raised when the engine is about to compile a shader
  31286. */
  31287. onBeforeShaderCompilationObservable: Observable<Engine>;
  31288. /**
  31289. * Observable raised when the engine has jsut compiled a shader
  31290. */
  31291. onAfterShaderCompilationObservable: Observable<Engine>;
  31292. /**
  31293. * Gets the audio engine
  31294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31295. * @ignorenaming
  31296. */
  31297. static audioEngine: IAudioEngine;
  31298. /**
  31299. * Default AudioEngine factory responsible of creating the Audio Engine.
  31300. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31301. */
  31302. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31303. /**
  31304. * Default offline support factory responsible of creating a tool used to store data locally.
  31305. * By default, this will create a Database object if the workload has been embedded.
  31306. */
  31307. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31308. private _loadingScreen;
  31309. private _pointerLockRequested;
  31310. private _dummyFramebuffer;
  31311. private _rescalePostProcess;
  31312. /** @hidden */
  31313. protected _alphaMode: number;
  31314. /** @hidden */
  31315. protected _alphaEquation: number;
  31316. private _deterministicLockstep;
  31317. private _lockstepMaxSteps;
  31318. protected readonly _supportsHardwareTextureRescaling: boolean;
  31319. private _fps;
  31320. private _deltaTime;
  31321. /**
  31322. * Turn this value on if you want to pause FPS computation when in background
  31323. */
  31324. disablePerformanceMonitorInBackground: boolean;
  31325. private _performanceMonitor;
  31326. /**
  31327. * Gets the performance monitor attached to this engine
  31328. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31329. */
  31330. readonly performanceMonitor: PerformanceMonitor;
  31331. private _onFocus;
  31332. private _onBlur;
  31333. private _onCanvasPointerOut;
  31334. private _onCanvasBlur;
  31335. private _onCanvasFocus;
  31336. private _onFullscreenChange;
  31337. private _onPointerLockChange;
  31338. /**
  31339. * Creates a new engine
  31340. * @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
  31341. * @param antialias defines enable antialiasing (default: false)
  31342. * @param options defines further options to be sent to the getContext() function
  31343. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31344. */
  31345. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31346. /**
  31347. * Gets current aspect ratio
  31348. * @param viewportOwner defines the camera to use to get the aspect ratio
  31349. * @param useScreen defines if screen size must be used (or the current render target if any)
  31350. * @returns a number defining the aspect ratio
  31351. */
  31352. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31353. /**
  31354. * Gets current screen aspect ratio
  31355. * @returns a number defining the aspect ratio
  31356. */
  31357. getScreenAspectRatio(): number;
  31358. /**
  31359. * Gets host document
  31360. * @returns the host document object
  31361. */
  31362. getHostDocument(): Document;
  31363. /**
  31364. * Gets the client rect of the HTML canvas attached with the current webGL context
  31365. * @returns a client rectanglee
  31366. */
  31367. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31368. /**
  31369. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31370. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31371. * @returns true if engine is in deterministic lock step mode
  31372. */
  31373. isDeterministicLockStep(): boolean;
  31374. /**
  31375. * Gets the max steps when engine is running in deterministic lock step
  31376. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31377. * @returns the max steps
  31378. */
  31379. getLockstepMaxSteps(): number;
  31380. /**
  31381. * Force the mipmap generation for the given render target texture
  31382. * @param texture defines the render target texture to use
  31383. */
  31384. generateMipMapsForCubemap(texture: InternalTexture): void;
  31385. /** States */
  31386. /**
  31387. * Set various states to the webGL context
  31388. * @param culling defines backface culling state
  31389. * @param zOffset defines the value to apply to zOffset (0 by default)
  31390. * @param force defines if states must be applied even if cache is up to date
  31391. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31392. */
  31393. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31394. /**
  31395. * Set the z offset to apply to current rendering
  31396. * @param value defines the offset to apply
  31397. */
  31398. setZOffset(value: number): void;
  31399. /**
  31400. * Gets the current value of the zOffset
  31401. * @returns the current zOffset state
  31402. */
  31403. getZOffset(): number;
  31404. /**
  31405. * Enable or disable depth buffering
  31406. * @param enable defines the state to set
  31407. */
  31408. setDepthBuffer(enable: boolean): void;
  31409. /**
  31410. * Gets a boolean indicating if depth writing is enabled
  31411. * @returns the current depth writing state
  31412. */
  31413. getDepthWrite(): boolean;
  31414. /**
  31415. * Enable or disable depth writing
  31416. * @param enable defines the state to set
  31417. */
  31418. setDepthWrite(enable: boolean): void;
  31419. /**
  31420. * Enable or disable color writing
  31421. * @param enable defines the state to set
  31422. */
  31423. setColorWrite(enable: boolean): void;
  31424. /**
  31425. * Gets a boolean indicating if color writing is enabled
  31426. * @returns the current color writing state
  31427. */
  31428. getColorWrite(): boolean;
  31429. /**
  31430. * Sets alpha constants used by some alpha blending modes
  31431. * @param r defines the red component
  31432. * @param g defines the green component
  31433. * @param b defines the blue component
  31434. * @param a defines the alpha component
  31435. */
  31436. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31437. /**
  31438. * Sets the current alpha mode
  31439. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31440. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31441. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31442. */
  31443. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31444. /**
  31445. * Gets the current alpha mode
  31446. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31447. * @returns the current alpha mode
  31448. */
  31449. getAlphaMode(): number;
  31450. /**
  31451. * Sets the current alpha equation
  31452. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31453. */
  31454. setAlphaEquation(equation: number): void;
  31455. /**
  31456. * Gets the current alpha equation.
  31457. * @returns the current alpha equation
  31458. */
  31459. getAlphaEquation(): number;
  31460. /**
  31461. * Gets a boolean indicating if stencil buffer is enabled
  31462. * @returns the current stencil buffer state
  31463. */
  31464. getStencilBuffer(): boolean;
  31465. /**
  31466. * Enable or disable the stencil buffer
  31467. * @param enable defines if the stencil buffer must be enabled or disabled
  31468. */
  31469. setStencilBuffer(enable: boolean): void;
  31470. /**
  31471. * Gets the current stencil mask
  31472. * @returns a number defining the new stencil mask to use
  31473. */
  31474. getStencilMask(): number;
  31475. /**
  31476. * Sets the current stencil mask
  31477. * @param mask defines the new stencil mask to use
  31478. */
  31479. setStencilMask(mask: number): void;
  31480. /**
  31481. * Gets the current stencil function
  31482. * @returns a number defining the stencil function to use
  31483. */
  31484. getStencilFunction(): number;
  31485. /**
  31486. * Gets the current stencil reference value
  31487. * @returns a number defining the stencil reference value to use
  31488. */
  31489. getStencilFunctionReference(): number;
  31490. /**
  31491. * Gets the current stencil mask
  31492. * @returns a number defining the stencil mask to use
  31493. */
  31494. getStencilFunctionMask(): number;
  31495. /**
  31496. * Sets the current stencil function
  31497. * @param stencilFunc defines the new stencil function to use
  31498. */
  31499. setStencilFunction(stencilFunc: number): void;
  31500. /**
  31501. * Sets the current stencil reference
  31502. * @param reference defines the new stencil reference to use
  31503. */
  31504. setStencilFunctionReference(reference: number): void;
  31505. /**
  31506. * Sets the current stencil mask
  31507. * @param mask defines the new stencil mask to use
  31508. */
  31509. setStencilFunctionMask(mask: number): void;
  31510. /**
  31511. * Gets the current stencil operation when stencil fails
  31512. * @returns a number defining stencil operation to use when stencil fails
  31513. */
  31514. getStencilOperationFail(): number;
  31515. /**
  31516. * Gets the current stencil operation when depth fails
  31517. * @returns a number defining stencil operation to use when depth fails
  31518. */
  31519. getStencilOperationDepthFail(): number;
  31520. /**
  31521. * Gets the current stencil operation when stencil passes
  31522. * @returns a number defining stencil operation to use when stencil passes
  31523. */
  31524. getStencilOperationPass(): number;
  31525. /**
  31526. * Sets the stencil operation to use when stencil fails
  31527. * @param operation defines the stencil operation to use when stencil fails
  31528. */
  31529. setStencilOperationFail(operation: number): void;
  31530. /**
  31531. * Sets the stencil operation to use when depth fails
  31532. * @param operation defines the stencil operation to use when depth fails
  31533. */
  31534. setStencilOperationDepthFail(operation: number): void;
  31535. /**
  31536. * Sets the stencil operation to use when stencil passes
  31537. * @param operation defines the stencil operation to use when stencil passes
  31538. */
  31539. setStencilOperationPass(operation: number): void;
  31540. /**
  31541. * Sets a boolean indicating if the dithering state is enabled or disabled
  31542. * @param value defines the dithering state
  31543. */
  31544. setDitheringState(value: boolean): void;
  31545. /**
  31546. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31547. * @param value defines the rasterizer state
  31548. */
  31549. setRasterizerState(value: boolean): void;
  31550. /**
  31551. * Gets the current depth function
  31552. * @returns a number defining the depth function
  31553. */
  31554. getDepthFunction(): Nullable<number>;
  31555. /**
  31556. * Sets the current depth function
  31557. * @param depthFunc defines the function to use
  31558. */
  31559. setDepthFunction(depthFunc: number): void;
  31560. /**
  31561. * Sets the current depth function to GREATER
  31562. */
  31563. setDepthFunctionToGreater(): void;
  31564. /**
  31565. * Sets the current depth function to GEQUAL
  31566. */
  31567. setDepthFunctionToGreaterOrEqual(): void;
  31568. /**
  31569. * Sets the current depth function to LESS
  31570. */
  31571. setDepthFunctionToLess(): void;
  31572. /**
  31573. * Sets the current depth function to LEQUAL
  31574. */
  31575. setDepthFunctionToLessOrEqual(): void;
  31576. private _cachedStencilBuffer;
  31577. private _cachedStencilFunction;
  31578. private _cachedStencilMask;
  31579. private _cachedStencilOperationPass;
  31580. private _cachedStencilOperationFail;
  31581. private _cachedStencilOperationDepthFail;
  31582. private _cachedStencilReference;
  31583. /**
  31584. * Caches the the state of the stencil buffer
  31585. */
  31586. cacheStencilState(): void;
  31587. /**
  31588. * Restores the state of the stencil buffer
  31589. */
  31590. restoreStencilState(): void;
  31591. /**
  31592. * Directly set the WebGL Viewport
  31593. * @param x defines the x coordinate of the viewport (in screen space)
  31594. * @param y defines the y coordinate of the viewport (in screen space)
  31595. * @param width defines the width of the viewport (in screen space)
  31596. * @param height defines the height of the viewport (in screen space)
  31597. * @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
  31598. */
  31599. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31600. /**
  31601. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31602. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31603. * @param y defines the y-coordinate of the corner of the clear rectangle
  31604. * @param width defines the width of the clear rectangle
  31605. * @param height defines the height of the clear rectangle
  31606. * @param clearColor defines the clear color
  31607. */
  31608. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31609. /**
  31610. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31611. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31612. * @param y defines the y-coordinate of the corner of the clear rectangle
  31613. * @param width defines the width of the clear rectangle
  31614. * @param height defines the height of the clear rectangle
  31615. */
  31616. enableScissor(x: number, y: number, width: number, height: number): void;
  31617. /**
  31618. * Disable previously set scissor test rectangle
  31619. */
  31620. disableScissor(): void;
  31621. /**
  31622. * Initializes a webVR display and starts listening to display change events
  31623. * The onVRDisplayChangedObservable will be notified upon these changes
  31624. * @returns The onVRDisplayChangedObservable
  31625. */
  31626. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31627. /** @hidden */
  31628. _prepareVRComponent(): void;
  31629. /** @hidden */
  31630. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31631. /** @hidden */
  31632. _submitVRFrame(): void;
  31633. /**
  31634. * Call this function to leave webVR mode
  31635. * Will do nothing if webVR is not supported or if there is no webVR device
  31636. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31637. */
  31638. disableVR(): void;
  31639. /**
  31640. * Gets a boolean indicating that the system is in VR mode and is presenting
  31641. * @returns true if VR mode is engaged
  31642. */
  31643. isVRPresenting(): boolean;
  31644. /** @hidden */
  31645. _requestVRFrame(): void;
  31646. /** @hidden */
  31647. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31648. /**
  31649. * Gets the source code of the vertex shader associated with a specific webGL program
  31650. * @param program defines the program to use
  31651. * @returns a string containing the source code of the vertex shader associated with the program
  31652. */
  31653. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31654. /**
  31655. * Gets the source code of the fragment shader associated with a specific webGL program
  31656. * @param program defines the program to use
  31657. * @returns a string containing the source code of the fragment shader associated with the program
  31658. */
  31659. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31660. /**
  31661. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31662. * @param x defines the x coordinate of the rectangle where pixels must be read
  31663. * @param y defines the y coordinate of the rectangle where pixels must be read
  31664. * @param width defines the width of the rectangle where pixels must be read
  31665. * @param height defines the height of the rectangle where pixels must be read
  31666. * @returns a Uint8Array containing RGBA colors
  31667. */
  31668. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31669. /**
  31670. * Sets a depth stencil texture from a render target to the according uniform.
  31671. * @param channel The texture channel
  31672. * @param uniform The uniform to set
  31673. * @param texture The render target texture containing the depth stencil texture to apply
  31674. */
  31675. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31676. /**
  31677. * Sets a texture to the webGL context from a postprocess
  31678. * @param channel defines the channel to use
  31679. * @param postProcess defines the source postprocess
  31680. */
  31681. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31682. /**
  31683. * Binds the output of the passed in post process to the texture channel specified
  31684. * @param channel The channel the texture should be bound to
  31685. * @param postProcess The post process which's output should be bound
  31686. */
  31687. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31688. /** @hidden */
  31689. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31690. protected _rebuildBuffers(): void;
  31691. _renderLoop(): void;
  31692. /**
  31693. * Toggle full screen mode
  31694. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31695. */
  31696. switchFullscreen(requestPointerLock: boolean): void;
  31697. /**
  31698. * Enters full screen mode
  31699. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31700. */
  31701. enterFullscreen(requestPointerLock: boolean): void;
  31702. /**
  31703. * Exits full screen mode
  31704. */
  31705. exitFullscreen(): void;
  31706. /**
  31707. * Enters Pointerlock mode
  31708. */
  31709. enterPointerlock(): void;
  31710. /**
  31711. * Exits Pointerlock mode
  31712. */
  31713. exitPointerlock(): void;
  31714. /**
  31715. * Begin a new frame
  31716. */
  31717. beginFrame(): void;
  31718. /**
  31719. * Enf the current frame
  31720. */
  31721. endFrame(): void;
  31722. resize(): void;
  31723. /**
  31724. * Set the compressed texture format to use, based on the formats you have, and the formats
  31725. * supported by the hardware / browser.
  31726. *
  31727. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31728. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31729. * to API arguments needed to compressed textures. This puts the burden on the container
  31730. * generator to house the arcane code for determining these for current & future formats.
  31731. *
  31732. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31733. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31734. *
  31735. * Note: The result of this call is not taken into account when a texture is base64.
  31736. *
  31737. * @param formatsAvailable defines the list of those format families you have created
  31738. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31739. *
  31740. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31741. * @returns The extension selected.
  31742. */
  31743. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31744. /**
  31745. * Force a specific size of the canvas
  31746. * @param width defines the new canvas' width
  31747. * @param height defines the new canvas' height
  31748. */
  31749. setSize(width: number, height: number): void;
  31750. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31751. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31752. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31753. _releaseTexture(texture: InternalTexture): void;
  31754. /**
  31755. * @hidden
  31756. * Rescales a texture
  31757. * @param source input texutre
  31758. * @param destination destination texture
  31759. * @param scene scene to use to render the resize
  31760. * @param internalFormat format to use when resizing
  31761. * @param onComplete callback to be called when resize has completed
  31762. */
  31763. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31764. /**
  31765. * Gets the current framerate
  31766. * @returns a number representing the framerate
  31767. */
  31768. getFps(): number;
  31769. /**
  31770. * Gets the time spent between current and previous frame
  31771. * @returns a number representing the delta time in ms
  31772. */
  31773. getDeltaTime(): number;
  31774. private _measureFps;
  31775. /**
  31776. * Creates a new render target texture
  31777. * @param size defines the size of the texture
  31778. * @param options defines the options used to create the texture
  31779. * @returns a new render target texture stored in an InternalTexture
  31780. */
  31781. createRenderTargetTexture(size: number | {
  31782. width: number;
  31783. height: number;
  31784. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31785. /**
  31786. * Updates the sample count of a render target texture
  31787. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31788. * @param texture defines the texture to update
  31789. * @param samples defines the sample count to set
  31790. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31791. */
  31792. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31793. /** @hidden */
  31794. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31795. dispose(): void;
  31796. private _disableTouchAction;
  31797. /**
  31798. * Display the loading screen
  31799. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31800. */
  31801. displayLoadingUI(): void;
  31802. /**
  31803. * Hide the loading screen
  31804. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31805. */
  31806. hideLoadingUI(): void;
  31807. /**
  31808. * Gets the current loading screen object
  31809. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31810. */
  31811. /**
  31812. * Sets the current loading screen object
  31813. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31814. */
  31815. loadingScreen: ILoadingScreen;
  31816. /**
  31817. * Sets the current loading screen text
  31818. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31819. */
  31820. loadingUIText: string;
  31821. /**
  31822. * Sets the current loading screen background color
  31823. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31824. */
  31825. loadingUIBackgroundColor: string;
  31826. /** Pointerlock and fullscreen */
  31827. /**
  31828. * Ask the browser to promote the current element to pointerlock mode
  31829. * @param element defines the DOM element to promote
  31830. */
  31831. static _RequestPointerlock(element: HTMLElement): void;
  31832. /**
  31833. * Asks the browser to exit pointerlock mode
  31834. */
  31835. static _ExitPointerlock(): void;
  31836. /**
  31837. * Ask the browser to promote the current element to fullscreen rendering mode
  31838. * @param element defines the DOM element to promote
  31839. */
  31840. static _RequestFullscreen(element: HTMLElement): void;
  31841. /**
  31842. * Asks the browser to exit fullscreen mode
  31843. */
  31844. static _ExitFullscreen(): void;
  31845. }
  31846. }
  31847. declare module BABYLON {
  31848. /**
  31849. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31850. * during the life time of the application.
  31851. */
  31852. export class EngineStore {
  31853. /** Gets the list of created engines */
  31854. static Instances: Engine[];
  31855. /** @hidden */
  31856. static _LastCreatedScene: Nullable<Scene>;
  31857. /**
  31858. * Gets the latest created engine
  31859. */
  31860. static readonly LastCreatedEngine: Nullable<Engine>;
  31861. /**
  31862. * Gets the latest created scene
  31863. */
  31864. static readonly LastCreatedScene: Nullable<Scene>;
  31865. /**
  31866. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31867. * @ignorenaming
  31868. */
  31869. static UseFallbackTexture: boolean;
  31870. /**
  31871. * Texture content used if a texture cannot loaded
  31872. * @ignorenaming
  31873. */
  31874. static FallbackTexture: string;
  31875. }
  31876. }
  31877. declare module BABYLON {
  31878. /**
  31879. * Helper class that provides a small promise polyfill
  31880. */
  31881. export class PromisePolyfill {
  31882. /**
  31883. * Static function used to check if the polyfill is required
  31884. * If this is the case then the function will inject the polyfill to window.Promise
  31885. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31886. */
  31887. static Apply(force?: boolean): void;
  31888. }
  31889. }
  31890. declare module BABYLON {
  31891. /**
  31892. * Interface for screenshot methods with describe argument called `size` as object with options
  31893. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31894. */
  31895. export interface IScreenshotSize {
  31896. /**
  31897. * number in pixels for canvas height
  31898. */
  31899. height?: number;
  31900. /**
  31901. * multiplier allowing render at a higher or lower resolution
  31902. * If value is defined then height and width will be ignored and taken from camera
  31903. */
  31904. precision?: number;
  31905. /**
  31906. * number in pixels for canvas width
  31907. */
  31908. width?: number;
  31909. }
  31910. }
  31911. declare module BABYLON {
  31912. interface IColor4Like {
  31913. r: float;
  31914. g: float;
  31915. b: float;
  31916. a: float;
  31917. }
  31918. /**
  31919. * Class containing a set of static utilities functions
  31920. */
  31921. export class Tools {
  31922. /**
  31923. * Gets or sets the base URL to use to load assets
  31924. */
  31925. static BaseUrl: string;
  31926. /**
  31927. * Enable/Disable Custom HTTP Request Headers globally.
  31928. * default = false
  31929. * @see CustomRequestHeaders
  31930. */
  31931. static UseCustomRequestHeaders: boolean;
  31932. /**
  31933. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31934. * i.e. when loading files, where the server/service expects an Authorization header
  31935. */
  31936. static CustomRequestHeaders: {
  31937. [key: string]: string;
  31938. };
  31939. /**
  31940. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31941. */
  31942. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31943. /**
  31944. * Default behaviour for cors in the application.
  31945. * It can be a string if the expected behavior is identical in the entire app.
  31946. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31947. */
  31948. static CorsBehavior: string | ((url: string | string[]) => string);
  31949. /**
  31950. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31951. * @ignorenaming
  31952. */
  31953. static UseFallbackTexture: boolean;
  31954. /**
  31955. * Use this object to register external classes like custom textures or material
  31956. * to allow the laoders to instantiate them
  31957. */
  31958. static RegisteredExternalClasses: {
  31959. [key: string]: Object;
  31960. };
  31961. /**
  31962. * Texture content used if a texture cannot loaded
  31963. * @ignorenaming
  31964. */
  31965. static fallbackTexture: string;
  31966. /**
  31967. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31968. * @param u defines the coordinate on X axis
  31969. * @param v defines the coordinate on Y axis
  31970. * @param width defines the width of the source data
  31971. * @param height defines the height of the source data
  31972. * @param pixels defines the source byte array
  31973. * @param color defines the output color
  31974. */
  31975. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31976. /**
  31977. * Interpolates between a and b via alpha
  31978. * @param a The lower value (returned when alpha = 0)
  31979. * @param b The upper value (returned when alpha = 1)
  31980. * @param alpha The interpolation-factor
  31981. * @return The mixed value
  31982. */
  31983. static Mix(a: number, b: number, alpha: number): number;
  31984. /**
  31985. * Tries to instantiate a new object from a given class name
  31986. * @param className defines the class name to instantiate
  31987. * @returns the new object or null if the system was not able to do the instantiation
  31988. */
  31989. static Instantiate(className: string): any;
  31990. /**
  31991. * Provides a slice function that will work even on IE
  31992. * @param data defines the array to slice
  31993. * @param start defines the start of the data (optional)
  31994. * @param end defines the end of the data (optional)
  31995. * @returns the new sliced array
  31996. */
  31997. static Slice<T>(data: T, start?: number, end?: number): T;
  31998. /**
  31999. * Polyfill for setImmediate
  32000. * @param action defines the action to execute after the current execution block
  32001. */
  32002. static SetImmediate(action: () => void): void;
  32003. /**
  32004. * Function indicating if a number is an exponent of 2
  32005. * @param value defines the value to test
  32006. * @returns true if the value is an exponent of 2
  32007. */
  32008. static IsExponentOfTwo(value: number): boolean;
  32009. private static _tmpFloatArray;
  32010. /**
  32011. * Returns the nearest 32-bit single precision float representation of a Number
  32012. * @param value A Number. If the parameter is of a different type, it will get converted
  32013. * to a number or to NaN if it cannot be converted
  32014. * @returns number
  32015. */
  32016. static FloatRound(value: number): number;
  32017. /**
  32018. * Extracts the filename from a path
  32019. * @param path defines the path to use
  32020. * @returns the filename
  32021. */
  32022. static GetFilename(path: string): string;
  32023. /**
  32024. * Extracts the "folder" part of a path (everything before the filename).
  32025. * @param uri The URI to extract the info from
  32026. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32027. * @returns The "folder" part of the path
  32028. */
  32029. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32030. /**
  32031. * Extracts text content from a DOM element hierarchy
  32032. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32033. */
  32034. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32035. /**
  32036. * Convert an angle in radians to degrees
  32037. * @param angle defines the angle to convert
  32038. * @returns the angle in degrees
  32039. */
  32040. static ToDegrees(angle: number): number;
  32041. /**
  32042. * Convert an angle in degrees to radians
  32043. * @param angle defines the angle to convert
  32044. * @returns the angle in radians
  32045. */
  32046. static ToRadians(angle: number): number;
  32047. /**
  32048. * Encode a buffer to a base64 string
  32049. * @param buffer defines the buffer to encode
  32050. * @returns the encoded string
  32051. */
  32052. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32053. /**
  32054. * Returns an array if obj is not an array
  32055. * @param obj defines the object to evaluate as an array
  32056. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32057. * @returns either obj directly if obj is an array or a new array containing obj
  32058. */
  32059. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32060. /**
  32061. * Gets the pointer prefix to use
  32062. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32063. */
  32064. static GetPointerPrefix(): string;
  32065. /**
  32066. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32067. * @param url define the url we are trying
  32068. * @param element define the dom element where to configure the cors policy
  32069. */
  32070. static SetCorsBehavior(url: string | string[], element: {
  32071. crossOrigin: string | null;
  32072. }): void;
  32073. /**
  32074. * Removes unwanted characters from an url
  32075. * @param url defines the url to clean
  32076. * @returns the cleaned url
  32077. */
  32078. static CleanUrl(url: string): string;
  32079. /**
  32080. * Gets or sets a function used to pre-process url before using them to load assets
  32081. */
  32082. static PreprocessUrl: (url: string) => string;
  32083. /**
  32084. * Loads an image as an HTMLImageElement.
  32085. * @param input url string, ArrayBuffer, or Blob to load
  32086. * @param onLoad callback called when the image successfully loads
  32087. * @param onError callback called when the image fails to load
  32088. * @param offlineProvider offline provider for caching
  32089. * @returns the HTMLImageElement of the loaded image
  32090. */
  32091. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32092. /**
  32093. * Loads a file
  32094. * @param url url string, ArrayBuffer, or Blob to load
  32095. * @param onSuccess callback called when the file successfully loads
  32096. * @param onProgress callback called while file is loading (if the server supports this mode)
  32097. * @param offlineProvider defines the offline provider for caching
  32098. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32099. * @param onError callback called when the file fails to load
  32100. * @returns a file request object
  32101. */
  32102. 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;
  32103. /**
  32104. * Loads a file from a url
  32105. * @param url the file url to load
  32106. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32107. */
  32108. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32109. /**
  32110. * Load a script (identified by an url). When the url returns, the
  32111. * content of this file is added into a new script element, attached to the DOM (body element)
  32112. * @param scriptUrl defines the url of the script to laod
  32113. * @param onSuccess defines the callback called when the script is loaded
  32114. * @param onError defines the callback to call if an error occurs
  32115. * @param scriptId defines the id of the script element
  32116. */
  32117. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32118. /**
  32119. * Load an asynchronous script (identified by an url). When the url returns, the
  32120. * content of this file is added into a new script element, attached to the DOM (body element)
  32121. * @param scriptUrl defines the url of the script to laod
  32122. * @param scriptId defines the id of the script element
  32123. * @returns a promise request object
  32124. */
  32125. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32126. /**
  32127. * Loads a file from a blob
  32128. * @param fileToLoad defines the blob to use
  32129. * @param callback defines the callback to call when data is loaded
  32130. * @param progressCallback defines the callback to call during loading process
  32131. * @returns a file request object
  32132. */
  32133. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32134. /**
  32135. * Loads a file
  32136. * @param fileToLoad defines the file to load
  32137. * @param callback defines the callback to call when data is loaded
  32138. * @param progressCallBack defines the callback to call during loading process
  32139. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32140. * @returns a file request object
  32141. */
  32142. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32143. /**
  32144. * Creates a data url from a given string content
  32145. * @param content defines the content to convert
  32146. * @returns the new data url link
  32147. */
  32148. static FileAsURL(content: string): string;
  32149. /**
  32150. * Format the given number to a specific decimal format
  32151. * @param value defines the number to format
  32152. * @param decimals defines the number of decimals to use
  32153. * @returns the formatted string
  32154. */
  32155. static Format(value: number, decimals?: number): string;
  32156. /**
  32157. * Tries to copy an object by duplicating every property
  32158. * @param source defines the source object
  32159. * @param destination defines the target object
  32160. * @param doNotCopyList defines a list of properties to avoid
  32161. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32162. */
  32163. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32164. /**
  32165. * Gets a boolean indicating if the given object has no own property
  32166. * @param obj defines the object to test
  32167. * @returns true if object has no own property
  32168. */
  32169. static IsEmpty(obj: any): boolean;
  32170. /**
  32171. * Function used to register events at window level
  32172. * @param windowElement defines the Window object to use
  32173. * @param events defines the events to register
  32174. */
  32175. static RegisterTopRootEvents(windowElement: Window, events: {
  32176. name: string;
  32177. handler: Nullable<(e: FocusEvent) => any>;
  32178. }[]): void;
  32179. /**
  32180. * Function used to unregister events from window level
  32181. * @param windowElement defines the Window object to use
  32182. * @param events defines the events to unregister
  32183. */
  32184. static UnregisterTopRootEvents(windowElement: Window, events: {
  32185. name: string;
  32186. handler: Nullable<(e: FocusEvent) => any>;
  32187. }[]): void;
  32188. /**
  32189. * @ignore
  32190. */
  32191. static _ScreenshotCanvas: HTMLCanvasElement;
  32192. /**
  32193. * Dumps the current bound framebuffer
  32194. * @param width defines the rendering width
  32195. * @param height defines the rendering height
  32196. * @param engine defines the hosting engine
  32197. * @param successCallback defines the callback triggered once the data are available
  32198. * @param mimeType defines the mime type of the result
  32199. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32200. */
  32201. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32202. /**
  32203. * Converts the canvas data to blob.
  32204. * This acts as a polyfill for browsers not supporting the to blob function.
  32205. * @param canvas Defines the canvas to extract the data from
  32206. * @param successCallback Defines the callback triggered once the data are available
  32207. * @param mimeType Defines the mime type of the result
  32208. */
  32209. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32210. /**
  32211. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32212. * @param successCallback defines the callback triggered once the data are available
  32213. * @param mimeType defines the mime type of the result
  32214. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32215. */
  32216. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32217. /**
  32218. * Downloads a blob in the browser
  32219. * @param blob defines the blob to download
  32220. * @param fileName defines the name of the downloaded file
  32221. */
  32222. static Download(blob: Blob, fileName: string): void;
  32223. /**
  32224. * Captures a screenshot of the current rendering
  32225. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32226. * @param engine defines the rendering engine
  32227. * @param camera defines the source camera
  32228. * @param size This parameter can be set to a single number or to an object with the
  32229. * following (optional) properties: precision, width, height. If a single number is passed,
  32230. * it will be used for both width and height. If an object is passed, the screenshot size
  32231. * will be derived from the parameters. The precision property is a multiplier allowing
  32232. * rendering at a higher or lower resolution
  32233. * @param successCallback defines the callback receives a single parameter which contains the
  32234. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32235. * src parameter of an <img> to display it
  32236. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32237. * Check your browser for supported MIME types
  32238. */
  32239. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32240. /**
  32241. * Captures a screenshot of the current rendering
  32242. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32243. * @param engine defines the rendering engine
  32244. * @param camera defines the source camera
  32245. * @param size This parameter can be set to a single number or to an object with the
  32246. * following (optional) properties: precision, width, height. If a single number is passed,
  32247. * it will be used for both width and height. If an object is passed, the screenshot size
  32248. * will be derived from the parameters. The precision property is a multiplier allowing
  32249. * rendering at a higher or lower resolution
  32250. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32251. * Check your browser for supported MIME types
  32252. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32253. * to the src parameter of an <img> to display it
  32254. */
  32255. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32256. /**
  32257. * Generates an image screenshot from the specified camera.
  32258. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32259. * @param engine The engine to use for rendering
  32260. * @param camera The camera to use for rendering
  32261. * @param size This parameter can be set to a single number or to an object with the
  32262. * following (optional) properties: precision, width, height. If a single number is passed,
  32263. * it will be used for both width and height. If an object is passed, the screenshot size
  32264. * will be derived from the parameters. The precision property is a multiplier allowing
  32265. * rendering at a higher or lower resolution
  32266. * @param successCallback The callback receives a single parameter which contains the
  32267. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32268. * src parameter of an <img> to display it
  32269. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32270. * Check your browser for supported MIME types
  32271. * @param samples Texture samples (default: 1)
  32272. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32273. * @param fileName A name for for the downloaded file.
  32274. */
  32275. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32276. /**
  32277. * Generates an image screenshot from the specified camera.
  32278. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32279. * @param engine The engine to use for rendering
  32280. * @param camera The camera to use for rendering
  32281. * @param size This parameter can be set to a single number or to an object with the
  32282. * following (optional) properties: precision, width, height. If a single number is passed,
  32283. * it will be used for both width and height. If an object is passed, the screenshot size
  32284. * will be derived from the parameters. The precision property is a multiplier allowing
  32285. * rendering at a higher or lower resolution
  32286. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32287. * Check your browser for supported MIME types
  32288. * @param samples Texture samples (default: 1)
  32289. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32290. * @param fileName A name for for the downloaded file.
  32291. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32292. * to the src parameter of an <img> to display it
  32293. */
  32294. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32295. /**
  32296. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32297. * Be aware Math.random() could cause collisions, but:
  32298. * "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"
  32299. * @returns a pseudo random id
  32300. */
  32301. static RandomId(): string;
  32302. /**
  32303. * Test if the given uri is a base64 string
  32304. * @param uri The uri to test
  32305. * @return True if the uri is a base64 string or false otherwise
  32306. */
  32307. static IsBase64(uri: string): boolean;
  32308. /**
  32309. * Decode the given base64 uri.
  32310. * @param uri The uri to decode
  32311. * @return The decoded base64 data.
  32312. */
  32313. static DecodeBase64(uri: string): ArrayBuffer;
  32314. /**
  32315. * Gets the absolute url.
  32316. * @param url the input url
  32317. * @return the absolute url
  32318. */
  32319. static GetAbsoluteUrl(url: string): string;
  32320. /**
  32321. * No log
  32322. */
  32323. static readonly NoneLogLevel: number;
  32324. /**
  32325. * Only message logs
  32326. */
  32327. static readonly MessageLogLevel: number;
  32328. /**
  32329. * Only warning logs
  32330. */
  32331. static readonly WarningLogLevel: number;
  32332. /**
  32333. * Only error logs
  32334. */
  32335. static readonly ErrorLogLevel: number;
  32336. /**
  32337. * All logs
  32338. */
  32339. static readonly AllLogLevel: number;
  32340. /**
  32341. * Gets a value indicating the number of loading errors
  32342. * @ignorenaming
  32343. */
  32344. static readonly errorsCount: number;
  32345. /**
  32346. * Callback called when a new log is added
  32347. */
  32348. static OnNewCacheEntry: (entry: string) => void;
  32349. /**
  32350. * Log a message to the console
  32351. * @param message defines the message to log
  32352. */
  32353. static Log(message: string): void;
  32354. /**
  32355. * Write a warning message to the console
  32356. * @param message defines the message to log
  32357. */
  32358. static Warn(message: string): void;
  32359. /**
  32360. * Write an error message to the console
  32361. * @param message defines the message to log
  32362. */
  32363. static Error(message: string): void;
  32364. /**
  32365. * Gets current log cache (list of logs)
  32366. */
  32367. static readonly LogCache: string;
  32368. /**
  32369. * Clears the log cache
  32370. */
  32371. static ClearLogCache(): void;
  32372. /**
  32373. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32374. */
  32375. static LogLevels: number;
  32376. /**
  32377. * Checks if the window object exists
  32378. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32379. */
  32380. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32381. /**
  32382. * No performance log
  32383. */
  32384. static readonly PerformanceNoneLogLevel: number;
  32385. /**
  32386. * Use user marks to log performance
  32387. */
  32388. static readonly PerformanceUserMarkLogLevel: number;
  32389. /**
  32390. * Log performance to the console
  32391. */
  32392. static readonly PerformanceConsoleLogLevel: number;
  32393. private static _performance;
  32394. /**
  32395. * Sets the current performance log level
  32396. */
  32397. static PerformanceLogLevel: number;
  32398. private static _StartPerformanceCounterDisabled;
  32399. private static _EndPerformanceCounterDisabled;
  32400. private static _StartUserMark;
  32401. private static _EndUserMark;
  32402. private static _StartPerformanceConsole;
  32403. private static _EndPerformanceConsole;
  32404. /**
  32405. * Starts a performance counter
  32406. */
  32407. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32408. /**
  32409. * Ends a specific performance coutner
  32410. */
  32411. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32412. /**
  32413. * Gets either window.performance.now() if supported or Date.now() else
  32414. */
  32415. static readonly Now: number;
  32416. /**
  32417. * This method will return the name of the class used to create the instance of the given object.
  32418. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32419. * @param object the object to get the class name from
  32420. * @param isType defines if the object is actually a type
  32421. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32422. */
  32423. static GetClassName(object: any, isType?: boolean): string;
  32424. /**
  32425. * Gets the first element of an array satisfying a given predicate
  32426. * @param array defines the array to browse
  32427. * @param predicate defines the predicate to use
  32428. * @returns null if not found or the element
  32429. */
  32430. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32431. /**
  32432. * This method will return the name of the full name of the class, including its owning module (if any).
  32433. * 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).
  32434. * @param object the object to get the class name from
  32435. * @param isType defines if the object is actually a type
  32436. * @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.
  32437. * @ignorenaming
  32438. */
  32439. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32440. /**
  32441. * Returns a promise that resolves after the given amount of time.
  32442. * @param delay Number of milliseconds to delay
  32443. * @returns Promise that resolves after the given amount of time
  32444. */
  32445. static DelayAsync(delay: number): Promise<void>;
  32446. }
  32447. /**
  32448. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32449. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32450. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32451. * @param name The name of the class, case should be preserved
  32452. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32453. */
  32454. export function className(name: string, module?: string): (target: Object) => void;
  32455. /**
  32456. * An implementation of a loop for asynchronous functions.
  32457. */
  32458. export class AsyncLoop {
  32459. /**
  32460. * Defines the number of iterations for the loop
  32461. */
  32462. iterations: number;
  32463. /**
  32464. * Defines the current index of the loop.
  32465. */
  32466. index: number;
  32467. private _done;
  32468. private _fn;
  32469. private _successCallback;
  32470. /**
  32471. * Constructor.
  32472. * @param iterations the number of iterations.
  32473. * @param func the function to run each iteration
  32474. * @param successCallback the callback that will be called upon succesful execution
  32475. * @param offset starting offset.
  32476. */
  32477. constructor(
  32478. /**
  32479. * Defines the number of iterations for the loop
  32480. */
  32481. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32482. /**
  32483. * Execute the next iteration. Must be called after the last iteration was finished.
  32484. */
  32485. executeNext(): void;
  32486. /**
  32487. * Break the loop and run the success callback.
  32488. */
  32489. breakLoop(): void;
  32490. /**
  32491. * Create and run an async loop.
  32492. * @param iterations the number of iterations.
  32493. * @param fn the function to run each iteration
  32494. * @param successCallback the callback that will be called upon succesful execution
  32495. * @param offset starting offset.
  32496. * @returns the created async loop object
  32497. */
  32498. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32499. /**
  32500. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32501. * @param iterations total number of iterations
  32502. * @param syncedIterations number of synchronous iterations in each async iteration.
  32503. * @param fn the function to call each iteration.
  32504. * @param callback a success call back that will be called when iterating stops.
  32505. * @param breakFunction a break condition (optional)
  32506. * @param timeout timeout settings for the setTimeout function. default - 0.
  32507. * @returns the created async loop object
  32508. */
  32509. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32510. }
  32511. }
  32512. declare module BABYLON {
  32513. /**
  32514. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32515. * The underlying implementation relies on an associative array to ensure the best performances.
  32516. * The value can be anything including 'null' but except 'undefined'
  32517. */
  32518. export class StringDictionary<T> {
  32519. /**
  32520. * This will clear this dictionary and copy the content from the 'source' one.
  32521. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32522. * @param source the dictionary to take the content from and copy to this dictionary
  32523. */
  32524. copyFrom(source: StringDictionary<T>): void;
  32525. /**
  32526. * Get a value based from its key
  32527. * @param key the given key to get the matching value from
  32528. * @return the value if found, otherwise undefined is returned
  32529. */
  32530. get(key: string): T | undefined;
  32531. /**
  32532. * Get a value from its key or add it if it doesn't exist.
  32533. * This method will ensure you that a given key/data will be present in the dictionary.
  32534. * @param key the given key to get the matching value from
  32535. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32536. * The factory will only be invoked if there's no data for the given key.
  32537. * @return the value corresponding to the key.
  32538. */
  32539. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32540. /**
  32541. * Get a value from its key if present in the dictionary otherwise add it
  32542. * @param key the key to get the value from
  32543. * @param val if there's no such key/value pair in the dictionary add it with this value
  32544. * @return the value corresponding to the key
  32545. */
  32546. getOrAdd(key: string, val: T): T;
  32547. /**
  32548. * Check if there's a given key in the dictionary
  32549. * @param key the key to check for
  32550. * @return true if the key is present, false otherwise
  32551. */
  32552. contains(key: string): boolean;
  32553. /**
  32554. * Add a new key and its corresponding value
  32555. * @param key the key to add
  32556. * @param value the value corresponding to the key
  32557. * @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
  32558. */
  32559. add(key: string, value: T): boolean;
  32560. /**
  32561. * Update a specific value associated to a key
  32562. * @param key defines the key to use
  32563. * @param value defines the value to store
  32564. * @returns true if the value was updated (or false if the key was not found)
  32565. */
  32566. set(key: string, value: T): boolean;
  32567. /**
  32568. * Get the element of the given key and remove it from the dictionary
  32569. * @param key defines the key to search
  32570. * @returns the value associated with the key or null if not found
  32571. */
  32572. getAndRemove(key: string): Nullable<T>;
  32573. /**
  32574. * Remove a key/value from the dictionary.
  32575. * @param key the key to remove
  32576. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32577. */
  32578. remove(key: string): boolean;
  32579. /**
  32580. * Clear the whole content of the dictionary
  32581. */
  32582. clear(): void;
  32583. /**
  32584. * Gets the current count
  32585. */
  32586. readonly count: number;
  32587. /**
  32588. * Execute a callback on each key/val of the dictionary.
  32589. * Note that you can remove any element in this dictionary in the callback implementation
  32590. * @param callback the callback to execute on a given key/value pair
  32591. */
  32592. forEach(callback: (key: string, val: T) => void): void;
  32593. /**
  32594. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32595. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32596. * Note that you can remove any element in this dictionary in the callback implementation
  32597. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32598. * @returns the first item
  32599. */
  32600. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32601. private _count;
  32602. private _data;
  32603. }
  32604. }
  32605. declare module BABYLON {
  32606. /** @hidden */
  32607. export interface ICollisionCoordinator {
  32608. createCollider(): Collider;
  32609. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32610. init(scene: Scene): void;
  32611. }
  32612. /** @hidden */
  32613. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32614. private _scene;
  32615. private _scaledPosition;
  32616. private _scaledVelocity;
  32617. private _finalPosition;
  32618. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32619. createCollider(): Collider;
  32620. init(scene: Scene): void;
  32621. private _collideWithWorld;
  32622. }
  32623. }
  32624. declare module BABYLON {
  32625. /**
  32626. * Class used to manage all inputs for the scene.
  32627. */
  32628. export class InputManager {
  32629. /** The distance in pixel that you have to move to prevent some events */
  32630. static DragMovementThreshold: number;
  32631. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32632. static LongPressDelay: number;
  32633. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32634. static DoubleClickDelay: number;
  32635. /** If you need to check double click without raising a single click at first click, enable this flag */
  32636. static ExclusiveDoubleClickMode: boolean;
  32637. private _wheelEventName;
  32638. private _onPointerMove;
  32639. private _onPointerDown;
  32640. private _onPointerUp;
  32641. private _initClickEvent;
  32642. private _initActionManager;
  32643. private _delayedSimpleClick;
  32644. private _delayedSimpleClickTimeout;
  32645. private _previousDelayedSimpleClickTimeout;
  32646. private _meshPickProceed;
  32647. private _previousButtonPressed;
  32648. private _currentPickResult;
  32649. private _previousPickResult;
  32650. private _totalPointersPressed;
  32651. private _doubleClickOccured;
  32652. private _pointerOverMesh;
  32653. private _pickedDownMesh;
  32654. private _pickedUpMesh;
  32655. private _pointerX;
  32656. private _pointerY;
  32657. private _unTranslatedPointerX;
  32658. private _unTranslatedPointerY;
  32659. private _startingPointerPosition;
  32660. private _previousStartingPointerPosition;
  32661. private _startingPointerTime;
  32662. private _previousStartingPointerTime;
  32663. private _pointerCaptures;
  32664. private _onKeyDown;
  32665. private _onKeyUp;
  32666. private _onCanvasFocusObserver;
  32667. private _onCanvasBlurObserver;
  32668. private _scene;
  32669. /**
  32670. * Creates a new InputManager
  32671. * @param scene defines the hosting scene
  32672. */
  32673. constructor(scene: Scene);
  32674. /**
  32675. * Gets the mesh that is currently under the pointer
  32676. */
  32677. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32678. /**
  32679. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32680. */
  32681. readonly unTranslatedPointer: Vector2;
  32682. /**
  32683. * Gets or sets the current on-screen X position of the pointer
  32684. */
  32685. pointerX: number;
  32686. /**
  32687. * Gets or sets the current on-screen Y position of the pointer
  32688. */
  32689. pointerY: number;
  32690. private _updatePointerPosition;
  32691. private _processPointerMove;
  32692. private _setRayOnPointerInfo;
  32693. private _checkPrePointerObservable;
  32694. /**
  32695. * Use this method to simulate a pointer move on a mesh
  32696. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32697. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32698. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32699. */
  32700. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32701. /**
  32702. * Use this method to simulate a pointer down on a mesh
  32703. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32704. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32705. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32706. */
  32707. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32708. private _processPointerDown;
  32709. /** @hidden */
  32710. _isPointerSwiping(): boolean;
  32711. /**
  32712. * Use this method to simulate a pointer up on a mesh
  32713. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32714. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32715. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32716. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32717. */
  32718. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32719. private _processPointerUp;
  32720. /**
  32721. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32722. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32723. * @returns true if the pointer was captured
  32724. */
  32725. isPointerCaptured(pointerId?: number): boolean;
  32726. /**
  32727. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32728. * @param attachUp defines if you want to attach events to pointerup
  32729. * @param attachDown defines if you want to attach events to pointerdown
  32730. * @param attachMove defines if you want to attach events to pointermove
  32731. */
  32732. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32733. /**
  32734. * Detaches all event handlers
  32735. */
  32736. detachControl(): void;
  32737. /**
  32738. * Force the value of meshUnderPointer
  32739. * @param mesh defines the mesh to use
  32740. */
  32741. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32742. /**
  32743. * Gets the mesh under the pointer
  32744. * @returns a Mesh or null if no mesh is under the pointer
  32745. */
  32746. getPointerOverMesh(): Nullable<AbstractMesh>;
  32747. }
  32748. }
  32749. declare module BABYLON {
  32750. /**
  32751. * Helper class used to generate session unique ID
  32752. */
  32753. export class UniqueIdGenerator {
  32754. private static _UniqueIdCounter;
  32755. /**
  32756. * Gets an unique (relatively to the current scene) Id
  32757. */
  32758. static readonly UniqueId: number;
  32759. }
  32760. }
  32761. declare module BABYLON {
  32762. /**
  32763. * This class defines the direct association between an animation and a target
  32764. */
  32765. export class TargetedAnimation {
  32766. /**
  32767. * Animation to perform
  32768. */
  32769. animation: Animation;
  32770. /**
  32771. * Target to animate
  32772. */
  32773. target: any;
  32774. /**
  32775. * Serialize the object
  32776. * @returns the JSON object representing the current entity
  32777. */
  32778. serialize(): any;
  32779. }
  32780. /**
  32781. * Use this class to create coordinated animations on multiple targets
  32782. */
  32783. export class AnimationGroup implements IDisposable {
  32784. /** The name of the animation group */
  32785. name: string;
  32786. private _scene;
  32787. private _targetedAnimations;
  32788. private _animatables;
  32789. private _from;
  32790. private _to;
  32791. private _isStarted;
  32792. private _isPaused;
  32793. private _speedRatio;
  32794. private _loopAnimation;
  32795. /**
  32796. * Gets or sets the unique id of the node
  32797. */
  32798. uniqueId: number;
  32799. /**
  32800. * This observable will notify when one animation have ended
  32801. */
  32802. onAnimationEndObservable: Observable<TargetedAnimation>;
  32803. /**
  32804. * Observer raised when one animation loops
  32805. */
  32806. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32807. /**
  32808. * This observable will notify when all animations have ended.
  32809. */
  32810. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32811. /**
  32812. * This observable will notify when all animations have paused.
  32813. */
  32814. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32815. /**
  32816. * This observable will notify when all animations are playing.
  32817. */
  32818. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32819. /**
  32820. * Gets the first frame
  32821. */
  32822. readonly from: number;
  32823. /**
  32824. * Gets the last frame
  32825. */
  32826. readonly to: number;
  32827. /**
  32828. * Define if the animations are started
  32829. */
  32830. readonly isStarted: boolean;
  32831. /**
  32832. * Gets a value indicating that the current group is playing
  32833. */
  32834. readonly isPlaying: boolean;
  32835. /**
  32836. * Gets or sets the speed ratio to use for all animations
  32837. */
  32838. /**
  32839. * Gets or sets the speed ratio to use for all animations
  32840. */
  32841. speedRatio: number;
  32842. /**
  32843. * Gets or sets if all animations should loop or not
  32844. */
  32845. loopAnimation: boolean;
  32846. /**
  32847. * Gets the targeted animations for this animation group
  32848. */
  32849. readonly targetedAnimations: Array<TargetedAnimation>;
  32850. /**
  32851. * returning the list of animatables controlled by this animation group.
  32852. */
  32853. readonly animatables: Array<Animatable>;
  32854. /**
  32855. * Instantiates a new Animation Group.
  32856. * This helps managing several animations at once.
  32857. * @see http://doc.babylonjs.com/how_to/group
  32858. * @param name Defines the name of the group
  32859. * @param scene Defines the scene the group belongs to
  32860. */
  32861. constructor(
  32862. /** The name of the animation group */
  32863. name: string, scene?: Nullable<Scene>);
  32864. /**
  32865. * Add an animation (with its target) in the group
  32866. * @param animation defines the animation we want to add
  32867. * @param target defines the target of the animation
  32868. * @returns the TargetedAnimation object
  32869. */
  32870. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32871. /**
  32872. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32873. * It can add constant keys at begin or end
  32874. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32875. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32876. * @returns the animation group
  32877. */
  32878. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32879. /**
  32880. * Start all animations on given targets
  32881. * @param loop defines if animations must loop
  32882. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32883. * @param from defines the from key (optional)
  32884. * @param to defines the to key (optional)
  32885. * @returns the current animation group
  32886. */
  32887. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32888. /**
  32889. * Pause all animations
  32890. * @returns the animation group
  32891. */
  32892. pause(): AnimationGroup;
  32893. /**
  32894. * Play all animations to initial state
  32895. * This function will start() the animations if they were not started or will restart() them if they were paused
  32896. * @param loop defines if animations must loop
  32897. * @returns the animation group
  32898. */
  32899. play(loop?: boolean): AnimationGroup;
  32900. /**
  32901. * Reset all animations to initial state
  32902. * @returns the animation group
  32903. */
  32904. reset(): AnimationGroup;
  32905. /**
  32906. * Restart animations from key 0
  32907. * @returns the animation group
  32908. */
  32909. restart(): AnimationGroup;
  32910. /**
  32911. * Stop all animations
  32912. * @returns the animation group
  32913. */
  32914. stop(): AnimationGroup;
  32915. /**
  32916. * Set animation weight for all animatables
  32917. * @param weight defines the weight to use
  32918. * @return the animationGroup
  32919. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32920. */
  32921. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32922. /**
  32923. * Synchronize and normalize all animatables with a source animatable
  32924. * @param root defines the root animatable to synchronize with
  32925. * @return the animationGroup
  32926. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32927. */
  32928. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32929. /**
  32930. * Goes to a specific frame in this animation group
  32931. * @param frame the frame number to go to
  32932. * @return the animationGroup
  32933. */
  32934. goToFrame(frame: number): AnimationGroup;
  32935. /**
  32936. * Dispose all associated resources
  32937. */
  32938. dispose(): void;
  32939. private _checkAnimationGroupEnded;
  32940. /**
  32941. * Clone the current animation group and returns a copy
  32942. * @param newName defines the name of the new group
  32943. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32944. * @returns the new aniamtion group
  32945. */
  32946. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32947. /**
  32948. * Serializes the animationGroup to an object
  32949. * @returns Serialized object
  32950. */
  32951. serialize(): any;
  32952. /**
  32953. * Returns a new AnimationGroup object parsed from the source provided.
  32954. * @param parsedAnimationGroup defines the source
  32955. * @param scene defines the scene that will receive the animationGroup
  32956. * @returns a new AnimationGroup
  32957. */
  32958. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32959. /**
  32960. * Returns the string "AnimationGroup"
  32961. * @returns "AnimationGroup"
  32962. */
  32963. getClassName(): string;
  32964. /**
  32965. * Creates a detailled string about the object
  32966. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32967. * @returns a string representing the object
  32968. */
  32969. toString(fullDetails?: boolean): string;
  32970. }
  32971. }
  32972. declare module BABYLON {
  32973. /**
  32974. * Define an interface for all classes that will hold resources
  32975. */
  32976. export interface IDisposable {
  32977. /**
  32978. * Releases all held resources
  32979. */
  32980. dispose(): void;
  32981. }
  32982. /** Interface defining initialization parameters for Scene class */
  32983. export interface SceneOptions {
  32984. /**
  32985. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32986. * It will improve performance when the number of geometries becomes important.
  32987. */
  32988. useGeometryUniqueIdsMap?: boolean;
  32989. /**
  32990. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32991. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32992. */
  32993. useMaterialMeshMap?: boolean;
  32994. /**
  32995. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32996. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32997. */
  32998. useClonedMeshhMap?: boolean;
  32999. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33000. virtual?: boolean;
  33001. }
  33002. /**
  33003. * Represents a scene to be rendered by the engine.
  33004. * @see http://doc.babylonjs.com/features/scene
  33005. */
  33006. export class Scene extends AbstractScene implements IAnimatable {
  33007. /** The fog is deactivated */
  33008. static readonly FOGMODE_NONE: number;
  33009. /** The fog density is following an exponential function */
  33010. static readonly FOGMODE_EXP: number;
  33011. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33012. static readonly FOGMODE_EXP2: number;
  33013. /** The fog density is following a linear function. */
  33014. static readonly FOGMODE_LINEAR: number;
  33015. /**
  33016. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33017. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33018. */
  33019. static MinDeltaTime: number;
  33020. /**
  33021. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33022. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33023. */
  33024. static MaxDeltaTime: number;
  33025. /**
  33026. * Factory used to create the default material.
  33027. * @param name The name of the material to create
  33028. * @param scene The scene to create the material for
  33029. * @returns The default material
  33030. */
  33031. static DefaultMaterialFactory(scene: Scene): Material;
  33032. /**
  33033. * Factory used to create the a collision coordinator.
  33034. * @returns The collision coordinator
  33035. */
  33036. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33037. /** @hidden */
  33038. _inputManager: InputManager;
  33039. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33040. cameraToUseForPointers: Nullable<Camera>;
  33041. /** @hidden */
  33042. readonly _isScene: boolean;
  33043. /**
  33044. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33045. */
  33046. autoClear: boolean;
  33047. /**
  33048. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33049. */
  33050. autoClearDepthAndStencil: boolean;
  33051. /**
  33052. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33053. */
  33054. clearColor: Color4;
  33055. /**
  33056. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33057. */
  33058. ambientColor: Color3;
  33059. /**
  33060. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33061. * It should only be one of the following (if not the default embedded one):
  33062. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33063. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33064. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33065. * The material properties need to be setup according to the type of texture in use.
  33066. */
  33067. environmentBRDFTexture: BaseTexture;
  33068. /** @hidden */
  33069. protected _environmentTexture: Nullable<BaseTexture>;
  33070. /**
  33071. * Texture used in all pbr material as the reflection texture.
  33072. * As in the majority of the scene they are the same (exception for multi room and so on),
  33073. * this is easier to reference from here than from all the materials.
  33074. */
  33075. /**
  33076. * Texture used in all pbr material as the reflection texture.
  33077. * As in the majority of the scene they are the same (exception for multi room and so on),
  33078. * this is easier to set here than in all the materials.
  33079. */
  33080. environmentTexture: Nullable<BaseTexture>;
  33081. /** @hidden */
  33082. protected _environmentIntensity: number;
  33083. /**
  33084. * Intensity of the environment in all pbr material.
  33085. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33086. * As in the majority of the scene they are the same (exception for multi room and so on),
  33087. * this is easier to reference from here than from all the materials.
  33088. */
  33089. /**
  33090. * Intensity of the environment in all pbr material.
  33091. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33092. * As in the majority of the scene they are the same (exception for multi room and so on),
  33093. * this is easier to set here than in all the materials.
  33094. */
  33095. environmentIntensity: number;
  33096. /** @hidden */
  33097. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33098. /**
  33099. * Default image processing configuration used either in the rendering
  33100. * Forward main pass or through the imageProcessingPostProcess if present.
  33101. * As in the majority of the scene they are the same (exception for multi camera),
  33102. * this is easier to reference from here than from all the materials and post process.
  33103. *
  33104. * No setter as we it is a shared configuration, you can set the values instead.
  33105. */
  33106. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33107. private _forceWireframe;
  33108. /**
  33109. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33110. */
  33111. forceWireframe: boolean;
  33112. private _forcePointsCloud;
  33113. /**
  33114. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33115. */
  33116. forcePointsCloud: boolean;
  33117. /**
  33118. * Gets or sets the active clipplane 1
  33119. */
  33120. clipPlane: Nullable<Plane>;
  33121. /**
  33122. * Gets or sets the active clipplane 2
  33123. */
  33124. clipPlane2: Nullable<Plane>;
  33125. /**
  33126. * Gets or sets the active clipplane 3
  33127. */
  33128. clipPlane3: Nullable<Plane>;
  33129. /**
  33130. * Gets or sets the active clipplane 4
  33131. */
  33132. clipPlane4: Nullable<Plane>;
  33133. /**
  33134. * Gets or sets a boolean indicating if animations are enabled
  33135. */
  33136. animationsEnabled: boolean;
  33137. private _animationPropertiesOverride;
  33138. /**
  33139. * Gets or sets the animation properties override
  33140. */
  33141. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33142. /**
  33143. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33144. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33145. */
  33146. useConstantAnimationDeltaTime: boolean;
  33147. /**
  33148. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33149. * Please note that it requires to run a ray cast through the scene on every frame
  33150. */
  33151. constantlyUpdateMeshUnderPointer: boolean;
  33152. /**
  33153. * Defines the HTML cursor to use when hovering over interactive elements
  33154. */
  33155. hoverCursor: string;
  33156. /**
  33157. * Defines the HTML default cursor to use (empty by default)
  33158. */
  33159. defaultCursor: string;
  33160. /**
  33161. * This is used to call preventDefault() on pointer down
  33162. * in order to block unwanted artifacts like system double clicks
  33163. */
  33164. preventDefaultOnPointerDown: boolean;
  33165. /**
  33166. * This is used to call preventDefault() on pointer up
  33167. * in order to block unwanted artifacts like system double clicks
  33168. */
  33169. preventDefaultOnPointerUp: boolean;
  33170. /**
  33171. * Gets or sets user defined metadata
  33172. */
  33173. metadata: any;
  33174. /**
  33175. * For internal use only. Please do not use.
  33176. */
  33177. reservedDataStore: any;
  33178. /**
  33179. * Gets the name of the plugin used to load this scene (null by default)
  33180. */
  33181. loadingPluginName: string;
  33182. /**
  33183. * Use this array to add regular expressions used to disable offline support for specific urls
  33184. */
  33185. disableOfflineSupportExceptionRules: RegExp[];
  33186. /**
  33187. * An event triggered when the scene is disposed.
  33188. */
  33189. onDisposeObservable: Observable<Scene>;
  33190. private _onDisposeObserver;
  33191. /** Sets a function to be executed when this scene is disposed. */
  33192. onDispose: () => void;
  33193. /**
  33194. * An event triggered before rendering the scene (right after animations and physics)
  33195. */
  33196. onBeforeRenderObservable: Observable<Scene>;
  33197. private _onBeforeRenderObserver;
  33198. /** Sets a function to be executed before rendering this scene */
  33199. beforeRender: Nullable<() => void>;
  33200. /**
  33201. * An event triggered after rendering the scene
  33202. */
  33203. onAfterRenderObservable: Observable<Scene>;
  33204. /**
  33205. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33206. */
  33207. onAfterRenderCameraObservable: Observable<Camera>;
  33208. private _onAfterRenderObserver;
  33209. /** Sets a function to be executed after rendering this scene */
  33210. afterRender: Nullable<() => void>;
  33211. /**
  33212. * An event triggered before animating the scene
  33213. */
  33214. onBeforeAnimationsObservable: Observable<Scene>;
  33215. /**
  33216. * An event triggered after animations processing
  33217. */
  33218. onAfterAnimationsObservable: Observable<Scene>;
  33219. /**
  33220. * An event triggered before draw calls are ready to be sent
  33221. */
  33222. onBeforeDrawPhaseObservable: Observable<Scene>;
  33223. /**
  33224. * An event triggered after draw calls have been sent
  33225. */
  33226. onAfterDrawPhaseObservable: Observable<Scene>;
  33227. /**
  33228. * An event triggered when the scene is ready
  33229. */
  33230. onReadyObservable: Observable<Scene>;
  33231. /**
  33232. * An event triggered before rendering a camera
  33233. */
  33234. onBeforeCameraRenderObservable: Observable<Camera>;
  33235. private _onBeforeCameraRenderObserver;
  33236. /** Sets a function to be executed before rendering a camera*/
  33237. beforeCameraRender: () => void;
  33238. /**
  33239. * An event triggered after rendering a camera
  33240. */
  33241. onAfterCameraRenderObservable: Observable<Camera>;
  33242. private _onAfterCameraRenderObserver;
  33243. /** Sets a function to be executed after rendering a camera*/
  33244. afterCameraRender: () => void;
  33245. /**
  33246. * An event triggered when active meshes evaluation is about to start
  33247. */
  33248. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33249. /**
  33250. * An event triggered when active meshes evaluation is done
  33251. */
  33252. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33253. /**
  33254. * An event triggered when particles rendering is about to start
  33255. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33256. */
  33257. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33258. /**
  33259. * An event triggered when particles rendering is done
  33260. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33261. */
  33262. onAfterParticlesRenderingObservable: Observable<Scene>;
  33263. /**
  33264. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33265. */
  33266. onDataLoadedObservable: Observable<Scene>;
  33267. /**
  33268. * An event triggered when a camera is created
  33269. */
  33270. onNewCameraAddedObservable: Observable<Camera>;
  33271. /**
  33272. * An event triggered when a camera is removed
  33273. */
  33274. onCameraRemovedObservable: Observable<Camera>;
  33275. /**
  33276. * An event triggered when a light is created
  33277. */
  33278. onNewLightAddedObservable: Observable<Light>;
  33279. /**
  33280. * An event triggered when a light is removed
  33281. */
  33282. onLightRemovedObservable: Observable<Light>;
  33283. /**
  33284. * An event triggered when a geometry is created
  33285. */
  33286. onNewGeometryAddedObservable: Observable<Geometry>;
  33287. /**
  33288. * An event triggered when a geometry is removed
  33289. */
  33290. onGeometryRemovedObservable: Observable<Geometry>;
  33291. /**
  33292. * An event triggered when a transform node is created
  33293. */
  33294. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33295. /**
  33296. * An event triggered when a transform node is removed
  33297. */
  33298. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33299. /**
  33300. * An event triggered when a mesh is created
  33301. */
  33302. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33303. /**
  33304. * An event triggered when a mesh is removed
  33305. */
  33306. onMeshRemovedObservable: Observable<AbstractMesh>;
  33307. /**
  33308. * An event triggered when a skeleton is created
  33309. */
  33310. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33311. /**
  33312. * An event triggered when a skeleton is removed
  33313. */
  33314. onSkeletonRemovedObservable: Observable<Skeleton>;
  33315. /**
  33316. * An event triggered when a material is created
  33317. */
  33318. onNewMaterialAddedObservable: Observable<Material>;
  33319. /**
  33320. * An event triggered when a material is removed
  33321. */
  33322. onMaterialRemovedObservable: Observable<Material>;
  33323. /**
  33324. * An event triggered when a texture is created
  33325. */
  33326. onNewTextureAddedObservable: Observable<BaseTexture>;
  33327. /**
  33328. * An event triggered when a texture is removed
  33329. */
  33330. onTextureRemovedObservable: Observable<BaseTexture>;
  33331. /**
  33332. * An event triggered when render targets are about to be rendered
  33333. * Can happen multiple times per frame.
  33334. */
  33335. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33336. /**
  33337. * An event triggered when render targets were rendered.
  33338. * Can happen multiple times per frame.
  33339. */
  33340. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33341. /**
  33342. * An event triggered before calculating deterministic simulation step
  33343. */
  33344. onBeforeStepObservable: Observable<Scene>;
  33345. /**
  33346. * An event triggered after calculating deterministic simulation step
  33347. */
  33348. onAfterStepObservable: Observable<Scene>;
  33349. /**
  33350. * An event triggered when the activeCamera property is updated
  33351. */
  33352. onActiveCameraChanged: Observable<Scene>;
  33353. /**
  33354. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33355. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33356. * 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)
  33357. */
  33358. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33359. /**
  33360. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33361. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33362. * 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)
  33363. */
  33364. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33365. /**
  33366. * This Observable will when a mesh has been imported into the scene.
  33367. */
  33368. onMeshImportedObservable: Observable<AbstractMesh>;
  33369. /**
  33370. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33371. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33372. */
  33373. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33374. /** @hidden */
  33375. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33376. /**
  33377. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33378. */
  33379. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33380. /**
  33381. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33382. */
  33383. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33384. /**
  33385. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33386. */
  33387. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33388. /** Callback called when a pointer move is detected */
  33389. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33390. /** Callback called when a pointer down is detected */
  33391. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33392. /** Callback called when a pointer up is detected */
  33393. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33394. /** Callback called when a pointer pick is detected */
  33395. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33396. /**
  33397. * 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).
  33398. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33399. */
  33400. onPrePointerObservable: Observable<PointerInfoPre>;
  33401. /**
  33402. * Observable event triggered each time an input event is received from the rendering canvas
  33403. */
  33404. onPointerObservable: Observable<PointerInfo>;
  33405. /**
  33406. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33407. */
  33408. readonly unTranslatedPointer: Vector2;
  33409. /**
  33410. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33411. */
  33412. static DragMovementThreshold: number;
  33413. /**
  33414. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33415. */
  33416. static LongPressDelay: number;
  33417. /**
  33418. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33419. */
  33420. static DoubleClickDelay: number;
  33421. /** If you need to check double click without raising a single click at first click, enable this flag */
  33422. static ExclusiveDoubleClickMode: boolean;
  33423. /** @hidden */
  33424. _mirroredCameraPosition: Nullable<Vector3>;
  33425. /**
  33426. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33427. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33428. */
  33429. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33430. /**
  33431. * Observable event triggered each time an keyboard event is received from the hosting window
  33432. */
  33433. onKeyboardObservable: Observable<KeyboardInfo>;
  33434. private _useRightHandedSystem;
  33435. /**
  33436. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33437. */
  33438. useRightHandedSystem: boolean;
  33439. private _timeAccumulator;
  33440. private _currentStepId;
  33441. private _currentInternalStep;
  33442. /**
  33443. * Sets the step Id used by deterministic lock step
  33444. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33445. * @param newStepId defines the step Id
  33446. */
  33447. setStepId(newStepId: number): void;
  33448. /**
  33449. * Gets the step Id used by deterministic lock step
  33450. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33451. * @returns the step Id
  33452. */
  33453. getStepId(): number;
  33454. /**
  33455. * Gets the internal step used by deterministic lock step
  33456. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33457. * @returns the internal step
  33458. */
  33459. getInternalStep(): number;
  33460. private _fogEnabled;
  33461. /**
  33462. * Gets or sets a boolean indicating if fog is enabled on this scene
  33463. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33464. * (Default is true)
  33465. */
  33466. fogEnabled: boolean;
  33467. private _fogMode;
  33468. /**
  33469. * Gets or sets the fog mode to use
  33470. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33471. * | mode | value |
  33472. * | --- | --- |
  33473. * | FOGMODE_NONE | 0 |
  33474. * | FOGMODE_EXP | 1 |
  33475. * | FOGMODE_EXP2 | 2 |
  33476. * | FOGMODE_LINEAR | 3 |
  33477. */
  33478. fogMode: number;
  33479. /**
  33480. * Gets or sets the fog color to use
  33481. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33482. * (Default is Color3(0.2, 0.2, 0.3))
  33483. */
  33484. fogColor: Color3;
  33485. /**
  33486. * Gets or sets the fog density to use
  33487. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33488. * (Default is 0.1)
  33489. */
  33490. fogDensity: number;
  33491. /**
  33492. * Gets or sets the fog start distance to use
  33493. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33494. * (Default is 0)
  33495. */
  33496. fogStart: number;
  33497. /**
  33498. * Gets or sets the fog end distance to use
  33499. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33500. * (Default is 1000)
  33501. */
  33502. fogEnd: number;
  33503. private _shadowsEnabled;
  33504. /**
  33505. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33506. */
  33507. shadowsEnabled: boolean;
  33508. private _lightsEnabled;
  33509. /**
  33510. * Gets or sets a boolean indicating if lights are enabled on this scene
  33511. */
  33512. lightsEnabled: boolean;
  33513. /** All of the active cameras added to this scene. */
  33514. activeCameras: Camera[];
  33515. /** @hidden */
  33516. _activeCamera: Nullable<Camera>;
  33517. /** Gets or sets the current active camera */
  33518. activeCamera: Nullable<Camera>;
  33519. private _defaultMaterial;
  33520. /** The default material used on meshes when no material is affected */
  33521. /** The default material used on meshes when no material is affected */
  33522. defaultMaterial: Material;
  33523. private _texturesEnabled;
  33524. /**
  33525. * Gets or sets a boolean indicating if textures are enabled on this scene
  33526. */
  33527. texturesEnabled: boolean;
  33528. /**
  33529. * Gets or sets a boolean indicating if particles are enabled on this scene
  33530. */
  33531. particlesEnabled: boolean;
  33532. /**
  33533. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33534. */
  33535. spritesEnabled: boolean;
  33536. private _skeletonsEnabled;
  33537. /**
  33538. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33539. */
  33540. skeletonsEnabled: boolean;
  33541. /**
  33542. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33543. */
  33544. lensFlaresEnabled: boolean;
  33545. /**
  33546. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33547. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33548. */
  33549. collisionsEnabled: boolean;
  33550. private _collisionCoordinator;
  33551. /** @hidden */
  33552. readonly collisionCoordinator: ICollisionCoordinator;
  33553. /**
  33554. * Defines the gravity applied to this scene (used only for collisions)
  33555. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33556. */
  33557. gravity: Vector3;
  33558. /**
  33559. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33560. */
  33561. postProcessesEnabled: boolean;
  33562. /**
  33563. * The list of postprocesses added to the scene
  33564. */
  33565. postProcesses: PostProcess[];
  33566. /**
  33567. * Gets the current postprocess manager
  33568. */
  33569. postProcessManager: PostProcessManager;
  33570. /**
  33571. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33572. */
  33573. renderTargetsEnabled: boolean;
  33574. /**
  33575. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33576. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33577. */
  33578. dumpNextRenderTargets: boolean;
  33579. /**
  33580. * The list of user defined render targets added to the scene
  33581. */
  33582. customRenderTargets: RenderTargetTexture[];
  33583. /**
  33584. * Defines if texture loading must be delayed
  33585. * If true, textures will only be loaded when they need to be rendered
  33586. */
  33587. useDelayedTextureLoading: boolean;
  33588. /**
  33589. * Gets the list of meshes imported to the scene through SceneLoader
  33590. */
  33591. importedMeshesFiles: String[];
  33592. /**
  33593. * Gets or sets a boolean indicating if probes are enabled on this scene
  33594. */
  33595. probesEnabled: boolean;
  33596. /**
  33597. * Gets or sets the current offline provider to use to store scene data
  33598. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33599. */
  33600. offlineProvider: IOfflineProvider;
  33601. /**
  33602. * Gets or sets the action manager associated with the scene
  33603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33604. */
  33605. actionManager: AbstractActionManager;
  33606. private _meshesForIntersections;
  33607. /**
  33608. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33609. */
  33610. proceduralTexturesEnabled: boolean;
  33611. private _engine;
  33612. private _totalVertices;
  33613. /** @hidden */
  33614. _activeIndices: PerfCounter;
  33615. /** @hidden */
  33616. _activeParticles: PerfCounter;
  33617. /** @hidden */
  33618. _activeBones: PerfCounter;
  33619. private _animationRatio;
  33620. /** @hidden */
  33621. _animationTimeLast: number;
  33622. /** @hidden */
  33623. _animationTime: number;
  33624. /**
  33625. * Gets or sets a general scale for animation speed
  33626. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33627. */
  33628. animationTimeScale: number;
  33629. /** @hidden */
  33630. _cachedMaterial: Nullable<Material>;
  33631. /** @hidden */
  33632. _cachedEffect: Nullable<Effect>;
  33633. /** @hidden */
  33634. _cachedVisibility: Nullable<number>;
  33635. private _renderId;
  33636. private _frameId;
  33637. private _executeWhenReadyTimeoutId;
  33638. private _intermediateRendering;
  33639. private _viewUpdateFlag;
  33640. private _projectionUpdateFlag;
  33641. /** @hidden */
  33642. _toBeDisposed: Nullable<IDisposable>[];
  33643. private _activeRequests;
  33644. /** @hidden */
  33645. _pendingData: any[];
  33646. private _isDisposed;
  33647. /**
  33648. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33649. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33650. */
  33651. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33652. private _activeMeshes;
  33653. private _processedMaterials;
  33654. private _renderTargets;
  33655. /** @hidden */
  33656. _activeParticleSystems: SmartArray<IParticleSystem>;
  33657. private _activeSkeletons;
  33658. private _softwareSkinnedMeshes;
  33659. private _renderingManager;
  33660. /** @hidden */
  33661. _activeAnimatables: Animatable[];
  33662. private _transformMatrix;
  33663. private _sceneUbo;
  33664. /** @hidden */
  33665. _viewMatrix: Matrix;
  33666. private _projectionMatrix;
  33667. /** @hidden */
  33668. _forcedViewPosition: Nullable<Vector3>;
  33669. /** @hidden */
  33670. _frustumPlanes: Plane[];
  33671. /**
  33672. * Gets the list of frustum planes (built from the active camera)
  33673. */
  33674. readonly frustumPlanes: Plane[];
  33675. /**
  33676. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33677. * This is useful if there are more lights that the maximum simulteanous authorized
  33678. */
  33679. requireLightSorting: boolean;
  33680. /** @hidden */
  33681. readonly useMaterialMeshMap: boolean;
  33682. /** @hidden */
  33683. readonly useClonedMeshhMap: boolean;
  33684. private _externalData;
  33685. private _uid;
  33686. /**
  33687. * @hidden
  33688. * Backing store of defined scene components.
  33689. */
  33690. _components: ISceneComponent[];
  33691. /**
  33692. * @hidden
  33693. * Backing store of defined scene components.
  33694. */
  33695. _serializableComponents: ISceneSerializableComponent[];
  33696. /**
  33697. * List of components to register on the next registration step.
  33698. */
  33699. private _transientComponents;
  33700. /**
  33701. * Registers the transient components if needed.
  33702. */
  33703. private _registerTransientComponents;
  33704. /**
  33705. * @hidden
  33706. * Add a component to the scene.
  33707. * Note that the ccomponent could be registered on th next frame if this is called after
  33708. * the register component stage.
  33709. * @param component Defines the component to add to the scene
  33710. */
  33711. _addComponent(component: ISceneComponent): void;
  33712. /**
  33713. * @hidden
  33714. * Gets a component from the scene.
  33715. * @param name defines the name of the component to retrieve
  33716. * @returns the component or null if not present
  33717. */
  33718. _getComponent(name: string): Nullable<ISceneComponent>;
  33719. /**
  33720. * @hidden
  33721. * Defines the actions happening before camera updates.
  33722. */
  33723. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33724. /**
  33725. * @hidden
  33726. * Defines the actions happening before clear the canvas.
  33727. */
  33728. _beforeClearStage: Stage<SimpleStageAction>;
  33729. /**
  33730. * @hidden
  33731. * Defines the actions when collecting render targets for the frame.
  33732. */
  33733. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33734. /**
  33735. * @hidden
  33736. * Defines the actions happening for one camera in the frame.
  33737. */
  33738. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33739. /**
  33740. * @hidden
  33741. * Defines the actions happening during the per mesh ready checks.
  33742. */
  33743. _isReadyForMeshStage: Stage<MeshStageAction>;
  33744. /**
  33745. * @hidden
  33746. * Defines the actions happening before evaluate active mesh checks.
  33747. */
  33748. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33749. /**
  33750. * @hidden
  33751. * Defines the actions happening during the evaluate sub mesh checks.
  33752. */
  33753. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33754. /**
  33755. * @hidden
  33756. * Defines the actions happening during the active mesh stage.
  33757. */
  33758. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33759. /**
  33760. * @hidden
  33761. * Defines the actions happening during the per camera render target step.
  33762. */
  33763. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33764. /**
  33765. * @hidden
  33766. * Defines the actions happening just before the active camera is drawing.
  33767. */
  33768. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33769. /**
  33770. * @hidden
  33771. * Defines the actions happening just before a render target is drawing.
  33772. */
  33773. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33774. /**
  33775. * @hidden
  33776. * Defines the actions happening just before a rendering group is drawing.
  33777. */
  33778. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33779. /**
  33780. * @hidden
  33781. * Defines the actions happening just before a mesh is drawing.
  33782. */
  33783. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33784. /**
  33785. * @hidden
  33786. * Defines the actions happening just after a mesh has been drawn.
  33787. */
  33788. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33789. /**
  33790. * @hidden
  33791. * Defines the actions happening just after a rendering group has been drawn.
  33792. */
  33793. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33794. /**
  33795. * @hidden
  33796. * Defines the actions happening just after the active camera has been drawn.
  33797. */
  33798. _afterCameraDrawStage: Stage<CameraStageAction>;
  33799. /**
  33800. * @hidden
  33801. * Defines the actions happening just after a render target has been drawn.
  33802. */
  33803. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33804. /**
  33805. * @hidden
  33806. * Defines the actions happening just after rendering all cameras and computing intersections.
  33807. */
  33808. _afterRenderStage: Stage<SimpleStageAction>;
  33809. /**
  33810. * @hidden
  33811. * Defines the actions happening when a pointer move event happens.
  33812. */
  33813. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33814. /**
  33815. * @hidden
  33816. * Defines the actions happening when a pointer down event happens.
  33817. */
  33818. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33819. /**
  33820. * @hidden
  33821. * Defines the actions happening when a pointer up event happens.
  33822. */
  33823. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33824. /**
  33825. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33826. */
  33827. private geometriesByUniqueId;
  33828. /**
  33829. * Creates a new Scene
  33830. * @param engine defines the engine to use to render this scene
  33831. * @param options defines the scene options
  33832. */
  33833. constructor(engine: Engine, options?: SceneOptions);
  33834. /**
  33835. * Gets a string idenfifying the name of the class
  33836. * @returns "Scene" string
  33837. */
  33838. getClassName(): string;
  33839. private _defaultMeshCandidates;
  33840. /**
  33841. * @hidden
  33842. */
  33843. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33844. private _defaultSubMeshCandidates;
  33845. /**
  33846. * @hidden
  33847. */
  33848. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33849. /**
  33850. * Sets the default candidate providers for the scene.
  33851. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33852. * and getCollidingSubMeshCandidates to their default function
  33853. */
  33854. setDefaultCandidateProviders(): void;
  33855. /**
  33856. * Gets the mesh that is currently under the pointer
  33857. */
  33858. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33859. /**
  33860. * Gets or sets the current on-screen X position of the pointer
  33861. */
  33862. pointerX: number;
  33863. /**
  33864. * Gets or sets the current on-screen Y position of the pointer
  33865. */
  33866. pointerY: number;
  33867. /**
  33868. * Gets the cached material (ie. the latest rendered one)
  33869. * @returns the cached material
  33870. */
  33871. getCachedMaterial(): Nullable<Material>;
  33872. /**
  33873. * Gets the cached effect (ie. the latest rendered one)
  33874. * @returns the cached effect
  33875. */
  33876. getCachedEffect(): Nullable<Effect>;
  33877. /**
  33878. * Gets the cached visibility state (ie. the latest rendered one)
  33879. * @returns the cached visibility state
  33880. */
  33881. getCachedVisibility(): Nullable<number>;
  33882. /**
  33883. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33884. * @param material defines the current material
  33885. * @param effect defines the current effect
  33886. * @param visibility defines the current visibility state
  33887. * @returns true if one parameter is not cached
  33888. */
  33889. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33890. /**
  33891. * Gets the engine associated with the scene
  33892. * @returns an Engine
  33893. */
  33894. getEngine(): Engine;
  33895. /**
  33896. * Gets the total number of vertices rendered per frame
  33897. * @returns the total number of vertices rendered per frame
  33898. */
  33899. getTotalVertices(): number;
  33900. /**
  33901. * Gets the performance counter for total vertices
  33902. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33903. */
  33904. readonly totalVerticesPerfCounter: PerfCounter;
  33905. /**
  33906. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33907. * @returns the total number of active indices rendered per frame
  33908. */
  33909. getActiveIndices(): number;
  33910. /**
  33911. * Gets the performance counter for active indices
  33912. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33913. */
  33914. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33915. /**
  33916. * Gets the total number of active particles rendered per frame
  33917. * @returns the total number of active particles rendered per frame
  33918. */
  33919. getActiveParticles(): number;
  33920. /**
  33921. * Gets the performance counter for active particles
  33922. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33923. */
  33924. readonly activeParticlesPerfCounter: PerfCounter;
  33925. /**
  33926. * Gets the total number of active bones rendered per frame
  33927. * @returns the total number of active bones rendered per frame
  33928. */
  33929. getActiveBones(): number;
  33930. /**
  33931. * Gets the performance counter for active bones
  33932. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33933. */
  33934. readonly activeBonesPerfCounter: PerfCounter;
  33935. /**
  33936. * Gets the array of active meshes
  33937. * @returns an array of AbstractMesh
  33938. */
  33939. getActiveMeshes(): SmartArray<AbstractMesh>;
  33940. /**
  33941. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33942. * @returns a number
  33943. */
  33944. getAnimationRatio(): number;
  33945. /**
  33946. * Gets an unique Id for the current render phase
  33947. * @returns a number
  33948. */
  33949. getRenderId(): number;
  33950. /**
  33951. * Gets an unique Id for the current frame
  33952. * @returns a number
  33953. */
  33954. getFrameId(): number;
  33955. /** Call this function if you want to manually increment the render Id*/
  33956. incrementRenderId(): void;
  33957. private _createUbo;
  33958. /**
  33959. * Use this method to simulate a pointer move on a mesh
  33960. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33961. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33962. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33963. * @returns the current scene
  33964. */
  33965. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33966. /**
  33967. * Use this method to simulate a pointer down on a mesh
  33968. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33969. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33970. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33971. * @returns the current scene
  33972. */
  33973. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33974. /**
  33975. * Use this method to simulate a pointer up on a mesh
  33976. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33977. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33978. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33979. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33980. * @returns the current scene
  33981. */
  33982. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33983. /**
  33984. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33985. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33986. * @returns true if the pointer was captured
  33987. */
  33988. isPointerCaptured(pointerId?: number): boolean;
  33989. /**
  33990. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33991. * @param attachUp defines if you want to attach events to pointerup
  33992. * @param attachDown defines if you want to attach events to pointerdown
  33993. * @param attachMove defines if you want to attach events to pointermove
  33994. */
  33995. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33996. /** Detaches all event handlers*/
  33997. detachControl(): void;
  33998. /**
  33999. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34000. * Delay loaded resources are not taking in account
  34001. * @return true if all required resources are ready
  34002. */
  34003. isReady(): boolean;
  34004. /** Resets all cached information relative to material (including effect and visibility) */
  34005. resetCachedMaterial(): void;
  34006. /**
  34007. * Registers a function to be called before every frame render
  34008. * @param func defines the function to register
  34009. */
  34010. registerBeforeRender(func: () => void): void;
  34011. /**
  34012. * Unregisters a function called before every frame render
  34013. * @param func defines the function to unregister
  34014. */
  34015. unregisterBeforeRender(func: () => void): void;
  34016. /**
  34017. * Registers a function to be called after every frame render
  34018. * @param func defines the function to register
  34019. */
  34020. registerAfterRender(func: () => void): void;
  34021. /**
  34022. * Unregisters a function called after every frame render
  34023. * @param func defines the function to unregister
  34024. */
  34025. unregisterAfterRender(func: () => void): void;
  34026. private _executeOnceBeforeRender;
  34027. /**
  34028. * The provided function will run before render once and will be disposed afterwards.
  34029. * A timeout delay can be provided so that the function will be executed in N ms.
  34030. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34031. * @param func The function to be executed.
  34032. * @param timeout optional delay in ms
  34033. */
  34034. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34035. /** @hidden */
  34036. _addPendingData(data: any): void;
  34037. /** @hidden */
  34038. _removePendingData(data: any): void;
  34039. /**
  34040. * Returns the number of items waiting to be loaded
  34041. * @returns the number of items waiting to be loaded
  34042. */
  34043. getWaitingItemsCount(): number;
  34044. /**
  34045. * Returns a boolean indicating if the scene is still loading data
  34046. */
  34047. readonly isLoading: boolean;
  34048. /**
  34049. * Registers a function to be executed when the scene is ready
  34050. * @param {Function} func - the function to be executed
  34051. */
  34052. executeWhenReady(func: () => void): void;
  34053. /**
  34054. * Returns a promise that resolves when the scene is ready
  34055. * @returns A promise that resolves when the scene is ready
  34056. */
  34057. whenReadyAsync(): Promise<void>;
  34058. /** @hidden */
  34059. _checkIsReady(): void;
  34060. /**
  34061. * Gets all animatable attached to the scene
  34062. */
  34063. readonly animatables: Animatable[];
  34064. /**
  34065. * Resets the last animation time frame.
  34066. * Useful to override when animations start running when loading a scene for the first time.
  34067. */
  34068. resetLastAnimationTimeFrame(): void;
  34069. /**
  34070. * Gets the current view matrix
  34071. * @returns a Matrix
  34072. */
  34073. getViewMatrix(): Matrix;
  34074. /**
  34075. * Gets the current projection matrix
  34076. * @returns a Matrix
  34077. */
  34078. getProjectionMatrix(): Matrix;
  34079. /**
  34080. * Gets the current transform matrix
  34081. * @returns a Matrix made of View * Projection
  34082. */
  34083. getTransformMatrix(): Matrix;
  34084. /**
  34085. * Sets the current transform matrix
  34086. * @param viewL defines the View matrix to use
  34087. * @param projectionL defines the Projection matrix to use
  34088. * @param viewR defines the right View matrix to use (if provided)
  34089. * @param projectionR defines the right Projection matrix to use (if provided)
  34090. */
  34091. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34092. /**
  34093. * Gets the uniform buffer used to store scene data
  34094. * @returns a UniformBuffer
  34095. */
  34096. getSceneUniformBuffer(): UniformBuffer;
  34097. /**
  34098. * Gets an unique (relatively to the current scene) Id
  34099. * @returns an unique number for the scene
  34100. */
  34101. getUniqueId(): number;
  34102. /**
  34103. * Add a mesh to the list of scene's meshes
  34104. * @param newMesh defines the mesh to add
  34105. * @param recursive if all child meshes should also be added to the scene
  34106. */
  34107. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34108. /**
  34109. * Remove a mesh for the list of scene's meshes
  34110. * @param toRemove defines the mesh to remove
  34111. * @param recursive if all child meshes should also be removed from the scene
  34112. * @returns the index where the mesh was in the mesh list
  34113. */
  34114. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34115. /**
  34116. * Add a transform node to the list of scene's transform nodes
  34117. * @param newTransformNode defines the transform node to add
  34118. */
  34119. addTransformNode(newTransformNode: TransformNode): void;
  34120. /**
  34121. * Remove a transform node for the list of scene's transform nodes
  34122. * @param toRemove defines the transform node to remove
  34123. * @returns the index where the transform node was in the transform node list
  34124. */
  34125. removeTransformNode(toRemove: TransformNode): number;
  34126. /**
  34127. * Remove a skeleton for the list of scene's skeletons
  34128. * @param toRemove defines the skeleton to remove
  34129. * @returns the index where the skeleton was in the skeleton list
  34130. */
  34131. removeSkeleton(toRemove: Skeleton): number;
  34132. /**
  34133. * Remove a morph target for the list of scene's morph targets
  34134. * @param toRemove defines the morph target to remove
  34135. * @returns the index where the morph target was in the morph target list
  34136. */
  34137. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34138. /**
  34139. * Remove a light for the list of scene's lights
  34140. * @param toRemove defines the light to remove
  34141. * @returns the index where the light was in the light list
  34142. */
  34143. removeLight(toRemove: Light): number;
  34144. /**
  34145. * Remove a camera for the list of scene's cameras
  34146. * @param toRemove defines the camera to remove
  34147. * @returns the index where the camera was in the camera list
  34148. */
  34149. removeCamera(toRemove: Camera): number;
  34150. /**
  34151. * Remove a particle system for the list of scene's particle systems
  34152. * @param toRemove defines the particle system to remove
  34153. * @returns the index where the particle system was in the particle system list
  34154. */
  34155. removeParticleSystem(toRemove: IParticleSystem): number;
  34156. /**
  34157. * Remove a animation for the list of scene's animations
  34158. * @param toRemove defines the animation to remove
  34159. * @returns the index where the animation was in the animation list
  34160. */
  34161. removeAnimation(toRemove: Animation): number;
  34162. /**
  34163. * Will stop the animation of the given target
  34164. * @param target - the target
  34165. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34166. * @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)
  34167. */
  34168. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34169. /**
  34170. * Removes the given animation group from this scene.
  34171. * @param toRemove The animation group to remove
  34172. * @returns The index of the removed animation group
  34173. */
  34174. removeAnimationGroup(toRemove: AnimationGroup): number;
  34175. /**
  34176. * Removes the given multi-material from this scene.
  34177. * @param toRemove The multi-material to remove
  34178. * @returns The index of the removed multi-material
  34179. */
  34180. removeMultiMaterial(toRemove: MultiMaterial): number;
  34181. /**
  34182. * Removes the given material from this scene.
  34183. * @param toRemove The material to remove
  34184. * @returns The index of the removed material
  34185. */
  34186. removeMaterial(toRemove: Material): number;
  34187. /**
  34188. * Removes the given action manager from this scene.
  34189. * @param toRemove The action manager to remove
  34190. * @returns The index of the removed action manager
  34191. */
  34192. removeActionManager(toRemove: AbstractActionManager): number;
  34193. /**
  34194. * Removes the given texture from this scene.
  34195. * @param toRemove The texture to remove
  34196. * @returns The index of the removed texture
  34197. */
  34198. removeTexture(toRemove: BaseTexture): number;
  34199. /**
  34200. * Adds the given light to this scene
  34201. * @param newLight The light to add
  34202. */
  34203. addLight(newLight: Light): void;
  34204. /**
  34205. * Sorts the list list based on light priorities
  34206. */
  34207. sortLightsByPriority(): void;
  34208. /**
  34209. * Adds the given camera to this scene
  34210. * @param newCamera The camera to add
  34211. */
  34212. addCamera(newCamera: Camera): void;
  34213. /**
  34214. * Adds the given skeleton to this scene
  34215. * @param newSkeleton The skeleton to add
  34216. */
  34217. addSkeleton(newSkeleton: Skeleton): void;
  34218. /**
  34219. * Adds the given particle system to this scene
  34220. * @param newParticleSystem The particle system to add
  34221. */
  34222. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34223. /**
  34224. * Adds the given animation to this scene
  34225. * @param newAnimation The animation to add
  34226. */
  34227. addAnimation(newAnimation: Animation): void;
  34228. /**
  34229. * Adds the given animation group to this scene.
  34230. * @param newAnimationGroup The animation group to add
  34231. */
  34232. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34233. /**
  34234. * Adds the given multi-material to this scene
  34235. * @param newMultiMaterial The multi-material to add
  34236. */
  34237. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34238. /**
  34239. * Adds the given material to this scene
  34240. * @param newMaterial The material to add
  34241. */
  34242. addMaterial(newMaterial: Material): void;
  34243. /**
  34244. * Adds the given morph target to this scene
  34245. * @param newMorphTargetManager The morph target to add
  34246. */
  34247. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34248. /**
  34249. * Adds the given geometry to this scene
  34250. * @param newGeometry The geometry to add
  34251. */
  34252. addGeometry(newGeometry: Geometry): void;
  34253. /**
  34254. * Adds the given action manager to this scene
  34255. * @param newActionManager The action manager to add
  34256. */
  34257. addActionManager(newActionManager: AbstractActionManager): void;
  34258. /**
  34259. * Adds the given texture to this scene.
  34260. * @param newTexture The texture to add
  34261. */
  34262. addTexture(newTexture: BaseTexture): void;
  34263. /**
  34264. * Switch active camera
  34265. * @param newCamera defines the new active camera
  34266. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34267. */
  34268. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34269. /**
  34270. * sets the active camera of the scene using its ID
  34271. * @param id defines the camera's ID
  34272. * @return the new active camera or null if none found.
  34273. */
  34274. setActiveCameraByID(id: string): Nullable<Camera>;
  34275. /**
  34276. * sets the active camera of the scene using its name
  34277. * @param name defines the camera's name
  34278. * @returns the new active camera or null if none found.
  34279. */
  34280. setActiveCameraByName(name: string): Nullable<Camera>;
  34281. /**
  34282. * get an animation group using its name
  34283. * @param name defines the material's name
  34284. * @return the animation group or null if none found.
  34285. */
  34286. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34287. /**
  34288. * Get a material using its unique id
  34289. * @param uniqueId defines the material's unique id
  34290. * @return the material or null if none found.
  34291. */
  34292. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34293. /**
  34294. * get a material using its id
  34295. * @param id defines the material's ID
  34296. * @return the material or null if none found.
  34297. */
  34298. getMaterialByID(id: string): Nullable<Material>;
  34299. /**
  34300. * Gets a the last added material using a given id
  34301. * @param id defines the material's ID
  34302. * @return the last material with the given id or null if none found.
  34303. */
  34304. getLastMaterialByID(id: string): Nullable<Material>;
  34305. /**
  34306. * Gets a material using its name
  34307. * @param name defines the material's name
  34308. * @return the material or null if none found.
  34309. */
  34310. getMaterialByName(name: string): Nullable<Material>;
  34311. /**
  34312. * Get a texture using its unique id
  34313. * @param uniqueId defines the texture's unique id
  34314. * @return the texture or null if none found.
  34315. */
  34316. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34317. /**
  34318. * Gets a camera using its id
  34319. * @param id defines the id to look for
  34320. * @returns the camera or null if not found
  34321. */
  34322. getCameraByID(id: string): Nullable<Camera>;
  34323. /**
  34324. * Gets a camera using its unique id
  34325. * @param uniqueId defines the unique id to look for
  34326. * @returns the camera or null if not found
  34327. */
  34328. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34329. /**
  34330. * Gets a camera using its name
  34331. * @param name defines the camera's name
  34332. * @return the camera or null if none found.
  34333. */
  34334. getCameraByName(name: string): Nullable<Camera>;
  34335. /**
  34336. * Gets a bone using its id
  34337. * @param id defines the bone's id
  34338. * @return the bone or null if not found
  34339. */
  34340. getBoneByID(id: string): Nullable<Bone>;
  34341. /**
  34342. * Gets a bone using its id
  34343. * @param name defines the bone's name
  34344. * @return the bone or null if not found
  34345. */
  34346. getBoneByName(name: string): Nullable<Bone>;
  34347. /**
  34348. * Gets a light node using its name
  34349. * @param name defines the the light's name
  34350. * @return the light or null if none found.
  34351. */
  34352. getLightByName(name: string): Nullable<Light>;
  34353. /**
  34354. * Gets a light node using its id
  34355. * @param id defines the light's id
  34356. * @return the light or null if none found.
  34357. */
  34358. getLightByID(id: string): Nullable<Light>;
  34359. /**
  34360. * Gets a light node using its scene-generated unique ID
  34361. * @param uniqueId defines the light's unique id
  34362. * @return the light or null if none found.
  34363. */
  34364. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34365. /**
  34366. * Gets a particle system by id
  34367. * @param id defines the particle system id
  34368. * @return the corresponding system or null if none found
  34369. */
  34370. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34371. /**
  34372. * Gets a geometry using its ID
  34373. * @param id defines the geometry's id
  34374. * @return the geometry or null if none found.
  34375. */
  34376. getGeometryByID(id: string): Nullable<Geometry>;
  34377. private _getGeometryByUniqueID;
  34378. /**
  34379. * Add a new geometry to this scene
  34380. * @param geometry defines the geometry to be added to the scene.
  34381. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34382. * @return a boolean defining if the geometry was added or not
  34383. */
  34384. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34385. /**
  34386. * Removes an existing geometry
  34387. * @param geometry defines the geometry to be removed from the scene
  34388. * @return a boolean defining if the geometry was removed or not
  34389. */
  34390. removeGeometry(geometry: Geometry): boolean;
  34391. /**
  34392. * Gets the list of geometries attached to the scene
  34393. * @returns an array of Geometry
  34394. */
  34395. getGeometries(): Geometry[];
  34396. /**
  34397. * Gets the first added mesh found of a given ID
  34398. * @param id defines the id to search for
  34399. * @return the mesh found or null if not found at all
  34400. */
  34401. getMeshByID(id: string): Nullable<AbstractMesh>;
  34402. /**
  34403. * Gets a list of meshes using their id
  34404. * @param id defines the id to search for
  34405. * @returns a list of meshes
  34406. */
  34407. getMeshesByID(id: string): Array<AbstractMesh>;
  34408. /**
  34409. * Gets the first added transform node found of a given ID
  34410. * @param id defines the id to search for
  34411. * @return the found transform node or null if not found at all.
  34412. */
  34413. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34414. /**
  34415. * Gets a transform node with its auto-generated unique id
  34416. * @param uniqueId efines the unique id to search for
  34417. * @return the found transform node or null if not found at all.
  34418. */
  34419. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34420. /**
  34421. * Gets a list of transform nodes using their id
  34422. * @param id defines the id to search for
  34423. * @returns a list of transform nodes
  34424. */
  34425. getTransformNodesByID(id: string): Array<TransformNode>;
  34426. /**
  34427. * Gets a mesh with its auto-generated unique id
  34428. * @param uniqueId defines the unique id to search for
  34429. * @return the found mesh or null if not found at all.
  34430. */
  34431. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34432. /**
  34433. * Gets a the last added mesh using a given id
  34434. * @param id defines the id to search for
  34435. * @return the found mesh or null if not found at all.
  34436. */
  34437. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34438. /**
  34439. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34440. * @param id defines the id to search for
  34441. * @return the found node or null if not found at all
  34442. */
  34443. getLastEntryByID(id: string): Nullable<Node>;
  34444. /**
  34445. * Gets a node (Mesh, Camera, Light) using a given id
  34446. * @param id defines the id to search for
  34447. * @return the found node or null if not found at all
  34448. */
  34449. getNodeByID(id: string): Nullable<Node>;
  34450. /**
  34451. * Gets a node (Mesh, Camera, Light) using a given name
  34452. * @param name defines the name to search for
  34453. * @return the found node or null if not found at all.
  34454. */
  34455. getNodeByName(name: string): Nullable<Node>;
  34456. /**
  34457. * Gets a mesh using a given name
  34458. * @param name defines the name to search for
  34459. * @return the found mesh or null if not found at all.
  34460. */
  34461. getMeshByName(name: string): Nullable<AbstractMesh>;
  34462. /**
  34463. * Gets a transform node using a given name
  34464. * @param name defines the name to search for
  34465. * @return the found transform node or null if not found at all.
  34466. */
  34467. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34468. /**
  34469. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34470. * @param id defines the id to search for
  34471. * @return the found skeleton or null if not found at all.
  34472. */
  34473. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34474. /**
  34475. * Gets a skeleton using a given auto generated unique id
  34476. * @param uniqueId defines the unique id to search for
  34477. * @return the found skeleton or null if not found at all.
  34478. */
  34479. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34480. /**
  34481. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34482. * @param id defines the id to search for
  34483. * @return the found skeleton or null if not found at all.
  34484. */
  34485. getSkeletonById(id: string): Nullable<Skeleton>;
  34486. /**
  34487. * Gets a skeleton using a given name
  34488. * @param name defines the name to search for
  34489. * @return the found skeleton or null if not found at all.
  34490. */
  34491. getSkeletonByName(name: string): Nullable<Skeleton>;
  34492. /**
  34493. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34494. * @param id defines the id to search for
  34495. * @return the found morph target manager or null if not found at all.
  34496. */
  34497. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34498. /**
  34499. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34500. * @param id defines the id to search for
  34501. * @return the found morph target or null if not found at all.
  34502. */
  34503. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34504. /**
  34505. * Gets a boolean indicating if the given mesh is active
  34506. * @param mesh defines the mesh to look for
  34507. * @returns true if the mesh is in the active list
  34508. */
  34509. isActiveMesh(mesh: AbstractMesh): boolean;
  34510. /**
  34511. * Return a unique id as a string which can serve as an identifier for the scene
  34512. */
  34513. readonly uid: string;
  34514. /**
  34515. * Add an externaly attached data from its key.
  34516. * This method call will fail and return false, if such key already exists.
  34517. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34518. * @param key the unique key that identifies the data
  34519. * @param data the data object to associate to the key for this Engine instance
  34520. * @return true if no such key were already present and the data was added successfully, false otherwise
  34521. */
  34522. addExternalData<T>(key: string, data: T): boolean;
  34523. /**
  34524. * Get an externaly attached data from its key
  34525. * @param key the unique key that identifies the data
  34526. * @return the associated data, if present (can be null), or undefined if not present
  34527. */
  34528. getExternalData<T>(key: string): Nullable<T>;
  34529. /**
  34530. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34531. * @param key the unique key that identifies the data
  34532. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34533. * @return the associated data, can be null if the factory returned null.
  34534. */
  34535. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34536. /**
  34537. * Remove an externaly attached data from the Engine instance
  34538. * @param key the unique key that identifies the data
  34539. * @return true if the data was successfully removed, false if it doesn't exist
  34540. */
  34541. removeExternalData(key: string): boolean;
  34542. private _evaluateSubMesh;
  34543. /**
  34544. * Clear the processed materials smart array preventing retention point in material dispose.
  34545. */
  34546. freeProcessedMaterials(): void;
  34547. private _preventFreeActiveMeshesAndRenderingGroups;
  34548. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34549. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34550. * when disposing several meshes in a row or a hierarchy of meshes.
  34551. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34552. */
  34553. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34554. /**
  34555. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34556. */
  34557. freeActiveMeshes(): void;
  34558. /**
  34559. * Clear the info related to rendering groups preventing retention points during dispose.
  34560. */
  34561. freeRenderingGroups(): void;
  34562. /** @hidden */
  34563. _isInIntermediateRendering(): boolean;
  34564. /**
  34565. * Lambda returning the list of potentially active meshes.
  34566. */
  34567. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34568. /**
  34569. * Lambda returning the list of potentially active sub meshes.
  34570. */
  34571. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34572. /**
  34573. * Lambda returning the list of potentially intersecting sub meshes.
  34574. */
  34575. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34576. /**
  34577. * Lambda returning the list of potentially colliding sub meshes.
  34578. */
  34579. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34580. private _activeMeshesFrozen;
  34581. /**
  34582. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34583. * @returns the current scene
  34584. */
  34585. freezeActiveMeshes(): Scene;
  34586. /**
  34587. * Use this function to restart evaluating active meshes on every frame
  34588. * @returns the current scene
  34589. */
  34590. unfreezeActiveMeshes(): Scene;
  34591. private _evaluateActiveMeshes;
  34592. private _activeMesh;
  34593. /**
  34594. * Update the transform matrix to update from the current active camera
  34595. * @param force defines a boolean used to force the update even if cache is up to date
  34596. */
  34597. updateTransformMatrix(force?: boolean): void;
  34598. private _bindFrameBuffer;
  34599. /** @hidden */
  34600. _allowPostProcessClearColor: boolean;
  34601. /** @hidden */
  34602. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34603. private _processSubCameras;
  34604. private _checkIntersections;
  34605. /** @hidden */
  34606. _advancePhysicsEngineStep(step: number): void;
  34607. /**
  34608. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34609. */
  34610. getDeterministicFrameTime: () => number;
  34611. /** @hidden */
  34612. _animate(): void;
  34613. /** Execute all animations (for a frame) */
  34614. animate(): void;
  34615. /**
  34616. * Render the scene
  34617. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34618. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34619. */
  34620. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34621. /**
  34622. * Freeze all materials
  34623. * A frozen material will not be updatable but should be faster to render
  34624. */
  34625. freezeMaterials(): void;
  34626. /**
  34627. * Unfreeze all materials
  34628. * A frozen material will not be updatable but should be faster to render
  34629. */
  34630. unfreezeMaterials(): void;
  34631. /**
  34632. * Releases all held ressources
  34633. */
  34634. dispose(): void;
  34635. /**
  34636. * Gets if the scene is already disposed
  34637. */
  34638. readonly isDisposed: boolean;
  34639. /**
  34640. * Call this function to reduce memory footprint of the scene.
  34641. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34642. */
  34643. clearCachedVertexData(): void;
  34644. /**
  34645. * This function will remove the local cached buffer data from texture.
  34646. * It will save memory but will prevent the texture from being rebuilt
  34647. */
  34648. cleanCachedTextureBuffer(): void;
  34649. /**
  34650. * Get the world extend vectors with an optional filter
  34651. *
  34652. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34653. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34654. */
  34655. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34656. min: Vector3;
  34657. max: Vector3;
  34658. };
  34659. /**
  34660. * Creates a ray that can be used to pick in the scene
  34661. * @param x defines the x coordinate of the origin (on-screen)
  34662. * @param y defines the y coordinate of the origin (on-screen)
  34663. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34664. * @param camera defines the camera to use for the picking
  34665. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34666. * @returns a Ray
  34667. */
  34668. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34669. /**
  34670. * Creates a ray that can be used to pick in the scene
  34671. * @param x defines the x coordinate of the origin (on-screen)
  34672. * @param y defines the y coordinate of the origin (on-screen)
  34673. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34674. * @param result defines the ray where to store the picking ray
  34675. * @param camera defines the camera to use for the picking
  34676. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34677. * @returns the current scene
  34678. */
  34679. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34680. /**
  34681. * Creates a ray that can be used to pick in the scene
  34682. * @param x defines the x coordinate of the origin (on-screen)
  34683. * @param y defines the y coordinate of the origin (on-screen)
  34684. * @param camera defines the camera to use for the picking
  34685. * @returns a Ray
  34686. */
  34687. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34688. /**
  34689. * Creates a ray that can be used to pick in the scene
  34690. * @param x defines the x coordinate of the origin (on-screen)
  34691. * @param y defines the y coordinate of the origin (on-screen)
  34692. * @param result defines the ray where to store the picking ray
  34693. * @param camera defines the camera to use for the picking
  34694. * @returns the current scene
  34695. */
  34696. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34697. /** Launch a ray to try to pick a mesh in the scene
  34698. * @param x position on screen
  34699. * @param y position on screen
  34700. * @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
  34701. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34702. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34703. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34704. * @returns a PickingInfo
  34705. */
  34706. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34707. /** Use the given ray to pick a mesh in the scene
  34708. * @param ray The ray to use to pick meshes
  34709. * @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
  34710. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34711. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34712. * @returns a PickingInfo
  34713. */
  34714. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34715. /**
  34716. * Launch a ray to try to pick a mesh in the scene
  34717. * @param x X position on screen
  34718. * @param y Y position on screen
  34719. * @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
  34720. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34721. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34722. * @returns an array of PickingInfo
  34723. */
  34724. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34725. /**
  34726. * Launch a ray to try to pick a mesh in the scene
  34727. * @param ray Ray to use
  34728. * @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
  34729. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34730. * @returns an array of PickingInfo
  34731. */
  34732. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34733. /**
  34734. * Force the value of meshUnderPointer
  34735. * @param mesh defines the mesh to use
  34736. */
  34737. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34738. /**
  34739. * Gets the mesh under the pointer
  34740. * @returns a Mesh or null if no mesh is under the pointer
  34741. */
  34742. getPointerOverMesh(): Nullable<AbstractMesh>;
  34743. /** @hidden */
  34744. _rebuildGeometries(): void;
  34745. /** @hidden */
  34746. _rebuildTextures(): void;
  34747. private _getByTags;
  34748. /**
  34749. * Get a list of meshes by tags
  34750. * @param tagsQuery defines the tags query to use
  34751. * @param forEach defines a predicate used to filter results
  34752. * @returns an array of Mesh
  34753. */
  34754. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34755. /**
  34756. * Get a list of cameras by tags
  34757. * @param tagsQuery defines the tags query to use
  34758. * @param forEach defines a predicate used to filter results
  34759. * @returns an array of Camera
  34760. */
  34761. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34762. /**
  34763. * Get a list of lights by tags
  34764. * @param tagsQuery defines the tags query to use
  34765. * @param forEach defines a predicate used to filter results
  34766. * @returns an array of Light
  34767. */
  34768. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34769. /**
  34770. * Get a list of materials by tags
  34771. * @param tagsQuery defines the tags query to use
  34772. * @param forEach defines a predicate used to filter results
  34773. * @returns an array of Material
  34774. */
  34775. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34776. /**
  34777. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34778. * This allowed control for front to back rendering or reversly depending of the special needs.
  34779. *
  34780. * @param renderingGroupId The rendering group id corresponding to its index
  34781. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34782. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34783. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34784. */
  34785. 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;
  34786. /**
  34787. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34788. *
  34789. * @param renderingGroupId The rendering group id corresponding to its index
  34790. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34791. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34792. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34793. */
  34794. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34795. /**
  34796. * Gets the current auto clear configuration for one rendering group of the rendering
  34797. * manager.
  34798. * @param index the rendering group index to get the information for
  34799. * @returns The auto clear setup for the requested rendering group
  34800. */
  34801. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34802. private _blockMaterialDirtyMechanism;
  34803. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34804. blockMaterialDirtyMechanism: boolean;
  34805. /**
  34806. * Will flag all materials as dirty to trigger new shader compilation
  34807. * @param flag defines the flag used to specify which material part must be marked as dirty
  34808. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34809. */
  34810. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34811. /** @hidden */
  34812. _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;
  34813. /** @hidden */
  34814. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34815. }
  34816. }
  34817. declare module BABYLON {
  34818. /**
  34819. * Set of assets to keep when moving a scene into an asset container.
  34820. */
  34821. export class KeepAssets extends AbstractScene {
  34822. }
  34823. /**
  34824. * Container with a set of assets that can be added or removed from a scene.
  34825. */
  34826. export class AssetContainer extends AbstractScene {
  34827. /**
  34828. * The scene the AssetContainer belongs to.
  34829. */
  34830. scene: Scene;
  34831. /**
  34832. * Instantiates an AssetContainer.
  34833. * @param scene The scene the AssetContainer belongs to.
  34834. */
  34835. constructor(scene: Scene);
  34836. /**
  34837. * Adds all the assets from the container to the scene.
  34838. */
  34839. addAllToScene(): void;
  34840. /**
  34841. * Removes all the assets in the container from the scene
  34842. */
  34843. removeAllFromScene(): void;
  34844. /**
  34845. * Disposes all the assets in the container
  34846. */
  34847. dispose(): void;
  34848. private _moveAssets;
  34849. /**
  34850. * Removes all the assets contained in the scene and adds them to the container.
  34851. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34852. */
  34853. moveAllFromScene(keepAssets?: KeepAssets): void;
  34854. /**
  34855. * 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.
  34856. * @returns the root mesh
  34857. */
  34858. createRootMesh(): Mesh;
  34859. }
  34860. }
  34861. declare module BABYLON {
  34862. /**
  34863. * Defines how the parser contract is defined.
  34864. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34865. */
  34866. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34867. /**
  34868. * Defines how the individual parser contract is defined.
  34869. * These parser can parse an individual asset
  34870. */
  34871. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34872. /**
  34873. * Base class of the scene acting as a container for the different elements composing a scene.
  34874. * This class is dynamically extended by the different components of the scene increasing
  34875. * flexibility and reducing coupling
  34876. */
  34877. export abstract class AbstractScene {
  34878. /**
  34879. * Stores the list of available parsers in the application.
  34880. */
  34881. private static _BabylonFileParsers;
  34882. /**
  34883. * Stores the list of available individual parsers in the application.
  34884. */
  34885. private static _IndividualBabylonFileParsers;
  34886. /**
  34887. * Adds a parser in the list of available ones
  34888. * @param name Defines the name of the parser
  34889. * @param parser Defines the parser to add
  34890. */
  34891. static AddParser(name: string, parser: BabylonFileParser): void;
  34892. /**
  34893. * Gets a general parser from the list of avaialble ones
  34894. * @param name Defines the name of the parser
  34895. * @returns the requested parser or null
  34896. */
  34897. static GetParser(name: string): Nullable<BabylonFileParser>;
  34898. /**
  34899. * Adds n individual parser in the list of available ones
  34900. * @param name Defines the name of the parser
  34901. * @param parser Defines the parser to add
  34902. */
  34903. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34904. /**
  34905. * Gets an individual parser from the list of avaialble ones
  34906. * @param name Defines the name of the parser
  34907. * @returns the requested parser or null
  34908. */
  34909. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34910. /**
  34911. * Parser json data and populate both a scene and its associated container object
  34912. * @param jsonData Defines the data to parse
  34913. * @param scene Defines the scene to parse the data for
  34914. * @param container Defines the container attached to the parsing sequence
  34915. * @param rootUrl Defines the root url of the data
  34916. */
  34917. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34918. /**
  34919. * Gets the list of root nodes (ie. nodes with no parent)
  34920. */
  34921. rootNodes: Node[];
  34922. /** All of the cameras added to this scene
  34923. * @see http://doc.babylonjs.com/babylon101/cameras
  34924. */
  34925. cameras: Camera[];
  34926. /**
  34927. * All of the lights added to this scene
  34928. * @see http://doc.babylonjs.com/babylon101/lights
  34929. */
  34930. lights: Light[];
  34931. /**
  34932. * All of the (abstract) meshes added to this scene
  34933. */
  34934. meshes: AbstractMesh[];
  34935. /**
  34936. * The list of skeletons added to the scene
  34937. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34938. */
  34939. skeletons: Skeleton[];
  34940. /**
  34941. * All of the particle systems added to this scene
  34942. * @see http://doc.babylonjs.com/babylon101/particles
  34943. */
  34944. particleSystems: IParticleSystem[];
  34945. /**
  34946. * Gets a list of Animations associated with the scene
  34947. */
  34948. animations: Animation[];
  34949. /**
  34950. * All of the animation groups added to this scene
  34951. * @see http://doc.babylonjs.com/how_to/group
  34952. */
  34953. animationGroups: AnimationGroup[];
  34954. /**
  34955. * All of the multi-materials added to this scene
  34956. * @see http://doc.babylonjs.com/how_to/multi_materials
  34957. */
  34958. multiMaterials: MultiMaterial[];
  34959. /**
  34960. * All of the materials added to this scene
  34961. * In the context of a Scene, it is not supposed to be modified manually.
  34962. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34963. * Note also that the order of the Material wihin the array is not significant and might change.
  34964. * @see http://doc.babylonjs.com/babylon101/materials
  34965. */
  34966. materials: Material[];
  34967. /**
  34968. * The list of morph target managers added to the scene
  34969. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34970. */
  34971. morphTargetManagers: MorphTargetManager[];
  34972. /**
  34973. * The list of geometries used in the scene.
  34974. */
  34975. geometries: Geometry[];
  34976. /**
  34977. * All of the tranform nodes added to this scene
  34978. * In the context of a Scene, it is not supposed to be modified manually.
  34979. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34980. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34981. * @see http://doc.babylonjs.com/how_to/transformnode
  34982. */
  34983. transformNodes: TransformNode[];
  34984. /**
  34985. * ActionManagers available on the scene.
  34986. */
  34987. actionManagers: AbstractActionManager[];
  34988. /**
  34989. * Textures to keep.
  34990. */
  34991. textures: BaseTexture[];
  34992. /**
  34993. * Environment texture for the scene
  34994. */
  34995. environmentTexture: Nullable<BaseTexture>;
  34996. }
  34997. }
  34998. declare module BABYLON {
  34999. /**
  35000. * Interface used to define options for Sound class
  35001. */
  35002. export interface ISoundOptions {
  35003. /**
  35004. * Does the sound autoplay once loaded.
  35005. */
  35006. autoplay?: boolean;
  35007. /**
  35008. * Does the sound loop after it finishes playing once.
  35009. */
  35010. loop?: boolean;
  35011. /**
  35012. * Sound's volume
  35013. */
  35014. volume?: number;
  35015. /**
  35016. * Is it a spatial sound?
  35017. */
  35018. spatialSound?: boolean;
  35019. /**
  35020. * Maximum distance to hear that sound
  35021. */
  35022. maxDistance?: number;
  35023. /**
  35024. * Uses user defined attenuation function
  35025. */
  35026. useCustomAttenuation?: boolean;
  35027. /**
  35028. * Define the roll off factor of spatial sounds.
  35029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35030. */
  35031. rolloffFactor?: number;
  35032. /**
  35033. * Define the reference distance the sound should be heard perfectly.
  35034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35035. */
  35036. refDistance?: number;
  35037. /**
  35038. * Define the distance attenuation model the sound will follow.
  35039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35040. */
  35041. distanceModel?: string;
  35042. /**
  35043. * Defines the playback speed (1 by default)
  35044. */
  35045. playbackRate?: number;
  35046. /**
  35047. * Defines if the sound is from a streaming source
  35048. */
  35049. streaming?: boolean;
  35050. /**
  35051. * Defines an optional length (in seconds) inside the sound file
  35052. */
  35053. length?: number;
  35054. /**
  35055. * Defines an optional offset (in seconds) inside the sound file
  35056. */
  35057. offset?: number;
  35058. /**
  35059. * If true, URLs will not be required to state the audio file codec to use.
  35060. */
  35061. skipCodecCheck?: boolean;
  35062. }
  35063. /**
  35064. * Defines a sound that can be played in the application.
  35065. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35067. */
  35068. export class Sound {
  35069. /**
  35070. * The name of the sound in the scene.
  35071. */
  35072. name: string;
  35073. /**
  35074. * Does the sound autoplay once loaded.
  35075. */
  35076. autoplay: boolean;
  35077. /**
  35078. * Does the sound loop after it finishes playing once.
  35079. */
  35080. loop: boolean;
  35081. /**
  35082. * Does the sound use a custom attenuation curve to simulate the falloff
  35083. * happening when the source gets further away from the camera.
  35084. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35085. */
  35086. useCustomAttenuation: boolean;
  35087. /**
  35088. * The sound track id this sound belongs to.
  35089. */
  35090. soundTrackId: number;
  35091. /**
  35092. * Is this sound currently played.
  35093. */
  35094. isPlaying: boolean;
  35095. /**
  35096. * Is this sound currently paused.
  35097. */
  35098. isPaused: boolean;
  35099. /**
  35100. * Does this sound enables spatial sound.
  35101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35102. */
  35103. spatialSound: boolean;
  35104. /**
  35105. * Define the reference distance the sound should be heard perfectly.
  35106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35107. */
  35108. refDistance: number;
  35109. /**
  35110. * Define the roll off factor of spatial sounds.
  35111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35112. */
  35113. rolloffFactor: number;
  35114. /**
  35115. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35117. */
  35118. maxDistance: number;
  35119. /**
  35120. * Define the distance attenuation model the sound will follow.
  35121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35122. */
  35123. distanceModel: string;
  35124. /**
  35125. * @hidden
  35126. * Back Compat
  35127. **/
  35128. onended: () => any;
  35129. /**
  35130. * Observable event when the current playing sound finishes.
  35131. */
  35132. onEndedObservable: Observable<Sound>;
  35133. private _panningModel;
  35134. private _playbackRate;
  35135. private _streaming;
  35136. private _startTime;
  35137. private _startOffset;
  35138. private _position;
  35139. /** @hidden */
  35140. _positionInEmitterSpace: boolean;
  35141. private _localDirection;
  35142. private _volume;
  35143. private _isReadyToPlay;
  35144. private _isDirectional;
  35145. private _readyToPlayCallback;
  35146. private _audioBuffer;
  35147. private _soundSource;
  35148. private _streamingSource;
  35149. private _soundPanner;
  35150. private _soundGain;
  35151. private _inputAudioNode;
  35152. private _outputAudioNode;
  35153. private _coneInnerAngle;
  35154. private _coneOuterAngle;
  35155. private _coneOuterGain;
  35156. private _scene;
  35157. private _connectedTransformNode;
  35158. private _customAttenuationFunction;
  35159. private _registerFunc;
  35160. private _isOutputConnected;
  35161. private _htmlAudioElement;
  35162. private _urlType;
  35163. private _length?;
  35164. private _offset?;
  35165. /** @hidden */
  35166. static _SceneComponentInitialization: (scene: Scene) => void;
  35167. /**
  35168. * Create a sound and attach it to a scene
  35169. * @param name Name of your sound
  35170. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35171. * @param scene defines the scene the sound belongs to
  35172. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35173. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35174. */
  35175. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35176. /**
  35177. * Release the sound and its associated resources
  35178. */
  35179. dispose(): void;
  35180. /**
  35181. * Gets if the sounds is ready to be played or not.
  35182. * @returns true if ready, otherwise false
  35183. */
  35184. isReady(): boolean;
  35185. private _soundLoaded;
  35186. /**
  35187. * Sets the data of the sound from an audiobuffer
  35188. * @param audioBuffer The audioBuffer containing the data
  35189. */
  35190. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35191. /**
  35192. * Updates the current sounds options such as maxdistance, loop...
  35193. * @param options A JSON object containing values named as the object properties
  35194. */
  35195. updateOptions(options: ISoundOptions): void;
  35196. private _createSpatialParameters;
  35197. private _updateSpatialParameters;
  35198. /**
  35199. * Switch the panning model to HRTF:
  35200. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35202. */
  35203. switchPanningModelToHRTF(): void;
  35204. /**
  35205. * Switch the panning model to Equal Power:
  35206. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35208. */
  35209. switchPanningModelToEqualPower(): void;
  35210. private _switchPanningModel;
  35211. /**
  35212. * Connect this sound to a sound track audio node like gain...
  35213. * @param soundTrackAudioNode the sound track audio node to connect to
  35214. */
  35215. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35216. /**
  35217. * Transform this sound into a directional source
  35218. * @param coneInnerAngle Size of the inner cone in degree
  35219. * @param coneOuterAngle Size of the outer cone in degree
  35220. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35221. */
  35222. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35223. /**
  35224. * Gets or sets the inner angle for the directional cone.
  35225. */
  35226. /**
  35227. * Gets or sets the inner angle for the directional cone.
  35228. */
  35229. directionalConeInnerAngle: number;
  35230. /**
  35231. * Gets or sets the outer angle for the directional cone.
  35232. */
  35233. /**
  35234. * Gets or sets the outer angle for the directional cone.
  35235. */
  35236. directionalConeOuterAngle: number;
  35237. /**
  35238. * Sets the position of the emitter if spatial sound is enabled
  35239. * @param newPosition Defines the new posisiton
  35240. */
  35241. setPosition(newPosition: Vector3): void;
  35242. /**
  35243. * Sets the local direction of the emitter if spatial sound is enabled
  35244. * @param newLocalDirection Defines the new local direction
  35245. */
  35246. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35247. private _updateDirection;
  35248. /** @hidden */
  35249. updateDistanceFromListener(): void;
  35250. /**
  35251. * Sets a new custom attenuation function for the sound.
  35252. * @param callback Defines the function used for the attenuation
  35253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35254. */
  35255. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35256. /**
  35257. * Play the sound
  35258. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35259. * @param offset (optional) Start the sound at a specific time in seconds
  35260. * @param length (optional) Sound duration (in seconds)
  35261. */
  35262. play(time?: number, offset?: number, length?: number): void;
  35263. private _onended;
  35264. /**
  35265. * Stop the sound
  35266. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35267. */
  35268. stop(time?: number): void;
  35269. /**
  35270. * Put the sound in pause
  35271. */
  35272. pause(): void;
  35273. /**
  35274. * Sets a dedicated volume for this sounds
  35275. * @param newVolume Define the new volume of the sound
  35276. * @param time Define time for gradual change to new volume
  35277. */
  35278. setVolume(newVolume: number, time?: number): void;
  35279. /**
  35280. * Set the sound play back rate
  35281. * @param newPlaybackRate Define the playback rate the sound should be played at
  35282. */
  35283. setPlaybackRate(newPlaybackRate: number): void;
  35284. /**
  35285. * Gets the volume of the sound.
  35286. * @returns the volume of the sound
  35287. */
  35288. getVolume(): number;
  35289. /**
  35290. * Attach the sound to a dedicated mesh
  35291. * @param transformNode The transform node to connect the sound with
  35292. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35293. */
  35294. attachToMesh(transformNode: TransformNode): void;
  35295. /**
  35296. * Detach the sound from the previously attached mesh
  35297. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35298. */
  35299. detachFromMesh(): void;
  35300. private _onRegisterAfterWorldMatrixUpdate;
  35301. /**
  35302. * Clone the current sound in the scene.
  35303. * @returns the new sound clone
  35304. */
  35305. clone(): Nullable<Sound>;
  35306. /**
  35307. * Gets the current underlying audio buffer containing the data
  35308. * @returns the audio buffer
  35309. */
  35310. getAudioBuffer(): Nullable<AudioBuffer>;
  35311. /**
  35312. * Serializes the Sound in a JSON representation
  35313. * @returns the JSON representation of the sound
  35314. */
  35315. serialize(): any;
  35316. /**
  35317. * Parse a JSON representation of a sound to innstantiate in a given scene
  35318. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35319. * @param scene Define the scene the new parsed sound should be created in
  35320. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35321. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35322. * @returns the newly parsed sound
  35323. */
  35324. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35325. }
  35326. }
  35327. declare module BABYLON {
  35328. /**
  35329. * This defines an action helpful to play a defined sound on a triggered action.
  35330. */
  35331. export class PlaySoundAction extends Action {
  35332. private _sound;
  35333. /**
  35334. * Instantiate the action
  35335. * @param triggerOptions defines the trigger options
  35336. * @param sound defines the sound to play
  35337. * @param condition defines the trigger related conditions
  35338. */
  35339. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35340. /** @hidden */
  35341. _prepare(): void;
  35342. /**
  35343. * Execute the action and play the sound.
  35344. */
  35345. execute(): void;
  35346. /**
  35347. * Serializes the actions and its related information.
  35348. * @param parent defines the object to serialize in
  35349. * @returns the serialized object
  35350. */
  35351. serialize(parent: any): any;
  35352. }
  35353. /**
  35354. * This defines an action helpful to stop a defined sound on a triggered action.
  35355. */
  35356. export class StopSoundAction extends Action {
  35357. private _sound;
  35358. /**
  35359. * Instantiate the action
  35360. * @param triggerOptions defines the trigger options
  35361. * @param sound defines the sound to stop
  35362. * @param condition defines the trigger related conditions
  35363. */
  35364. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35365. /** @hidden */
  35366. _prepare(): void;
  35367. /**
  35368. * Execute the action and stop the sound.
  35369. */
  35370. execute(): void;
  35371. /**
  35372. * Serializes the actions and its related information.
  35373. * @param parent defines the object to serialize in
  35374. * @returns the serialized object
  35375. */
  35376. serialize(parent: any): any;
  35377. }
  35378. }
  35379. declare module BABYLON {
  35380. /**
  35381. * This defines an action responsible to change the value of a property
  35382. * by interpolating between its current value and the newly set one once triggered.
  35383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35384. */
  35385. export class InterpolateValueAction extends Action {
  35386. /**
  35387. * Defines the path of the property where the value should be interpolated
  35388. */
  35389. propertyPath: string;
  35390. /**
  35391. * Defines the target value at the end of the interpolation.
  35392. */
  35393. value: any;
  35394. /**
  35395. * Defines the time it will take for the property to interpolate to the value.
  35396. */
  35397. duration: number;
  35398. /**
  35399. * Defines if the other scene animations should be stopped when the action has been triggered
  35400. */
  35401. stopOtherAnimations?: boolean;
  35402. /**
  35403. * Defines a callback raised once the interpolation animation has been done.
  35404. */
  35405. onInterpolationDone?: () => void;
  35406. /**
  35407. * Observable triggered once the interpolation animation has been done.
  35408. */
  35409. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35410. private _target;
  35411. private _effectiveTarget;
  35412. private _property;
  35413. /**
  35414. * Instantiate the action
  35415. * @param triggerOptions defines the trigger options
  35416. * @param target defines the object containing the value to interpolate
  35417. * @param propertyPath defines the path to the property in the target object
  35418. * @param value defines the target value at the end of the interpolation
  35419. * @param duration deines the time it will take for the property to interpolate to the value.
  35420. * @param condition defines the trigger related conditions
  35421. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35422. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35423. */
  35424. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35425. /** @hidden */
  35426. _prepare(): void;
  35427. /**
  35428. * Execute the action starts the value interpolation.
  35429. */
  35430. execute(): void;
  35431. /**
  35432. * Serializes the actions and its related information.
  35433. * @param parent defines the object to serialize in
  35434. * @returns the serialized object
  35435. */
  35436. serialize(parent: any): any;
  35437. }
  35438. }
  35439. declare module BABYLON {
  35440. /**
  35441. * Options allowed during the creation of a sound track.
  35442. */
  35443. export interface ISoundTrackOptions {
  35444. /**
  35445. * The volume the sound track should take during creation
  35446. */
  35447. volume?: number;
  35448. /**
  35449. * Define if the sound track is the main sound track of the scene
  35450. */
  35451. mainTrack?: boolean;
  35452. }
  35453. /**
  35454. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35455. * It will be also used in a future release to apply effects on a specific track.
  35456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35457. */
  35458. export class SoundTrack {
  35459. /**
  35460. * The unique identifier of the sound track in the scene.
  35461. */
  35462. id: number;
  35463. /**
  35464. * The list of sounds included in the sound track.
  35465. */
  35466. soundCollection: Array<Sound>;
  35467. private _outputAudioNode;
  35468. private _scene;
  35469. private _isMainTrack;
  35470. private _connectedAnalyser;
  35471. private _options;
  35472. private _isInitialized;
  35473. /**
  35474. * Creates a new sound track.
  35475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35476. * @param scene Define the scene the sound track belongs to
  35477. * @param options
  35478. */
  35479. constructor(scene: Scene, options?: ISoundTrackOptions);
  35480. private _initializeSoundTrackAudioGraph;
  35481. /**
  35482. * Release the sound track and its associated resources
  35483. */
  35484. dispose(): void;
  35485. /**
  35486. * Adds a sound to this sound track
  35487. * @param sound define the cound to add
  35488. * @ignoreNaming
  35489. */
  35490. AddSound(sound: Sound): void;
  35491. /**
  35492. * Removes a sound to this sound track
  35493. * @param sound define the cound to remove
  35494. * @ignoreNaming
  35495. */
  35496. RemoveSound(sound: Sound): void;
  35497. /**
  35498. * Set a global volume for the full sound track.
  35499. * @param newVolume Define the new volume of the sound track
  35500. */
  35501. setVolume(newVolume: number): void;
  35502. /**
  35503. * Switch the panning model to HRTF:
  35504. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35505. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35506. */
  35507. switchPanningModelToHRTF(): void;
  35508. /**
  35509. * Switch the panning model to Equal Power:
  35510. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35512. */
  35513. switchPanningModelToEqualPower(): void;
  35514. /**
  35515. * Connect the sound track to an audio analyser allowing some amazing
  35516. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35518. * @param analyser The analyser to connect to the engine
  35519. */
  35520. connectToAnalyser(analyser: Analyser): void;
  35521. }
  35522. }
  35523. declare module BABYLON {
  35524. interface AbstractScene {
  35525. /**
  35526. * The list of sounds used in the scene.
  35527. */
  35528. sounds: Nullable<Array<Sound>>;
  35529. }
  35530. interface Scene {
  35531. /**
  35532. * @hidden
  35533. * Backing field
  35534. */
  35535. _mainSoundTrack: SoundTrack;
  35536. /**
  35537. * The main sound track played by the scene.
  35538. * It cotains your primary collection of sounds.
  35539. */
  35540. mainSoundTrack: SoundTrack;
  35541. /**
  35542. * The list of sound tracks added to the scene
  35543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35544. */
  35545. soundTracks: Nullable<Array<SoundTrack>>;
  35546. /**
  35547. * Gets a sound using a given name
  35548. * @param name defines the name to search for
  35549. * @return the found sound or null if not found at all.
  35550. */
  35551. getSoundByName(name: string): Nullable<Sound>;
  35552. /**
  35553. * Gets or sets if audio support is enabled
  35554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35555. */
  35556. audioEnabled: boolean;
  35557. /**
  35558. * Gets or sets if audio will be output to headphones
  35559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35560. */
  35561. headphone: boolean;
  35562. /**
  35563. * Gets or sets custom audio listener position provider
  35564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35565. */
  35566. audioListenerPositionProvider: Nullable<() => Vector3>;
  35567. }
  35568. /**
  35569. * Defines the sound scene component responsible to manage any sounds
  35570. * in a given scene.
  35571. */
  35572. export class AudioSceneComponent implements ISceneSerializableComponent {
  35573. /**
  35574. * The component name helpfull to identify the component in the list of scene components.
  35575. */
  35576. readonly name: string;
  35577. /**
  35578. * The scene the component belongs to.
  35579. */
  35580. scene: Scene;
  35581. private _audioEnabled;
  35582. /**
  35583. * Gets whether audio is enabled or not.
  35584. * Please use related enable/disable method to switch state.
  35585. */
  35586. readonly audioEnabled: boolean;
  35587. private _headphone;
  35588. /**
  35589. * Gets whether audio is outputing to headphone or not.
  35590. * Please use the according Switch methods to change output.
  35591. */
  35592. readonly headphone: boolean;
  35593. private _audioListenerPositionProvider;
  35594. /**
  35595. * Gets the current audio listener position provider
  35596. */
  35597. /**
  35598. * Sets a custom listener position for all sounds in the scene
  35599. * By default, this is the position of the first active camera
  35600. */
  35601. audioListenerPositionProvider: Nullable<() => Vector3>;
  35602. /**
  35603. * Creates a new instance of the component for the given scene
  35604. * @param scene Defines the scene to register the component in
  35605. */
  35606. constructor(scene: Scene);
  35607. /**
  35608. * Registers the component in a given scene
  35609. */
  35610. register(): void;
  35611. /**
  35612. * Rebuilds the elements related to this component in case of
  35613. * context lost for instance.
  35614. */
  35615. rebuild(): void;
  35616. /**
  35617. * Serializes the component data to the specified json object
  35618. * @param serializationObject The object to serialize to
  35619. */
  35620. serialize(serializationObject: any): void;
  35621. /**
  35622. * Adds all the elements from the container to the scene
  35623. * @param container the container holding the elements
  35624. */
  35625. addFromContainer(container: AbstractScene): void;
  35626. /**
  35627. * Removes all the elements in the container from the scene
  35628. * @param container contains the elements to remove
  35629. * @param dispose if the removed element should be disposed (default: false)
  35630. */
  35631. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35632. /**
  35633. * Disposes the component and the associated ressources.
  35634. */
  35635. dispose(): void;
  35636. /**
  35637. * Disables audio in the associated scene.
  35638. */
  35639. disableAudio(): void;
  35640. /**
  35641. * Enables audio in the associated scene.
  35642. */
  35643. enableAudio(): void;
  35644. /**
  35645. * Switch audio to headphone output.
  35646. */
  35647. switchAudioModeForHeadphones(): void;
  35648. /**
  35649. * Switch audio to normal speakers.
  35650. */
  35651. switchAudioModeForNormalSpeakers(): void;
  35652. private _afterRender;
  35653. }
  35654. }
  35655. declare module BABYLON {
  35656. /**
  35657. * Wraps one or more Sound objects and selects one with random weight for playback.
  35658. */
  35659. export class WeightedSound {
  35660. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35661. loop: boolean;
  35662. private _coneInnerAngle;
  35663. private _coneOuterAngle;
  35664. private _volume;
  35665. /** A Sound is currently playing. */
  35666. isPlaying: boolean;
  35667. /** A Sound is currently paused. */
  35668. isPaused: boolean;
  35669. private _sounds;
  35670. private _weights;
  35671. private _currentIndex?;
  35672. /**
  35673. * Creates a new WeightedSound from the list of sounds given.
  35674. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35675. * @param sounds Array of Sounds that will be selected from.
  35676. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35677. */
  35678. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35679. /**
  35680. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35681. */
  35682. /**
  35683. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35684. */
  35685. directionalConeInnerAngle: number;
  35686. /**
  35687. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35688. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35689. */
  35690. /**
  35691. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35692. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35693. */
  35694. directionalConeOuterAngle: number;
  35695. /**
  35696. * Playback volume.
  35697. */
  35698. /**
  35699. * Playback volume.
  35700. */
  35701. volume: number;
  35702. private _onended;
  35703. /**
  35704. * Suspend playback
  35705. */
  35706. pause(): void;
  35707. /**
  35708. * Stop playback
  35709. */
  35710. stop(): void;
  35711. /**
  35712. * Start playback.
  35713. * @param startOffset Position the clip head at a specific time in seconds.
  35714. */
  35715. play(startOffset?: number): void;
  35716. }
  35717. }
  35718. declare module BABYLON {
  35719. /**
  35720. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35721. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35722. */
  35723. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35724. /**
  35725. * Gets the name of the behavior.
  35726. */
  35727. readonly name: string;
  35728. /**
  35729. * The easing function used by animations
  35730. */
  35731. static EasingFunction: BackEase;
  35732. /**
  35733. * The easing mode used by animations
  35734. */
  35735. static EasingMode: number;
  35736. /**
  35737. * The duration of the animation, in milliseconds
  35738. */
  35739. transitionDuration: number;
  35740. /**
  35741. * Length of the distance animated by the transition when lower radius is reached
  35742. */
  35743. lowerRadiusTransitionRange: number;
  35744. /**
  35745. * Length of the distance animated by the transition when upper radius is reached
  35746. */
  35747. upperRadiusTransitionRange: number;
  35748. private _autoTransitionRange;
  35749. /**
  35750. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35751. */
  35752. /**
  35753. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35754. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35755. */
  35756. autoTransitionRange: boolean;
  35757. private _attachedCamera;
  35758. private _onAfterCheckInputsObserver;
  35759. private _onMeshTargetChangedObserver;
  35760. /**
  35761. * Initializes the behavior.
  35762. */
  35763. init(): void;
  35764. /**
  35765. * Attaches the behavior to its arc rotate camera.
  35766. * @param camera Defines the camera to attach the behavior to
  35767. */
  35768. attach(camera: ArcRotateCamera): void;
  35769. /**
  35770. * Detaches the behavior from its current arc rotate camera.
  35771. */
  35772. detach(): void;
  35773. private _radiusIsAnimating;
  35774. private _radiusBounceTransition;
  35775. private _animatables;
  35776. private _cachedWheelPrecision;
  35777. /**
  35778. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35779. * @param radiusLimit The limit to check against.
  35780. * @return Bool to indicate if at limit.
  35781. */
  35782. private _isRadiusAtLimit;
  35783. /**
  35784. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35785. * @param radiusDelta The delta by which to animate to. Can be negative.
  35786. */
  35787. private _applyBoundRadiusAnimation;
  35788. /**
  35789. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35790. */
  35791. protected _clearAnimationLocks(): void;
  35792. /**
  35793. * Stops and removes all animations that have been applied to the camera
  35794. */
  35795. stopAllAnimations(): void;
  35796. }
  35797. }
  35798. declare module BABYLON {
  35799. /**
  35800. * 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.
  35801. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35802. */
  35803. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35804. /**
  35805. * Gets the name of the behavior.
  35806. */
  35807. readonly name: string;
  35808. private _mode;
  35809. private _radiusScale;
  35810. private _positionScale;
  35811. private _defaultElevation;
  35812. private _elevationReturnTime;
  35813. private _elevationReturnWaitTime;
  35814. private _zoomStopsAnimation;
  35815. private _framingTime;
  35816. /**
  35817. * The easing function used by animations
  35818. */
  35819. static EasingFunction: ExponentialEase;
  35820. /**
  35821. * The easing mode used by animations
  35822. */
  35823. static EasingMode: number;
  35824. /**
  35825. * Sets the current mode used by the behavior
  35826. */
  35827. /**
  35828. * Gets current mode used by the behavior.
  35829. */
  35830. mode: number;
  35831. /**
  35832. * Sets the scale applied to the radius (1 by default)
  35833. */
  35834. /**
  35835. * Gets the scale applied to the radius
  35836. */
  35837. radiusScale: number;
  35838. /**
  35839. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35840. */
  35841. /**
  35842. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35843. */
  35844. positionScale: number;
  35845. /**
  35846. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35847. * behaviour is triggered, in radians.
  35848. */
  35849. /**
  35850. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35851. * behaviour is triggered, in radians.
  35852. */
  35853. defaultElevation: number;
  35854. /**
  35855. * Sets the time (in milliseconds) taken to return to the default beta position.
  35856. * Negative value indicates camera should not return to default.
  35857. */
  35858. /**
  35859. * Gets the time (in milliseconds) taken to return to the default beta position.
  35860. * Negative value indicates camera should not return to default.
  35861. */
  35862. elevationReturnTime: number;
  35863. /**
  35864. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35865. */
  35866. /**
  35867. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35868. */
  35869. elevationReturnWaitTime: number;
  35870. /**
  35871. * Sets the flag that indicates if user zooming should stop animation.
  35872. */
  35873. /**
  35874. * Gets the flag that indicates if user zooming should stop animation.
  35875. */
  35876. zoomStopsAnimation: boolean;
  35877. /**
  35878. * Sets the transition time when framing the mesh, in milliseconds
  35879. */
  35880. /**
  35881. * Gets the transition time when framing the mesh, in milliseconds
  35882. */
  35883. framingTime: number;
  35884. /**
  35885. * Define if the behavior should automatically change the configured
  35886. * camera limits and sensibilities.
  35887. */
  35888. autoCorrectCameraLimitsAndSensibility: boolean;
  35889. private _onPrePointerObservableObserver;
  35890. private _onAfterCheckInputsObserver;
  35891. private _onMeshTargetChangedObserver;
  35892. private _attachedCamera;
  35893. private _isPointerDown;
  35894. private _lastInteractionTime;
  35895. /**
  35896. * Initializes the behavior.
  35897. */
  35898. init(): void;
  35899. /**
  35900. * Attaches the behavior to its arc rotate camera.
  35901. * @param camera Defines the camera to attach the behavior to
  35902. */
  35903. attach(camera: ArcRotateCamera): void;
  35904. /**
  35905. * Detaches the behavior from its current arc rotate camera.
  35906. */
  35907. detach(): void;
  35908. private _animatables;
  35909. private _betaIsAnimating;
  35910. private _betaTransition;
  35911. private _radiusTransition;
  35912. private _vectorTransition;
  35913. /**
  35914. * Targets the given mesh and updates zoom level accordingly.
  35915. * @param mesh The mesh to target.
  35916. * @param radius Optional. If a cached radius position already exists, overrides default.
  35917. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35918. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35919. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35920. */
  35921. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35922. /**
  35923. * Targets the given mesh with its children and updates zoom level accordingly.
  35924. * @param mesh The mesh to target.
  35925. * @param radius Optional. If a cached radius position already exists, overrides default.
  35926. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35927. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35928. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35929. */
  35930. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35931. /**
  35932. * Targets the given meshes with their children and updates zoom level accordingly.
  35933. * @param meshes The mesh to target.
  35934. * @param radius Optional. If a cached radius position already exists, overrides default.
  35935. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35936. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35937. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35938. */
  35939. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35940. /**
  35941. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35942. * @param minimumWorld Determines the smaller position of the bounding box extend
  35943. * @param maximumWorld Determines the bigger position of the bounding box extend
  35944. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35945. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35946. */
  35947. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35948. /**
  35949. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35950. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35951. * frustum width.
  35952. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35953. * to fully enclose the mesh in the viewing frustum.
  35954. */
  35955. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35956. /**
  35957. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35958. * is automatically returned to its default position (expected to be above ground plane).
  35959. */
  35960. private _maintainCameraAboveGround;
  35961. /**
  35962. * Returns the frustum slope based on the canvas ratio and camera FOV
  35963. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35964. */
  35965. private _getFrustumSlope;
  35966. /**
  35967. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35968. */
  35969. private _clearAnimationLocks;
  35970. /**
  35971. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35972. */
  35973. private _applyUserInteraction;
  35974. /**
  35975. * Stops and removes all animations that have been applied to the camera
  35976. */
  35977. stopAllAnimations(): void;
  35978. /**
  35979. * Gets a value indicating if the user is moving the camera
  35980. */
  35981. readonly isUserIsMoving: boolean;
  35982. /**
  35983. * The camera can move all the way towards the mesh.
  35984. */
  35985. static IgnoreBoundsSizeMode: number;
  35986. /**
  35987. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35988. */
  35989. static FitFrustumSidesMode: number;
  35990. }
  35991. }
  35992. declare module BABYLON {
  35993. /**
  35994. * Base class for Camera Pointer Inputs.
  35995. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35996. * for example usage.
  35997. */
  35998. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35999. /**
  36000. * Defines the camera the input is attached to.
  36001. */
  36002. abstract camera: Camera;
  36003. /**
  36004. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36005. */
  36006. protected _altKey: boolean;
  36007. protected _ctrlKey: boolean;
  36008. protected _metaKey: boolean;
  36009. protected _shiftKey: boolean;
  36010. /**
  36011. * Which mouse buttons were pressed at time of last mouse event.
  36012. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36013. */
  36014. protected _buttonsPressed: number;
  36015. /**
  36016. * Defines the buttons associated with the input to handle camera move.
  36017. */
  36018. buttons: number[];
  36019. /**
  36020. * Attach the input controls to a specific dom element to get the input from.
  36021. * @param element Defines the element the controls should be listened from
  36022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36023. */
  36024. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36025. /**
  36026. * Detach the current controls from the specified dom element.
  36027. * @param element Defines the element to stop listening the inputs from
  36028. */
  36029. detachControl(element: Nullable<HTMLElement>): void;
  36030. /**
  36031. * Gets the class name of the current input.
  36032. * @returns the class name
  36033. */
  36034. getClassName(): string;
  36035. /**
  36036. * Get the friendly name associated with the input class.
  36037. * @returns the input friendly name
  36038. */
  36039. getSimpleName(): string;
  36040. /**
  36041. * Called on pointer POINTERDOUBLETAP event.
  36042. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36043. */
  36044. protected onDoubleTap(type: string): void;
  36045. /**
  36046. * Called on pointer POINTERMOVE event if only a single touch is active.
  36047. * Override this method to provide functionality.
  36048. */
  36049. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36050. /**
  36051. * Called on pointer POINTERMOVE event if multiple touches are active.
  36052. * Override this method to provide functionality.
  36053. */
  36054. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36055. /**
  36056. * Called on JS contextmenu event.
  36057. * Override this method to provide functionality.
  36058. */
  36059. protected onContextMenu(evt: PointerEvent): void;
  36060. /**
  36061. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36062. * press.
  36063. * Override this method to provide functionality.
  36064. */
  36065. protected onButtonDown(evt: PointerEvent): void;
  36066. /**
  36067. * Called each time a new POINTERUP event occurs. Ie, for each button
  36068. * release.
  36069. * Override this method to provide functionality.
  36070. */
  36071. protected onButtonUp(evt: PointerEvent): void;
  36072. /**
  36073. * Called when window becomes inactive.
  36074. * Override this method to provide functionality.
  36075. */
  36076. protected onLostFocus(): void;
  36077. private _pointerInput;
  36078. private _observer;
  36079. private _onLostFocus;
  36080. private pointA;
  36081. private pointB;
  36082. }
  36083. }
  36084. declare module BABYLON {
  36085. /**
  36086. * Manage the pointers inputs to control an arc rotate camera.
  36087. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36088. */
  36089. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36090. /**
  36091. * Defines the camera the input is attached to.
  36092. */
  36093. camera: ArcRotateCamera;
  36094. /**
  36095. * Gets the class name of the current input.
  36096. * @returns the class name
  36097. */
  36098. getClassName(): string;
  36099. /**
  36100. * Defines the buttons associated with the input to handle camera move.
  36101. */
  36102. buttons: number[];
  36103. /**
  36104. * Defines the pointer angular sensibility along the X axis or how fast is
  36105. * the camera rotating.
  36106. */
  36107. angularSensibilityX: number;
  36108. /**
  36109. * Defines the pointer angular sensibility along the Y axis or how fast is
  36110. * the camera rotating.
  36111. */
  36112. angularSensibilityY: number;
  36113. /**
  36114. * Defines the pointer pinch precision or how fast is the camera zooming.
  36115. */
  36116. pinchPrecision: number;
  36117. /**
  36118. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36119. * from 0.
  36120. * It defines the percentage of current camera.radius to use as delta when
  36121. * pinch zoom is used.
  36122. */
  36123. pinchDeltaPercentage: number;
  36124. /**
  36125. * Defines the pointer panning sensibility or how fast is the camera moving.
  36126. */
  36127. panningSensibility: number;
  36128. /**
  36129. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36130. */
  36131. multiTouchPanning: boolean;
  36132. /**
  36133. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36134. * zoom (pinch) through multitouch.
  36135. */
  36136. multiTouchPanAndZoom: boolean;
  36137. /**
  36138. * Revers pinch action direction.
  36139. */
  36140. pinchInwards: boolean;
  36141. private _isPanClick;
  36142. private _twoFingerActivityCount;
  36143. private _isPinching;
  36144. /**
  36145. * Called on pointer POINTERMOVE event if only a single touch is active.
  36146. */
  36147. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36148. /**
  36149. * Called on pointer POINTERDOUBLETAP event.
  36150. */
  36151. protected onDoubleTap(type: string): void;
  36152. /**
  36153. * Called on pointer POINTERMOVE event if multiple touches are active.
  36154. */
  36155. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36156. /**
  36157. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36158. * press.
  36159. */
  36160. protected onButtonDown(evt: PointerEvent): void;
  36161. /**
  36162. * Called each time a new POINTERUP event occurs. Ie, for each button
  36163. * release.
  36164. */
  36165. protected onButtonUp(evt: PointerEvent): void;
  36166. /**
  36167. * Called when window becomes inactive.
  36168. */
  36169. protected onLostFocus(): void;
  36170. }
  36171. }
  36172. declare module BABYLON {
  36173. /**
  36174. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36176. */
  36177. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36178. /**
  36179. * Defines the camera the input is attached to.
  36180. */
  36181. camera: ArcRotateCamera;
  36182. /**
  36183. * Defines the list of key codes associated with the up action (increase alpha)
  36184. */
  36185. keysUp: number[];
  36186. /**
  36187. * Defines the list of key codes associated with the down action (decrease alpha)
  36188. */
  36189. keysDown: number[];
  36190. /**
  36191. * Defines the list of key codes associated with the left action (increase beta)
  36192. */
  36193. keysLeft: number[];
  36194. /**
  36195. * Defines the list of key codes associated with the right action (decrease beta)
  36196. */
  36197. keysRight: number[];
  36198. /**
  36199. * Defines the list of key codes associated with the reset action.
  36200. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36201. */
  36202. keysReset: number[];
  36203. /**
  36204. * Defines the panning sensibility of the inputs.
  36205. * (How fast is the camera paning)
  36206. */
  36207. panningSensibility: number;
  36208. /**
  36209. * Defines the zooming sensibility of the inputs.
  36210. * (How fast is the camera zooming)
  36211. */
  36212. zoomingSensibility: number;
  36213. /**
  36214. * Defines wether maintaining the alt key down switch the movement mode from
  36215. * orientation to zoom.
  36216. */
  36217. useAltToZoom: boolean;
  36218. /**
  36219. * Rotation speed of the camera
  36220. */
  36221. angularSpeed: number;
  36222. private _keys;
  36223. private _ctrlPressed;
  36224. private _altPressed;
  36225. private _onCanvasBlurObserver;
  36226. private _onKeyboardObserver;
  36227. private _engine;
  36228. private _scene;
  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. * Update the current camera state depending on the inputs that have been used this frame.
  36242. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36243. */
  36244. checkInputs(): void;
  36245. /**
  36246. * Gets the class name of the current intput.
  36247. * @returns the class name
  36248. */
  36249. getClassName(): string;
  36250. /**
  36251. * Get the friendly name associated with the input class.
  36252. * @returns the input friendly name
  36253. */
  36254. getSimpleName(): string;
  36255. }
  36256. }
  36257. declare module BABYLON {
  36258. /**
  36259. * Manage the mouse wheel inputs to control an arc rotate camera.
  36260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36261. */
  36262. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36263. /**
  36264. * Defines the camera the input is attached to.
  36265. */
  36266. camera: ArcRotateCamera;
  36267. /**
  36268. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36269. */
  36270. wheelPrecision: number;
  36271. /**
  36272. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36273. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36274. */
  36275. wheelDeltaPercentage: number;
  36276. private _wheel;
  36277. private _observer;
  36278. private computeDeltaFromMouseWheelLegacyEvent;
  36279. /**
  36280. * Attach the input controls to a specific dom element to get the input from.
  36281. * @param element Defines the element the controls should be listened from
  36282. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36283. */
  36284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36285. /**
  36286. * Detach the current controls from the specified dom element.
  36287. * @param element Defines the element to stop listening the inputs from
  36288. */
  36289. detachControl(element: Nullable<HTMLElement>): void;
  36290. /**
  36291. * Gets the class name of the current intput.
  36292. * @returns the class name
  36293. */
  36294. getClassName(): string;
  36295. /**
  36296. * Get the friendly name associated with the input class.
  36297. * @returns the input friendly name
  36298. */
  36299. getSimpleName(): string;
  36300. }
  36301. }
  36302. declare module BABYLON {
  36303. /**
  36304. * Default Inputs manager for the ArcRotateCamera.
  36305. * It groups all the default supported inputs for ease of use.
  36306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36307. */
  36308. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36309. /**
  36310. * Instantiates a new ArcRotateCameraInputsManager.
  36311. * @param camera Defines the camera the inputs belong to
  36312. */
  36313. constructor(camera: ArcRotateCamera);
  36314. /**
  36315. * Add mouse wheel input support to the input manager.
  36316. * @returns the current input manager
  36317. */
  36318. addMouseWheel(): ArcRotateCameraInputsManager;
  36319. /**
  36320. * Add pointers input support to the input manager.
  36321. * @returns the current input manager
  36322. */
  36323. addPointers(): ArcRotateCameraInputsManager;
  36324. /**
  36325. * Add keyboard input support to the input manager.
  36326. * @returns the current input manager
  36327. */
  36328. addKeyboard(): ArcRotateCameraInputsManager;
  36329. }
  36330. }
  36331. declare module BABYLON {
  36332. /**
  36333. * This represents an orbital type of camera.
  36334. *
  36335. * 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.
  36336. * 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.
  36337. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36338. */
  36339. export class ArcRotateCamera extends TargetCamera {
  36340. /**
  36341. * Defines the rotation angle of the camera along the longitudinal axis.
  36342. */
  36343. alpha: number;
  36344. /**
  36345. * Defines the rotation angle of the camera along the latitudinal axis.
  36346. */
  36347. beta: number;
  36348. /**
  36349. * Defines the radius of the camera from it s target point.
  36350. */
  36351. radius: number;
  36352. protected _target: Vector3;
  36353. protected _targetHost: Nullable<AbstractMesh>;
  36354. /**
  36355. * Defines the target point of the camera.
  36356. * The camera looks towards it form the radius distance.
  36357. */
  36358. target: Vector3;
  36359. /**
  36360. * Define the current local position of the camera in the scene
  36361. */
  36362. position: Vector3;
  36363. protected _upVector: Vector3;
  36364. protected _upToYMatrix: Matrix;
  36365. protected _YToUpMatrix: Matrix;
  36366. /**
  36367. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36368. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36369. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36370. */
  36371. upVector: Vector3;
  36372. /**
  36373. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36374. */
  36375. setMatUp(): void;
  36376. /**
  36377. * Current inertia value on the longitudinal axis.
  36378. * The bigger this number the longer it will take for the camera to stop.
  36379. */
  36380. inertialAlphaOffset: number;
  36381. /**
  36382. * Current inertia value on the latitudinal axis.
  36383. * The bigger this number the longer it will take for the camera to stop.
  36384. */
  36385. inertialBetaOffset: number;
  36386. /**
  36387. * Current inertia value on the radius axis.
  36388. * The bigger this number the longer it will take for the camera to stop.
  36389. */
  36390. inertialRadiusOffset: number;
  36391. /**
  36392. * Minimum allowed angle on the longitudinal axis.
  36393. * This can help limiting how the Camera is able to move in the scene.
  36394. */
  36395. lowerAlphaLimit: Nullable<number>;
  36396. /**
  36397. * Maximum allowed angle on the longitudinal axis.
  36398. * This can help limiting how the Camera is able to move in the scene.
  36399. */
  36400. upperAlphaLimit: Nullable<number>;
  36401. /**
  36402. * Minimum allowed angle on the latitudinal axis.
  36403. * This can help limiting how the Camera is able to move in the scene.
  36404. */
  36405. lowerBetaLimit: number;
  36406. /**
  36407. * Maximum allowed angle on the latitudinal axis.
  36408. * This can help limiting how the Camera is able to move in the scene.
  36409. */
  36410. upperBetaLimit: number;
  36411. /**
  36412. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36413. * This can help limiting how the Camera is able to move in the scene.
  36414. */
  36415. lowerRadiusLimit: Nullable<number>;
  36416. /**
  36417. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36418. * This can help limiting how the Camera is able to move in the scene.
  36419. */
  36420. upperRadiusLimit: Nullable<number>;
  36421. /**
  36422. * Defines the current inertia value used during panning of the camera along the X axis.
  36423. */
  36424. inertialPanningX: number;
  36425. /**
  36426. * Defines the current inertia value used during panning of the camera along the Y axis.
  36427. */
  36428. inertialPanningY: number;
  36429. /**
  36430. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36431. * Basically if your fingers moves away from more than this distance you will be considered
  36432. * in pinch mode.
  36433. */
  36434. pinchToPanMaxDistance: number;
  36435. /**
  36436. * Defines the maximum distance the camera can pan.
  36437. * This could help keeping the cammera always in your scene.
  36438. */
  36439. panningDistanceLimit: Nullable<number>;
  36440. /**
  36441. * Defines the target of the camera before paning.
  36442. */
  36443. panningOriginTarget: Vector3;
  36444. /**
  36445. * Defines the value of the inertia used during panning.
  36446. * 0 would mean stop inertia and one would mean no decelleration at all.
  36447. */
  36448. panningInertia: number;
  36449. /**
  36450. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36451. */
  36452. angularSensibilityX: number;
  36453. /**
  36454. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36455. */
  36456. angularSensibilityY: number;
  36457. /**
  36458. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36459. */
  36460. pinchPrecision: number;
  36461. /**
  36462. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36463. * It will be used instead of pinchDeltaPrecision if different from 0.
  36464. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36465. */
  36466. pinchDeltaPercentage: number;
  36467. /**
  36468. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36469. */
  36470. panningSensibility: number;
  36471. /**
  36472. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36473. */
  36474. keysUp: number[];
  36475. /**
  36476. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36477. */
  36478. keysDown: number[];
  36479. /**
  36480. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36481. */
  36482. keysLeft: number[];
  36483. /**
  36484. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36485. */
  36486. keysRight: number[];
  36487. /**
  36488. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36489. */
  36490. wheelPrecision: number;
  36491. /**
  36492. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36493. * It will be used instead of pinchDeltaPrecision if different from 0.
  36494. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36495. */
  36496. wheelDeltaPercentage: number;
  36497. /**
  36498. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36499. */
  36500. zoomOnFactor: number;
  36501. /**
  36502. * Defines a screen offset for the camera position.
  36503. */
  36504. targetScreenOffset: Vector2;
  36505. /**
  36506. * Allows the camera to be completely reversed.
  36507. * If false the camera can not arrive upside down.
  36508. */
  36509. allowUpsideDown: boolean;
  36510. /**
  36511. * Define if double tap/click is used to restore the previously saved state of the camera.
  36512. */
  36513. useInputToRestoreState: boolean;
  36514. /** @hidden */
  36515. _viewMatrix: Matrix;
  36516. /** @hidden */
  36517. _useCtrlForPanning: boolean;
  36518. /** @hidden */
  36519. _panningMouseButton: number;
  36520. /**
  36521. * Defines the input associated to the camera.
  36522. */
  36523. inputs: ArcRotateCameraInputsManager;
  36524. /** @hidden */
  36525. _reset: () => void;
  36526. /**
  36527. * Defines the allowed panning axis.
  36528. */
  36529. panningAxis: Vector3;
  36530. protected _localDirection: Vector3;
  36531. protected _transformedDirection: Vector3;
  36532. private _bouncingBehavior;
  36533. /**
  36534. * Gets the bouncing behavior of the camera if it has been enabled.
  36535. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36536. */
  36537. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36538. /**
  36539. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36540. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36541. */
  36542. useBouncingBehavior: boolean;
  36543. private _framingBehavior;
  36544. /**
  36545. * Gets the framing behavior of the camera if it has been enabled.
  36546. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36547. */
  36548. readonly framingBehavior: Nullable<FramingBehavior>;
  36549. /**
  36550. * Defines if the framing behavior of the camera is enabled on the camera.
  36551. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36552. */
  36553. useFramingBehavior: boolean;
  36554. private _autoRotationBehavior;
  36555. /**
  36556. * Gets the auto rotation behavior of the camera if it has been enabled.
  36557. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36558. */
  36559. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36560. /**
  36561. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36562. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36563. */
  36564. useAutoRotationBehavior: boolean;
  36565. /**
  36566. * Observable triggered when the mesh target has been changed on the camera.
  36567. */
  36568. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36569. /**
  36570. * Event raised when the camera is colliding with a mesh.
  36571. */
  36572. onCollide: (collidedMesh: AbstractMesh) => void;
  36573. /**
  36574. * Defines whether the camera should check collision with the objects oh the scene.
  36575. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36576. */
  36577. checkCollisions: boolean;
  36578. /**
  36579. * Defines the collision radius of the camera.
  36580. * This simulates a sphere around the camera.
  36581. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36582. */
  36583. collisionRadius: Vector3;
  36584. protected _collider: Collider;
  36585. protected _previousPosition: Vector3;
  36586. protected _collisionVelocity: Vector3;
  36587. protected _newPosition: Vector3;
  36588. protected _previousAlpha: number;
  36589. protected _previousBeta: number;
  36590. protected _previousRadius: number;
  36591. protected _collisionTriggered: boolean;
  36592. protected _targetBoundingCenter: Nullable<Vector3>;
  36593. private _computationVector;
  36594. /**
  36595. * Instantiates a new ArcRotateCamera in a given scene
  36596. * @param name Defines the name of the camera
  36597. * @param alpha Defines the camera rotation along the logitudinal axis
  36598. * @param beta Defines the camera rotation along the latitudinal axis
  36599. * @param radius Defines the camera distance from its target
  36600. * @param target Defines the camera target
  36601. * @param scene Defines the scene the camera belongs to
  36602. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36603. */
  36604. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36605. /** @hidden */
  36606. _initCache(): void;
  36607. /** @hidden */
  36608. _updateCache(ignoreParentClass?: boolean): void;
  36609. protected _getTargetPosition(): Vector3;
  36610. private _storedAlpha;
  36611. private _storedBeta;
  36612. private _storedRadius;
  36613. private _storedTarget;
  36614. private _storedTargetScreenOffset;
  36615. /**
  36616. * Stores the current state of the camera (alpha, beta, radius and target)
  36617. * @returns the camera itself
  36618. */
  36619. storeState(): Camera;
  36620. /**
  36621. * @hidden
  36622. * Restored camera state. You must call storeState() first
  36623. */
  36624. _restoreStateValues(): boolean;
  36625. /** @hidden */
  36626. _isSynchronizedViewMatrix(): boolean;
  36627. /**
  36628. * Attached controls to the current camera.
  36629. * @param element Defines the element the controls should be listened from
  36630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36631. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36632. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36633. */
  36634. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36635. /**
  36636. * Detach the current controls from the camera.
  36637. * The camera will stop reacting to inputs.
  36638. * @param element Defines the element to stop listening the inputs from
  36639. */
  36640. detachControl(element: HTMLElement): void;
  36641. /** @hidden */
  36642. _checkInputs(): void;
  36643. protected _checkLimits(): void;
  36644. /**
  36645. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36646. */
  36647. rebuildAnglesAndRadius(): void;
  36648. /**
  36649. * Use a position to define the current camera related information like alpha, beta and radius
  36650. * @param position Defines the position to set the camera at
  36651. */
  36652. setPosition(position: Vector3): void;
  36653. /**
  36654. * Defines the target the camera should look at.
  36655. * This will automatically adapt alpha beta and radius to fit within the new target.
  36656. * @param target Defines the new target as a Vector or a mesh
  36657. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36658. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36659. */
  36660. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36661. /** @hidden */
  36662. _getViewMatrix(): Matrix;
  36663. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36664. /**
  36665. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36666. * @param meshes Defines the mesh to zoom on
  36667. * @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)
  36668. */
  36669. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36670. /**
  36671. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36672. * The target will be changed but the radius
  36673. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36674. * @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)
  36675. */
  36676. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36677. min: Vector3;
  36678. max: Vector3;
  36679. distance: number;
  36680. }, doNotUpdateMaxZ?: boolean): void;
  36681. /**
  36682. * @override
  36683. * Override Camera.createRigCamera
  36684. */
  36685. createRigCamera(name: string, cameraIndex: number): Camera;
  36686. /**
  36687. * @hidden
  36688. * @override
  36689. * Override Camera._updateRigCameras
  36690. */
  36691. _updateRigCameras(): void;
  36692. /**
  36693. * Destroy the camera and release the current resources hold by it.
  36694. */
  36695. dispose(): void;
  36696. /**
  36697. * Gets the current object class name.
  36698. * @return the class name
  36699. */
  36700. getClassName(): string;
  36701. }
  36702. }
  36703. declare module BABYLON {
  36704. /**
  36705. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36706. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36707. */
  36708. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36709. /**
  36710. * Gets the name of the behavior.
  36711. */
  36712. readonly name: string;
  36713. private _zoomStopsAnimation;
  36714. private _idleRotationSpeed;
  36715. private _idleRotationWaitTime;
  36716. private _idleRotationSpinupTime;
  36717. /**
  36718. * Sets the flag that indicates if user zooming should stop animation.
  36719. */
  36720. /**
  36721. * Gets the flag that indicates if user zooming should stop animation.
  36722. */
  36723. zoomStopsAnimation: boolean;
  36724. /**
  36725. * Sets the default speed at which the camera rotates around the model.
  36726. */
  36727. /**
  36728. * Gets the default speed at which the camera rotates around the model.
  36729. */
  36730. idleRotationSpeed: number;
  36731. /**
  36732. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36733. */
  36734. /**
  36735. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36736. */
  36737. idleRotationWaitTime: number;
  36738. /**
  36739. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36740. */
  36741. /**
  36742. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36743. */
  36744. idleRotationSpinupTime: number;
  36745. /**
  36746. * Gets a value indicating if the camera is currently rotating because of this behavior
  36747. */
  36748. readonly rotationInProgress: boolean;
  36749. private _onPrePointerObservableObserver;
  36750. private _onAfterCheckInputsObserver;
  36751. private _attachedCamera;
  36752. private _isPointerDown;
  36753. private _lastFrameTime;
  36754. private _lastInteractionTime;
  36755. private _cameraRotationSpeed;
  36756. /**
  36757. * Initializes the behavior.
  36758. */
  36759. init(): void;
  36760. /**
  36761. * Attaches the behavior to its arc rotate camera.
  36762. * @param camera Defines the camera to attach the behavior to
  36763. */
  36764. attach(camera: ArcRotateCamera): void;
  36765. /**
  36766. * Detaches the behavior from its current arc rotate camera.
  36767. */
  36768. detach(): void;
  36769. /**
  36770. * Returns true if user is scrolling.
  36771. * @return true if user is scrolling.
  36772. */
  36773. private _userIsZooming;
  36774. private _lastFrameRadius;
  36775. private _shouldAnimationStopForInteraction;
  36776. /**
  36777. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36778. */
  36779. private _applyUserInteraction;
  36780. private _userIsMoving;
  36781. }
  36782. }
  36783. declare module BABYLON {
  36784. /**
  36785. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36786. */
  36787. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36788. private ui;
  36789. /**
  36790. * The name of the behavior
  36791. */
  36792. name: string;
  36793. /**
  36794. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36795. */
  36796. distanceAwayFromFace: number;
  36797. /**
  36798. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36799. */
  36800. distanceAwayFromBottomOfFace: number;
  36801. private _faceVectors;
  36802. private _target;
  36803. private _scene;
  36804. private _onRenderObserver;
  36805. private _tmpMatrix;
  36806. private _tmpVector;
  36807. /**
  36808. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36809. * @param ui The transform node that should be attched to the mesh
  36810. */
  36811. constructor(ui: TransformNode);
  36812. /**
  36813. * Initializes the behavior
  36814. */
  36815. init(): void;
  36816. private _closestFace;
  36817. private _zeroVector;
  36818. private _lookAtTmpMatrix;
  36819. private _lookAtToRef;
  36820. /**
  36821. * Attaches the AttachToBoxBehavior to the passed in mesh
  36822. * @param target The mesh that the specified node will be attached to
  36823. */
  36824. attach(target: Mesh): void;
  36825. /**
  36826. * Detaches the behavior from the mesh
  36827. */
  36828. detach(): void;
  36829. }
  36830. }
  36831. declare module BABYLON {
  36832. /**
  36833. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36834. */
  36835. export class FadeInOutBehavior implements Behavior<Mesh> {
  36836. /**
  36837. * Time in milliseconds to delay before fading in (Default: 0)
  36838. */
  36839. delay: number;
  36840. /**
  36841. * Time in milliseconds for the mesh to fade in (Default: 300)
  36842. */
  36843. fadeInTime: number;
  36844. private _millisecondsPerFrame;
  36845. private _hovered;
  36846. private _hoverValue;
  36847. private _ownerNode;
  36848. /**
  36849. * Instatiates the FadeInOutBehavior
  36850. */
  36851. constructor();
  36852. /**
  36853. * The name of the behavior
  36854. */
  36855. readonly name: string;
  36856. /**
  36857. * Initializes the behavior
  36858. */
  36859. init(): void;
  36860. /**
  36861. * Attaches the fade behavior on the passed in mesh
  36862. * @param ownerNode The mesh that will be faded in/out once attached
  36863. */
  36864. attach(ownerNode: Mesh): void;
  36865. /**
  36866. * Detaches the behavior from the mesh
  36867. */
  36868. detach(): void;
  36869. /**
  36870. * Triggers the mesh to begin fading in or out
  36871. * @param value if the object should fade in or out (true to fade in)
  36872. */
  36873. fadeIn(value: boolean): void;
  36874. private _update;
  36875. private _setAllVisibility;
  36876. }
  36877. }
  36878. declare module BABYLON {
  36879. /**
  36880. * Class containing a set of static utilities functions for managing Pivots
  36881. * @hidden
  36882. */
  36883. export class PivotTools {
  36884. private static _PivotCached;
  36885. private static _OldPivotPoint;
  36886. private static _PivotTranslation;
  36887. private static _PivotTmpVector;
  36888. /** @hidden */
  36889. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36890. /** @hidden */
  36891. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36892. }
  36893. }
  36894. declare module BABYLON {
  36895. /**
  36896. * Class containing static functions to help procedurally build meshes
  36897. */
  36898. export class PlaneBuilder {
  36899. /**
  36900. * Creates a plane mesh
  36901. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36902. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36903. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36905. * * 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
  36906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36907. * @param name defines the name of the mesh
  36908. * @param options defines the options used to create the mesh
  36909. * @param scene defines the hosting scene
  36910. * @returns the plane mesh
  36911. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36912. */
  36913. static CreatePlane(name: string, options: {
  36914. size?: number;
  36915. width?: number;
  36916. height?: number;
  36917. sideOrientation?: number;
  36918. frontUVs?: Vector4;
  36919. backUVs?: Vector4;
  36920. updatable?: boolean;
  36921. sourcePlane?: Plane;
  36922. }, scene?: Nullable<Scene>): Mesh;
  36923. }
  36924. }
  36925. declare module BABYLON {
  36926. /**
  36927. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36928. */
  36929. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36930. private static _AnyMouseID;
  36931. /**
  36932. * Abstract mesh the behavior is set on
  36933. */
  36934. attachedNode: AbstractMesh;
  36935. private _dragPlane;
  36936. private _scene;
  36937. private _pointerObserver;
  36938. private _beforeRenderObserver;
  36939. private static _planeScene;
  36940. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36941. /**
  36942. * 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)
  36943. */
  36944. maxDragAngle: number;
  36945. /**
  36946. * @hidden
  36947. */
  36948. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36949. /**
  36950. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36951. */
  36952. currentDraggingPointerID: number;
  36953. /**
  36954. * The last position where the pointer hit the drag plane in world space
  36955. */
  36956. lastDragPosition: Vector3;
  36957. /**
  36958. * If the behavior is currently in a dragging state
  36959. */
  36960. dragging: boolean;
  36961. /**
  36962. * 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)
  36963. */
  36964. dragDeltaRatio: number;
  36965. /**
  36966. * If the drag plane orientation should be updated during the dragging (Default: true)
  36967. */
  36968. updateDragPlane: boolean;
  36969. private _debugMode;
  36970. private _moving;
  36971. /**
  36972. * Fires each time the attached mesh is dragged with the pointer
  36973. * * delta between last drag position and current drag position in world space
  36974. * * dragDistance along the drag axis
  36975. * * dragPlaneNormal normal of the current drag plane used during the drag
  36976. * * dragPlanePoint in world space where the drag intersects the drag plane
  36977. */
  36978. onDragObservable: Observable<{
  36979. delta: Vector3;
  36980. dragPlanePoint: Vector3;
  36981. dragPlaneNormal: Vector3;
  36982. dragDistance: number;
  36983. pointerId: number;
  36984. }>;
  36985. /**
  36986. * Fires each time a drag begins (eg. mouse down on mesh)
  36987. */
  36988. onDragStartObservable: Observable<{
  36989. dragPlanePoint: Vector3;
  36990. pointerId: number;
  36991. }>;
  36992. /**
  36993. * Fires each time a drag ends (eg. mouse release after drag)
  36994. */
  36995. onDragEndObservable: Observable<{
  36996. dragPlanePoint: Vector3;
  36997. pointerId: number;
  36998. }>;
  36999. /**
  37000. * If the attached mesh should be moved when dragged
  37001. */
  37002. moveAttached: boolean;
  37003. /**
  37004. * If the drag behavior will react to drag events (Default: true)
  37005. */
  37006. enabled: boolean;
  37007. /**
  37008. * If pointer events should start and release the drag (Default: true)
  37009. */
  37010. startAndReleaseDragOnPointerEvents: boolean;
  37011. /**
  37012. * If camera controls should be detached during the drag
  37013. */
  37014. detachCameraControls: boolean;
  37015. /**
  37016. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37017. */
  37018. useObjectOrienationForDragging: boolean;
  37019. private _options;
  37020. /**
  37021. * Creates a pointer drag behavior that can be attached to a mesh
  37022. * @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)
  37023. */
  37024. constructor(options?: {
  37025. dragAxis?: Vector3;
  37026. dragPlaneNormal?: Vector3;
  37027. });
  37028. /**
  37029. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37030. */
  37031. validateDrag: (targetPosition: Vector3) => boolean;
  37032. /**
  37033. * The name of the behavior
  37034. */
  37035. readonly name: string;
  37036. /**
  37037. * Initializes the behavior
  37038. */
  37039. init(): void;
  37040. private _tmpVector;
  37041. private _alternatePickedPoint;
  37042. private _worldDragAxis;
  37043. private _targetPosition;
  37044. private _attachedElement;
  37045. /**
  37046. * Attaches the drag behavior the passed in mesh
  37047. * @param ownerNode The mesh that will be dragged around once attached
  37048. * @param predicate Predicate to use for pick filtering
  37049. */
  37050. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37051. /**
  37052. * Force relase the drag action by code.
  37053. */
  37054. releaseDrag(): void;
  37055. private _startDragRay;
  37056. private _lastPointerRay;
  37057. /**
  37058. * Simulates the start of a pointer drag event on the behavior
  37059. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37060. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37061. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37062. */
  37063. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37064. private _startDrag;
  37065. private _dragDelta;
  37066. private _moveDrag;
  37067. private _pickWithRayOnDragPlane;
  37068. private _pointA;
  37069. private _pointB;
  37070. private _pointC;
  37071. private _lineA;
  37072. private _lineB;
  37073. private _localAxis;
  37074. private _lookAt;
  37075. private _updateDragPlanePosition;
  37076. /**
  37077. * Detaches the behavior from the mesh
  37078. */
  37079. detach(): void;
  37080. }
  37081. }
  37082. declare module BABYLON {
  37083. /**
  37084. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37085. */
  37086. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37087. private _dragBehaviorA;
  37088. private _dragBehaviorB;
  37089. private _startDistance;
  37090. private _initialScale;
  37091. private _targetScale;
  37092. private _ownerNode;
  37093. private _sceneRenderObserver;
  37094. /**
  37095. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37096. */
  37097. constructor();
  37098. /**
  37099. * The name of the behavior
  37100. */
  37101. readonly name: string;
  37102. /**
  37103. * Initializes the behavior
  37104. */
  37105. init(): void;
  37106. private _getCurrentDistance;
  37107. /**
  37108. * Attaches the scale behavior the passed in mesh
  37109. * @param ownerNode The mesh that will be scaled around once attached
  37110. */
  37111. attach(ownerNode: Mesh): void;
  37112. /**
  37113. * Detaches the behavior from the mesh
  37114. */
  37115. detach(): void;
  37116. }
  37117. }
  37118. declare module BABYLON {
  37119. /**
  37120. * 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
  37121. */
  37122. export class SixDofDragBehavior implements Behavior<Mesh> {
  37123. private static _virtualScene;
  37124. private _ownerNode;
  37125. private _sceneRenderObserver;
  37126. private _scene;
  37127. private _targetPosition;
  37128. private _virtualOriginMesh;
  37129. private _virtualDragMesh;
  37130. private _pointerObserver;
  37131. private _moving;
  37132. private _startingOrientation;
  37133. /**
  37134. * 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)
  37135. */
  37136. private zDragFactor;
  37137. /**
  37138. * If the object should rotate to face the drag origin
  37139. */
  37140. rotateDraggedObject: boolean;
  37141. /**
  37142. * If the behavior is currently in a dragging state
  37143. */
  37144. dragging: boolean;
  37145. /**
  37146. * 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)
  37147. */
  37148. dragDeltaRatio: number;
  37149. /**
  37150. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37151. */
  37152. currentDraggingPointerID: number;
  37153. /**
  37154. * If camera controls should be detached during the drag
  37155. */
  37156. detachCameraControls: boolean;
  37157. /**
  37158. * Fires each time a drag starts
  37159. */
  37160. onDragStartObservable: Observable<{}>;
  37161. /**
  37162. * Fires each time a drag ends (eg. mouse release after drag)
  37163. */
  37164. onDragEndObservable: Observable<{}>;
  37165. /**
  37166. * 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
  37167. */
  37168. constructor();
  37169. /**
  37170. * The name of the behavior
  37171. */
  37172. readonly name: string;
  37173. /**
  37174. * Initializes the behavior
  37175. */
  37176. init(): void;
  37177. /**
  37178. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37179. */
  37180. private readonly _pointerCamera;
  37181. /**
  37182. * Attaches the scale behavior the passed in mesh
  37183. * @param ownerNode The mesh that will be scaled around once attached
  37184. */
  37185. attach(ownerNode: Mesh): void;
  37186. /**
  37187. * Detaches the behavior from the mesh
  37188. */
  37189. detach(): void;
  37190. }
  37191. }
  37192. declare module BABYLON {
  37193. /**
  37194. * Class used to apply inverse kinematics to bones
  37195. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37196. */
  37197. export class BoneIKController {
  37198. private static _tmpVecs;
  37199. private static _tmpQuat;
  37200. private static _tmpMats;
  37201. /**
  37202. * Gets or sets the target mesh
  37203. */
  37204. targetMesh: AbstractMesh;
  37205. /** Gets or sets the mesh used as pole */
  37206. poleTargetMesh: AbstractMesh;
  37207. /**
  37208. * Gets or sets the bone used as pole
  37209. */
  37210. poleTargetBone: Nullable<Bone>;
  37211. /**
  37212. * Gets or sets the target position
  37213. */
  37214. targetPosition: Vector3;
  37215. /**
  37216. * Gets or sets the pole target position
  37217. */
  37218. poleTargetPosition: Vector3;
  37219. /**
  37220. * Gets or sets the pole target local offset
  37221. */
  37222. poleTargetLocalOffset: Vector3;
  37223. /**
  37224. * Gets or sets the pole angle
  37225. */
  37226. poleAngle: number;
  37227. /**
  37228. * Gets or sets the mesh associated with the controller
  37229. */
  37230. mesh: AbstractMesh;
  37231. /**
  37232. * 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)
  37233. */
  37234. slerpAmount: number;
  37235. private _bone1Quat;
  37236. private _bone1Mat;
  37237. private _bone2Ang;
  37238. private _bone1;
  37239. private _bone2;
  37240. private _bone1Length;
  37241. private _bone2Length;
  37242. private _maxAngle;
  37243. private _maxReach;
  37244. private _rightHandedSystem;
  37245. private _bendAxis;
  37246. private _slerping;
  37247. private _adjustRoll;
  37248. /**
  37249. * Gets or sets maximum allowed angle
  37250. */
  37251. maxAngle: number;
  37252. /**
  37253. * Creates a new BoneIKController
  37254. * @param mesh defines the mesh to control
  37255. * @param bone defines the bone to control
  37256. * @param options defines options to set up the controller
  37257. */
  37258. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37259. targetMesh?: AbstractMesh;
  37260. poleTargetMesh?: AbstractMesh;
  37261. poleTargetBone?: Bone;
  37262. poleTargetLocalOffset?: Vector3;
  37263. poleAngle?: number;
  37264. bendAxis?: Vector3;
  37265. maxAngle?: number;
  37266. slerpAmount?: number;
  37267. });
  37268. private _setMaxAngle;
  37269. /**
  37270. * Force the controller to update the bones
  37271. */
  37272. update(): void;
  37273. }
  37274. }
  37275. declare module BABYLON {
  37276. /**
  37277. * Class used to make a bone look toward a point in space
  37278. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37279. */
  37280. export class BoneLookController {
  37281. private static _tmpVecs;
  37282. private static _tmpQuat;
  37283. private static _tmpMats;
  37284. /**
  37285. * The target Vector3 that the bone will look at
  37286. */
  37287. target: Vector3;
  37288. /**
  37289. * The mesh that the bone is attached to
  37290. */
  37291. mesh: AbstractMesh;
  37292. /**
  37293. * The bone that will be looking to the target
  37294. */
  37295. bone: Bone;
  37296. /**
  37297. * The up axis of the coordinate system that is used when the bone is rotated
  37298. */
  37299. upAxis: Vector3;
  37300. /**
  37301. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37302. */
  37303. upAxisSpace: Space;
  37304. /**
  37305. * Used to make an adjustment to the yaw of the bone
  37306. */
  37307. adjustYaw: number;
  37308. /**
  37309. * Used to make an adjustment to the pitch of the bone
  37310. */
  37311. adjustPitch: number;
  37312. /**
  37313. * Used to make an adjustment to the roll of the bone
  37314. */
  37315. adjustRoll: number;
  37316. /**
  37317. * 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)
  37318. */
  37319. slerpAmount: number;
  37320. private _minYaw;
  37321. private _maxYaw;
  37322. private _minPitch;
  37323. private _maxPitch;
  37324. private _minYawSin;
  37325. private _minYawCos;
  37326. private _maxYawSin;
  37327. private _maxYawCos;
  37328. private _midYawConstraint;
  37329. private _minPitchTan;
  37330. private _maxPitchTan;
  37331. private _boneQuat;
  37332. private _slerping;
  37333. private _transformYawPitch;
  37334. private _transformYawPitchInv;
  37335. private _firstFrameSkipped;
  37336. private _yawRange;
  37337. private _fowardAxis;
  37338. /**
  37339. * Gets or sets the minimum yaw angle that the bone can look to
  37340. */
  37341. minYaw: number;
  37342. /**
  37343. * Gets or sets the maximum yaw angle that the bone can look to
  37344. */
  37345. maxYaw: number;
  37346. /**
  37347. * Gets or sets the minimum pitch angle that the bone can look to
  37348. */
  37349. minPitch: number;
  37350. /**
  37351. * Gets or sets the maximum pitch angle that the bone can look to
  37352. */
  37353. maxPitch: number;
  37354. /**
  37355. * Create a BoneLookController
  37356. * @param mesh the mesh that the bone belongs to
  37357. * @param bone the bone that will be looking to the target
  37358. * @param target the target Vector3 to look at
  37359. * @param options optional settings:
  37360. * * maxYaw: the maximum angle the bone will yaw to
  37361. * * minYaw: the minimum angle the bone will yaw to
  37362. * * maxPitch: the maximum angle the bone will pitch to
  37363. * * minPitch: the minimum angle the bone will yaw to
  37364. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37365. * * upAxis: the up axis of the coordinate system
  37366. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37367. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37368. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37369. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37370. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37371. * * adjustRoll: used to make an adjustment to the roll of the bone
  37372. **/
  37373. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37374. maxYaw?: number;
  37375. minYaw?: number;
  37376. maxPitch?: number;
  37377. minPitch?: number;
  37378. slerpAmount?: number;
  37379. upAxis?: Vector3;
  37380. upAxisSpace?: Space;
  37381. yawAxis?: Vector3;
  37382. pitchAxis?: Vector3;
  37383. adjustYaw?: number;
  37384. adjustPitch?: number;
  37385. adjustRoll?: number;
  37386. });
  37387. /**
  37388. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37389. */
  37390. update(): void;
  37391. private _getAngleDiff;
  37392. private _getAngleBetween;
  37393. private _isAngleBetween;
  37394. }
  37395. }
  37396. declare module BABYLON {
  37397. /**
  37398. * Manage the gamepad inputs to control an arc rotate camera.
  37399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37400. */
  37401. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37402. /**
  37403. * Defines the camera the input is attached to.
  37404. */
  37405. camera: ArcRotateCamera;
  37406. /**
  37407. * Defines the gamepad the input is gathering event from.
  37408. */
  37409. gamepad: Nullable<Gamepad>;
  37410. /**
  37411. * Defines the gamepad rotation sensiblity.
  37412. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37413. */
  37414. gamepadRotationSensibility: number;
  37415. /**
  37416. * Defines the gamepad move sensiblity.
  37417. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37418. */
  37419. gamepadMoveSensibility: number;
  37420. private _onGamepadConnectedObserver;
  37421. private _onGamepadDisconnectedObserver;
  37422. /**
  37423. * Attach the input controls to a specific dom element to get the input from.
  37424. * @param element Defines the element the controls should be listened from
  37425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37426. */
  37427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37428. /**
  37429. * Detach the current controls from the specified dom element.
  37430. * @param element Defines the element to stop listening the inputs from
  37431. */
  37432. detachControl(element: Nullable<HTMLElement>): void;
  37433. /**
  37434. * Update the current camera state depending on the inputs that have been used this frame.
  37435. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37436. */
  37437. checkInputs(): void;
  37438. /**
  37439. * Gets the class name of the current intput.
  37440. * @returns the class name
  37441. */
  37442. getClassName(): string;
  37443. /**
  37444. * Get the friendly name associated with the input class.
  37445. * @returns the input friendly name
  37446. */
  37447. getSimpleName(): string;
  37448. }
  37449. }
  37450. declare module BABYLON {
  37451. interface ArcRotateCameraInputsManager {
  37452. /**
  37453. * Add orientation input support to the input manager.
  37454. * @returns the current input manager
  37455. */
  37456. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37457. }
  37458. /**
  37459. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37461. */
  37462. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37463. /**
  37464. * Defines the camera the input is attached to.
  37465. */
  37466. camera: ArcRotateCamera;
  37467. /**
  37468. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37469. */
  37470. alphaCorrection: number;
  37471. /**
  37472. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37473. */
  37474. gammaCorrection: number;
  37475. private _alpha;
  37476. private _gamma;
  37477. private _dirty;
  37478. private _deviceOrientationHandler;
  37479. /**
  37480. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37481. */
  37482. constructor();
  37483. /**
  37484. * Attach the input controls to a specific dom element to get the input from.
  37485. * @param element Defines the element the controls should be listened from
  37486. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37487. */
  37488. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37489. /** @hidden */
  37490. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37491. /**
  37492. * Update the current camera state depending on the inputs that have been used this frame.
  37493. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37494. */
  37495. checkInputs(): void;
  37496. /**
  37497. * Detach the current controls from the specified dom element.
  37498. * @param element Defines the element to stop listening the inputs from
  37499. */
  37500. detachControl(element: Nullable<HTMLElement>): void;
  37501. /**
  37502. * Gets the class name of the current intput.
  37503. * @returns the class name
  37504. */
  37505. getClassName(): string;
  37506. /**
  37507. * Get the friendly name associated with the input class.
  37508. * @returns the input friendly name
  37509. */
  37510. getSimpleName(): string;
  37511. }
  37512. }
  37513. declare module BABYLON {
  37514. /**
  37515. * Listen to mouse events to control the camera.
  37516. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37517. */
  37518. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37519. /**
  37520. * Defines the camera the input is attached to.
  37521. */
  37522. camera: FlyCamera;
  37523. /**
  37524. * Defines if touch is enabled. (Default is true.)
  37525. */
  37526. touchEnabled: boolean;
  37527. /**
  37528. * Defines the buttons associated with the input to handle camera rotation.
  37529. */
  37530. buttons: number[];
  37531. /**
  37532. * Assign buttons for Yaw control.
  37533. */
  37534. buttonsYaw: number[];
  37535. /**
  37536. * Assign buttons for Pitch control.
  37537. */
  37538. buttonsPitch: number[];
  37539. /**
  37540. * Assign buttons for Roll control.
  37541. */
  37542. buttonsRoll: number[];
  37543. /**
  37544. * Detect if any button is being pressed while mouse is moved.
  37545. * -1 = Mouse locked.
  37546. * 0 = Left button.
  37547. * 1 = Middle Button.
  37548. * 2 = Right Button.
  37549. */
  37550. activeButton: number;
  37551. /**
  37552. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37553. * Higher values reduce its sensitivity.
  37554. */
  37555. angularSensibility: number;
  37556. private _mousemoveCallback;
  37557. private _observer;
  37558. private _rollObserver;
  37559. private previousPosition;
  37560. private noPreventDefault;
  37561. private element;
  37562. /**
  37563. * Listen to mouse events to control the camera.
  37564. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37565. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37566. */
  37567. constructor(touchEnabled?: boolean);
  37568. /**
  37569. * Attach the mouse control to the HTML DOM element.
  37570. * @param element Defines the element that listens to the input events.
  37571. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37572. */
  37573. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37574. /**
  37575. * Detach the current controls from the specified dom element.
  37576. * @param element Defines the element to stop listening the inputs from
  37577. */
  37578. detachControl(element: Nullable<HTMLElement>): void;
  37579. /**
  37580. * Gets the class name of the current input.
  37581. * @returns the class name.
  37582. */
  37583. getClassName(): string;
  37584. /**
  37585. * Get the friendly name associated with the input class.
  37586. * @returns the input's friendly name.
  37587. */
  37588. getSimpleName(): string;
  37589. private _pointerInput;
  37590. private _onMouseMove;
  37591. /**
  37592. * Rotate camera by mouse offset.
  37593. */
  37594. private rotateCamera;
  37595. }
  37596. }
  37597. declare module BABYLON {
  37598. /**
  37599. * Default Inputs manager for the FlyCamera.
  37600. * It groups all the default supported inputs for ease of use.
  37601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37602. */
  37603. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37604. /**
  37605. * Instantiates a new FlyCameraInputsManager.
  37606. * @param camera Defines the camera the inputs belong to.
  37607. */
  37608. constructor(camera: FlyCamera);
  37609. /**
  37610. * Add keyboard input support to the input manager.
  37611. * @returns the new FlyCameraKeyboardMoveInput().
  37612. */
  37613. addKeyboard(): FlyCameraInputsManager;
  37614. /**
  37615. * Add mouse input support to the input manager.
  37616. * @param touchEnabled Enable touch screen support.
  37617. * @returns the new FlyCameraMouseInput().
  37618. */
  37619. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37620. }
  37621. }
  37622. declare module BABYLON {
  37623. /**
  37624. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37625. * such as in a 3D Space Shooter or a Flight Simulator.
  37626. */
  37627. export class FlyCamera extends TargetCamera {
  37628. /**
  37629. * Define the collision ellipsoid of the camera.
  37630. * This is helpful for simulating a camera body, like a player's body.
  37631. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37632. */
  37633. ellipsoid: Vector3;
  37634. /**
  37635. * Define an offset for the position of the ellipsoid around the camera.
  37636. * This can be helpful if the camera is attached away from the player's body center,
  37637. * such as at its head.
  37638. */
  37639. ellipsoidOffset: Vector3;
  37640. /**
  37641. * Enable or disable collisions of the camera with the rest of the scene objects.
  37642. */
  37643. checkCollisions: boolean;
  37644. /**
  37645. * Enable or disable gravity on the camera.
  37646. */
  37647. applyGravity: boolean;
  37648. /**
  37649. * Define the current direction the camera is moving to.
  37650. */
  37651. cameraDirection: Vector3;
  37652. /**
  37653. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37654. * This overrides and empties cameraRotation.
  37655. */
  37656. rotationQuaternion: Quaternion;
  37657. /**
  37658. * Track Roll to maintain the wanted Rolling when looking around.
  37659. */
  37660. _trackRoll: number;
  37661. /**
  37662. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37663. */
  37664. rollCorrect: number;
  37665. /**
  37666. * Mimic a banked turn, Rolling the camera when Yawing.
  37667. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37668. */
  37669. bankedTurn: boolean;
  37670. /**
  37671. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37672. */
  37673. bankedTurnLimit: number;
  37674. /**
  37675. * Value of 0 disables the banked Roll.
  37676. * Value of 1 is equal to the Yaw angle in radians.
  37677. */
  37678. bankedTurnMultiplier: number;
  37679. /**
  37680. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37681. */
  37682. inputs: FlyCameraInputsManager;
  37683. /**
  37684. * Gets the input sensibility for mouse input.
  37685. * Higher values reduce sensitivity.
  37686. */
  37687. /**
  37688. * Sets the input sensibility for a mouse input.
  37689. * Higher values reduce sensitivity.
  37690. */
  37691. angularSensibility: number;
  37692. /**
  37693. * Get the keys for camera movement forward.
  37694. */
  37695. /**
  37696. * Set the keys for camera movement forward.
  37697. */
  37698. keysForward: number[];
  37699. /**
  37700. * Get the keys for camera movement backward.
  37701. */
  37702. keysBackward: number[];
  37703. /**
  37704. * Get the keys for camera movement up.
  37705. */
  37706. /**
  37707. * Set the keys for camera movement up.
  37708. */
  37709. keysUp: number[];
  37710. /**
  37711. * Get the keys for camera movement down.
  37712. */
  37713. /**
  37714. * Set the keys for camera movement down.
  37715. */
  37716. keysDown: number[];
  37717. /**
  37718. * Get the keys for camera movement left.
  37719. */
  37720. /**
  37721. * Set the keys for camera movement left.
  37722. */
  37723. keysLeft: number[];
  37724. /**
  37725. * Set the keys for camera movement right.
  37726. */
  37727. /**
  37728. * Set the keys for camera movement right.
  37729. */
  37730. keysRight: number[];
  37731. /**
  37732. * Event raised when the camera collides with a mesh in the scene.
  37733. */
  37734. onCollide: (collidedMesh: AbstractMesh) => void;
  37735. private _collider;
  37736. private _needMoveForGravity;
  37737. private _oldPosition;
  37738. private _diffPosition;
  37739. private _newPosition;
  37740. /** @hidden */
  37741. _localDirection: Vector3;
  37742. /** @hidden */
  37743. _transformedDirection: Vector3;
  37744. /**
  37745. * Instantiates a FlyCamera.
  37746. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37747. * such as in a 3D Space Shooter or a Flight Simulator.
  37748. * @param name Define the name of the camera in the scene.
  37749. * @param position Define the starting position of the camera in the scene.
  37750. * @param scene Define the scene the camera belongs to.
  37751. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37752. */
  37753. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37754. /**
  37755. * Attach a control to the HTML DOM element.
  37756. * @param element Defines the element that listens to the input events.
  37757. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37758. */
  37759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37760. /**
  37761. * Detach a control from the HTML DOM element.
  37762. * The camera will stop reacting to that input.
  37763. * @param element Defines the element that listens to the input events.
  37764. */
  37765. detachControl(element: HTMLElement): void;
  37766. private _collisionMask;
  37767. /**
  37768. * Get the mask that the camera ignores in collision events.
  37769. */
  37770. /**
  37771. * Set the mask that the camera ignores in collision events.
  37772. */
  37773. collisionMask: number;
  37774. /** @hidden */
  37775. _collideWithWorld(displacement: Vector3): void;
  37776. /** @hidden */
  37777. private _onCollisionPositionChange;
  37778. /** @hidden */
  37779. _checkInputs(): void;
  37780. /** @hidden */
  37781. _decideIfNeedsToMove(): boolean;
  37782. /** @hidden */
  37783. _updatePosition(): void;
  37784. /**
  37785. * Restore the Roll to its target value at the rate specified.
  37786. * @param rate - Higher means slower restoring.
  37787. * @hidden
  37788. */
  37789. restoreRoll(rate: number): void;
  37790. /**
  37791. * Destroy the camera and release the current resources held by it.
  37792. */
  37793. dispose(): void;
  37794. /**
  37795. * Get the current object class name.
  37796. * @returns the class name.
  37797. */
  37798. getClassName(): string;
  37799. }
  37800. }
  37801. declare module BABYLON {
  37802. /**
  37803. * Listen to keyboard events to control the camera.
  37804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37805. */
  37806. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37807. /**
  37808. * Defines the camera the input is attached to.
  37809. */
  37810. camera: FlyCamera;
  37811. /**
  37812. * The list of keyboard keys used to control the forward move of the camera.
  37813. */
  37814. keysForward: number[];
  37815. /**
  37816. * The list of keyboard keys used to control the backward move of the camera.
  37817. */
  37818. keysBackward: number[];
  37819. /**
  37820. * The list of keyboard keys used to control the forward move of the camera.
  37821. */
  37822. keysUp: number[];
  37823. /**
  37824. * The list of keyboard keys used to control the backward move of the camera.
  37825. */
  37826. keysDown: number[];
  37827. /**
  37828. * The list of keyboard keys used to control the right strafe move of the camera.
  37829. */
  37830. keysRight: number[];
  37831. /**
  37832. * The list of keyboard keys used to control the left strafe move of the camera.
  37833. */
  37834. keysLeft: number[];
  37835. private _keys;
  37836. private _onCanvasBlurObserver;
  37837. private _onKeyboardObserver;
  37838. private _engine;
  37839. private _scene;
  37840. /**
  37841. * Attach the input controls to a specific dom element to get the input from.
  37842. * @param element Defines the element the controls should be listened from
  37843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37844. */
  37845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37846. /**
  37847. * Detach the current controls from the specified dom element.
  37848. * @param element Defines the element to stop listening the inputs from
  37849. */
  37850. detachControl(element: Nullable<HTMLElement>): void;
  37851. /**
  37852. * Gets the class name of the current intput.
  37853. * @returns the class name
  37854. */
  37855. getClassName(): string;
  37856. /** @hidden */
  37857. _onLostFocus(e: FocusEvent): void;
  37858. /**
  37859. * Get the friendly name associated with the input class.
  37860. * @returns the input friendly name
  37861. */
  37862. getSimpleName(): string;
  37863. /**
  37864. * Update the current camera state depending on the inputs that have been used this frame.
  37865. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37866. */
  37867. checkInputs(): void;
  37868. }
  37869. }
  37870. declare module BABYLON {
  37871. /**
  37872. * Manage the mouse wheel inputs to control a follow camera.
  37873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37874. */
  37875. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37876. /**
  37877. * Defines the camera the input is attached to.
  37878. */
  37879. camera: FollowCamera;
  37880. /**
  37881. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37882. */
  37883. axisControlRadius: boolean;
  37884. /**
  37885. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37886. */
  37887. axisControlHeight: boolean;
  37888. /**
  37889. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37890. */
  37891. axisControlRotation: boolean;
  37892. /**
  37893. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37894. * relation to mouseWheel events.
  37895. */
  37896. wheelPrecision: number;
  37897. /**
  37898. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37899. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37900. */
  37901. wheelDeltaPercentage: number;
  37902. private _wheel;
  37903. private _observer;
  37904. /**
  37905. * Attach the input controls to a specific dom element to get the input from.
  37906. * @param element Defines the element the controls should be listened from
  37907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37908. */
  37909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37910. /**
  37911. * Detach the current controls from the specified dom element.
  37912. * @param element Defines the element to stop listening the inputs from
  37913. */
  37914. detachControl(element: Nullable<HTMLElement>): void;
  37915. /**
  37916. * Gets the class name of the current intput.
  37917. * @returns the class name
  37918. */
  37919. getClassName(): string;
  37920. /**
  37921. * Get the friendly name associated with the input class.
  37922. * @returns the input friendly name
  37923. */
  37924. getSimpleName(): string;
  37925. }
  37926. }
  37927. declare module BABYLON {
  37928. /**
  37929. * Manage the pointers inputs to control an follow camera.
  37930. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37931. */
  37932. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37933. /**
  37934. * Defines the camera the input is attached to.
  37935. */
  37936. camera: FollowCamera;
  37937. /**
  37938. * Gets the class name of the current input.
  37939. * @returns the class name
  37940. */
  37941. getClassName(): string;
  37942. /**
  37943. * Defines the pointer angular sensibility along the X axis or how fast is
  37944. * the camera rotating.
  37945. * A negative number will reverse the axis direction.
  37946. */
  37947. angularSensibilityX: number;
  37948. /**
  37949. * Defines the pointer angular sensibility along the Y axis or how fast is
  37950. * the camera rotating.
  37951. * A negative number will reverse the axis direction.
  37952. */
  37953. angularSensibilityY: number;
  37954. /**
  37955. * Defines the pointer pinch precision or how fast is the camera zooming.
  37956. * A negative number will reverse the axis direction.
  37957. */
  37958. pinchPrecision: number;
  37959. /**
  37960. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37961. * from 0.
  37962. * It defines the percentage of current camera.radius to use as delta when
  37963. * pinch zoom is used.
  37964. */
  37965. pinchDeltaPercentage: number;
  37966. /**
  37967. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37968. */
  37969. axisXControlRadius: boolean;
  37970. /**
  37971. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37972. */
  37973. axisXControlHeight: boolean;
  37974. /**
  37975. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37976. */
  37977. axisXControlRotation: boolean;
  37978. /**
  37979. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37980. */
  37981. axisYControlRadius: boolean;
  37982. /**
  37983. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37984. */
  37985. axisYControlHeight: boolean;
  37986. /**
  37987. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37988. */
  37989. axisYControlRotation: boolean;
  37990. /**
  37991. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37992. */
  37993. axisPinchControlRadius: boolean;
  37994. /**
  37995. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37996. */
  37997. axisPinchControlHeight: boolean;
  37998. /**
  37999. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38000. */
  38001. axisPinchControlRotation: boolean;
  38002. /**
  38003. * Log error messages if basic misconfiguration has occurred.
  38004. */
  38005. warningEnable: boolean;
  38006. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38007. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38008. private _warningCounter;
  38009. private _warning;
  38010. }
  38011. }
  38012. declare module BABYLON {
  38013. /**
  38014. * Default Inputs manager for the FollowCamera.
  38015. * It groups all the default supported inputs for ease of use.
  38016. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38017. */
  38018. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38019. /**
  38020. * Instantiates a new FollowCameraInputsManager.
  38021. * @param camera Defines the camera the inputs belong to
  38022. */
  38023. constructor(camera: FollowCamera);
  38024. /**
  38025. * Add keyboard input support to the input manager.
  38026. * @returns the current input manager
  38027. */
  38028. addKeyboard(): FollowCameraInputsManager;
  38029. /**
  38030. * Add mouse wheel input support to the input manager.
  38031. * @returns the current input manager
  38032. */
  38033. addMouseWheel(): FollowCameraInputsManager;
  38034. /**
  38035. * Add pointers input support to the input manager.
  38036. * @returns the current input manager
  38037. */
  38038. addPointers(): FollowCameraInputsManager;
  38039. /**
  38040. * Add orientation input support to the input manager.
  38041. * @returns the current input manager
  38042. */
  38043. addVRDeviceOrientation(): FollowCameraInputsManager;
  38044. }
  38045. }
  38046. declare module BABYLON {
  38047. /**
  38048. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38049. * an arc rotate version arcFollowCamera are available.
  38050. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38051. */
  38052. export class FollowCamera extends TargetCamera {
  38053. /**
  38054. * Distance the follow camera should follow an object at
  38055. */
  38056. radius: number;
  38057. /**
  38058. * Minimum allowed distance of the camera to the axis of rotation
  38059. * (The camera can not get closer).
  38060. * This can help limiting how the Camera is able to move in the scene.
  38061. */
  38062. lowerRadiusLimit: Nullable<number>;
  38063. /**
  38064. * Maximum allowed distance of the camera to the axis of rotation
  38065. * (The camera can not get further).
  38066. * This can help limiting how the Camera is able to move in the scene.
  38067. */
  38068. upperRadiusLimit: Nullable<number>;
  38069. /**
  38070. * Define a rotation offset between the camera and the object it follows
  38071. */
  38072. rotationOffset: number;
  38073. /**
  38074. * Minimum allowed angle to camera position relative to target object.
  38075. * This can help limiting how the Camera is able to move in the scene.
  38076. */
  38077. lowerRotationOffsetLimit: Nullable<number>;
  38078. /**
  38079. * Maximum allowed angle to camera position relative to target object.
  38080. * This can help limiting how the Camera is able to move in the scene.
  38081. */
  38082. upperRotationOffsetLimit: Nullable<number>;
  38083. /**
  38084. * Define a height offset between the camera and the object it follows.
  38085. * It can help following an object from the top (like a car chaing a plane)
  38086. */
  38087. heightOffset: number;
  38088. /**
  38089. * Minimum allowed height of camera position relative to target object.
  38090. * This can help limiting how the Camera is able to move in the scene.
  38091. */
  38092. lowerHeightOffsetLimit: Nullable<number>;
  38093. /**
  38094. * Maximum allowed height of camera position relative to target object.
  38095. * This can help limiting how the Camera is able to move in the scene.
  38096. */
  38097. upperHeightOffsetLimit: Nullable<number>;
  38098. /**
  38099. * Define how fast the camera can accelerate to follow it s target.
  38100. */
  38101. cameraAcceleration: number;
  38102. /**
  38103. * Define the speed limit of the camera following an object.
  38104. */
  38105. maxCameraSpeed: number;
  38106. /**
  38107. * Define the target of the camera.
  38108. */
  38109. lockedTarget: Nullable<AbstractMesh>;
  38110. /**
  38111. * Defines the input associated with the camera.
  38112. */
  38113. inputs: FollowCameraInputsManager;
  38114. /**
  38115. * Instantiates the follow camera.
  38116. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38117. * @param name Define the name of the camera in the scene
  38118. * @param position Define the position of the camera
  38119. * @param scene Define the scene the camera belong to
  38120. * @param lockedTarget Define the target of the camera
  38121. */
  38122. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38123. private _follow;
  38124. /**
  38125. * Attached controls to the current camera.
  38126. * @param element Defines the element the controls should be listened from
  38127. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38128. */
  38129. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38130. /**
  38131. * Detach the current controls from the camera.
  38132. * The camera will stop reacting to inputs.
  38133. * @param element Defines the element to stop listening the inputs from
  38134. */
  38135. detachControl(element: HTMLElement): void;
  38136. /** @hidden */
  38137. _checkInputs(): void;
  38138. private _checkLimits;
  38139. /**
  38140. * Gets the camera class name.
  38141. * @returns the class name
  38142. */
  38143. getClassName(): string;
  38144. }
  38145. /**
  38146. * Arc Rotate version of the follow camera.
  38147. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38148. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38149. */
  38150. export class ArcFollowCamera extends TargetCamera {
  38151. /** The longitudinal angle of the camera */
  38152. alpha: number;
  38153. /** The latitudinal angle of the camera */
  38154. beta: number;
  38155. /** The radius of the camera from its target */
  38156. radius: number;
  38157. /** Define the camera target (the messh it should follow) */
  38158. target: Nullable<AbstractMesh>;
  38159. private _cartesianCoordinates;
  38160. /**
  38161. * Instantiates a new ArcFollowCamera
  38162. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38163. * @param name Define the name of the camera
  38164. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38165. * @param beta Define the rotation angle of the camera around the elevation axis
  38166. * @param radius Define the radius of the camera from its target point
  38167. * @param target Define the target of the camera
  38168. * @param scene Define the scene the camera belongs to
  38169. */
  38170. constructor(name: string,
  38171. /** The longitudinal angle of the camera */
  38172. alpha: number,
  38173. /** The latitudinal angle of the camera */
  38174. beta: number,
  38175. /** The radius of the camera from its target */
  38176. radius: number,
  38177. /** Define the camera target (the messh it should follow) */
  38178. target: Nullable<AbstractMesh>, scene: Scene);
  38179. private _follow;
  38180. /** @hidden */
  38181. _checkInputs(): void;
  38182. /**
  38183. * Returns the class name of the object.
  38184. * It is mostly used internally for serialization purposes.
  38185. */
  38186. getClassName(): string;
  38187. }
  38188. }
  38189. declare module BABYLON {
  38190. /**
  38191. * Manage the keyboard inputs to control the movement of a follow camera.
  38192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38193. */
  38194. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38195. /**
  38196. * Defines the camera the input is attached to.
  38197. */
  38198. camera: FollowCamera;
  38199. /**
  38200. * Defines the list of key codes associated with the up action (increase heightOffset)
  38201. */
  38202. keysHeightOffsetIncr: number[];
  38203. /**
  38204. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38205. */
  38206. keysHeightOffsetDecr: number[];
  38207. /**
  38208. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38209. */
  38210. keysHeightOffsetModifierAlt: boolean;
  38211. /**
  38212. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38213. */
  38214. keysHeightOffsetModifierCtrl: boolean;
  38215. /**
  38216. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38217. */
  38218. keysHeightOffsetModifierShift: boolean;
  38219. /**
  38220. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38221. */
  38222. keysRotationOffsetIncr: number[];
  38223. /**
  38224. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38225. */
  38226. keysRotationOffsetDecr: number[];
  38227. /**
  38228. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38229. */
  38230. keysRotationOffsetModifierAlt: boolean;
  38231. /**
  38232. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38233. */
  38234. keysRotationOffsetModifierCtrl: boolean;
  38235. /**
  38236. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38237. */
  38238. keysRotationOffsetModifierShift: boolean;
  38239. /**
  38240. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38241. */
  38242. keysRadiusIncr: number[];
  38243. /**
  38244. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38245. */
  38246. keysRadiusDecr: number[];
  38247. /**
  38248. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38249. */
  38250. keysRadiusModifierAlt: boolean;
  38251. /**
  38252. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38253. */
  38254. keysRadiusModifierCtrl: boolean;
  38255. /**
  38256. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38257. */
  38258. keysRadiusModifierShift: boolean;
  38259. /**
  38260. * Defines the rate of change of heightOffset.
  38261. */
  38262. heightSensibility: number;
  38263. /**
  38264. * Defines the rate of change of rotationOffset.
  38265. */
  38266. rotationSensibility: number;
  38267. /**
  38268. * Defines the rate of change of radius.
  38269. */
  38270. radiusSensibility: number;
  38271. private _keys;
  38272. private _ctrlPressed;
  38273. private _altPressed;
  38274. private _shiftPressed;
  38275. private _onCanvasBlurObserver;
  38276. private _onKeyboardObserver;
  38277. private _engine;
  38278. private _scene;
  38279. /**
  38280. * Attach the input controls to a specific dom element to get the input from.
  38281. * @param element Defines the element the controls should be listened from
  38282. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38283. */
  38284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38285. /**
  38286. * Detach the current controls from the specified dom element.
  38287. * @param element Defines the element to stop listening the inputs from
  38288. */
  38289. detachControl(element: Nullable<HTMLElement>): void;
  38290. /**
  38291. * Update the current camera state depending on the inputs that have been used this frame.
  38292. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38293. */
  38294. checkInputs(): void;
  38295. /**
  38296. * Gets the class name of the current input.
  38297. * @returns the class name
  38298. */
  38299. getClassName(): string;
  38300. /**
  38301. * Get the friendly name associated with the input class.
  38302. * @returns the input friendly name
  38303. */
  38304. getSimpleName(): string;
  38305. /**
  38306. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38307. * allow modification of the heightOffset value.
  38308. */
  38309. private _modifierHeightOffset;
  38310. /**
  38311. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38312. * allow modification of the rotationOffset value.
  38313. */
  38314. private _modifierRotationOffset;
  38315. /**
  38316. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38317. * allow modification of the radius value.
  38318. */
  38319. private _modifierRadius;
  38320. }
  38321. }
  38322. declare module BABYLON {
  38323. interface FreeCameraInputsManager {
  38324. /**
  38325. * @hidden
  38326. */
  38327. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38328. /**
  38329. * Add orientation input support to the input manager.
  38330. * @returns the current input manager
  38331. */
  38332. addDeviceOrientation(): FreeCameraInputsManager;
  38333. }
  38334. /**
  38335. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38336. * Screen rotation is taken into account.
  38337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38338. */
  38339. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38340. private _camera;
  38341. private _screenOrientationAngle;
  38342. private _constantTranform;
  38343. private _screenQuaternion;
  38344. private _alpha;
  38345. private _beta;
  38346. private _gamma;
  38347. /**
  38348. * Can be used to detect if a device orientation sensor is availible on a device
  38349. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38350. * @returns a promise that will resolve on orientation change
  38351. */
  38352. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38353. /**
  38354. * @hidden
  38355. */
  38356. _onDeviceOrientationChangedObservable: Observable<void>;
  38357. /**
  38358. * Instantiates a new input
  38359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38360. */
  38361. constructor();
  38362. /**
  38363. * Define the camera controlled by the input.
  38364. */
  38365. camera: FreeCamera;
  38366. /**
  38367. * Attach the input controls to a specific dom element to get the input from.
  38368. * @param element Defines the element the controls should be listened from
  38369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38370. */
  38371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38372. private _orientationChanged;
  38373. private _deviceOrientation;
  38374. /**
  38375. * Detach the current controls from the specified dom element.
  38376. * @param element Defines the element to stop listening the inputs from
  38377. */
  38378. detachControl(element: Nullable<HTMLElement>): void;
  38379. /**
  38380. * Update the current camera state depending on the inputs that have been used this frame.
  38381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38382. */
  38383. checkInputs(): void;
  38384. /**
  38385. * Gets the class name of the current intput.
  38386. * @returns the class name
  38387. */
  38388. getClassName(): string;
  38389. /**
  38390. * Get the friendly name associated with the input class.
  38391. * @returns the input friendly name
  38392. */
  38393. getSimpleName(): string;
  38394. }
  38395. }
  38396. declare module BABYLON {
  38397. /**
  38398. * Manage the gamepad inputs to control a free camera.
  38399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38400. */
  38401. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38402. /**
  38403. * Define the camera the input is attached to.
  38404. */
  38405. camera: FreeCamera;
  38406. /**
  38407. * Define the Gamepad controlling the input
  38408. */
  38409. gamepad: Nullable<Gamepad>;
  38410. /**
  38411. * Defines the gamepad rotation sensiblity.
  38412. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38413. */
  38414. gamepadAngularSensibility: number;
  38415. /**
  38416. * Defines the gamepad move sensiblity.
  38417. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38418. */
  38419. gamepadMoveSensibility: number;
  38420. private _onGamepadConnectedObserver;
  38421. private _onGamepadDisconnectedObserver;
  38422. private _cameraTransform;
  38423. private _deltaTransform;
  38424. private _vector3;
  38425. private _vector2;
  38426. /**
  38427. * Attach the input controls to a specific dom element to get the input from.
  38428. * @param element Defines the element the controls should be listened from
  38429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38430. */
  38431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38432. /**
  38433. * Detach the current controls from the specified dom element.
  38434. * @param element Defines the element to stop listening the inputs from
  38435. */
  38436. detachControl(element: Nullable<HTMLElement>): void;
  38437. /**
  38438. * Update the current camera state depending on the inputs that have been used this frame.
  38439. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38440. */
  38441. checkInputs(): void;
  38442. /**
  38443. * Gets the class name of the current intput.
  38444. * @returns the class name
  38445. */
  38446. getClassName(): string;
  38447. /**
  38448. * Get the friendly name associated with the input class.
  38449. * @returns the input friendly name
  38450. */
  38451. getSimpleName(): string;
  38452. }
  38453. }
  38454. declare module BABYLON {
  38455. /**
  38456. * Defines the potential axis of a Joystick
  38457. */
  38458. export enum JoystickAxis {
  38459. /** X axis */
  38460. X = 0,
  38461. /** Y axis */
  38462. Y = 1,
  38463. /** Z axis */
  38464. Z = 2
  38465. }
  38466. /**
  38467. * Class used to define virtual joystick (used in touch mode)
  38468. */
  38469. export class VirtualJoystick {
  38470. /**
  38471. * Gets or sets a boolean indicating that left and right values must be inverted
  38472. */
  38473. reverseLeftRight: boolean;
  38474. /**
  38475. * Gets or sets a boolean indicating that up and down values must be inverted
  38476. */
  38477. reverseUpDown: boolean;
  38478. /**
  38479. * Gets the offset value for the position (ie. the change of the position value)
  38480. */
  38481. deltaPosition: Vector3;
  38482. /**
  38483. * Gets a boolean indicating if the virtual joystick was pressed
  38484. */
  38485. pressed: boolean;
  38486. /**
  38487. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38488. */
  38489. static Canvas: Nullable<HTMLCanvasElement>;
  38490. private static _globalJoystickIndex;
  38491. private static vjCanvasContext;
  38492. private static vjCanvasWidth;
  38493. private static vjCanvasHeight;
  38494. private static halfWidth;
  38495. private _action;
  38496. private _axisTargetedByLeftAndRight;
  38497. private _axisTargetedByUpAndDown;
  38498. private _joystickSensibility;
  38499. private _inversedSensibility;
  38500. private _joystickPointerID;
  38501. private _joystickColor;
  38502. private _joystickPointerPos;
  38503. private _joystickPreviousPointerPos;
  38504. private _joystickPointerStartPos;
  38505. private _deltaJoystickVector;
  38506. private _leftJoystick;
  38507. private _touches;
  38508. private _onPointerDownHandlerRef;
  38509. private _onPointerMoveHandlerRef;
  38510. private _onPointerUpHandlerRef;
  38511. private _onResize;
  38512. /**
  38513. * Creates a new virtual joystick
  38514. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38515. */
  38516. constructor(leftJoystick?: boolean);
  38517. /**
  38518. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38519. * @param newJoystickSensibility defines the new sensibility
  38520. */
  38521. setJoystickSensibility(newJoystickSensibility: number): void;
  38522. private _onPointerDown;
  38523. private _onPointerMove;
  38524. private _onPointerUp;
  38525. /**
  38526. * Change the color of the virtual joystick
  38527. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38528. */
  38529. setJoystickColor(newColor: string): void;
  38530. /**
  38531. * Defines a callback to call when the joystick is touched
  38532. * @param action defines the callback
  38533. */
  38534. setActionOnTouch(action: () => any): void;
  38535. /**
  38536. * Defines which axis you'd like to control for left & right
  38537. * @param axis defines the axis to use
  38538. */
  38539. setAxisForLeftRight(axis: JoystickAxis): void;
  38540. /**
  38541. * Defines which axis you'd like to control for up & down
  38542. * @param axis defines the axis to use
  38543. */
  38544. setAxisForUpDown(axis: JoystickAxis): void;
  38545. private _drawVirtualJoystick;
  38546. /**
  38547. * Release internal HTML canvas
  38548. */
  38549. releaseCanvas(): void;
  38550. }
  38551. }
  38552. declare module BABYLON {
  38553. interface FreeCameraInputsManager {
  38554. /**
  38555. * Add virtual joystick input support to the input manager.
  38556. * @returns the current input manager
  38557. */
  38558. addVirtualJoystick(): FreeCameraInputsManager;
  38559. }
  38560. /**
  38561. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38563. */
  38564. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38565. /**
  38566. * Defines the camera the input is attached to.
  38567. */
  38568. camera: FreeCamera;
  38569. private _leftjoystick;
  38570. private _rightjoystick;
  38571. /**
  38572. * Gets the left stick of the virtual joystick.
  38573. * @returns The virtual Joystick
  38574. */
  38575. getLeftJoystick(): VirtualJoystick;
  38576. /**
  38577. * Gets the right stick of the virtual joystick.
  38578. * @returns The virtual Joystick
  38579. */
  38580. getRightJoystick(): VirtualJoystick;
  38581. /**
  38582. * Update the current camera state depending on the inputs that have been used this frame.
  38583. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38584. */
  38585. checkInputs(): void;
  38586. /**
  38587. * Attach the input controls to a specific dom element to get the input from.
  38588. * @param element Defines the element the controls should be listened from
  38589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38590. */
  38591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38592. /**
  38593. * Detach the current controls from the specified dom element.
  38594. * @param element Defines the element to stop listening the inputs from
  38595. */
  38596. detachControl(element: Nullable<HTMLElement>): void;
  38597. /**
  38598. * Gets the class name of the current intput.
  38599. * @returns the class name
  38600. */
  38601. getClassName(): string;
  38602. /**
  38603. * Get the friendly name associated with the input class.
  38604. * @returns the input friendly name
  38605. */
  38606. getSimpleName(): string;
  38607. }
  38608. }
  38609. declare module BABYLON {
  38610. /**
  38611. * This represents a FPS type of camera controlled by touch.
  38612. * This is like a universal camera minus the Gamepad controls.
  38613. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38614. */
  38615. export class TouchCamera extends FreeCamera {
  38616. /**
  38617. * Defines the touch sensibility for rotation.
  38618. * The higher the faster.
  38619. */
  38620. touchAngularSensibility: number;
  38621. /**
  38622. * Defines the touch sensibility for move.
  38623. * The higher the faster.
  38624. */
  38625. touchMoveSensibility: number;
  38626. /**
  38627. * Instantiates a new touch camera.
  38628. * This represents a FPS type of camera controlled by touch.
  38629. * This is like a universal camera minus the Gamepad controls.
  38630. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38631. * @param name Define the name of the camera in the scene
  38632. * @param position Define the start position of the camera in the scene
  38633. * @param scene Define the scene the camera belongs to
  38634. */
  38635. constructor(name: string, position: Vector3, scene: Scene);
  38636. /**
  38637. * Gets the current object class name.
  38638. * @return the class name
  38639. */
  38640. getClassName(): string;
  38641. /** @hidden */
  38642. _setupInputs(): void;
  38643. }
  38644. }
  38645. declare module BABYLON {
  38646. /**
  38647. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38648. * being tilted forward or back and left or right.
  38649. */
  38650. export class DeviceOrientationCamera extends FreeCamera {
  38651. private _initialQuaternion;
  38652. private _quaternionCache;
  38653. private _tmpDragQuaternion;
  38654. private _disablePointerInputWhenUsingDeviceOrientation;
  38655. /**
  38656. * Creates a new device orientation camera
  38657. * @param name The name of the camera
  38658. * @param position The start position camera
  38659. * @param scene The scene the camera belongs to
  38660. */
  38661. constructor(name: string, position: Vector3, scene: Scene);
  38662. /**
  38663. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38664. */
  38665. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38666. private _dragFactor;
  38667. /**
  38668. * Enabled turning on the y axis when the orientation sensor is active
  38669. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38670. */
  38671. enableHorizontalDragging(dragFactor?: number): void;
  38672. /**
  38673. * Gets the current instance class name ("DeviceOrientationCamera").
  38674. * This helps avoiding instanceof at run time.
  38675. * @returns the class name
  38676. */
  38677. getClassName(): string;
  38678. /**
  38679. * @hidden
  38680. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38681. */
  38682. _checkInputs(): void;
  38683. /**
  38684. * Reset the camera to its default orientation on the specified axis only.
  38685. * @param axis The axis to reset
  38686. */
  38687. resetToCurrentRotation(axis?: Axis): void;
  38688. }
  38689. }
  38690. declare module BABYLON {
  38691. /**
  38692. * Defines supported buttons for XBox360 compatible gamepads
  38693. */
  38694. export enum Xbox360Button {
  38695. /** A */
  38696. A = 0,
  38697. /** B */
  38698. B = 1,
  38699. /** X */
  38700. X = 2,
  38701. /** Y */
  38702. Y = 3,
  38703. /** Start */
  38704. Start = 4,
  38705. /** Back */
  38706. Back = 5,
  38707. /** Left button */
  38708. LB = 6,
  38709. /** Right button */
  38710. RB = 7,
  38711. /** Left stick */
  38712. LeftStick = 8,
  38713. /** Right stick */
  38714. RightStick = 9
  38715. }
  38716. /** Defines values for XBox360 DPad */
  38717. export enum Xbox360Dpad {
  38718. /** Up */
  38719. Up = 0,
  38720. /** Down */
  38721. Down = 1,
  38722. /** Left */
  38723. Left = 2,
  38724. /** Right */
  38725. Right = 3
  38726. }
  38727. /**
  38728. * Defines a XBox360 gamepad
  38729. */
  38730. export class Xbox360Pad extends Gamepad {
  38731. private _leftTrigger;
  38732. private _rightTrigger;
  38733. private _onlefttriggerchanged;
  38734. private _onrighttriggerchanged;
  38735. private _onbuttondown;
  38736. private _onbuttonup;
  38737. private _ondpaddown;
  38738. private _ondpadup;
  38739. /** Observable raised when a button is pressed */
  38740. onButtonDownObservable: Observable<Xbox360Button>;
  38741. /** Observable raised when a button is released */
  38742. onButtonUpObservable: Observable<Xbox360Button>;
  38743. /** Observable raised when a pad is pressed */
  38744. onPadDownObservable: Observable<Xbox360Dpad>;
  38745. /** Observable raised when a pad is released */
  38746. onPadUpObservable: Observable<Xbox360Dpad>;
  38747. private _buttonA;
  38748. private _buttonB;
  38749. private _buttonX;
  38750. private _buttonY;
  38751. private _buttonBack;
  38752. private _buttonStart;
  38753. private _buttonLB;
  38754. private _buttonRB;
  38755. private _buttonLeftStick;
  38756. private _buttonRightStick;
  38757. private _dPadUp;
  38758. private _dPadDown;
  38759. private _dPadLeft;
  38760. private _dPadRight;
  38761. private _isXboxOnePad;
  38762. /**
  38763. * Creates a new XBox360 gamepad object
  38764. * @param id defines the id of this gamepad
  38765. * @param index defines its index
  38766. * @param gamepad defines the internal HTML gamepad object
  38767. * @param xboxOne defines if it is a XBox One gamepad
  38768. */
  38769. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38770. /**
  38771. * Defines the callback to call when left trigger is pressed
  38772. * @param callback defines the callback to use
  38773. */
  38774. onlefttriggerchanged(callback: (value: number) => void): void;
  38775. /**
  38776. * Defines the callback to call when right trigger is pressed
  38777. * @param callback defines the callback to use
  38778. */
  38779. onrighttriggerchanged(callback: (value: number) => void): void;
  38780. /**
  38781. * Gets the left trigger value
  38782. */
  38783. /**
  38784. * Sets the left trigger value
  38785. */
  38786. leftTrigger: number;
  38787. /**
  38788. * Gets the right trigger value
  38789. */
  38790. /**
  38791. * Sets the right trigger value
  38792. */
  38793. rightTrigger: number;
  38794. /**
  38795. * Defines the callback to call when a button is pressed
  38796. * @param callback defines the callback to use
  38797. */
  38798. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38799. /**
  38800. * Defines the callback to call when a button is released
  38801. * @param callback defines the callback to use
  38802. */
  38803. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38804. /**
  38805. * Defines the callback to call when a pad is pressed
  38806. * @param callback defines the callback to use
  38807. */
  38808. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38809. /**
  38810. * Defines the callback to call when a pad is released
  38811. * @param callback defines the callback to use
  38812. */
  38813. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38814. private _setButtonValue;
  38815. private _setDPadValue;
  38816. /**
  38817. * Gets the value of the `A` button
  38818. */
  38819. /**
  38820. * Sets the value of the `A` button
  38821. */
  38822. buttonA: number;
  38823. /**
  38824. * Gets the value of the `B` button
  38825. */
  38826. /**
  38827. * Sets the value of the `B` button
  38828. */
  38829. buttonB: number;
  38830. /**
  38831. * Gets the value of the `X` button
  38832. */
  38833. /**
  38834. * Sets the value of the `X` button
  38835. */
  38836. buttonX: number;
  38837. /**
  38838. * Gets the value of the `Y` button
  38839. */
  38840. /**
  38841. * Sets the value of the `Y` button
  38842. */
  38843. buttonY: number;
  38844. /**
  38845. * Gets the value of the `Start` button
  38846. */
  38847. /**
  38848. * Sets the value of the `Start` button
  38849. */
  38850. buttonStart: number;
  38851. /**
  38852. * Gets the value of the `Back` button
  38853. */
  38854. /**
  38855. * Sets the value of the `Back` button
  38856. */
  38857. buttonBack: number;
  38858. /**
  38859. * Gets the value of the `Left` button
  38860. */
  38861. /**
  38862. * Sets the value of the `Left` button
  38863. */
  38864. buttonLB: number;
  38865. /**
  38866. * Gets the value of the `Right` button
  38867. */
  38868. /**
  38869. * Sets the value of the `Right` button
  38870. */
  38871. buttonRB: number;
  38872. /**
  38873. * Gets the value of the Left joystick
  38874. */
  38875. /**
  38876. * Sets the value of the Left joystick
  38877. */
  38878. buttonLeftStick: number;
  38879. /**
  38880. * Gets the value of the Right joystick
  38881. */
  38882. /**
  38883. * Sets the value of the Right joystick
  38884. */
  38885. buttonRightStick: number;
  38886. /**
  38887. * Gets the value of D-pad up
  38888. */
  38889. /**
  38890. * Sets the value of D-pad up
  38891. */
  38892. dPadUp: number;
  38893. /**
  38894. * Gets the value of D-pad down
  38895. */
  38896. /**
  38897. * Sets the value of D-pad down
  38898. */
  38899. dPadDown: number;
  38900. /**
  38901. * Gets the value of D-pad left
  38902. */
  38903. /**
  38904. * Sets the value of D-pad left
  38905. */
  38906. dPadLeft: number;
  38907. /**
  38908. * Gets the value of D-pad right
  38909. */
  38910. /**
  38911. * Sets the value of D-pad right
  38912. */
  38913. dPadRight: number;
  38914. /**
  38915. * Force the gamepad to synchronize with device values
  38916. */
  38917. update(): void;
  38918. /**
  38919. * Disposes the gamepad
  38920. */
  38921. dispose(): void;
  38922. }
  38923. }
  38924. declare module BABYLON {
  38925. /**
  38926. * Defines supported buttons for DualShock compatible gamepads
  38927. */
  38928. export enum DualShockButton {
  38929. /** Cross */
  38930. Cross = 0,
  38931. /** Circle */
  38932. Circle = 1,
  38933. /** Square */
  38934. Square = 2,
  38935. /** Triangle */
  38936. Triangle = 3,
  38937. /** Options */
  38938. Options = 4,
  38939. /** Share */
  38940. Share = 5,
  38941. /** L1 */
  38942. L1 = 6,
  38943. /** R1 */
  38944. R1 = 7,
  38945. /** Left stick */
  38946. LeftStick = 8,
  38947. /** Right stick */
  38948. RightStick = 9
  38949. }
  38950. /** Defines values for DualShock DPad */
  38951. export enum DualShockDpad {
  38952. /** Up */
  38953. Up = 0,
  38954. /** Down */
  38955. Down = 1,
  38956. /** Left */
  38957. Left = 2,
  38958. /** Right */
  38959. Right = 3
  38960. }
  38961. /**
  38962. * Defines a DualShock gamepad
  38963. */
  38964. export class DualShockPad extends Gamepad {
  38965. private _leftTrigger;
  38966. private _rightTrigger;
  38967. private _onlefttriggerchanged;
  38968. private _onrighttriggerchanged;
  38969. private _onbuttondown;
  38970. private _onbuttonup;
  38971. private _ondpaddown;
  38972. private _ondpadup;
  38973. /** Observable raised when a button is pressed */
  38974. onButtonDownObservable: Observable<DualShockButton>;
  38975. /** Observable raised when a button is released */
  38976. onButtonUpObservable: Observable<DualShockButton>;
  38977. /** Observable raised when a pad is pressed */
  38978. onPadDownObservable: Observable<DualShockDpad>;
  38979. /** Observable raised when a pad is released */
  38980. onPadUpObservable: Observable<DualShockDpad>;
  38981. private _buttonCross;
  38982. private _buttonCircle;
  38983. private _buttonSquare;
  38984. private _buttonTriangle;
  38985. private _buttonShare;
  38986. private _buttonOptions;
  38987. private _buttonL1;
  38988. private _buttonR1;
  38989. private _buttonLeftStick;
  38990. private _buttonRightStick;
  38991. private _dPadUp;
  38992. private _dPadDown;
  38993. private _dPadLeft;
  38994. private _dPadRight;
  38995. /**
  38996. * Creates a new DualShock gamepad object
  38997. * @param id defines the id of this gamepad
  38998. * @param index defines its index
  38999. * @param gamepad defines the internal HTML gamepad object
  39000. */
  39001. constructor(id: string, index: number, gamepad: any);
  39002. /**
  39003. * Defines the callback to call when left trigger is pressed
  39004. * @param callback defines the callback to use
  39005. */
  39006. onlefttriggerchanged(callback: (value: number) => void): void;
  39007. /**
  39008. * Defines the callback to call when right trigger is pressed
  39009. * @param callback defines the callback to use
  39010. */
  39011. onrighttriggerchanged(callback: (value: number) => void): void;
  39012. /**
  39013. * Gets the left trigger value
  39014. */
  39015. /**
  39016. * Sets the left trigger value
  39017. */
  39018. leftTrigger: number;
  39019. /**
  39020. * Gets the right trigger value
  39021. */
  39022. /**
  39023. * Sets the right trigger value
  39024. */
  39025. rightTrigger: number;
  39026. /**
  39027. * Defines the callback to call when a button is pressed
  39028. * @param callback defines the callback to use
  39029. */
  39030. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39031. /**
  39032. * Defines the callback to call when a button is released
  39033. * @param callback defines the callback to use
  39034. */
  39035. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39036. /**
  39037. * Defines the callback to call when a pad is pressed
  39038. * @param callback defines the callback to use
  39039. */
  39040. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39041. /**
  39042. * Defines the callback to call when a pad is released
  39043. * @param callback defines the callback to use
  39044. */
  39045. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39046. private _setButtonValue;
  39047. private _setDPadValue;
  39048. /**
  39049. * Gets the value of the `Cross` button
  39050. */
  39051. /**
  39052. * Sets the value of the `Cross` button
  39053. */
  39054. buttonCross: number;
  39055. /**
  39056. * Gets the value of the `Circle` button
  39057. */
  39058. /**
  39059. * Sets the value of the `Circle` button
  39060. */
  39061. buttonCircle: number;
  39062. /**
  39063. * Gets the value of the `Square` button
  39064. */
  39065. /**
  39066. * Sets the value of the `Square` button
  39067. */
  39068. buttonSquare: number;
  39069. /**
  39070. * Gets the value of the `Triangle` button
  39071. */
  39072. /**
  39073. * Sets the value of the `Triangle` button
  39074. */
  39075. buttonTriangle: number;
  39076. /**
  39077. * Gets the value of the `Options` button
  39078. */
  39079. /**
  39080. * Sets the value of the `Options` button
  39081. */
  39082. buttonOptions: number;
  39083. /**
  39084. * Gets the value of the `Share` button
  39085. */
  39086. /**
  39087. * Sets the value of the `Share` button
  39088. */
  39089. buttonShare: number;
  39090. /**
  39091. * Gets the value of the `L1` button
  39092. */
  39093. /**
  39094. * Sets the value of the `L1` button
  39095. */
  39096. buttonL1: number;
  39097. /**
  39098. * Gets the value of the `R1` button
  39099. */
  39100. /**
  39101. * Sets the value of the `R1` button
  39102. */
  39103. buttonR1: number;
  39104. /**
  39105. * Gets the value of the Left joystick
  39106. */
  39107. /**
  39108. * Sets the value of the Left joystick
  39109. */
  39110. buttonLeftStick: number;
  39111. /**
  39112. * Gets the value of the Right joystick
  39113. */
  39114. /**
  39115. * Sets the value of the Right joystick
  39116. */
  39117. buttonRightStick: number;
  39118. /**
  39119. * Gets the value of D-pad up
  39120. */
  39121. /**
  39122. * Sets the value of D-pad up
  39123. */
  39124. dPadUp: number;
  39125. /**
  39126. * Gets the value of D-pad down
  39127. */
  39128. /**
  39129. * Sets the value of D-pad down
  39130. */
  39131. dPadDown: number;
  39132. /**
  39133. * Gets the value of D-pad left
  39134. */
  39135. /**
  39136. * Sets the value of D-pad left
  39137. */
  39138. dPadLeft: number;
  39139. /**
  39140. * Gets the value of D-pad right
  39141. */
  39142. /**
  39143. * Sets the value of D-pad right
  39144. */
  39145. dPadRight: number;
  39146. /**
  39147. * Force the gamepad to synchronize with device values
  39148. */
  39149. update(): void;
  39150. /**
  39151. * Disposes the gamepad
  39152. */
  39153. dispose(): void;
  39154. }
  39155. }
  39156. declare module BABYLON {
  39157. /**
  39158. * Manager for handling gamepads
  39159. */
  39160. export class GamepadManager {
  39161. private _scene?;
  39162. private _babylonGamepads;
  39163. private _oneGamepadConnected;
  39164. /** @hidden */
  39165. _isMonitoring: boolean;
  39166. private _gamepadEventSupported;
  39167. private _gamepadSupport;
  39168. /**
  39169. * observable to be triggered when the gamepad controller has been connected
  39170. */
  39171. onGamepadConnectedObservable: Observable<Gamepad>;
  39172. /**
  39173. * observable to be triggered when the gamepad controller has been disconnected
  39174. */
  39175. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39176. private _onGamepadConnectedEvent;
  39177. private _onGamepadDisconnectedEvent;
  39178. /**
  39179. * Initializes the gamepad manager
  39180. * @param _scene BabylonJS scene
  39181. */
  39182. constructor(_scene?: Scene | undefined);
  39183. /**
  39184. * The gamepads in the game pad manager
  39185. */
  39186. readonly gamepads: Gamepad[];
  39187. /**
  39188. * Get the gamepad controllers based on type
  39189. * @param type The type of gamepad controller
  39190. * @returns Nullable gamepad
  39191. */
  39192. getGamepadByType(type?: number): Nullable<Gamepad>;
  39193. /**
  39194. * Disposes the gamepad manager
  39195. */
  39196. dispose(): void;
  39197. private _addNewGamepad;
  39198. private _startMonitoringGamepads;
  39199. private _stopMonitoringGamepads;
  39200. /** @hidden */
  39201. _checkGamepadsStatus(): void;
  39202. private _updateGamepadObjects;
  39203. }
  39204. }
  39205. declare module BABYLON {
  39206. interface Scene {
  39207. /** @hidden */
  39208. _gamepadManager: Nullable<GamepadManager>;
  39209. /**
  39210. * Gets the gamepad manager associated with the scene
  39211. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39212. */
  39213. gamepadManager: GamepadManager;
  39214. }
  39215. /**
  39216. * Interface representing a free camera inputs manager
  39217. */
  39218. interface FreeCameraInputsManager {
  39219. /**
  39220. * Adds gamepad input support to the FreeCameraInputsManager.
  39221. * @returns the FreeCameraInputsManager
  39222. */
  39223. addGamepad(): FreeCameraInputsManager;
  39224. }
  39225. /**
  39226. * Interface representing an arc rotate camera inputs manager
  39227. */
  39228. interface ArcRotateCameraInputsManager {
  39229. /**
  39230. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39231. * @returns the camera inputs manager
  39232. */
  39233. addGamepad(): ArcRotateCameraInputsManager;
  39234. }
  39235. /**
  39236. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39237. */
  39238. export class GamepadSystemSceneComponent implements ISceneComponent {
  39239. /**
  39240. * The component name helpfull to identify the component in the list of scene components.
  39241. */
  39242. readonly name: string;
  39243. /**
  39244. * The scene the component belongs to.
  39245. */
  39246. scene: Scene;
  39247. /**
  39248. * Creates a new instance of the component for the given scene
  39249. * @param scene Defines the scene to register the component in
  39250. */
  39251. constructor(scene: Scene);
  39252. /**
  39253. * Registers the component in a given scene
  39254. */
  39255. register(): void;
  39256. /**
  39257. * Rebuilds the elements related to this component in case of
  39258. * context lost for instance.
  39259. */
  39260. rebuild(): void;
  39261. /**
  39262. * Disposes the component and the associated ressources
  39263. */
  39264. dispose(): void;
  39265. private _beforeCameraUpdate;
  39266. }
  39267. }
  39268. declare module BABYLON {
  39269. /**
  39270. * 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,
  39271. * which still works and will still be found in many Playgrounds.
  39272. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39273. */
  39274. export class UniversalCamera extends TouchCamera {
  39275. /**
  39276. * Defines the gamepad rotation sensiblity.
  39277. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39278. */
  39279. gamepadAngularSensibility: number;
  39280. /**
  39281. * Defines the gamepad move sensiblity.
  39282. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39283. */
  39284. gamepadMoveSensibility: number;
  39285. /**
  39286. * 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,
  39287. * which still works and will still be found in many Playgrounds.
  39288. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39289. * @param name Define the name of the camera in the scene
  39290. * @param position Define the start position of the camera in the scene
  39291. * @param scene Define the scene the camera belongs to
  39292. */
  39293. constructor(name: string, position: Vector3, scene: Scene);
  39294. /**
  39295. * Gets the current object class name.
  39296. * @return the class name
  39297. */
  39298. getClassName(): string;
  39299. }
  39300. }
  39301. declare module BABYLON {
  39302. /**
  39303. * This represents a FPS type of camera. This is only here for back compat purpose.
  39304. * Please use the UniversalCamera instead as both are identical.
  39305. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39306. */
  39307. export class GamepadCamera extends UniversalCamera {
  39308. /**
  39309. * Instantiates a new Gamepad Camera
  39310. * This represents a FPS type of camera. This is only here for back compat purpose.
  39311. * Please use the UniversalCamera instead as both are identical.
  39312. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39313. * @param name Define the name of the camera in the scene
  39314. * @param position Define the start position of the camera in the scene
  39315. * @param scene Define the scene the camera belongs to
  39316. */
  39317. constructor(name: string, position: Vector3, scene: Scene);
  39318. /**
  39319. * Gets the current object class name.
  39320. * @return the class name
  39321. */
  39322. getClassName(): string;
  39323. }
  39324. }
  39325. declare module BABYLON {
  39326. /** @hidden */
  39327. export var passPixelShader: {
  39328. name: string;
  39329. shader: string;
  39330. };
  39331. }
  39332. declare module BABYLON {
  39333. /** @hidden */
  39334. export var passCubePixelShader: {
  39335. name: string;
  39336. shader: string;
  39337. };
  39338. }
  39339. declare module BABYLON {
  39340. /**
  39341. * PassPostProcess which produces an output the same as it's input
  39342. */
  39343. export class PassPostProcess extends PostProcess {
  39344. /**
  39345. * Creates the PassPostProcess
  39346. * @param name The name of the effect.
  39347. * @param options The required width/height ratio to downsize to before computing the render pass.
  39348. * @param camera The camera to apply the render pass to.
  39349. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39350. * @param engine The engine which the post process will be applied. (default: current engine)
  39351. * @param reusable If the post process can be reused on the same frame. (default: false)
  39352. * @param textureType The type of texture to be used when performing the post processing.
  39353. * @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)
  39354. */
  39355. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39356. }
  39357. /**
  39358. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39359. */
  39360. export class PassCubePostProcess extends PostProcess {
  39361. private _face;
  39362. /**
  39363. * Gets or sets the cube face to display.
  39364. * * 0 is +X
  39365. * * 1 is -X
  39366. * * 2 is +Y
  39367. * * 3 is -Y
  39368. * * 4 is +Z
  39369. * * 5 is -Z
  39370. */
  39371. face: number;
  39372. /**
  39373. * Creates the PassCubePostProcess
  39374. * @param name The name of the effect.
  39375. * @param options The required width/height ratio to downsize to before computing the render pass.
  39376. * @param camera The camera to apply the render pass to.
  39377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39378. * @param engine The engine which the post process will be applied. (default: current engine)
  39379. * @param reusable If the post process can be reused on the same frame. (default: false)
  39380. * @param textureType The type of texture to be used when performing the post processing.
  39381. * @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)
  39382. */
  39383. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39384. }
  39385. }
  39386. declare module BABYLON {
  39387. /** @hidden */
  39388. export var anaglyphPixelShader: {
  39389. name: string;
  39390. shader: string;
  39391. };
  39392. }
  39393. declare module BABYLON {
  39394. /**
  39395. * Postprocess used to generate anaglyphic rendering
  39396. */
  39397. export class AnaglyphPostProcess extends PostProcess {
  39398. private _passedProcess;
  39399. /**
  39400. * Creates a new AnaglyphPostProcess
  39401. * @param name defines postprocess name
  39402. * @param options defines creation options or target ratio scale
  39403. * @param rigCameras defines cameras using this postprocess
  39404. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39405. * @param engine defines hosting engine
  39406. * @param reusable defines if the postprocess will be reused multiple times per frame
  39407. */
  39408. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39409. }
  39410. }
  39411. declare module BABYLON {
  39412. /**
  39413. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39414. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39415. */
  39416. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39417. /**
  39418. * Creates a new AnaglyphArcRotateCamera
  39419. * @param name defines camera name
  39420. * @param alpha defines alpha angle (in radians)
  39421. * @param beta defines beta angle (in radians)
  39422. * @param radius defines radius
  39423. * @param target defines camera target
  39424. * @param interaxialDistance defines distance between each color axis
  39425. * @param scene defines the hosting scene
  39426. */
  39427. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39428. /**
  39429. * Gets camera class name
  39430. * @returns AnaglyphArcRotateCamera
  39431. */
  39432. getClassName(): string;
  39433. }
  39434. }
  39435. declare module BABYLON {
  39436. /**
  39437. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39438. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39439. */
  39440. export class AnaglyphFreeCamera extends FreeCamera {
  39441. /**
  39442. * Creates a new AnaglyphFreeCamera
  39443. * @param name defines camera name
  39444. * @param position defines initial position
  39445. * @param interaxialDistance defines distance between each color axis
  39446. * @param scene defines the hosting scene
  39447. */
  39448. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39449. /**
  39450. * Gets camera class name
  39451. * @returns AnaglyphFreeCamera
  39452. */
  39453. getClassName(): string;
  39454. }
  39455. }
  39456. declare module BABYLON {
  39457. /**
  39458. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39459. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39460. */
  39461. export class AnaglyphGamepadCamera extends GamepadCamera {
  39462. /**
  39463. * Creates a new AnaglyphGamepadCamera
  39464. * @param name defines camera name
  39465. * @param position defines initial position
  39466. * @param interaxialDistance defines distance between each color axis
  39467. * @param scene defines the hosting scene
  39468. */
  39469. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39470. /**
  39471. * Gets camera class name
  39472. * @returns AnaglyphGamepadCamera
  39473. */
  39474. getClassName(): string;
  39475. }
  39476. }
  39477. declare module BABYLON {
  39478. /**
  39479. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39480. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39481. */
  39482. export class AnaglyphUniversalCamera extends UniversalCamera {
  39483. /**
  39484. * Creates a new AnaglyphUniversalCamera
  39485. * @param name defines camera name
  39486. * @param position defines initial position
  39487. * @param interaxialDistance defines distance between each color axis
  39488. * @param scene defines the hosting scene
  39489. */
  39490. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39491. /**
  39492. * Gets camera class name
  39493. * @returns AnaglyphUniversalCamera
  39494. */
  39495. getClassName(): string;
  39496. }
  39497. }
  39498. declare module BABYLON {
  39499. /** @hidden */
  39500. export var stereoscopicInterlacePixelShader: {
  39501. name: string;
  39502. shader: string;
  39503. };
  39504. }
  39505. declare module BABYLON {
  39506. /**
  39507. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39508. */
  39509. export class StereoscopicInterlacePostProcess extends PostProcess {
  39510. private _stepSize;
  39511. private _passedProcess;
  39512. /**
  39513. * Initializes a StereoscopicInterlacePostProcess
  39514. * @param name The name of the effect.
  39515. * @param rigCameras The rig cameras to be appled to the post process
  39516. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39518. * @param engine The engine which the post process will be applied. (default: current engine)
  39519. * @param reusable If the post process can be reused on the same frame. (default: false)
  39520. */
  39521. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39522. }
  39523. }
  39524. declare module BABYLON {
  39525. /**
  39526. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39527. * @see http://doc.babylonjs.com/features/cameras
  39528. */
  39529. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39530. /**
  39531. * Creates a new StereoscopicArcRotateCamera
  39532. * @param name defines camera name
  39533. * @param alpha defines alpha angle (in radians)
  39534. * @param beta defines beta angle (in radians)
  39535. * @param radius defines radius
  39536. * @param target defines camera target
  39537. * @param interaxialDistance defines distance between each color axis
  39538. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39539. * @param scene defines the hosting scene
  39540. */
  39541. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39542. /**
  39543. * Gets camera class name
  39544. * @returns StereoscopicArcRotateCamera
  39545. */
  39546. getClassName(): string;
  39547. }
  39548. }
  39549. declare module BABYLON {
  39550. /**
  39551. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39552. * @see http://doc.babylonjs.com/features/cameras
  39553. */
  39554. export class StereoscopicFreeCamera extends FreeCamera {
  39555. /**
  39556. * Creates a new StereoscopicFreeCamera
  39557. * @param name defines camera name
  39558. * @param position defines initial position
  39559. * @param interaxialDistance defines distance between each color axis
  39560. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39561. * @param scene defines the hosting scene
  39562. */
  39563. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39564. /**
  39565. * Gets camera class name
  39566. * @returns StereoscopicFreeCamera
  39567. */
  39568. getClassName(): string;
  39569. }
  39570. }
  39571. declare module BABYLON {
  39572. /**
  39573. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39574. * @see http://doc.babylonjs.com/features/cameras
  39575. */
  39576. export class StereoscopicGamepadCamera extends GamepadCamera {
  39577. /**
  39578. * Creates a new StereoscopicGamepadCamera
  39579. * @param name defines camera name
  39580. * @param position defines initial position
  39581. * @param interaxialDistance defines distance between each color axis
  39582. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39583. * @param scene defines the hosting scene
  39584. */
  39585. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39586. /**
  39587. * Gets camera class name
  39588. * @returns StereoscopicGamepadCamera
  39589. */
  39590. getClassName(): string;
  39591. }
  39592. }
  39593. declare module BABYLON {
  39594. /**
  39595. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39596. * @see http://doc.babylonjs.com/features/cameras
  39597. */
  39598. export class StereoscopicUniversalCamera extends UniversalCamera {
  39599. /**
  39600. * Creates a new StereoscopicUniversalCamera
  39601. * @param name defines camera name
  39602. * @param position defines initial position
  39603. * @param interaxialDistance defines distance between each color axis
  39604. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39605. * @param scene defines the hosting scene
  39606. */
  39607. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39608. /**
  39609. * Gets camera class name
  39610. * @returns StereoscopicUniversalCamera
  39611. */
  39612. getClassName(): string;
  39613. }
  39614. }
  39615. declare module BABYLON {
  39616. /**
  39617. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39618. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39619. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39620. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39621. */
  39622. export class VirtualJoysticksCamera extends FreeCamera {
  39623. /**
  39624. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39625. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39626. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39627. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39628. * @param name Define the name of the camera in the scene
  39629. * @param position Define the start position of the camera in the scene
  39630. * @param scene Define the scene the camera belongs to
  39631. */
  39632. constructor(name: string, position: Vector3, scene: Scene);
  39633. /**
  39634. * Gets the current object class name.
  39635. * @return the class name
  39636. */
  39637. getClassName(): string;
  39638. }
  39639. }
  39640. declare module BABYLON {
  39641. /**
  39642. * This represents all the required metrics to create a VR camera.
  39643. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39644. */
  39645. export class VRCameraMetrics {
  39646. /**
  39647. * Define the horizontal resolution off the screen.
  39648. */
  39649. hResolution: number;
  39650. /**
  39651. * Define the vertical resolution off the screen.
  39652. */
  39653. vResolution: number;
  39654. /**
  39655. * Define the horizontal screen size.
  39656. */
  39657. hScreenSize: number;
  39658. /**
  39659. * Define the vertical screen size.
  39660. */
  39661. vScreenSize: number;
  39662. /**
  39663. * Define the vertical screen center position.
  39664. */
  39665. vScreenCenter: number;
  39666. /**
  39667. * Define the distance of the eyes to the screen.
  39668. */
  39669. eyeToScreenDistance: number;
  39670. /**
  39671. * Define the distance between both lenses
  39672. */
  39673. lensSeparationDistance: number;
  39674. /**
  39675. * Define the distance between both viewer's eyes.
  39676. */
  39677. interpupillaryDistance: number;
  39678. /**
  39679. * Define the distortion factor of the VR postprocess.
  39680. * Please, touch with care.
  39681. */
  39682. distortionK: number[];
  39683. /**
  39684. * Define the chromatic aberration correction factors for the VR post process.
  39685. */
  39686. chromaAbCorrection: number[];
  39687. /**
  39688. * Define the scale factor of the post process.
  39689. * The smaller the better but the slower.
  39690. */
  39691. postProcessScaleFactor: number;
  39692. /**
  39693. * Define an offset for the lens center.
  39694. */
  39695. lensCenterOffset: number;
  39696. /**
  39697. * Define if the current vr camera should compensate the distortion of the lense or not.
  39698. */
  39699. compensateDistortion: boolean;
  39700. /**
  39701. * Defines if multiview should be enabled when rendering (Default: false)
  39702. */
  39703. multiviewEnabled: boolean;
  39704. /**
  39705. * Gets the rendering aspect ratio based on the provided resolutions.
  39706. */
  39707. readonly aspectRatio: number;
  39708. /**
  39709. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39710. */
  39711. readonly aspectRatioFov: number;
  39712. /**
  39713. * @hidden
  39714. */
  39715. readonly leftHMatrix: Matrix;
  39716. /**
  39717. * @hidden
  39718. */
  39719. readonly rightHMatrix: Matrix;
  39720. /**
  39721. * @hidden
  39722. */
  39723. readonly leftPreViewMatrix: Matrix;
  39724. /**
  39725. * @hidden
  39726. */
  39727. readonly rightPreViewMatrix: Matrix;
  39728. /**
  39729. * Get the default VRMetrics based on the most generic setup.
  39730. * @returns the default vr metrics
  39731. */
  39732. static GetDefault(): VRCameraMetrics;
  39733. }
  39734. }
  39735. declare module BABYLON {
  39736. /** @hidden */
  39737. export var vrDistortionCorrectionPixelShader: {
  39738. name: string;
  39739. shader: string;
  39740. };
  39741. }
  39742. declare module BABYLON {
  39743. /**
  39744. * VRDistortionCorrectionPostProcess used for mobile VR
  39745. */
  39746. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39747. private _isRightEye;
  39748. private _distortionFactors;
  39749. private _postProcessScaleFactor;
  39750. private _lensCenterOffset;
  39751. private _scaleIn;
  39752. private _scaleFactor;
  39753. private _lensCenter;
  39754. /**
  39755. * Initializes the VRDistortionCorrectionPostProcess
  39756. * @param name The name of the effect.
  39757. * @param camera The camera to apply the render pass to.
  39758. * @param isRightEye If this is for the right eye distortion
  39759. * @param vrMetrics All the required metrics for the VR camera
  39760. */
  39761. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39762. }
  39763. }
  39764. declare module BABYLON {
  39765. /**
  39766. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39767. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39768. */
  39769. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39770. /**
  39771. * Creates a new VRDeviceOrientationArcRotateCamera
  39772. * @param name defines camera name
  39773. * @param alpha defines the camera rotation along the logitudinal axis
  39774. * @param beta defines the camera rotation along the latitudinal axis
  39775. * @param radius defines the camera distance from its target
  39776. * @param target defines the camera target
  39777. * @param scene defines the scene the camera belongs to
  39778. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39779. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39780. */
  39781. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39782. /**
  39783. * Gets camera class name
  39784. * @returns VRDeviceOrientationArcRotateCamera
  39785. */
  39786. getClassName(): string;
  39787. }
  39788. }
  39789. declare module BABYLON {
  39790. /**
  39791. * Camera used to simulate VR rendering (based on FreeCamera)
  39792. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39793. */
  39794. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39795. /**
  39796. * Creates a new VRDeviceOrientationFreeCamera
  39797. * @param name defines camera name
  39798. * @param position defines the start position of the camera
  39799. * @param scene defines the scene the camera belongs to
  39800. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39801. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39802. */
  39803. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39804. /**
  39805. * Gets camera class name
  39806. * @returns VRDeviceOrientationFreeCamera
  39807. */
  39808. getClassName(): string;
  39809. }
  39810. }
  39811. declare module BABYLON {
  39812. /**
  39813. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39814. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39815. */
  39816. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39817. /**
  39818. * Creates a new VRDeviceOrientationGamepadCamera
  39819. * @param name defines camera name
  39820. * @param position defines the start position of the camera
  39821. * @param scene defines the scene the camera belongs to
  39822. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39823. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39824. */
  39825. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39826. /**
  39827. * Gets camera class name
  39828. * @returns VRDeviceOrientationGamepadCamera
  39829. */
  39830. getClassName(): string;
  39831. }
  39832. }
  39833. declare module BABYLON {
  39834. /**
  39835. * Base class of materials working in push mode in babylon JS
  39836. * @hidden
  39837. */
  39838. export class PushMaterial extends Material {
  39839. protected _activeEffect: Effect;
  39840. protected _normalMatrix: Matrix;
  39841. /**
  39842. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39843. * This means that the material can keep using a previous shader while a new one is being compiled.
  39844. * This is mostly used when shader parallel compilation is supported (true by default)
  39845. */
  39846. allowShaderHotSwapping: boolean;
  39847. constructor(name: string, scene: Scene);
  39848. getEffect(): Effect;
  39849. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39850. /**
  39851. * Binds the given world matrix to the active effect
  39852. *
  39853. * @param world the matrix to bind
  39854. */
  39855. bindOnlyWorldMatrix(world: Matrix): void;
  39856. /**
  39857. * Binds the given normal matrix to the active effect
  39858. *
  39859. * @param normalMatrix the matrix to bind
  39860. */
  39861. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39862. bind(world: Matrix, mesh?: Mesh): void;
  39863. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39864. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39865. }
  39866. }
  39867. declare module BABYLON {
  39868. /**
  39869. * This groups all the flags used to control the materials channel.
  39870. */
  39871. export class MaterialFlags {
  39872. private static _DiffuseTextureEnabled;
  39873. /**
  39874. * Are diffuse textures enabled in the application.
  39875. */
  39876. static DiffuseTextureEnabled: boolean;
  39877. private static _AmbientTextureEnabled;
  39878. /**
  39879. * Are ambient textures enabled in the application.
  39880. */
  39881. static AmbientTextureEnabled: boolean;
  39882. private static _OpacityTextureEnabled;
  39883. /**
  39884. * Are opacity textures enabled in the application.
  39885. */
  39886. static OpacityTextureEnabled: boolean;
  39887. private static _ReflectionTextureEnabled;
  39888. /**
  39889. * Are reflection textures enabled in the application.
  39890. */
  39891. static ReflectionTextureEnabled: boolean;
  39892. private static _EmissiveTextureEnabled;
  39893. /**
  39894. * Are emissive textures enabled in the application.
  39895. */
  39896. static EmissiveTextureEnabled: boolean;
  39897. private static _SpecularTextureEnabled;
  39898. /**
  39899. * Are specular textures enabled in the application.
  39900. */
  39901. static SpecularTextureEnabled: boolean;
  39902. private static _BumpTextureEnabled;
  39903. /**
  39904. * Are bump textures enabled in the application.
  39905. */
  39906. static BumpTextureEnabled: boolean;
  39907. private static _LightmapTextureEnabled;
  39908. /**
  39909. * Are lightmap textures enabled in the application.
  39910. */
  39911. static LightmapTextureEnabled: boolean;
  39912. private static _RefractionTextureEnabled;
  39913. /**
  39914. * Are refraction textures enabled in the application.
  39915. */
  39916. static RefractionTextureEnabled: boolean;
  39917. private static _ColorGradingTextureEnabled;
  39918. /**
  39919. * Are color grading textures enabled in the application.
  39920. */
  39921. static ColorGradingTextureEnabled: boolean;
  39922. private static _FresnelEnabled;
  39923. /**
  39924. * Are fresnels enabled in the application.
  39925. */
  39926. static FresnelEnabled: boolean;
  39927. private static _ClearCoatTextureEnabled;
  39928. /**
  39929. * Are clear coat textures enabled in the application.
  39930. */
  39931. static ClearCoatTextureEnabled: boolean;
  39932. private static _ClearCoatBumpTextureEnabled;
  39933. /**
  39934. * Are clear coat bump textures enabled in the application.
  39935. */
  39936. static ClearCoatBumpTextureEnabled: boolean;
  39937. private static _ClearCoatTintTextureEnabled;
  39938. /**
  39939. * Are clear coat tint textures enabled in the application.
  39940. */
  39941. static ClearCoatTintTextureEnabled: boolean;
  39942. private static _SheenTextureEnabled;
  39943. /**
  39944. * Are sheen textures enabled in the application.
  39945. */
  39946. static SheenTextureEnabled: boolean;
  39947. private static _AnisotropicTextureEnabled;
  39948. /**
  39949. * Are anisotropic textures enabled in the application.
  39950. */
  39951. static AnisotropicTextureEnabled: boolean;
  39952. private static _ThicknessTextureEnabled;
  39953. /**
  39954. * Are thickness textures enabled in the application.
  39955. */
  39956. static ThicknessTextureEnabled: boolean;
  39957. }
  39958. }
  39959. declare module BABYLON {
  39960. /** @hidden */
  39961. export var defaultFragmentDeclaration: {
  39962. name: string;
  39963. shader: string;
  39964. };
  39965. }
  39966. declare module BABYLON {
  39967. /** @hidden */
  39968. export var defaultUboDeclaration: {
  39969. name: string;
  39970. shader: string;
  39971. };
  39972. }
  39973. declare module BABYLON {
  39974. /** @hidden */
  39975. export var lightFragmentDeclaration: {
  39976. name: string;
  39977. shader: string;
  39978. };
  39979. }
  39980. declare module BABYLON {
  39981. /** @hidden */
  39982. export var lightUboDeclaration: {
  39983. name: string;
  39984. shader: string;
  39985. };
  39986. }
  39987. declare module BABYLON {
  39988. /** @hidden */
  39989. export var lightsFragmentFunctions: {
  39990. name: string;
  39991. shader: string;
  39992. };
  39993. }
  39994. declare module BABYLON {
  39995. /** @hidden */
  39996. export var shadowsFragmentFunctions: {
  39997. name: string;
  39998. shader: string;
  39999. };
  40000. }
  40001. declare module BABYLON {
  40002. /** @hidden */
  40003. export var fresnelFunction: {
  40004. name: string;
  40005. shader: string;
  40006. };
  40007. }
  40008. declare module BABYLON {
  40009. /** @hidden */
  40010. export var reflectionFunction: {
  40011. name: string;
  40012. shader: string;
  40013. };
  40014. }
  40015. declare module BABYLON {
  40016. /** @hidden */
  40017. export var bumpFragmentFunctions: {
  40018. name: string;
  40019. shader: string;
  40020. };
  40021. }
  40022. declare module BABYLON {
  40023. /** @hidden */
  40024. export var logDepthDeclaration: {
  40025. name: string;
  40026. shader: string;
  40027. };
  40028. }
  40029. declare module BABYLON {
  40030. /** @hidden */
  40031. export var bumpFragment: {
  40032. name: string;
  40033. shader: string;
  40034. };
  40035. }
  40036. declare module BABYLON {
  40037. /** @hidden */
  40038. export var depthPrePass: {
  40039. name: string;
  40040. shader: string;
  40041. };
  40042. }
  40043. declare module BABYLON {
  40044. /** @hidden */
  40045. export var lightFragment: {
  40046. name: string;
  40047. shader: string;
  40048. };
  40049. }
  40050. declare module BABYLON {
  40051. /** @hidden */
  40052. export var logDepthFragment: {
  40053. name: string;
  40054. shader: string;
  40055. };
  40056. }
  40057. declare module BABYLON {
  40058. /** @hidden */
  40059. export var defaultPixelShader: {
  40060. name: string;
  40061. shader: string;
  40062. };
  40063. }
  40064. declare module BABYLON {
  40065. /** @hidden */
  40066. export var defaultVertexDeclaration: {
  40067. name: string;
  40068. shader: string;
  40069. };
  40070. }
  40071. declare module BABYLON {
  40072. /** @hidden */
  40073. export var bumpVertexDeclaration: {
  40074. name: string;
  40075. shader: string;
  40076. };
  40077. }
  40078. declare module BABYLON {
  40079. /** @hidden */
  40080. export var bumpVertex: {
  40081. name: string;
  40082. shader: string;
  40083. };
  40084. }
  40085. declare module BABYLON {
  40086. /** @hidden */
  40087. export var fogVertex: {
  40088. name: string;
  40089. shader: string;
  40090. };
  40091. }
  40092. declare module BABYLON {
  40093. /** @hidden */
  40094. export var shadowsVertex: {
  40095. name: string;
  40096. shader: string;
  40097. };
  40098. }
  40099. declare module BABYLON {
  40100. /** @hidden */
  40101. export var pointCloudVertex: {
  40102. name: string;
  40103. shader: string;
  40104. };
  40105. }
  40106. declare module BABYLON {
  40107. /** @hidden */
  40108. export var logDepthVertex: {
  40109. name: string;
  40110. shader: string;
  40111. };
  40112. }
  40113. declare module BABYLON {
  40114. /** @hidden */
  40115. export var defaultVertexShader: {
  40116. name: string;
  40117. shader: string;
  40118. };
  40119. }
  40120. declare module BABYLON {
  40121. /** @hidden */
  40122. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40123. MAINUV1: boolean;
  40124. MAINUV2: boolean;
  40125. DIFFUSE: boolean;
  40126. DIFFUSEDIRECTUV: number;
  40127. AMBIENT: boolean;
  40128. AMBIENTDIRECTUV: number;
  40129. OPACITY: boolean;
  40130. OPACITYDIRECTUV: number;
  40131. OPACITYRGB: boolean;
  40132. REFLECTION: boolean;
  40133. EMISSIVE: boolean;
  40134. EMISSIVEDIRECTUV: number;
  40135. SPECULAR: boolean;
  40136. SPECULARDIRECTUV: number;
  40137. BUMP: boolean;
  40138. BUMPDIRECTUV: number;
  40139. PARALLAX: boolean;
  40140. PARALLAXOCCLUSION: boolean;
  40141. SPECULAROVERALPHA: boolean;
  40142. CLIPPLANE: boolean;
  40143. CLIPPLANE2: boolean;
  40144. CLIPPLANE3: boolean;
  40145. CLIPPLANE4: boolean;
  40146. ALPHATEST: boolean;
  40147. DEPTHPREPASS: boolean;
  40148. ALPHAFROMDIFFUSE: boolean;
  40149. POINTSIZE: boolean;
  40150. FOG: boolean;
  40151. SPECULARTERM: boolean;
  40152. DIFFUSEFRESNEL: boolean;
  40153. OPACITYFRESNEL: boolean;
  40154. REFLECTIONFRESNEL: boolean;
  40155. REFRACTIONFRESNEL: boolean;
  40156. EMISSIVEFRESNEL: boolean;
  40157. FRESNEL: boolean;
  40158. NORMAL: boolean;
  40159. UV1: boolean;
  40160. UV2: boolean;
  40161. VERTEXCOLOR: boolean;
  40162. VERTEXALPHA: boolean;
  40163. NUM_BONE_INFLUENCERS: number;
  40164. BonesPerMesh: number;
  40165. BONETEXTURE: boolean;
  40166. INSTANCES: boolean;
  40167. GLOSSINESS: boolean;
  40168. ROUGHNESS: boolean;
  40169. EMISSIVEASILLUMINATION: boolean;
  40170. LINKEMISSIVEWITHDIFFUSE: boolean;
  40171. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40172. LIGHTMAP: boolean;
  40173. LIGHTMAPDIRECTUV: number;
  40174. OBJECTSPACE_NORMALMAP: boolean;
  40175. USELIGHTMAPASSHADOWMAP: boolean;
  40176. REFLECTIONMAP_3D: boolean;
  40177. REFLECTIONMAP_SPHERICAL: boolean;
  40178. REFLECTIONMAP_PLANAR: boolean;
  40179. REFLECTIONMAP_CUBIC: boolean;
  40180. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40181. REFLECTIONMAP_PROJECTION: boolean;
  40182. REFLECTIONMAP_SKYBOX: boolean;
  40183. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40184. REFLECTIONMAP_EXPLICIT: boolean;
  40185. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40186. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40187. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40188. INVERTCUBICMAP: boolean;
  40189. LOGARITHMICDEPTH: boolean;
  40190. REFRACTION: boolean;
  40191. REFRACTIONMAP_3D: boolean;
  40192. REFLECTIONOVERALPHA: boolean;
  40193. TWOSIDEDLIGHTING: boolean;
  40194. SHADOWFLOAT: boolean;
  40195. MORPHTARGETS: boolean;
  40196. MORPHTARGETS_NORMAL: boolean;
  40197. MORPHTARGETS_TANGENT: boolean;
  40198. MORPHTARGETS_UV: boolean;
  40199. NUM_MORPH_INFLUENCERS: number;
  40200. NONUNIFORMSCALING: boolean;
  40201. PREMULTIPLYALPHA: boolean;
  40202. IMAGEPROCESSING: boolean;
  40203. VIGNETTE: boolean;
  40204. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40205. VIGNETTEBLENDMODEOPAQUE: boolean;
  40206. TONEMAPPING: boolean;
  40207. TONEMAPPING_ACES: boolean;
  40208. CONTRAST: boolean;
  40209. COLORCURVES: boolean;
  40210. COLORGRADING: boolean;
  40211. COLORGRADING3D: boolean;
  40212. SAMPLER3DGREENDEPTH: boolean;
  40213. SAMPLER3DBGRMAP: boolean;
  40214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40215. MULTIVIEW: boolean;
  40216. /**
  40217. * If the reflection texture on this material is in linear color space
  40218. * @hidden
  40219. */
  40220. IS_REFLECTION_LINEAR: boolean;
  40221. /**
  40222. * If the refraction texture on this material is in linear color space
  40223. * @hidden
  40224. */
  40225. IS_REFRACTION_LINEAR: boolean;
  40226. EXPOSURE: boolean;
  40227. constructor();
  40228. setReflectionMode(modeToEnable: string): void;
  40229. }
  40230. /**
  40231. * This is the default material used in Babylon. It is the best trade off between quality
  40232. * and performances.
  40233. * @see http://doc.babylonjs.com/babylon101/materials
  40234. */
  40235. export class StandardMaterial extends PushMaterial {
  40236. private _diffuseTexture;
  40237. /**
  40238. * The basic texture of the material as viewed under a light.
  40239. */
  40240. diffuseTexture: Nullable<BaseTexture>;
  40241. private _ambientTexture;
  40242. /**
  40243. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40244. */
  40245. ambientTexture: Nullable<BaseTexture>;
  40246. private _opacityTexture;
  40247. /**
  40248. * Define the transparency of the material from a texture.
  40249. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40250. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40251. */
  40252. opacityTexture: Nullable<BaseTexture>;
  40253. private _reflectionTexture;
  40254. /**
  40255. * Define the texture used to display the reflection.
  40256. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40257. */
  40258. reflectionTexture: Nullable<BaseTexture>;
  40259. private _emissiveTexture;
  40260. /**
  40261. * Define texture of the material as if self lit.
  40262. * This will be mixed in the final result even in the absence of light.
  40263. */
  40264. emissiveTexture: Nullable<BaseTexture>;
  40265. private _specularTexture;
  40266. /**
  40267. * Define how the color and intensity of the highlight given by the light in the material.
  40268. */
  40269. specularTexture: Nullable<BaseTexture>;
  40270. private _bumpTexture;
  40271. /**
  40272. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40273. * 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.
  40274. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40275. */
  40276. bumpTexture: Nullable<BaseTexture>;
  40277. private _lightmapTexture;
  40278. /**
  40279. * Complex lighting can be computationally expensive to compute at runtime.
  40280. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40281. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40282. */
  40283. lightmapTexture: Nullable<BaseTexture>;
  40284. private _refractionTexture;
  40285. /**
  40286. * Define the texture used to display the refraction.
  40287. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40288. */
  40289. refractionTexture: Nullable<BaseTexture>;
  40290. /**
  40291. * The color of the material lit by the environmental background lighting.
  40292. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40293. */
  40294. ambientColor: Color3;
  40295. /**
  40296. * The basic color of the material as viewed under a light.
  40297. */
  40298. diffuseColor: Color3;
  40299. /**
  40300. * Define how the color and intensity of the highlight given by the light in the material.
  40301. */
  40302. specularColor: Color3;
  40303. /**
  40304. * Define the color of the material as if self lit.
  40305. * This will be mixed in the final result even in the absence of light.
  40306. */
  40307. emissiveColor: Color3;
  40308. /**
  40309. * Defines how sharp are the highlights in the material.
  40310. * The bigger the value the sharper giving a more glossy feeling to the result.
  40311. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40312. */
  40313. specularPower: number;
  40314. private _useAlphaFromDiffuseTexture;
  40315. /**
  40316. * Does the transparency come from the diffuse texture alpha channel.
  40317. */
  40318. useAlphaFromDiffuseTexture: boolean;
  40319. private _useEmissiveAsIllumination;
  40320. /**
  40321. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40322. */
  40323. useEmissiveAsIllumination: boolean;
  40324. private _linkEmissiveWithDiffuse;
  40325. /**
  40326. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40327. * the emissive level when the final color is close to one.
  40328. */
  40329. linkEmissiveWithDiffuse: boolean;
  40330. private _useSpecularOverAlpha;
  40331. /**
  40332. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40333. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40334. */
  40335. useSpecularOverAlpha: boolean;
  40336. private _useReflectionOverAlpha;
  40337. /**
  40338. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40339. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40340. */
  40341. useReflectionOverAlpha: boolean;
  40342. private _disableLighting;
  40343. /**
  40344. * Does lights from the scene impacts this material.
  40345. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40346. */
  40347. disableLighting: boolean;
  40348. private _useObjectSpaceNormalMap;
  40349. /**
  40350. * Allows using an object space normal map (instead of tangent space).
  40351. */
  40352. useObjectSpaceNormalMap: boolean;
  40353. private _useParallax;
  40354. /**
  40355. * Is parallax enabled or not.
  40356. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40357. */
  40358. useParallax: boolean;
  40359. private _useParallaxOcclusion;
  40360. /**
  40361. * Is parallax occlusion enabled or not.
  40362. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40363. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40364. */
  40365. useParallaxOcclusion: boolean;
  40366. /**
  40367. * 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.
  40368. */
  40369. parallaxScaleBias: number;
  40370. private _roughness;
  40371. /**
  40372. * Helps to define how blurry the reflections should appears in the material.
  40373. */
  40374. roughness: number;
  40375. /**
  40376. * In case of refraction, define the value of the index of refraction.
  40377. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40378. */
  40379. indexOfRefraction: number;
  40380. /**
  40381. * Invert the refraction texture alongside the y axis.
  40382. * It can be useful with procedural textures or probe for instance.
  40383. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40384. */
  40385. invertRefractionY: boolean;
  40386. /**
  40387. * Defines the alpha limits in alpha test mode.
  40388. */
  40389. alphaCutOff: number;
  40390. private _useLightmapAsShadowmap;
  40391. /**
  40392. * In case of light mapping, define whether the map contains light or shadow informations.
  40393. */
  40394. useLightmapAsShadowmap: boolean;
  40395. private _diffuseFresnelParameters;
  40396. /**
  40397. * Define the diffuse fresnel parameters of the material.
  40398. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40399. */
  40400. diffuseFresnelParameters: FresnelParameters;
  40401. private _opacityFresnelParameters;
  40402. /**
  40403. * Define the opacity fresnel parameters of the material.
  40404. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40405. */
  40406. opacityFresnelParameters: FresnelParameters;
  40407. private _reflectionFresnelParameters;
  40408. /**
  40409. * Define the reflection fresnel parameters of the material.
  40410. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40411. */
  40412. reflectionFresnelParameters: FresnelParameters;
  40413. private _refractionFresnelParameters;
  40414. /**
  40415. * Define the refraction fresnel parameters of the material.
  40416. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40417. */
  40418. refractionFresnelParameters: FresnelParameters;
  40419. private _emissiveFresnelParameters;
  40420. /**
  40421. * Define the emissive fresnel parameters of the material.
  40422. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40423. */
  40424. emissiveFresnelParameters: FresnelParameters;
  40425. private _useReflectionFresnelFromSpecular;
  40426. /**
  40427. * If true automatically deducts the fresnels values from the material specularity.
  40428. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40429. */
  40430. useReflectionFresnelFromSpecular: boolean;
  40431. private _useGlossinessFromSpecularMapAlpha;
  40432. /**
  40433. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40434. */
  40435. useGlossinessFromSpecularMapAlpha: boolean;
  40436. private _maxSimultaneousLights;
  40437. /**
  40438. * Defines the maximum number of lights that can be used in the material
  40439. */
  40440. maxSimultaneousLights: number;
  40441. private _invertNormalMapX;
  40442. /**
  40443. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40444. */
  40445. invertNormalMapX: boolean;
  40446. private _invertNormalMapY;
  40447. /**
  40448. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40449. */
  40450. invertNormalMapY: boolean;
  40451. private _twoSidedLighting;
  40452. /**
  40453. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40454. */
  40455. twoSidedLighting: boolean;
  40456. /**
  40457. * Default configuration related to image processing available in the standard Material.
  40458. */
  40459. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40460. /**
  40461. * Gets the image processing configuration used either in this material.
  40462. */
  40463. /**
  40464. * Sets the Default image processing configuration used either in the this material.
  40465. *
  40466. * If sets to null, the scene one is in use.
  40467. */
  40468. imageProcessingConfiguration: ImageProcessingConfiguration;
  40469. /**
  40470. * Keep track of the image processing observer to allow dispose and replace.
  40471. */
  40472. private _imageProcessingObserver;
  40473. /**
  40474. * Attaches a new image processing configuration to the Standard Material.
  40475. * @param configuration
  40476. */
  40477. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40478. /**
  40479. * Gets wether the color curves effect is enabled.
  40480. */
  40481. /**
  40482. * Sets wether the color curves effect is enabled.
  40483. */
  40484. cameraColorCurvesEnabled: boolean;
  40485. /**
  40486. * Gets wether the color grading effect is enabled.
  40487. */
  40488. /**
  40489. * Gets wether the color grading effect is enabled.
  40490. */
  40491. cameraColorGradingEnabled: boolean;
  40492. /**
  40493. * Gets wether tonemapping is enabled or not.
  40494. */
  40495. /**
  40496. * Sets wether tonemapping is enabled or not
  40497. */
  40498. cameraToneMappingEnabled: boolean;
  40499. /**
  40500. * The camera exposure used on this material.
  40501. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40502. * This corresponds to a photographic exposure.
  40503. */
  40504. /**
  40505. * The camera exposure used on this material.
  40506. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40507. * This corresponds to a photographic exposure.
  40508. */
  40509. cameraExposure: number;
  40510. /**
  40511. * Gets The camera contrast used on this material.
  40512. */
  40513. /**
  40514. * Sets The camera contrast used on this material.
  40515. */
  40516. cameraContrast: number;
  40517. /**
  40518. * Gets the Color Grading 2D Lookup Texture.
  40519. */
  40520. /**
  40521. * Sets the Color Grading 2D Lookup Texture.
  40522. */
  40523. cameraColorGradingTexture: Nullable<BaseTexture>;
  40524. /**
  40525. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40526. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40527. * 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;
  40528. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40529. */
  40530. /**
  40531. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40532. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40533. * 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;
  40534. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40535. */
  40536. cameraColorCurves: Nullable<ColorCurves>;
  40537. /**
  40538. * Custom callback helping to override the default shader used in the material.
  40539. */
  40540. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40541. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40542. protected _worldViewProjectionMatrix: Matrix;
  40543. protected _globalAmbientColor: Color3;
  40544. protected _useLogarithmicDepth: boolean;
  40545. protected _rebuildInParallel: boolean;
  40546. /**
  40547. * Instantiates a new standard material.
  40548. * This is the default material used in Babylon. It is the best trade off between quality
  40549. * and performances.
  40550. * @see http://doc.babylonjs.com/babylon101/materials
  40551. * @param name Define the name of the material in the scene
  40552. * @param scene Define the scene the material belong to
  40553. */
  40554. constructor(name: string, scene: Scene);
  40555. /**
  40556. * Gets a boolean indicating that current material needs to register RTT
  40557. */
  40558. readonly hasRenderTargetTextures: boolean;
  40559. /**
  40560. * Gets the current class name of the material e.g. "StandardMaterial"
  40561. * Mainly use in serialization.
  40562. * @returns the class name
  40563. */
  40564. getClassName(): string;
  40565. /**
  40566. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40567. * You can try switching to logarithmic depth.
  40568. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40569. */
  40570. useLogarithmicDepth: boolean;
  40571. /**
  40572. * Specifies if the material will require alpha blending
  40573. * @returns a boolean specifying if alpha blending is needed
  40574. */
  40575. needAlphaBlending(): boolean;
  40576. /**
  40577. * Specifies if this material should be rendered in alpha test mode
  40578. * @returns a boolean specifying if an alpha test is needed.
  40579. */
  40580. needAlphaTesting(): boolean;
  40581. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40582. /**
  40583. * Get the texture used for alpha test purpose.
  40584. * @returns the diffuse texture in case of the standard material.
  40585. */
  40586. getAlphaTestTexture(): Nullable<BaseTexture>;
  40587. /**
  40588. * Get if the submesh is ready to be used and all its information available.
  40589. * Child classes can use it to update shaders
  40590. * @param mesh defines the mesh to check
  40591. * @param subMesh defines which submesh to check
  40592. * @param useInstances specifies that instances should be used
  40593. * @returns a boolean indicating that the submesh is ready or not
  40594. */
  40595. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40596. /**
  40597. * Builds the material UBO layouts.
  40598. * Used internally during the effect preparation.
  40599. */
  40600. buildUniformLayout(): void;
  40601. /**
  40602. * Unbinds the material from the mesh
  40603. */
  40604. unbind(): void;
  40605. /**
  40606. * Binds the submesh to this material by preparing the effect and shader to draw
  40607. * @param world defines the world transformation matrix
  40608. * @param mesh defines the mesh containing the submesh
  40609. * @param subMesh defines the submesh to bind the material to
  40610. */
  40611. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40612. /**
  40613. * Get the list of animatables in the material.
  40614. * @returns the list of animatables object used in the material
  40615. */
  40616. getAnimatables(): IAnimatable[];
  40617. /**
  40618. * Gets the active textures from the material
  40619. * @returns an array of textures
  40620. */
  40621. getActiveTextures(): BaseTexture[];
  40622. /**
  40623. * Specifies if the material uses a texture
  40624. * @param texture defines the texture to check against the material
  40625. * @returns a boolean specifying if the material uses the texture
  40626. */
  40627. hasTexture(texture: BaseTexture): boolean;
  40628. /**
  40629. * Disposes the material
  40630. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40631. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40632. */
  40633. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40634. /**
  40635. * Makes a duplicate of the material, and gives it a new name
  40636. * @param name defines the new name for the duplicated material
  40637. * @returns the cloned material
  40638. */
  40639. clone(name: string): StandardMaterial;
  40640. /**
  40641. * Serializes this material in a JSON representation
  40642. * @returns the serialized material object
  40643. */
  40644. serialize(): any;
  40645. /**
  40646. * Creates a standard material from parsed material data
  40647. * @param source defines the JSON representation of the material
  40648. * @param scene defines the hosting scene
  40649. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40650. * @returns a new standard material
  40651. */
  40652. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40653. /**
  40654. * Are diffuse textures enabled in the application.
  40655. */
  40656. static DiffuseTextureEnabled: boolean;
  40657. /**
  40658. * Are ambient textures enabled in the application.
  40659. */
  40660. static AmbientTextureEnabled: boolean;
  40661. /**
  40662. * Are opacity textures enabled in the application.
  40663. */
  40664. static OpacityTextureEnabled: boolean;
  40665. /**
  40666. * Are reflection textures enabled in the application.
  40667. */
  40668. static ReflectionTextureEnabled: boolean;
  40669. /**
  40670. * Are emissive textures enabled in the application.
  40671. */
  40672. static EmissiveTextureEnabled: boolean;
  40673. /**
  40674. * Are specular textures enabled in the application.
  40675. */
  40676. static SpecularTextureEnabled: boolean;
  40677. /**
  40678. * Are bump textures enabled in the application.
  40679. */
  40680. static BumpTextureEnabled: boolean;
  40681. /**
  40682. * Are lightmap textures enabled in the application.
  40683. */
  40684. static LightmapTextureEnabled: boolean;
  40685. /**
  40686. * Are refraction textures enabled in the application.
  40687. */
  40688. static RefractionTextureEnabled: boolean;
  40689. /**
  40690. * Are color grading textures enabled in the application.
  40691. */
  40692. static ColorGradingTextureEnabled: boolean;
  40693. /**
  40694. * Are fresnels enabled in the application.
  40695. */
  40696. static FresnelEnabled: boolean;
  40697. }
  40698. }
  40699. declare module BABYLON {
  40700. /** @hidden */
  40701. export var imageProcessingPixelShader: {
  40702. name: string;
  40703. shader: string;
  40704. };
  40705. }
  40706. declare module BABYLON {
  40707. /**
  40708. * ImageProcessingPostProcess
  40709. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40710. */
  40711. export class ImageProcessingPostProcess extends PostProcess {
  40712. /**
  40713. * Default configuration related to image processing available in the PBR Material.
  40714. */
  40715. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40716. /**
  40717. * Gets the image processing configuration used either in this material.
  40718. */
  40719. /**
  40720. * Sets the Default image processing configuration used either in the this material.
  40721. *
  40722. * If sets to null, the scene one is in use.
  40723. */
  40724. imageProcessingConfiguration: ImageProcessingConfiguration;
  40725. /**
  40726. * Keep track of the image processing observer to allow dispose and replace.
  40727. */
  40728. private _imageProcessingObserver;
  40729. /**
  40730. * Attaches a new image processing configuration to the PBR Material.
  40731. * @param configuration
  40732. */
  40733. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40734. /**
  40735. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40736. */
  40737. /**
  40738. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40739. */
  40740. colorCurves: Nullable<ColorCurves>;
  40741. /**
  40742. * Gets wether the color curves effect is enabled.
  40743. */
  40744. /**
  40745. * Sets wether the color curves effect is enabled.
  40746. */
  40747. colorCurvesEnabled: boolean;
  40748. /**
  40749. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40750. */
  40751. /**
  40752. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40753. */
  40754. colorGradingTexture: Nullable<BaseTexture>;
  40755. /**
  40756. * Gets wether the color grading effect is enabled.
  40757. */
  40758. /**
  40759. * Gets wether the color grading effect is enabled.
  40760. */
  40761. colorGradingEnabled: boolean;
  40762. /**
  40763. * Gets exposure used in the effect.
  40764. */
  40765. /**
  40766. * Sets exposure used in the effect.
  40767. */
  40768. exposure: number;
  40769. /**
  40770. * Gets wether tonemapping is enabled or not.
  40771. */
  40772. /**
  40773. * Sets wether tonemapping is enabled or not
  40774. */
  40775. toneMappingEnabled: boolean;
  40776. /**
  40777. * Gets the type of tone mapping effect.
  40778. */
  40779. /**
  40780. * Sets the type of tone mapping effect.
  40781. */
  40782. toneMappingType: number;
  40783. /**
  40784. * Gets contrast used in the effect.
  40785. */
  40786. /**
  40787. * Sets contrast used in the effect.
  40788. */
  40789. contrast: number;
  40790. /**
  40791. * Gets Vignette stretch size.
  40792. */
  40793. /**
  40794. * Sets Vignette stretch size.
  40795. */
  40796. vignetteStretch: number;
  40797. /**
  40798. * Gets Vignette centre X Offset.
  40799. */
  40800. /**
  40801. * Sets Vignette centre X Offset.
  40802. */
  40803. vignetteCentreX: number;
  40804. /**
  40805. * Gets Vignette centre Y Offset.
  40806. */
  40807. /**
  40808. * Sets Vignette centre Y Offset.
  40809. */
  40810. vignetteCentreY: number;
  40811. /**
  40812. * Gets Vignette weight or intensity of the vignette effect.
  40813. */
  40814. /**
  40815. * Sets Vignette weight or intensity of the vignette effect.
  40816. */
  40817. vignetteWeight: number;
  40818. /**
  40819. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40820. * if vignetteEnabled is set to true.
  40821. */
  40822. /**
  40823. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40824. * if vignetteEnabled is set to true.
  40825. */
  40826. vignetteColor: Color4;
  40827. /**
  40828. * Gets Camera field of view used by the Vignette effect.
  40829. */
  40830. /**
  40831. * Sets Camera field of view used by the Vignette effect.
  40832. */
  40833. vignetteCameraFov: number;
  40834. /**
  40835. * Gets the vignette blend mode allowing different kind of effect.
  40836. */
  40837. /**
  40838. * Sets the vignette blend mode allowing different kind of effect.
  40839. */
  40840. vignetteBlendMode: number;
  40841. /**
  40842. * Gets wether the vignette effect is enabled.
  40843. */
  40844. /**
  40845. * Sets wether the vignette effect is enabled.
  40846. */
  40847. vignetteEnabled: boolean;
  40848. private _fromLinearSpace;
  40849. /**
  40850. * Gets wether the input of the processing is in Gamma or Linear Space.
  40851. */
  40852. /**
  40853. * Sets wether the input of the processing is in Gamma or Linear Space.
  40854. */
  40855. fromLinearSpace: boolean;
  40856. /**
  40857. * Defines cache preventing GC.
  40858. */
  40859. private _defines;
  40860. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40861. /**
  40862. * "ImageProcessingPostProcess"
  40863. * @returns "ImageProcessingPostProcess"
  40864. */
  40865. getClassName(): string;
  40866. protected _updateParameters(): void;
  40867. dispose(camera?: Camera): void;
  40868. }
  40869. }
  40870. declare module BABYLON {
  40871. /**
  40872. * Class containing static functions to help procedurally build meshes
  40873. */
  40874. export class GroundBuilder {
  40875. /**
  40876. * Creates a ground mesh
  40877. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40878. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40880. * @param name defines the name of the mesh
  40881. * @param options defines the options used to create the mesh
  40882. * @param scene defines the hosting scene
  40883. * @returns the ground mesh
  40884. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40885. */
  40886. static CreateGround(name: string, options: {
  40887. width?: number;
  40888. height?: number;
  40889. subdivisions?: number;
  40890. subdivisionsX?: number;
  40891. subdivisionsY?: number;
  40892. updatable?: boolean;
  40893. }, scene: any): Mesh;
  40894. /**
  40895. * Creates a tiled ground mesh
  40896. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40897. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40898. * * 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
  40899. * * 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
  40900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40901. * @param name defines the name of the mesh
  40902. * @param options defines the options used to create the mesh
  40903. * @param scene defines the hosting scene
  40904. * @returns the tiled ground mesh
  40905. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40906. */
  40907. static CreateTiledGround(name: string, options: {
  40908. xmin: number;
  40909. zmin: number;
  40910. xmax: number;
  40911. zmax: number;
  40912. subdivisions?: {
  40913. w: number;
  40914. h: number;
  40915. };
  40916. precision?: {
  40917. w: number;
  40918. h: number;
  40919. };
  40920. updatable?: boolean;
  40921. }, scene?: Nullable<Scene>): Mesh;
  40922. /**
  40923. * Creates a ground mesh from a height map
  40924. * * The parameter `url` sets the URL of the height map image resource.
  40925. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40926. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40927. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40928. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40929. * * 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.
  40930. * * 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).
  40931. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40933. * @param name defines the name of the mesh
  40934. * @param url defines the url to the height map
  40935. * @param options defines the options used to create the mesh
  40936. * @param scene defines the hosting scene
  40937. * @returns the ground mesh
  40938. * @see https://doc.babylonjs.com/babylon101/height_map
  40939. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40940. */
  40941. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40942. width?: number;
  40943. height?: number;
  40944. subdivisions?: number;
  40945. minHeight?: number;
  40946. maxHeight?: number;
  40947. colorFilter?: Color3;
  40948. alphaFilter?: number;
  40949. updatable?: boolean;
  40950. onReady?: (mesh: GroundMesh) => void;
  40951. }, scene?: Nullable<Scene>): GroundMesh;
  40952. }
  40953. }
  40954. declare module BABYLON {
  40955. /**
  40956. * Class containing static functions to help procedurally build meshes
  40957. */
  40958. export class TorusBuilder {
  40959. /**
  40960. * Creates a torus mesh
  40961. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40962. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40963. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40965. * * 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
  40966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40967. * @param name defines the name of the mesh
  40968. * @param options defines the options used to create the mesh
  40969. * @param scene defines the hosting scene
  40970. * @returns the torus mesh
  40971. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40972. */
  40973. static CreateTorus(name: string, options: {
  40974. diameter?: number;
  40975. thickness?: number;
  40976. tessellation?: number;
  40977. updatable?: boolean;
  40978. sideOrientation?: number;
  40979. frontUVs?: Vector4;
  40980. backUVs?: Vector4;
  40981. }, scene: any): Mesh;
  40982. }
  40983. }
  40984. declare module BABYLON {
  40985. /**
  40986. * Class containing static functions to help procedurally build meshes
  40987. */
  40988. export class CylinderBuilder {
  40989. /**
  40990. * Creates a cylinder or a cone mesh
  40991. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40992. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40993. * * 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.
  40994. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40995. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40996. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40997. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40998. * * 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).
  40999. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41000. * * 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).
  41001. * * 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
  41002. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41003. * * 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
  41004. * * 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.
  41005. * * If `enclose` is false, a ring surface is one element.
  41006. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41007. * * 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
  41008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41009. * * 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
  41010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41011. * @param name defines the name of the mesh
  41012. * @param options defines the options used to create the mesh
  41013. * @param scene defines the hosting scene
  41014. * @returns the cylinder mesh
  41015. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41016. */
  41017. static CreateCylinder(name: string, options: {
  41018. height?: number;
  41019. diameterTop?: number;
  41020. diameterBottom?: number;
  41021. diameter?: number;
  41022. tessellation?: number;
  41023. subdivisions?: number;
  41024. arc?: number;
  41025. faceColors?: Color4[];
  41026. faceUV?: Vector4[];
  41027. updatable?: boolean;
  41028. hasRings?: boolean;
  41029. enclose?: boolean;
  41030. cap?: number;
  41031. sideOrientation?: number;
  41032. frontUVs?: Vector4;
  41033. backUVs?: Vector4;
  41034. }, scene: any): Mesh;
  41035. }
  41036. }
  41037. declare module BABYLON {
  41038. /**
  41039. * Options to modify the vr teleportation behavior.
  41040. */
  41041. export interface VRTeleportationOptions {
  41042. /**
  41043. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41044. */
  41045. floorMeshName?: string;
  41046. /**
  41047. * A list of meshes to be used as the teleportation floor. (default: empty)
  41048. */
  41049. floorMeshes?: Mesh[];
  41050. }
  41051. /**
  41052. * Options to modify the vr experience helper's behavior.
  41053. */
  41054. export interface VRExperienceHelperOptions extends WebVROptions {
  41055. /**
  41056. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41057. */
  41058. createDeviceOrientationCamera?: boolean;
  41059. /**
  41060. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41061. */
  41062. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41063. /**
  41064. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41065. */
  41066. laserToggle?: boolean;
  41067. /**
  41068. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41069. */
  41070. floorMeshes?: Mesh[];
  41071. /**
  41072. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41073. */
  41074. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41075. }
  41076. /**
  41077. * Event containing information after VR has been entered
  41078. */
  41079. export class OnAfterEnteringVRObservableEvent {
  41080. /**
  41081. * If entering vr was successful
  41082. */
  41083. success: boolean;
  41084. }
  41085. /**
  41086. * Helps to quickly add VR support to an existing scene.
  41087. * See http://doc.babylonjs.com/how_to/webvr_helper
  41088. */
  41089. export class VRExperienceHelper {
  41090. /** Options to modify the vr experience helper's behavior. */
  41091. webVROptions: VRExperienceHelperOptions;
  41092. private _scene;
  41093. private _position;
  41094. private _btnVR;
  41095. private _btnVRDisplayed;
  41096. private _webVRsupported;
  41097. private _webVRready;
  41098. private _webVRrequesting;
  41099. private _webVRpresenting;
  41100. private _hasEnteredVR;
  41101. private _fullscreenVRpresenting;
  41102. private _canvas;
  41103. private _webVRCamera;
  41104. private _vrDeviceOrientationCamera;
  41105. private _deviceOrientationCamera;
  41106. private _existingCamera;
  41107. private _onKeyDown;
  41108. private _onVrDisplayPresentChange;
  41109. private _onVRDisplayChanged;
  41110. private _onVRRequestPresentStart;
  41111. private _onVRRequestPresentComplete;
  41112. /**
  41113. * 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)
  41114. */
  41115. enableGazeEvenWhenNoPointerLock: boolean;
  41116. /**
  41117. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41118. */
  41119. exitVROnDoubleTap: boolean;
  41120. /**
  41121. * Observable raised right before entering VR.
  41122. */
  41123. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41124. /**
  41125. * Observable raised when entering VR has completed.
  41126. */
  41127. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41128. /**
  41129. * Observable raised when exiting VR.
  41130. */
  41131. onExitingVRObservable: Observable<VRExperienceHelper>;
  41132. /**
  41133. * Observable raised when controller mesh is loaded.
  41134. */
  41135. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41136. /** Return this.onEnteringVRObservable
  41137. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41138. */
  41139. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41140. /** Return this.onExitingVRObservable
  41141. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41142. */
  41143. readonly onExitingVR: Observable<VRExperienceHelper>;
  41144. /** Return this.onControllerMeshLoadedObservable
  41145. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41146. */
  41147. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41148. private _rayLength;
  41149. private _useCustomVRButton;
  41150. private _teleportationRequested;
  41151. private _teleportActive;
  41152. private _floorMeshName;
  41153. private _floorMeshesCollection;
  41154. private _rotationAllowed;
  41155. private _teleportBackwardsVector;
  41156. private _teleportationTarget;
  41157. private _isDefaultTeleportationTarget;
  41158. private _postProcessMove;
  41159. private _teleportationFillColor;
  41160. private _teleportationBorderColor;
  41161. private _rotationAngle;
  41162. private _haloCenter;
  41163. private _cameraGazer;
  41164. private _padSensibilityUp;
  41165. private _padSensibilityDown;
  41166. private _leftController;
  41167. private _rightController;
  41168. /**
  41169. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41170. */
  41171. onNewMeshSelected: Observable<AbstractMesh>;
  41172. /**
  41173. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41174. * This observable will provide the mesh and the controller used to select the mesh
  41175. */
  41176. onMeshSelectedWithController: Observable<{
  41177. mesh: AbstractMesh;
  41178. controller: WebVRController;
  41179. }>;
  41180. /**
  41181. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41182. */
  41183. onNewMeshPicked: Observable<PickingInfo>;
  41184. private _circleEase;
  41185. /**
  41186. * Observable raised before camera teleportation
  41187. */
  41188. onBeforeCameraTeleport: Observable<Vector3>;
  41189. /**
  41190. * Observable raised after camera teleportation
  41191. */
  41192. onAfterCameraTeleport: Observable<Vector3>;
  41193. /**
  41194. * Observable raised when current selected mesh gets unselected
  41195. */
  41196. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41197. private _raySelectionPredicate;
  41198. /**
  41199. * To be optionaly changed by user to define custom ray selection
  41200. */
  41201. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41202. /**
  41203. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41204. */
  41205. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41206. /**
  41207. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41208. */
  41209. teleportationEnabled: boolean;
  41210. private _defaultHeight;
  41211. private _teleportationInitialized;
  41212. private _interactionsEnabled;
  41213. private _interactionsRequested;
  41214. private _displayGaze;
  41215. private _displayLaserPointer;
  41216. /**
  41217. * The mesh used to display where the user is going to teleport.
  41218. */
  41219. /**
  41220. * Sets the mesh to be used to display where the user is going to teleport.
  41221. */
  41222. teleportationTarget: Mesh;
  41223. /**
  41224. * 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
  41225. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41226. * See http://doc.babylonjs.com/resources/baking_transformations
  41227. */
  41228. gazeTrackerMesh: Mesh;
  41229. /**
  41230. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41231. */
  41232. updateGazeTrackerScale: boolean;
  41233. /**
  41234. * If the gaze trackers color should be updated when selecting meshes
  41235. */
  41236. updateGazeTrackerColor: boolean;
  41237. /**
  41238. * If the controller laser color should be updated when selecting meshes
  41239. */
  41240. updateControllerLaserColor: boolean;
  41241. /**
  41242. * The gaze tracking mesh corresponding to the left controller
  41243. */
  41244. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41245. /**
  41246. * The gaze tracking mesh corresponding to the right controller
  41247. */
  41248. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41249. /**
  41250. * If the ray of the gaze should be displayed.
  41251. */
  41252. /**
  41253. * Sets if the ray of the gaze should be displayed.
  41254. */
  41255. displayGaze: boolean;
  41256. /**
  41257. * If the ray of the LaserPointer should be displayed.
  41258. */
  41259. /**
  41260. * Sets if the ray of the LaserPointer should be displayed.
  41261. */
  41262. displayLaserPointer: boolean;
  41263. /**
  41264. * The deviceOrientationCamera used as the camera when not in VR.
  41265. */
  41266. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41267. /**
  41268. * Based on the current WebVR support, returns the current VR camera used.
  41269. */
  41270. readonly currentVRCamera: Nullable<Camera>;
  41271. /**
  41272. * The webVRCamera which is used when in VR.
  41273. */
  41274. readonly webVRCamera: WebVRFreeCamera;
  41275. /**
  41276. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41277. */
  41278. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41279. /**
  41280. * The html button that is used to trigger entering into VR.
  41281. */
  41282. readonly vrButton: Nullable<HTMLButtonElement>;
  41283. private readonly _teleportationRequestInitiated;
  41284. /**
  41285. * Defines wether or not Pointer lock should be requested when switching to
  41286. * full screen.
  41287. */
  41288. requestPointerLockOnFullScreen: boolean;
  41289. /**
  41290. * Instantiates a VRExperienceHelper.
  41291. * Helps to quickly add VR support to an existing scene.
  41292. * @param scene The scene the VRExperienceHelper belongs to.
  41293. * @param webVROptions Options to modify the vr experience helper's behavior.
  41294. */
  41295. constructor(scene: Scene,
  41296. /** Options to modify the vr experience helper's behavior. */
  41297. webVROptions?: VRExperienceHelperOptions);
  41298. private _onDefaultMeshLoaded;
  41299. private _onResize;
  41300. private _onFullscreenChange;
  41301. /**
  41302. * Gets a value indicating if we are currently in VR mode.
  41303. */
  41304. readonly isInVRMode: boolean;
  41305. private onVrDisplayPresentChange;
  41306. private onVRDisplayChanged;
  41307. private moveButtonToBottomRight;
  41308. private displayVRButton;
  41309. private updateButtonVisibility;
  41310. private _cachedAngularSensibility;
  41311. /**
  41312. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41313. * Otherwise, will use the fullscreen API.
  41314. */
  41315. enterVR(): void;
  41316. /**
  41317. * Attempt to exit VR, or fullscreen.
  41318. */
  41319. exitVR(): void;
  41320. /**
  41321. * The position of the vr experience helper.
  41322. */
  41323. /**
  41324. * Sets the position of the vr experience helper.
  41325. */
  41326. position: Vector3;
  41327. /**
  41328. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41329. */
  41330. enableInteractions(): void;
  41331. private readonly _noControllerIsActive;
  41332. private beforeRender;
  41333. private _isTeleportationFloor;
  41334. /**
  41335. * Adds a floor mesh to be used for teleportation.
  41336. * @param floorMesh the mesh to be used for teleportation.
  41337. */
  41338. addFloorMesh(floorMesh: Mesh): void;
  41339. /**
  41340. * Removes a floor mesh from being used for teleportation.
  41341. * @param floorMesh the mesh to be removed.
  41342. */
  41343. removeFloorMesh(floorMesh: Mesh): void;
  41344. /**
  41345. * Enables interactions and teleportation using the VR controllers and gaze.
  41346. * @param vrTeleportationOptions options to modify teleportation behavior.
  41347. */
  41348. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41349. private _onNewGamepadConnected;
  41350. private _tryEnableInteractionOnController;
  41351. private _onNewGamepadDisconnected;
  41352. private _enableInteractionOnController;
  41353. private _checkTeleportWithRay;
  41354. private _checkRotate;
  41355. private _checkTeleportBackwards;
  41356. private _enableTeleportationOnController;
  41357. private _createTeleportationCircles;
  41358. private _displayTeleportationTarget;
  41359. private _hideTeleportationTarget;
  41360. private _rotateCamera;
  41361. private _moveTeleportationSelectorTo;
  41362. private _workingVector;
  41363. private _workingQuaternion;
  41364. private _workingMatrix;
  41365. /**
  41366. * Teleports the users feet to the desired location
  41367. * @param location The location where the user's feet should be placed
  41368. */
  41369. teleportCamera(location: Vector3): void;
  41370. private _convertNormalToDirectionOfRay;
  41371. private _castRayAndSelectObject;
  41372. private _notifySelectedMeshUnselected;
  41373. /**
  41374. * Sets the color of the laser ray from the vr controllers.
  41375. * @param color new color for the ray.
  41376. */
  41377. changeLaserColor(color: Color3): void;
  41378. /**
  41379. * Sets the color of the ray from the vr headsets gaze.
  41380. * @param color new color for the ray.
  41381. */
  41382. changeGazeColor(color: Color3): void;
  41383. /**
  41384. * Exits VR and disposes of the vr experience helper
  41385. */
  41386. dispose(): void;
  41387. /**
  41388. * Gets the name of the VRExperienceHelper class
  41389. * @returns "VRExperienceHelper"
  41390. */
  41391. getClassName(): string;
  41392. }
  41393. }
  41394. declare module BABYLON {
  41395. /**
  41396. * Manages an XRSession to work with Babylon's engine
  41397. * @see https://doc.babylonjs.com/how_to/webxr
  41398. */
  41399. export class WebXRSessionManager implements IDisposable {
  41400. private scene;
  41401. /**
  41402. * Fires every time a new xrFrame arrives which can be used to update the camera
  41403. */
  41404. onXRFrameObservable: Observable<any>;
  41405. /**
  41406. * Fires when the xr session is ended either by the device or manually done
  41407. */
  41408. onXRSessionEnded: Observable<any>;
  41409. /**
  41410. * Underlying xr session
  41411. */
  41412. session: XRSession;
  41413. /**
  41414. * Type of reference space used when creating the session
  41415. */
  41416. referenceSpace: XRReferenceSpace;
  41417. /** @hidden */
  41418. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41419. /**
  41420. * Current XR frame
  41421. */
  41422. currentFrame: Nullable<XRFrame>;
  41423. private _xrNavigator;
  41424. private baseLayer;
  41425. /**
  41426. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41427. * @param scene The scene which the session should be created for
  41428. */
  41429. constructor(scene: Scene);
  41430. /**
  41431. * Initializes the manager
  41432. * After initialization enterXR can be called to start an XR session
  41433. * @returns Promise which resolves after it is initialized
  41434. */
  41435. initializeAsync(): Promise<void>;
  41436. /**
  41437. * Initializes an xr session
  41438. * @param xrSessionMode mode to initialize
  41439. * @returns a promise which will resolve once the session has been initialized
  41440. */
  41441. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41442. /**
  41443. * Sets the reference space on the xr session
  41444. * @param referenceSpace space to set
  41445. * @returns a promise that will resolve once the reference space has been set
  41446. */
  41447. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41448. /**
  41449. * Updates the render state of the session
  41450. * @param state state to set
  41451. * @returns a promise that resolves once the render state has been updated
  41452. */
  41453. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41454. /**
  41455. * Starts rendering to the xr layer
  41456. * @returns a promise that will resolve once rendering has started
  41457. */
  41458. startRenderingToXRAsync(): Promise<void>;
  41459. /**
  41460. * Stops the xrSession and restores the renderloop
  41461. * @returns Promise which resolves after it exits XR
  41462. */
  41463. exitXRAsync(): Promise<unknown>;
  41464. /**
  41465. * Checks if a session would be supported for the creation options specified
  41466. * @param sessionMode session mode to check if supported eg. immersive-vr
  41467. * @returns true if supported
  41468. */
  41469. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41470. /**
  41471. * @hidden
  41472. * Converts the render layer of xrSession to a render target
  41473. * @param session session to create render target for
  41474. * @param scene scene the new render target should be created for
  41475. */
  41476. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41477. /**
  41478. * Disposes of the session manager
  41479. */
  41480. dispose(): void;
  41481. }
  41482. }
  41483. declare module BABYLON {
  41484. /**
  41485. * WebXR Camera which holds the views for the xrSession
  41486. * @see https://doc.babylonjs.com/how_to/webxr
  41487. */
  41488. export class WebXRCamera extends FreeCamera {
  41489. private static _TmpMatrix;
  41490. /**
  41491. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41492. * @param name the name of the camera
  41493. * @param scene the scene to add the camera to
  41494. */
  41495. constructor(name: string, scene: Scene);
  41496. private _updateNumberOfRigCameras;
  41497. /** @hidden */
  41498. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41499. /**
  41500. * Updates the cameras position from the current pose information of the XR session
  41501. * @param xrSessionManager the session containing pose information
  41502. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41503. */
  41504. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41505. }
  41506. }
  41507. declare module BABYLON {
  41508. /**
  41509. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41510. */
  41511. export class WebXRManagedOutputCanvas implements IDisposable {
  41512. private helper;
  41513. private _canvas;
  41514. /**
  41515. * xrpresent context of the canvas which can be used to display/mirror xr content
  41516. */
  41517. canvasContext: WebGLRenderingContext;
  41518. /**
  41519. * xr layer for the canvas
  41520. */
  41521. xrLayer: Nullable<XRWebGLLayer>;
  41522. /**
  41523. * Initializes the xr layer for the session
  41524. * @param xrSession xr session
  41525. * @returns a promise that will resolve once the XR Layer has been created
  41526. */
  41527. initializeXRLayerAsync(xrSession: any): any;
  41528. /**
  41529. * Initializes the canvas to be added/removed upon entering/exiting xr
  41530. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41531. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41532. */
  41533. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41534. /**
  41535. * Disposes of the object
  41536. */
  41537. dispose(): void;
  41538. private _setManagedOutputCanvas;
  41539. private _addCanvas;
  41540. private _removeCanvas;
  41541. }
  41542. }
  41543. declare module BABYLON {
  41544. /**
  41545. * States of the webXR experience
  41546. */
  41547. export enum WebXRState {
  41548. /**
  41549. * Transitioning to being in XR mode
  41550. */
  41551. ENTERING_XR = 0,
  41552. /**
  41553. * Transitioning to non XR mode
  41554. */
  41555. EXITING_XR = 1,
  41556. /**
  41557. * In XR mode and presenting
  41558. */
  41559. IN_XR = 2,
  41560. /**
  41561. * Not entered XR mode
  41562. */
  41563. NOT_IN_XR = 3
  41564. }
  41565. /**
  41566. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41567. * @see https://doc.babylonjs.com/how_to/webxr
  41568. */
  41569. export class WebXRExperienceHelper implements IDisposable {
  41570. private scene;
  41571. /**
  41572. * 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
  41573. */
  41574. container: AbstractMesh;
  41575. /**
  41576. * Camera used to render xr content
  41577. */
  41578. camera: WebXRCamera;
  41579. /**
  41580. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41581. */
  41582. state: WebXRState;
  41583. private _setState;
  41584. private static _TmpVector;
  41585. /**
  41586. * Fires when the state of the experience helper has changed
  41587. */
  41588. onStateChangedObservable: Observable<WebXRState>;
  41589. /** Session manager used to keep track of xr session */
  41590. sessionManager: WebXRSessionManager;
  41591. private _nonVRCamera;
  41592. private _originalSceneAutoClear;
  41593. private _supported;
  41594. /**
  41595. * Creates the experience helper
  41596. * @param scene the scene to attach the experience helper to
  41597. * @returns a promise for the experience helper
  41598. */
  41599. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41600. /**
  41601. * Creates a WebXRExperienceHelper
  41602. * @param scene The scene the helper should be created in
  41603. */
  41604. private constructor();
  41605. /**
  41606. * Exits XR mode and returns the scene to its original state
  41607. * @returns promise that resolves after xr mode has exited
  41608. */
  41609. exitXRAsync(): Promise<unknown>;
  41610. /**
  41611. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41612. * @param sessionCreationOptions options for the XR session
  41613. * @param referenceSpaceType frame of reference of the XR session
  41614. * @param outputCanvas the output canvas that will be used to enter XR mode
  41615. * @returns promise that resolves after xr mode has entered
  41616. */
  41617. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41618. /**
  41619. * Updates the global position of the camera by moving the camera's container
  41620. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41621. * @param position The desired global position of the camera
  41622. */
  41623. setPositionOfCameraUsingContainer(position: Vector3): void;
  41624. /**
  41625. * Rotates the xr camera by rotating the camera's container around the camera's position
  41626. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41627. * @param rotation the desired quaternion rotation to apply to the camera
  41628. */
  41629. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41630. /**
  41631. * Disposes of the experience helper
  41632. */
  41633. dispose(): void;
  41634. }
  41635. }
  41636. declare module BABYLON {
  41637. /**
  41638. * Button which can be used to enter a different mode of XR
  41639. */
  41640. export class WebXREnterExitUIButton {
  41641. /** button element */
  41642. element: HTMLElement;
  41643. /** XR initialization options for the button */
  41644. sessionMode: XRSessionMode;
  41645. /** Reference space type */
  41646. referenceSpaceType: XRReferenceSpaceType;
  41647. /**
  41648. * Creates a WebXREnterExitUIButton
  41649. * @param element button element
  41650. * @param sessionMode XR initialization session mode
  41651. * @param referenceSpaceType the type of reference space to be used
  41652. */
  41653. constructor(
  41654. /** button element */
  41655. element: HTMLElement,
  41656. /** XR initialization options for the button */
  41657. sessionMode: XRSessionMode,
  41658. /** Reference space type */
  41659. referenceSpaceType: XRReferenceSpaceType);
  41660. /**
  41661. * Overwritable function which can be used to update the button's visuals when the state changes
  41662. * @param activeButton the current active button in the UI
  41663. */
  41664. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41665. }
  41666. /**
  41667. * Options to create the webXR UI
  41668. */
  41669. export class WebXREnterExitUIOptions {
  41670. /**
  41671. * Context to enter xr with
  41672. */
  41673. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41674. /**
  41675. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41676. */
  41677. customButtons?: Array<WebXREnterExitUIButton>;
  41678. }
  41679. /**
  41680. * UI to allow the user to enter/exit XR mode
  41681. */
  41682. export class WebXREnterExitUI implements IDisposable {
  41683. private scene;
  41684. private _overlay;
  41685. private _buttons;
  41686. private _activeButton;
  41687. /**
  41688. * Fired every time the active button is changed.
  41689. *
  41690. * When xr is entered via a button that launches xr that button will be the callback parameter
  41691. *
  41692. * When exiting xr the callback parameter will be null)
  41693. */
  41694. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41695. /**
  41696. * Creates UI to allow the user to enter/exit XR mode
  41697. * @param scene the scene to add the ui to
  41698. * @param helper the xr experience helper to enter/exit xr with
  41699. * @param options options to configure the UI
  41700. * @returns the created ui
  41701. */
  41702. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41703. private constructor();
  41704. private _updateButtons;
  41705. /**
  41706. * Disposes of the object
  41707. */
  41708. dispose(): void;
  41709. }
  41710. }
  41711. declare module BABYLON {
  41712. /**
  41713. * Represents an XR input
  41714. */
  41715. export class WebXRController {
  41716. private scene;
  41717. /** The underlying input source for the controller */
  41718. inputSource: XRInputSource;
  41719. private parentContainer;
  41720. /**
  41721. * 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
  41722. */
  41723. grip?: AbstractMesh;
  41724. /**
  41725. * Pointer which can be used to select objects or attach a visible laser to
  41726. */
  41727. pointer: AbstractMesh;
  41728. /**
  41729. * Event that fires when the controller is removed/disposed
  41730. */
  41731. onDisposeObservable: Observable<{}>;
  41732. private _tmpMatrix;
  41733. private _tmpQuaternion;
  41734. private _tmpVector;
  41735. /**
  41736. * Creates the controller
  41737. * @see https://doc.babylonjs.com/how_to/webxr
  41738. * @param scene the scene which the controller should be associated to
  41739. * @param inputSource the underlying input source for the controller
  41740. * @param parentContainer parent that the controller meshes should be children of
  41741. */
  41742. constructor(scene: Scene,
  41743. /** The underlying input source for the controller */
  41744. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41745. /**
  41746. * Updates the controller pose based on the given XRFrame
  41747. * @param xrFrame xr frame to update the pose with
  41748. * @param referenceSpace reference space to use
  41749. */
  41750. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41751. /**
  41752. * Gets a world space ray coming from the controller
  41753. * @param result the resulting ray
  41754. */
  41755. getWorldPointerRayToRef(result: Ray): void;
  41756. /**
  41757. * Disposes of the object
  41758. */
  41759. dispose(): void;
  41760. }
  41761. }
  41762. declare module BABYLON {
  41763. /**
  41764. * XR input used to track XR inputs such as controllers/rays
  41765. */
  41766. export class WebXRInput implements IDisposable {
  41767. /**
  41768. * Base experience the input listens to
  41769. */
  41770. baseExperience: WebXRExperienceHelper;
  41771. /**
  41772. * XR controllers being tracked
  41773. */
  41774. controllers: Array<WebXRController>;
  41775. private _frameObserver;
  41776. private _stateObserver;
  41777. /**
  41778. * Event when a controller has been connected/added
  41779. */
  41780. onControllerAddedObservable: Observable<WebXRController>;
  41781. /**
  41782. * Event when a controller has been removed/disconnected
  41783. */
  41784. onControllerRemovedObservable: Observable<WebXRController>;
  41785. /**
  41786. * Initializes the WebXRInput
  41787. * @param baseExperience experience helper which the input should be created for
  41788. */
  41789. constructor(
  41790. /**
  41791. * Base experience the input listens to
  41792. */
  41793. baseExperience: WebXRExperienceHelper);
  41794. private _onInputSourcesChange;
  41795. private _addAndRemoveControllers;
  41796. /**
  41797. * Disposes of the object
  41798. */
  41799. dispose(): void;
  41800. }
  41801. }
  41802. declare module BABYLON {
  41803. /**
  41804. * Enables teleportation
  41805. */
  41806. export class WebXRControllerTeleportation {
  41807. private _teleportationFillColor;
  41808. private _teleportationBorderColor;
  41809. private _tmpRay;
  41810. private _tmpVector;
  41811. /**
  41812. * Creates a WebXRControllerTeleportation
  41813. * @param input input manager to add teleportation to
  41814. * @param floorMeshes floormeshes which can be teleported to
  41815. */
  41816. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41817. }
  41818. }
  41819. declare module BABYLON {
  41820. /**
  41821. * Handles pointer input automatically for the pointer of XR controllers
  41822. */
  41823. export class WebXRControllerPointerSelection {
  41824. private static _idCounter;
  41825. private _tmpRay;
  41826. /**
  41827. * Creates a WebXRControllerPointerSelection
  41828. * @param input input manager to setup pointer selection
  41829. */
  41830. constructor(input: WebXRInput);
  41831. private _convertNormalToDirectionOfRay;
  41832. private _updatePointerDistance;
  41833. }
  41834. }
  41835. declare module BABYLON {
  41836. /**
  41837. * Class used to represent data loading progression
  41838. */
  41839. export class SceneLoaderProgressEvent {
  41840. /** defines if data length to load can be evaluated */
  41841. readonly lengthComputable: boolean;
  41842. /** defines the loaded data length */
  41843. readonly loaded: number;
  41844. /** defines the data length to load */
  41845. readonly total: number;
  41846. /**
  41847. * Create a new progress event
  41848. * @param lengthComputable defines if data length to load can be evaluated
  41849. * @param loaded defines the loaded data length
  41850. * @param total defines the data length to load
  41851. */
  41852. constructor(
  41853. /** defines if data length to load can be evaluated */
  41854. lengthComputable: boolean,
  41855. /** defines the loaded data length */
  41856. loaded: number,
  41857. /** defines the data length to load */
  41858. total: number);
  41859. /**
  41860. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41861. * @param event defines the source event
  41862. * @returns a new SceneLoaderProgressEvent
  41863. */
  41864. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41865. }
  41866. /**
  41867. * Interface used by SceneLoader plugins to define supported file extensions
  41868. */
  41869. export interface ISceneLoaderPluginExtensions {
  41870. /**
  41871. * Defines the list of supported extensions
  41872. */
  41873. [extension: string]: {
  41874. isBinary: boolean;
  41875. };
  41876. }
  41877. /**
  41878. * Interface used by SceneLoader plugin factory
  41879. */
  41880. export interface ISceneLoaderPluginFactory {
  41881. /**
  41882. * Defines the name of the factory
  41883. */
  41884. name: string;
  41885. /**
  41886. * Function called to create a new plugin
  41887. * @return the new plugin
  41888. */
  41889. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41890. /**
  41891. * Boolean indicating if the plugin can direct load specific data
  41892. */
  41893. canDirectLoad?: (data: string) => boolean;
  41894. }
  41895. /**
  41896. * Interface used to define a SceneLoader plugin
  41897. */
  41898. export interface ISceneLoaderPlugin {
  41899. /**
  41900. * The friendly name of this plugin.
  41901. */
  41902. name: string;
  41903. /**
  41904. * The file extensions supported by this plugin.
  41905. */
  41906. extensions: string | ISceneLoaderPluginExtensions;
  41907. /**
  41908. * Import meshes into a scene.
  41909. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41910. * @param scene The scene to import into
  41911. * @param data The data to import
  41912. * @param rootUrl The root url for scene and resources
  41913. * @param meshes The meshes array to import into
  41914. * @param particleSystems The particle systems array to import into
  41915. * @param skeletons The skeletons array to import into
  41916. * @param onError The callback when import fails
  41917. * @returns True if successful or false otherwise
  41918. */
  41919. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41920. /**
  41921. * Load into a scene.
  41922. * @param scene The scene to load into
  41923. * @param data The data to import
  41924. * @param rootUrl The root url for scene and resources
  41925. * @param onError The callback when import fails
  41926. * @returns true if successful or false otherwise
  41927. */
  41928. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41929. /**
  41930. * The callback that returns true if the data can be directly loaded.
  41931. */
  41932. canDirectLoad?: (data: string) => boolean;
  41933. /**
  41934. * The callback that allows custom handling of the root url based on the response url.
  41935. */
  41936. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41937. /**
  41938. * Load into an asset container.
  41939. * @param scene The scene to load into
  41940. * @param data The data to import
  41941. * @param rootUrl The root url for scene and resources
  41942. * @param onError The callback when import fails
  41943. * @returns The loaded asset container
  41944. */
  41945. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41946. }
  41947. /**
  41948. * Interface used to define an async SceneLoader plugin
  41949. */
  41950. export interface ISceneLoaderPluginAsync {
  41951. /**
  41952. * The friendly name of this plugin.
  41953. */
  41954. name: string;
  41955. /**
  41956. * The file extensions supported by this plugin.
  41957. */
  41958. extensions: string | ISceneLoaderPluginExtensions;
  41959. /**
  41960. * Import meshes into a scene.
  41961. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41962. * @param scene The scene to import into
  41963. * @param data The data to import
  41964. * @param rootUrl The root url for scene and resources
  41965. * @param onProgress The callback when the load progresses
  41966. * @param fileName Defines the name of the file to load
  41967. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41968. */
  41969. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41970. meshes: AbstractMesh[];
  41971. particleSystems: IParticleSystem[];
  41972. skeletons: Skeleton[];
  41973. animationGroups: AnimationGroup[];
  41974. }>;
  41975. /**
  41976. * Load into a scene.
  41977. * @param scene The scene to load into
  41978. * @param data The data to import
  41979. * @param rootUrl The root url for scene and resources
  41980. * @param onProgress The callback when the load progresses
  41981. * @param fileName Defines the name of the file to load
  41982. * @returns Nothing
  41983. */
  41984. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41985. /**
  41986. * The callback that returns true if the data can be directly loaded.
  41987. */
  41988. canDirectLoad?: (data: string) => boolean;
  41989. /**
  41990. * The callback that allows custom handling of the root url based on the response url.
  41991. */
  41992. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41993. /**
  41994. * Load into an asset container.
  41995. * @param scene The scene to load into
  41996. * @param data The data to import
  41997. * @param rootUrl The root url for scene and resources
  41998. * @param onProgress The callback when the load progresses
  41999. * @param fileName Defines the name of the file to load
  42000. * @returns The loaded asset container
  42001. */
  42002. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42003. }
  42004. /**
  42005. * Class used to load scene from various file formats using registered plugins
  42006. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42007. */
  42008. export class SceneLoader {
  42009. /**
  42010. * No logging while loading
  42011. */
  42012. static readonly NO_LOGGING: number;
  42013. /**
  42014. * Minimal logging while loading
  42015. */
  42016. static readonly MINIMAL_LOGGING: number;
  42017. /**
  42018. * Summary logging while loading
  42019. */
  42020. static readonly SUMMARY_LOGGING: number;
  42021. /**
  42022. * Detailled logging while loading
  42023. */
  42024. static readonly DETAILED_LOGGING: number;
  42025. /**
  42026. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42027. */
  42028. static ForceFullSceneLoadingForIncremental: boolean;
  42029. /**
  42030. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42031. */
  42032. static ShowLoadingScreen: boolean;
  42033. /**
  42034. * Defines the current logging level (while loading the scene)
  42035. * @ignorenaming
  42036. */
  42037. static loggingLevel: number;
  42038. /**
  42039. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42040. */
  42041. static CleanBoneMatrixWeights: boolean;
  42042. /**
  42043. * Event raised when a plugin is used to load a scene
  42044. */
  42045. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42046. private static _registeredPlugins;
  42047. private static _getDefaultPlugin;
  42048. private static _getPluginForExtension;
  42049. private static _getPluginForDirectLoad;
  42050. private static _getPluginForFilename;
  42051. private static _getDirectLoad;
  42052. private static _loadData;
  42053. private static _getFileInfo;
  42054. /**
  42055. * Gets a plugin that can load the given extension
  42056. * @param extension defines the extension to load
  42057. * @returns a plugin or null if none works
  42058. */
  42059. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42060. /**
  42061. * Gets a boolean indicating that the given extension can be loaded
  42062. * @param extension defines the extension to load
  42063. * @returns true if the extension is supported
  42064. */
  42065. static IsPluginForExtensionAvailable(extension: string): boolean;
  42066. /**
  42067. * Adds a new plugin to the list of registered plugins
  42068. * @param plugin defines the plugin to add
  42069. */
  42070. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42071. /**
  42072. * Import meshes into a scene
  42073. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 scene the instance of BABYLON.Scene to append to
  42077. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42078. * @param onProgress a callback with a progress event for each file being loaded
  42079. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42080. * @param pluginExtension the extension used to determine the plugin
  42081. * @returns The loaded plugin
  42082. */
  42083. 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>;
  42084. /**
  42085. * Import meshes into a scene
  42086. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42087. * @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)
  42088. * @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)
  42089. * @param scene the instance of BABYLON.Scene to append to
  42090. * @param onProgress a callback with a progress event for each file being loaded
  42091. * @param pluginExtension the extension used to determine the plugin
  42092. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42093. */
  42094. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42095. meshes: AbstractMesh[];
  42096. particleSystems: IParticleSystem[];
  42097. skeletons: Skeleton[];
  42098. animationGroups: AnimationGroup[];
  42099. }>;
  42100. /**
  42101. * Load a scene
  42102. * @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)
  42103. * @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)
  42104. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42105. * @param onSuccess a callback with the scene when import succeeds
  42106. * @param onProgress a callback with a progress event for each file being loaded
  42107. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42108. * @param pluginExtension the extension used to determine the plugin
  42109. * @returns The loaded plugin
  42110. */
  42111. 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>;
  42112. /**
  42113. * Load a scene
  42114. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  42115. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  42116. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42117. * @param onProgress a callback with a progress event for each file being loaded
  42118. * @param pluginExtension the extension used to determine the plugin
  42119. * @returns The loaded scene
  42120. */
  42121. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42122. /**
  42123. * Append a scene
  42124. * @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)
  42125. * @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)
  42126. * @param scene is the instance of BABYLON.Scene to append to
  42127. * @param onSuccess a callback with the scene when import succeeds
  42128. * @param onProgress a callback with a progress event for each file being loaded
  42129. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42130. * @param pluginExtension the extension used to determine the plugin
  42131. * @returns The loaded plugin
  42132. */
  42133. 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>;
  42134. /**
  42135. * Append a scene
  42136. * @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)
  42137. * @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)
  42138. * @param scene is the instance of BABYLON.Scene to append to
  42139. * @param onProgress a callback with a progress event for each file being loaded
  42140. * @param pluginExtension the extension used to determine the plugin
  42141. * @returns The given scene
  42142. */
  42143. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42144. /**
  42145. * Load a scene into an asset container
  42146. * @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)
  42147. * @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)
  42148. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42149. * @param onSuccess a callback with the scene when import succeeds
  42150. * @param onProgress a callback with a progress event for each file being loaded
  42151. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42152. * @param pluginExtension the extension used to determine the plugin
  42153. * @returns The loaded plugin
  42154. */
  42155. 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>;
  42156. /**
  42157. * Load a scene into an asset container
  42158. * @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)
  42159. * @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)
  42160. * @param scene is the instance of Scene to append to
  42161. * @param onProgress a callback with a progress event for each file being loaded
  42162. * @param pluginExtension the extension used to determine the plugin
  42163. * @returns The loaded asset container
  42164. */
  42165. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42166. }
  42167. }
  42168. declare module BABYLON {
  42169. /**
  42170. * Generic Controller
  42171. */
  42172. export class GenericController extends WebVRController {
  42173. /**
  42174. * Base Url for the controller model.
  42175. */
  42176. static readonly MODEL_BASE_URL: string;
  42177. /**
  42178. * File name for the controller model.
  42179. */
  42180. static readonly MODEL_FILENAME: string;
  42181. /**
  42182. * Creates a new GenericController from a gamepad
  42183. * @param vrGamepad the gamepad that the controller should be created from
  42184. */
  42185. constructor(vrGamepad: any);
  42186. /**
  42187. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42188. * @param scene scene in which to add meshes
  42189. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42190. */
  42191. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42192. /**
  42193. * Called once for each button that changed state since the last frame
  42194. * @param buttonIdx Which button index changed
  42195. * @param state New state of the button
  42196. * @param changes Which properties on the state changed since last frame
  42197. */
  42198. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42199. }
  42200. }
  42201. declare module BABYLON {
  42202. /**
  42203. * Defines the WindowsMotionController object that the state of the windows motion controller
  42204. */
  42205. export class WindowsMotionController extends WebVRController {
  42206. /**
  42207. * The base url used to load the left and right controller models
  42208. */
  42209. static MODEL_BASE_URL: string;
  42210. /**
  42211. * The name of the left controller model file
  42212. */
  42213. static MODEL_LEFT_FILENAME: string;
  42214. /**
  42215. * The name of the right controller model file
  42216. */
  42217. static MODEL_RIGHT_FILENAME: string;
  42218. /**
  42219. * The controller name prefix for this controller type
  42220. */
  42221. static readonly GAMEPAD_ID_PREFIX: string;
  42222. /**
  42223. * The controller id pattern for this controller type
  42224. */
  42225. private static readonly GAMEPAD_ID_PATTERN;
  42226. private _loadedMeshInfo;
  42227. private readonly _mapping;
  42228. /**
  42229. * Fired when the trackpad on this controller is clicked
  42230. */
  42231. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42232. /**
  42233. * Fired when the trackpad on this controller is modified
  42234. */
  42235. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42236. /**
  42237. * The current x and y values of this controller's trackpad
  42238. */
  42239. trackpad: StickValues;
  42240. /**
  42241. * Creates a new WindowsMotionController from a gamepad
  42242. * @param vrGamepad the gamepad that the controller should be created from
  42243. */
  42244. constructor(vrGamepad: any);
  42245. /**
  42246. * Fired when the trigger on this controller is modified
  42247. */
  42248. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42249. /**
  42250. * Fired when the menu button on this controller is modified
  42251. */
  42252. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42253. /**
  42254. * Fired when the grip button on this controller is modified
  42255. */
  42256. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42257. /**
  42258. * Fired when the thumbstick button on this controller is modified
  42259. */
  42260. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42261. /**
  42262. * Fired when the touchpad button on this controller is modified
  42263. */
  42264. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42265. /**
  42266. * Fired when the touchpad values on this controller are modified
  42267. */
  42268. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42269. private _updateTrackpad;
  42270. /**
  42271. * Called once per frame by the engine.
  42272. */
  42273. update(): void;
  42274. /**
  42275. * Called once for each button that changed state since the last frame
  42276. * @param buttonIdx Which button index changed
  42277. * @param state New state of the button
  42278. * @param changes Which properties on the state changed since last frame
  42279. */
  42280. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42281. /**
  42282. * Moves the buttons on the controller mesh based on their current state
  42283. * @param buttonName the name of the button to move
  42284. * @param buttonValue the value of the button which determines the buttons new position
  42285. */
  42286. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42287. /**
  42288. * Moves the axis on the controller mesh based on its current state
  42289. * @param axis the index of the axis
  42290. * @param axisValue the value of the axis which determines the meshes new position
  42291. * @hidden
  42292. */
  42293. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42294. /**
  42295. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42296. * @param scene scene in which to add meshes
  42297. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42298. */
  42299. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42300. /**
  42301. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42302. * can be transformed by button presses and axes values, based on this._mapping.
  42303. *
  42304. * @param scene scene in which the meshes exist
  42305. * @param meshes list of meshes that make up the controller model to process
  42306. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42307. */
  42308. private processModel;
  42309. private createMeshInfo;
  42310. /**
  42311. * Gets the ray of the controller in the direction the controller is pointing
  42312. * @param length the length the resulting ray should be
  42313. * @returns a ray in the direction the controller is pointing
  42314. */
  42315. getForwardRay(length?: number): Ray;
  42316. /**
  42317. * Disposes of the controller
  42318. */
  42319. dispose(): void;
  42320. }
  42321. }
  42322. declare module BABYLON {
  42323. /**
  42324. * Oculus Touch Controller
  42325. */
  42326. export class OculusTouchController extends WebVRController {
  42327. /**
  42328. * Base Url for the controller model.
  42329. */
  42330. static MODEL_BASE_URL: string;
  42331. /**
  42332. * File name for the left controller model.
  42333. */
  42334. static MODEL_LEFT_FILENAME: string;
  42335. /**
  42336. * File name for the right controller model.
  42337. */
  42338. static MODEL_RIGHT_FILENAME: string;
  42339. /**
  42340. * Base Url for the Quest controller model.
  42341. */
  42342. static QUEST_MODEL_BASE_URL: string;
  42343. /**
  42344. * @hidden
  42345. * If the controllers are running on a device that needs the updated Quest controller models
  42346. */
  42347. static _IsQuest: boolean;
  42348. /**
  42349. * Fired when the secondary trigger on this controller is modified
  42350. */
  42351. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42352. /**
  42353. * Fired when the thumb rest on this controller is modified
  42354. */
  42355. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42356. /**
  42357. * Creates a new OculusTouchController from a gamepad
  42358. * @param vrGamepad the gamepad that the controller should be created from
  42359. */
  42360. constructor(vrGamepad: any);
  42361. /**
  42362. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42363. * @param scene scene in which to add meshes
  42364. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42365. */
  42366. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42367. /**
  42368. * Fired when the A button on this controller is modified
  42369. */
  42370. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42371. /**
  42372. * Fired when the B button on this controller is modified
  42373. */
  42374. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42375. /**
  42376. * Fired when the X button on this controller is modified
  42377. */
  42378. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42379. /**
  42380. * Fired when the Y button on this controller is modified
  42381. */
  42382. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42383. /**
  42384. * Called once for each button that changed state since the last frame
  42385. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42386. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42387. * 2) secondary trigger (same)
  42388. * 3) A (right) X (left), touch, pressed = value
  42389. * 4) B / Y
  42390. * 5) thumb rest
  42391. * @param buttonIdx Which button index changed
  42392. * @param state New state of the button
  42393. * @param changes Which properties on the state changed since last frame
  42394. */
  42395. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42396. }
  42397. }
  42398. declare module BABYLON {
  42399. /**
  42400. * Vive Controller
  42401. */
  42402. export class ViveController extends WebVRController {
  42403. /**
  42404. * Base Url for the controller model.
  42405. */
  42406. static MODEL_BASE_URL: string;
  42407. /**
  42408. * File name for the controller model.
  42409. */
  42410. static MODEL_FILENAME: string;
  42411. /**
  42412. * Creates a new ViveController from a gamepad
  42413. * @param vrGamepad the gamepad that the controller should be created from
  42414. */
  42415. constructor(vrGamepad: any);
  42416. /**
  42417. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42418. * @param scene scene in which to add meshes
  42419. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42420. */
  42421. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42422. /**
  42423. * Fired when the left button on this controller is modified
  42424. */
  42425. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42426. /**
  42427. * Fired when the right button on this controller is modified
  42428. */
  42429. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42430. /**
  42431. * Fired when the menu button on this controller is modified
  42432. */
  42433. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42434. /**
  42435. * Called once for each button that changed state since the last frame
  42436. * Vive mapping:
  42437. * 0: touchpad
  42438. * 1: trigger
  42439. * 2: left AND right buttons
  42440. * 3: menu button
  42441. * @param buttonIdx Which button index changed
  42442. * @param state New state of the button
  42443. * @param changes Which properties on the state changed since last frame
  42444. */
  42445. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42446. }
  42447. }
  42448. declare module BABYLON {
  42449. /**
  42450. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42451. */
  42452. export class WebXRControllerModelLoader {
  42453. /**
  42454. * Creates the WebXRControllerModelLoader
  42455. * @param input xr input that creates the controllers
  42456. */
  42457. constructor(input: WebXRInput);
  42458. }
  42459. }
  42460. declare module BABYLON {
  42461. /**
  42462. * Contains an array of blocks representing the octree
  42463. */
  42464. export interface IOctreeContainer<T> {
  42465. /**
  42466. * Blocks within the octree
  42467. */
  42468. blocks: Array<OctreeBlock<T>>;
  42469. }
  42470. /**
  42471. * Class used to store a cell in an octree
  42472. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42473. */
  42474. export class OctreeBlock<T> {
  42475. /**
  42476. * Gets the content of the current block
  42477. */
  42478. entries: T[];
  42479. /**
  42480. * Gets the list of block children
  42481. */
  42482. blocks: Array<OctreeBlock<T>>;
  42483. private _depth;
  42484. private _maxDepth;
  42485. private _capacity;
  42486. private _minPoint;
  42487. private _maxPoint;
  42488. private _boundingVectors;
  42489. private _creationFunc;
  42490. /**
  42491. * Creates a new block
  42492. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42493. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42494. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42495. * @param depth defines the current depth of this block in the octree
  42496. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42497. * @param creationFunc defines a callback to call when an element is added to the block
  42498. */
  42499. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42500. /**
  42501. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42502. */
  42503. readonly capacity: number;
  42504. /**
  42505. * Gets the minimum vector (in world space) of the block's bounding box
  42506. */
  42507. readonly minPoint: Vector3;
  42508. /**
  42509. * Gets the maximum vector (in world space) of the block's bounding box
  42510. */
  42511. readonly maxPoint: Vector3;
  42512. /**
  42513. * Add a new element to this block
  42514. * @param entry defines the element to add
  42515. */
  42516. addEntry(entry: T): void;
  42517. /**
  42518. * Remove an element from this block
  42519. * @param entry defines the element to remove
  42520. */
  42521. removeEntry(entry: T): void;
  42522. /**
  42523. * Add an array of elements to this block
  42524. * @param entries defines the array of elements to add
  42525. */
  42526. addEntries(entries: T[]): void;
  42527. /**
  42528. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42529. * @param frustumPlanes defines the frustum planes to test
  42530. * @param selection defines the array to store current content if selection is positive
  42531. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42532. */
  42533. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42534. /**
  42535. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42536. * @param sphereCenter defines the bounding sphere center
  42537. * @param sphereRadius defines the bounding sphere radius
  42538. * @param selection defines the array to store current content if selection is positive
  42539. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42540. */
  42541. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42542. /**
  42543. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42544. * @param ray defines the ray to test with
  42545. * @param selection defines the array to store current content if selection is positive
  42546. */
  42547. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42548. /**
  42549. * Subdivide the content into child blocks (this block will then be empty)
  42550. */
  42551. createInnerBlocks(): void;
  42552. /**
  42553. * @hidden
  42554. */
  42555. 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;
  42556. }
  42557. }
  42558. declare module BABYLON {
  42559. /**
  42560. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42561. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42562. */
  42563. export class Octree<T> {
  42564. /** 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.) */
  42565. maxDepth: number;
  42566. /**
  42567. * Blocks within the octree containing objects
  42568. */
  42569. blocks: Array<OctreeBlock<T>>;
  42570. /**
  42571. * Content stored in the octree
  42572. */
  42573. dynamicContent: T[];
  42574. private _maxBlockCapacity;
  42575. private _selectionContent;
  42576. private _creationFunc;
  42577. /**
  42578. * Creates a octree
  42579. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42580. * @param creationFunc function to be used to instatiate the octree
  42581. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42582. * @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.)
  42583. */
  42584. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42585. /** 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.) */
  42586. maxDepth?: number);
  42587. /**
  42588. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42589. * @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);
  42590. * @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);
  42591. * @param entries meshes to be added to the octree blocks
  42592. */
  42593. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42594. /**
  42595. * Adds a mesh to the octree
  42596. * @param entry Mesh to add to the octree
  42597. */
  42598. addMesh(entry: T): void;
  42599. /**
  42600. * Remove an element from the octree
  42601. * @param entry defines the element to remove
  42602. */
  42603. removeMesh(entry: T): void;
  42604. /**
  42605. * Selects an array of meshes within the frustum
  42606. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42607. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42608. * @returns array of meshes within the frustum
  42609. */
  42610. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42611. /**
  42612. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42613. * @param sphereCenter defines the bounding sphere center
  42614. * @param sphereRadius defines the bounding sphere radius
  42615. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42616. * @returns an array of objects that intersect the sphere
  42617. */
  42618. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42619. /**
  42620. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42621. * @param ray defines the ray to test with
  42622. * @returns array of intersected objects
  42623. */
  42624. intersectsRay(ray: Ray): SmartArray<T>;
  42625. /**
  42626. * Adds a mesh into the octree block if it intersects the block
  42627. */
  42628. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42629. /**
  42630. * Adds a submesh into the octree block if it intersects the block
  42631. */
  42632. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42633. }
  42634. }
  42635. declare module BABYLON {
  42636. interface Scene {
  42637. /**
  42638. * @hidden
  42639. * Backing Filed
  42640. */
  42641. _selectionOctree: Octree<AbstractMesh>;
  42642. /**
  42643. * Gets the octree used to boost mesh selection (picking)
  42644. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42645. */
  42646. selectionOctree: Octree<AbstractMesh>;
  42647. /**
  42648. * Creates or updates the octree used to boost selection (picking)
  42649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42650. * @param maxCapacity defines the maximum capacity per leaf
  42651. * @param maxDepth defines the maximum depth of the octree
  42652. * @returns an octree of AbstractMesh
  42653. */
  42654. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42655. }
  42656. interface AbstractMesh {
  42657. /**
  42658. * @hidden
  42659. * Backing Field
  42660. */
  42661. _submeshesOctree: Octree<SubMesh>;
  42662. /**
  42663. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42664. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42665. * @param maxCapacity defines the maximum size of each block (64 by default)
  42666. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42667. * @returns the new octree
  42668. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42669. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42670. */
  42671. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42672. }
  42673. /**
  42674. * Defines the octree scene component responsible to manage any octrees
  42675. * in a given scene.
  42676. */
  42677. export class OctreeSceneComponent {
  42678. /**
  42679. * The component name help to identify the component in the list of scene components.
  42680. */
  42681. readonly name: string;
  42682. /**
  42683. * The scene the component belongs to.
  42684. */
  42685. scene: Scene;
  42686. /**
  42687. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42688. */
  42689. readonly checksIsEnabled: boolean;
  42690. /**
  42691. * Creates a new instance of the component for the given scene
  42692. * @param scene Defines the scene to register the component in
  42693. */
  42694. constructor(scene: Scene);
  42695. /**
  42696. * Registers the component in a given scene
  42697. */
  42698. register(): void;
  42699. /**
  42700. * Return the list of active meshes
  42701. * @returns the list of active meshes
  42702. */
  42703. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42704. /**
  42705. * Return the list of active sub meshes
  42706. * @param mesh The mesh to get the candidates sub meshes from
  42707. * @returns the list of active sub meshes
  42708. */
  42709. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42710. private _tempRay;
  42711. /**
  42712. * Return the list of sub meshes intersecting with a given local ray
  42713. * @param mesh defines the mesh to find the submesh for
  42714. * @param localRay defines the ray in local space
  42715. * @returns the list of intersecting sub meshes
  42716. */
  42717. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42718. /**
  42719. * Return the list of sub meshes colliding with a collider
  42720. * @param mesh defines the mesh to find the submesh for
  42721. * @param collider defines the collider to evaluate the collision against
  42722. * @returns the list of colliding sub meshes
  42723. */
  42724. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42725. /**
  42726. * Rebuilds the elements related to this component in case of
  42727. * context lost for instance.
  42728. */
  42729. rebuild(): void;
  42730. /**
  42731. * Disposes the component and the associated ressources.
  42732. */
  42733. dispose(): void;
  42734. }
  42735. }
  42736. declare module BABYLON {
  42737. /**
  42738. * Renders a layer on top of an existing scene
  42739. */
  42740. export class UtilityLayerRenderer implements IDisposable {
  42741. /** the original scene that will be rendered on top of */
  42742. originalScene: Scene;
  42743. private _pointerCaptures;
  42744. private _lastPointerEvents;
  42745. private static _DefaultUtilityLayer;
  42746. private static _DefaultKeepDepthUtilityLayer;
  42747. private _sharedGizmoLight;
  42748. private _renderCamera;
  42749. /**
  42750. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42751. * @returns the camera that is used when rendering the utility layer
  42752. */
  42753. getRenderCamera(): Nullable<Camera>;
  42754. /**
  42755. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42756. * @param cam the camera that should be used when rendering the utility layer
  42757. */
  42758. setRenderCamera(cam: Nullable<Camera>): void;
  42759. /**
  42760. * @hidden
  42761. * Light which used by gizmos to get light shading
  42762. */
  42763. _getSharedGizmoLight(): HemisphericLight;
  42764. /**
  42765. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42766. */
  42767. pickUtilitySceneFirst: boolean;
  42768. /**
  42769. * 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)
  42770. */
  42771. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42772. /**
  42773. * 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)
  42774. */
  42775. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42776. /**
  42777. * The scene that is rendered on top of the original scene
  42778. */
  42779. utilityLayerScene: Scene;
  42780. /**
  42781. * If the utility layer should automatically be rendered on top of existing scene
  42782. */
  42783. shouldRender: boolean;
  42784. /**
  42785. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42786. */
  42787. onlyCheckPointerDownEvents: boolean;
  42788. /**
  42789. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42790. */
  42791. processAllEvents: boolean;
  42792. /**
  42793. * Observable raised when the pointer move from the utility layer scene to the main scene
  42794. */
  42795. onPointerOutObservable: Observable<number>;
  42796. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42797. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42798. private _afterRenderObserver;
  42799. private _sceneDisposeObserver;
  42800. private _originalPointerObserver;
  42801. /**
  42802. * Instantiates a UtilityLayerRenderer
  42803. * @param originalScene the original scene that will be rendered on top of
  42804. * @param handleEvents boolean indicating if the utility layer should handle events
  42805. */
  42806. constructor(
  42807. /** the original scene that will be rendered on top of */
  42808. originalScene: Scene, handleEvents?: boolean);
  42809. private _notifyObservers;
  42810. /**
  42811. * Renders the utility layers scene on top of the original scene
  42812. */
  42813. render(): void;
  42814. /**
  42815. * Disposes of the renderer
  42816. */
  42817. dispose(): void;
  42818. private _updateCamera;
  42819. }
  42820. }
  42821. declare module BABYLON {
  42822. /**
  42823. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42824. */
  42825. export class Gizmo implements IDisposable {
  42826. /** The utility layer the gizmo will be added to */
  42827. gizmoLayer: UtilityLayerRenderer;
  42828. /**
  42829. * The root mesh of the gizmo
  42830. */
  42831. _rootMesh: Mesh;
  42832. private _attachedMesh;
  42833. /**
  42834. * Ratio for the scale of the gizmo (Default: 1)
  42835. */
  42836. scaleRatio: number;
  42837. /**
  42838. * If a custom mesh has been set (Default: false)
  42839. */
  42840. protected _customMeshSet: boolean;
  42841. /**
  42842. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42843. * * When set, interactions will be enabled
  42844. */
  42845. attachedMesh: Nullable<AbstractMesh>;
  42846. /**
  42847. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42848. * @param mesh The mesh to replace the default mesh of the gizmo
  42849. */
  42850. setCustomMesh(mesh: Mesh): void;
  42851. /**
  42852. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42853. */
  42854. updateGizmoRotationToMatchAttachedMesh: boolean;
  42855. /**
  42856. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42857. */
  42858. updateGizmoPositionToMatchAttachedMesh: boolean;
  42859. /**
  42860. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42861. */
  42862. updateScale: boolean;
  42863. protected _interactionsEnabled: boolean;
  42864. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42865. private _beforeRenderObserver;
  42866. private _tempVector;
  42867. /**
  42868. * Creates a gizmo
  42869. * @param gizmoLayer The utility layer the gizmo will be added to
  42870. */
  42871. constructor(
  42872. /** The utility layer the gizmo will be added to */
  42873. gizmoLayer?: UtilityLayerRenderer);
  42874. /**
  42875. * Updates the gizmo to match the attached mesh's position/rotation
  42876. */
  42877. protected _update(): void;
  42878. /**
  42879. * Disposes of the gizmo
  42880. */
  42881. dispose(): void;
  42882. }
  42883. }
  42884. declare module BABYLON {
  42885. /**
  42886. * Single plane drag gizmo
  42887. */
  42888. export class PlaneDragGizmo extends Gizmo {
  42889. /**
  42890. * Drag behavior responsible for the gizmos dragging interactions
  42891. */
  42892. dragBehavior: PointerDragBehavior;
  42893. private _pointerObserver;
  42894. /**
  42895. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42896. */
  42897. snapDistance: number;
  42898. /**
  42899. * Event that fires each time the gizmo snaps to a new location.
  42900. * * snapDistance is the the change in distance
  42901. */
  42902. onSnapObservable: Observable<{
  42903. snapDistance: number;
  42904. }>;
  42905. private _plane;
  42906. private _coloredMaterial;
  42907. private _hoverMaterial;
  42908. private _isEnabled;
  42909. private _parent;
  42910. /** @hidden */
  42911. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42912. /** @hidden */
  42913. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42914. /**
  42915. * Creates a PlaneDragGizmo
  42916. * @param gizmoLayer The utility layer the gizmo will be added to
  42917. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42918. * @param color The color of the gizmo
  42919. */
  42920. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42921. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42922. /**
  42923. * If the gizmo is enabled
  42924. */
  42925. isEnabled: boolean;
  42926. /**
  42927. * Disposes of the gizmo
  42928. */
  42929. dispose(): void;
  42930. }
  42931. }
  42932. declare module BABYLON {
  42933. /**
  42934. * Gizmo that enables dragging a mesh along 3 axis
  42935. */
  42936. export class PositionGizmo extends Gizmo {
  42937. /**
  42938. * Internal gizmo used for interactions on the x axis
  42939. */
  42940. xGizmo: AxisDragGizmo;
  42941. /**
  42942. * Internal gizmo used for interactions on the y axis
  42943. */
  42944. yGizmo: AxisDragGizmo;
  42945. /**
  42946. * Internal gizmo used for interactions on the z axis
  42947. */
  42948. zGizmo: AxisDragGizmo;
  42949. /**
  42950. * Internal gizmo used for interactions on the yz plane
  42951. */
  42952. xPlaneGizmo: PlaneDragGizmo;
  42953. /**
  42954. * Internal gizmo used for interactions on the xz plane
  42955. */
  42956. yPlaneGizmo: PlaneDragGizmo;
  42957. /**
  42958. * Internal gizmo used for interactions on the xy plane
  42959. */
  42960. zPlaneGizmo: PlaneDragGizmo;
  42961. /**
  42962. * private variables
  42963. */
  42964. private _meshAttached;
  42965. private _updateGizmoRotationToMatchAttachedMesh;
  42966. private _snapDistance;
  42967. private _scaleRatio;
  42968. /** Fires an event when any of it's sub gizmos are dragged */
  42969. onDragStartObservable: Observable<unknown>;
  42970. /** Fires an event when any of it's sub gizmos are released from dragging */
  42971. onDragEndObservable: Observable<unknown>;
  42972. /**
  42973. * If set to true, planar drag is enabled
  42974. */
  42975. private _planarGizmoEnabled;
  42976. attachedMesh: Nullable<AbstractMesh>;
  42977. /**
  42978. * Creates a PositionGizmo
  42979. * @param gizmoLayer The utility layer the gizmo will be added to
  42980. */
  42981. constructor(gizmoLayer?: UtilityLayerRenderer);
  42982. /**
  42983. * If the planar drag gizmo is enabled
  42984. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42985. */
  42986. planarGizmoEnabled: boolean;
  42987. updateGizmoRotationToMatchAttachedMesh: boolean;
  42988. /**
  42989. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42990. */
  42991. snapDistance: number;
  42992. /**
  42993. * Ratio for the scale of the gizmo (Default: 1)
  42994. */
  42995. scaleRatio: number;
  42996. /**
  42997. * Disposes of the gizmo
  42998. */
  42999. dispose(): void;
  43000. /**
  43001. * CustomMeshes are not supported by this gizmo
  43002. * @param mesh The mesh to replace the default mesh of the gizmo
  43003. */
  43004. setCustomMesh(mesh: Mesh): void;
  43005. }
  43006. }
  43007. declare module BABYLON {
  43008. /**
  43009. * Single axis drag gizmo
  43010. */
  43011. export class AxisDragGizmo extends Gizmo {
  43012. /**
  43013. * Drag behavior responsible for the gizmos dragging interactions
  43014. */
  43015. dragBehavior: PointerDragBehavior;
  43016. private _pointerObserver;
  43017. /**
  43018. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43019. */
  43020. snapDistance: number;
  43021. /**
  43022. * Event that fires each time the gizmo snaps to a new location.
  43023. * * snapDistance is the the change in distance
  43024. */
  43025. onSnapObservable: Observable<{
  43026. snapDistance: number;
  43027. }>;
  43028. private _isEnabled;
  43029. private _parent;
  43030. private _arrow;
  43031. private _coloredMaterial;
  43032. private _hoverMaterial;
  43033. /** @hidden */
  43034. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43035. /** @hidden */
  43036. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43037. /**
  43038. * Creates an AxisDragGizmo
  43039. * @param gizmoLayer The utility layer the gizmo will be added to
  43040. * @param dragAxis The axis which the gizmo will be able to drag on
  43041. * @param color The color of the gizmo
  43042. */
  43043. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43044. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43045. /**
  43046. * If the gizmo is enabled
  43047. */
  43048. isEnabled: boolean;
  43049. /**
  43050. * Disposes of the gizmo
  43051. */
  43052. dispose(): void;
  43053. }
  43054. }
  43055. declare module BABYLON.Debug {
  43056. /**
  43057. * The Axes viewer will show 3 axes in a specific point in space
  43058. */
  43059. export class AxesViewer {
  43060. private _xAxis;
  43061. private _yAxis;
  43062. private _zAxis;
  43063. private _scaleLinesFactor;
  43064. private _instanced;
  43065. /**
  43066. * Gets the hosting scene
  43067. */
  43068. scene: Scene;
  43069. /**
  43070. * Gets or sets a number used to scale line length
  43071. */
  43072. scaleLines: number;
  43073. /** Gets the node hierarchy used to render x-axis */
  43074. readonly xAxis: TransformNode;
  43075. /** Gets the node hierarchy used to render y-axis */
  43076. readonly yAxis: TransformNode;
  43077. /** Gets the node hierarchy used to render z-axis */
  43078. readonly zAxis: TransformNode;
  43079. /**
  43080. * Creates a new AxesViewer
  43081. * @param scene defines the hosting scene
  43082. * @param scaleLines defines a number used to scale line length (1 by default)
  43083. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43084. * @param xAxis defines the node hierarchy used to render the x-axis
  43085. * @param yAxis defines the node hierarchy used to render the y-axis
  43086. * @param zAxis defines the node hierarchy used to render the z-axis
  43087. */
  43088. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43089. /**
  43090. * Force the viewer to update
  43091. * @param position defines the position of the viewer
  43092. * @param xaxis defines the x axis of the viewer
  43093. * @param yaxis defines the y axis of the viewer
  43094. * @param zaxis defines the z axis of the viewer
  43095. */
  43096. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43097. /**
  43098. * Creates an instance of this axes viewer.
  43099. * @returns a new axes viewer with instanced meshes
  43100. */
  43101. createInstance(): AxesViewer;
  43102. /** Releases resources */
  43103. dispose(): void;
  43104. private static _SetRenderingGroupId;
  43105. }
  43106. }
  43107. declare module BABYLON.Debug {
  43108. /**
  43109. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43110. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43111. */
  43112. export class BoneAxesViewer extends AxesViewer {
  43113. /**
  43114. * Gets or sets the target mesh where to display the axes viewer
  43115. */
  43116. mesh: Nullable<Mesh>;
  43117. /**
  43118. * Gets or sets the target bone where to display the axes viewer
  43119. */
  43120. bone: Nullable<Bone>;
  43121. /** Gets current position */
  43122. pos: Vector3;
  43123. /** Gets direction of X axis */
  43124. xaxis: Vector3;
  43125. /** Gets direction of Y axis */
  43126. yaxis: Vector3;
  43127. /** Gets direction of Z axis */
  43128. zaxis: Vector3;
  43129. /**
  43130. * Creates a new BoneAxesViewer
  43131. * @param scene defines the hosting scene
  43132. * @param bone defines the target bone
  43133. * @param mesh defines the target mesh
  43134. * @param scaleLines defines a scaling factor for line length (1 by default)
  43135. */
  43136. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43137. /**
  43138. * Force the viewer to update
  43139. */
  43140. update(): void;
  43141. /** Releases resources */
  43142. dispose(): void;
  43143. }
  43144. }
  43145. declare module BABYLON {
  43146. /**
  43147. * Interface used to define scene explorer extensibility option
  43148. */
  43149. export interface IExplorerExtensibilityOption {
  43150. /**
  43151. * Define the option label
  43152. */
  43153. label: string;
  43154. /**
  43155. * Defines the action to execute on click
  43156. */
  43157. action: (entity: any) => void;
  43158. }
  43159. /**
  43160. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43161. */
  43162. export interface IExplorerExtensibilityGroup {
  43163. /**
  43164. * Defines a predicate to test if a given type mut be extended
  43165. */
  43166. predicate: (entity: any) => boolean;
  43167. /**
  43168. * Gets the list of options added to a type
  43169. */
  43170. entries: IExplorerExtensibilityOption[];
  43171. }
  43172. /**
  43173. * Interface used to define the options to use to create the Inspector
  43174. */
  43175. export interface IInspectorOptions {
  43176. /**
  43177. * Display in overlay mode (default: false)
  43178. */
  43179. overlay?: boolean;
  43180. /**
  43181. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43182. */
  43183. globalRoot?: HTMLElement;
  43184. /**
  43185. * Display the Scene explorer
  43186. */
  43187. showExplorer?: boolean;
  43188. /**
  43189. * Display the property inspector
  43190. */
  43191. showInspector?: boolean;
  43192. /**
  43193. * Display in embed mode (both panes on the right)
  43194. */
  43195. embedMode?: boolean;
  43196. /**
  43197. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43198. */
  43199. handleResize?: boolean;
  43200. /**
  43201. * Allow the panes to popup (default: true)
  43202. */
  43203. enablePopup?: boolean;
  43204. /**
  43205. * Allow the panes to be closed by users (default: true)
  43206. */
  43207. enableClose?: boolean;
  43208. /**
  43209. * Optional list of extensibility entries
  43210. */
  43211. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43212. /**
  43213. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43214. */
  43215. inspectorURL?: string;
  43216. }
  43217. interface Scene {
  43218. /**
  43219. * @hidden
  43220. * Backing field
  43221. */
  43222. _debugLayer: DebugLayer;
  43223. /**
  43224. * Gets the debug layer (aka Inspector) associated with the scene
  43225. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43226. */
  43227. debugLayer: DebugLayer;
  43228. }
  43229. /**
  43230. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43231. * what is happening in your scene
  43232. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43233. */
  43234. export class DebugLayer {
  43235. /**
  43236. * Define the url to get the inspector script from.
  43237. * By default it uses the babylonjs CDN.
  43238. * @ignoreNaming
  43239. */
  43240. static InspectorURL: string;
  43241. private _scene;
  43242. private BJSINSPECTOR;
  43243. private _onPropertyChangedObservable?;
  43244. /**
  43245. * Observable triggered when a property is changed through the inspector.
  43246. */
  43247. readonly onPropertyChangedObservable: any;
  43248. /**
  43249. * Instantiates a new debug layer.
  43250. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43251. * what is happening in your scene
  43252. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43253. * @param scene Defines the scene to inspect
  43254. */
  43255. constructor(scene: Scene);
  43256. /** Creates the inspector window. */
  43257. private _createInspector;
  43258. /**
  43259. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43260. * @param entity defines the entity to select
  43261. * @param lineContainerTitle defines the specific block to highlight
  43262. */
  43263. select(entity: any, lineContainerTitle?: string): void;
  43264. /** Get the inspector from bundle or global */
  43265. private _getGlobalInspector;
  43266. /**
  43267. * Get if the inspector is visible or not.
  43268. * @returns true if visible otherwise, false
  43269. */
  43270. isVisible(): boolean;
  43271. /**
  43272. * Hide the inspector and close its window.
  43273. */
  43274. hide(): void;
  43275. /**
  43276. * Launch the debugLayer.
  43277. * @param config Define the configuration of the inspector
  43278. * @return a promise fulfilled when the debug layer is visible
  43279. */
  43280. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43281. }
  43282. }
  43283. declare module BABYLON {
  43284. /**
  43285. * Class containing static functions to help procedurally build meshes
  43286. */
  43287. export class BoxBuilder {
  43288. /**
  43289. * Creates a box mesh
  43290. * * The parameter `size` sets the size (float) of each box side (default 1)
  43291. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43292. * * 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)
  43293. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43295. * * 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
  43296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43297. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43298. * @param name defines the name of the mesh
  43299. * @param options defines the options used to create the mesh
  43300. * @param scene defines the hosting scene
  43301. * @returns the box mesh
  43302. */
  43303. static CreateBox(name: string, options: {
  43304. size?: number;
  43305. width?: number;
  43306. height?: number;
  43307. depth?: number;
  43308. faceUV?: Vector4[];
  43309. faceColors?: Color4[];
  43310. sideOrientation?: number;
  43311. frontUVs?: Vector4;
  43312. backUVs?: Vector4;
  43313. wrap?: boolean;
  43314. topBaseAt?: number;
  43315. bottomBaseAt?: number;
  43316. updatable?: boolean;
  43317. }, scene?: Nullable<Scene>): Mesh;
  43318. }
  43319. }
  43320. declare module BABYLON {
  43321. /**
  43322. * Class containing static functions to help procedurally build meshes
  43323. */
  43324. export class SphereBuilder {
  43325. /**
  43326. * Creates a sphere mesh
  43327. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43328. * * 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`)
  43329. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43330. * * 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
  43331. * * 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)
  43332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43333. * * 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
  43334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43335. * @param name defines the name of the mesh
  43336. * @param options defines the options used to create the mesh
  43337. * @param scene defines the hosting scene
  43338. * @returns the sphere mesh
  43339. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43340. */
  43341. static CreateSphere(name: string, options: {
  43342. segments?: number;
  43343. diameter?: number;
  43344. diameterX?: number;
  43345. diameterY?: number;
  43346. diameterZ?: number;
  43347. arc?: number;
  43348. slice?: number;
  43349. sideOrientation?: number;
  43350. frontUVs?: Vector4;
  43351. backUVs?: Vector4;
  43352. updatable?: boolean;
  43353. }, scene?: Nullable<Scene>): Mesh;
  43354. }
  43355. }
  43356. declare module BABYLON.Debug {
  43357. /**
  43358. * Used to show the physics impostor around the specific mesh
  43359. */
  43360. export class PhysicsViewer {
  43361. /** @hidden */
  43362. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43363. /** @hidden */
  43364. protected _meshes: Array<Nullable<AbstractMesh>>;
  43365. /** @hidden */
  43366. protected _scene: Nullable<Scene>;
  43367. /** @hidden */
  43368. protected _numMeshes: number;
  43369. /** @hidden */
  43370. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43371. private _renderFunction;
  43372. private _utilityLayer;
  43373. private _debugBoxMesh;
  43374. private _debugSphereMesh;
  43375. private _debugCylinderMesh;
  43376. private _debugMaterial;
  43377. private _debugMeshMeshes;
  43378. /**
  43379. * Creates a new PhysicsViewer
  43380. * @param scene defines the hosting scene
  43381. */
  43382. constructor(scene: Scene);
  43383. /** @hidden */
  43384. protected _updateDebugMeshes(): void;
  43385. /**
  43386. * Renders a specified physic impostor
  43387. * @param impostor defines the impostor to render
  43388. * @param targetMesh defines the mesh represented by the impostor
  43389. * @returns the new debug mesh used to render the impostor
  43390. */
  43391. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43392. /**
  43393. * Hides a specified physic impostor
  43394. * @param impostor defines the impostor to hide
  43395. */
  43396. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43397. private _getDebugMaterial;
  43398. private _getDebugBoxMesh;
  43399. private _getDebugSphereMesh;
  43400. private _getDebugCylinderMesh;
  43401. private _getDebugMeshMesh;
  43402. private _getDebugMesh;
  43403. /** Releases all resources */
  43404. dispose(): void;
  43405. }
  43406. }
  43407. declare module BABYLON {
  43408. /**
  43409. * Class containing static functions to help procedurally build meshes
  43410. */
  43411. export class LinesBuilder {
  43412. /**
  43413. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43414. * * 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
  43415. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43416. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43417. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43418. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43419. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43420. * * 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
  43421. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43424. * @param name defines the name of the new line system
  43425. * @param options defines the options used to create the line system
  43426. * @param scene defines the hosting scene
  43427. * @returns a new line system mesh
  43428. */
  43429. static CreateLineSystem(name: string, options: {
  43430. lines: Vector3[][];
  43431. updatable?: boolean;
  43432. instance?: Nullable<LinesMesh>;
  43433. colors?: Nullable<Color4[][]>;
  43434. useVertexAlpha?: boolean;
  43435. }, scene: Nullable<Scene>): LinesMesh;
  43436. /**
  43437. * Creates a line mesh
  43438. * 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
  43439. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43440. * * The parameter `points` is an array successive Vector3
  43441. * * 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
  43442. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43443. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43444. * * When updating an instance, remember that only point positions can change, not the number of points
  43445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43447. * @param name defines the name of the new line system
  43448. * @param options defines the options used to create the line system
  43449. * @param scene defines the hosting scene
  43450. * @returns a new line mesh
  43451. */
  43452. static CreateLines(name: string, options: {
  43453. points: Vector3[];
  43454. updatable?: boolean;
  43455. instance?: Nullable<LinesMesh>;
  43456. colors?: Color4[];
  43457. useVertexAlpha?: boolean;
  43458. }, scene?: Nullable<Scene>): LinesMesh;
  43459. /**
  43460. * Creates a dashed line mesh
  43461. * * 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
  43462. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43463. * * The parameter `points` is an array successive Vector3
  43464. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43465. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43466. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43467. * * 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
  43468. * * When updating an instance, remember that only point positions can change, not the number of points
  43469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43470. * @param name defines the name of the mesh
  43471. * @param options defines the options used to create the mesh
  43472. * @param scene defines the hosting scene
  43473. * @returns the dashed line mesh
  43474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43475. */
  43476. static CreateDashedLines(name: string, options: {
  43477. points: Vector3[];
  43478. dashSize?: number;
  43479. gapSize?: number;
  43480. dashNb?: number;
  43481. updatable?: boolean;
  43482. instance?: LinesMesh;
  43483. }, scene?: Nullable<Scene>): LinesMesh;
  43484. }
  43485. }
  43486. declare module BABYLON {
  43487. /**
  43488. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43489. * in order to better appreciate the issue one might have.
  43490. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43491. */
  43492. export class RayHelper {
  43493. /**
  43494. * Defines the ray we are currently tryin to visualize.
  43495. */
  43496. ray: Nullable<Ray>;
  43497. private _renderPoints;
  43498. private _renderLine;
  43499. private _renderFunction;
  43500. private _scene;
  43501. private _updateToMeshFunction;
  43502. private _attachedToMesh;
  43503. private _meshSpaceDirection;
  43504. private _meshSpaceOrigin;
  43505. /**
  43506. * Helper function to create a colored helper in a scene in one line.
  43507. * @param ray Defines the ray we are currently tryin to visualize
  43508. * @param scene Defines the scene the ray is used in
  43509. * @param color Defines the color we want to see the ray in
  43510. * @returns The newly created ray helper.
  43511. */
  43512. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43513. /**
  43514. * Instantiate a new ray helper.
  43515. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43516. * in order to better appreciate the issue one might have.
  43517. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43518. * @param ray Defines the ray we are currently tryin to visualize
  43519. */
  43520. constructor(ray: Ray);
  43521. /**
  43522. * Shows the ray we are willing to debug.
  43523. * @param scene Defines the scene the ray needs to be rendered in
  43524. * @param color Defines the color the ray needs to be rendered in
  43525. */
  43526. show(scene: Scene, color?: Color3): void;
  43527. /**
  43528. * Hides the ray we are debugging.
  43529. */
  43530. hide(): void;
  43531. private _render;
  43532. /**
  43533. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43534. * @param mesh Defines the mesh we want the helper attached to
  43535. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43536. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43537. * @param length Defines the length of the ray
  43538. */
  43539. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43540. /**
  43541. * Detach the ray helper from the mesh it has previously been attached to.
  43542. */
  43543. detachFromMesh(): void;
  43544. private _updateToMesh;
  43545. /**
  43546. * Dispose the helper and release its associated resources.
  43547. */
  43548. dispose(): void;
  43549. }
  43550. }
  43551. declare module BABYLON.Debug {
  43552. /**
  43553. * Class used to render a debug view of a given skeleton
  43554. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43555. */
  43556. export class SkeletonViewer {
  43557. /** defines the skeleton to render */
  43558. skeleton: Skeleton;
  43559. /** defines the mesh attached to the skeleton */
  43560. mesh: AbstractMesh;
  43561. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43562. autoUpdateBonesMatrices: boolean;
  43563. /** defines the rendering group id to use with the viewer */
  43564. renderingGroupId: number;
  43565. /** Gets or sets the color used to render the skeleton */
  43566. color: Color3;
  43567. private _scene;
  43568. private _debugLines;
  43569. private _debugMesh;
  43570. private _isEnabled;
  43571. private _renderFunction;
  43572. private _utilityLayer;
  43573. /**
  43574. * Returns the mesh used to render the bones
  43575. */
  43576. readonly debugMesh: Nullable<LinesMesh>;
  43577. /**
  43578. * Creates a new SkeletonViewer
  43579. * @param skeleton defines the skeleton to render
  43580. * @param mesh defines the mesh attached to the skeleton
  43581. * @param scene defines the hosting scene
  43582. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43583. * @param renderingGroupId defines the rendering group id to use with the viewer
  43584. */
  43585. constructor(
  43586. /** defines the skeleton to render */
  43587. skeleton: Skeleton,
  43588. /** defines the mesh attached to the skeleton */
  43589. mesh: AbstractMesh, scene: Scene,
  43590. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43591. autoUpdateBonesMatrices?: boolean,
  43592. /** defines the rendering group id to use with the viewer */
  43593. renderingGroupId?: number);
  43594. /** Gets or sets a boolean indicating if the viewer is enabled */
  43595. isEnabled: boolean;
  43596. private _getBonePosition;
  43597. private _getLinesForBonesWithLength;
  43598. private _getLinesForBonesNoLength;
  43599. /** Update the viewer to sync with current skeleton state */
  43600. update(): void;
  43601. /** Release associated resources */
  43602. dispose(): void;
  43603. }
  43604. }
  43605. declare module BABYLON {
  43606. /**
  43607. * Options to create the null engine
  43608. */
  43609. export class NullEngineOptions {
  43610. /**
  43611. * Render width (Default: 512)
  43612. */
  43613. renderWidth: number;
  43614. /**
  43615. * Render height (Default: 256)
  43616. */
  43617. renderHeight: number;
  43618. /**
  43619. * Texture size (Default: 512)
  43620. */
  43621. textureSize: number;
  43622. /**
  43623. * If delta time between frames should be constant
  43624. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43625. */
  43626. deterministicLockstep: boolean;
  43627. /**
  43628. * Maximum about of steps between frames (Default: 4)
  43629. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43630. */
  43631. lockstepMaxSteps: number;
  43632. }
  43633. /**
  43634. * The null engine class provides support for headless version of babylon.js.
  43635. * This can be used in server side scenario or for testing purposes
  43636. */
  43637. export class NullEngine extends Engine {
  43638. private _options;
  43639. /**
  43640. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43641. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43642. * @returns true if engine is in deterministic lock step mode
  43643. */
  43644. isDeterministicLockStep(): boolean;
  43645. /**
  43646. * Gets the max steps when engine is running in deterministic lock step
  43647. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43648. * @returns the max steps
  43649. */
  43650. getLockstepMaxSteps(): number;
  43651. /**
  43652. * Gets the current hardware scaling level.
  43653. * By default the hardware scaling level is computed from the window device ratio.
  43654. * 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.
  43655. * @returns a number indicating the current hardware scaling level
  43656. */
  43657. getHardwareScalingLevel(): number;
  43658. constructor(options?: NullEngineOptions);
  43659. /**
  43660. * Creates a vertex buffer
  43661. * @param vertices the data for the vertex buffer
  43662. * @returns the new WebGL static buffer
  43663. */
  43664. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43665. /**
  43666. * Creates a new index buffer
  43667. * @param indices defines the content of the index buffer
  43668. * @param updatable defines if the index buffer must be updatable
  43669. * @returns a new webGL buffer
  43670. */
  43671. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43672. /**
  43673. * Clear the current render buffer or the current render target (if any is set up)
  43674. * @param color defines the color to use
  43675. * @param backBuffer defines if the back buffer must be cleared
  43676. * @param depth defines if the depth buffer must be cleared
  43677. * @param stencil defines if the stencil buffer must be cleared
  43678. */
  43679. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43680. /**
  43681. * Gets the current render width
  43682. * @param useScreen defines if screen size must be used (or the current render target if any)
  43683. * @returns a number defining the current render width
  43684. */
  43685. getRenderWidth(useScreen?: boolean): number;
  43686. /**
  43687. * Gets the current render height
  43688. * @param useScreen defines if screen size must be used (or the current render target if any)
  43689. * @returns a number defining the current render height
  43690. */
  43691. getRenderHeight(useScreen?: boolean): number;
  43692. /**
  43693. * Set the WebGL's viewport
  43694. * @param viewport defines the viewport element to be used
  43695. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43696. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43697. */
  43698. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43699. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43700. /**
  43701. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43702. * @param pipelineContext defines the pipeline context to use
  43703. * @param uniformsNames defines the list of uniform names
  43704. * @returns an array of webGL uniform locations
  43705. */
  43706. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43707. /**
  43708. * Gets the lsit of active attributes for a given webGL program
  43709. * @param pipelineContext defines the pipeline context to use
  43710. * @param attributesNames defines the list of attribute names to get
  43711. * @returns an array of indices indicating the offset of each attribute
  43712. */
  43713. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43714. /**
  43715. * Binds an effect to the webGL context
  43716. * @param effect defines the effect to bind
  43717. */
  43718. bindSamplers(effect: Effect): void;
  43719. /**
  43720. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43721. * @param effect defines the effect to activate
  43722. */
  43723. enableEffect(effect: Effect): void;
  43724. /**
  43725. * Set various states to the webGL context
  43726. * @param culling defines backface culling state
  43727. * @param zOffset defines the value to apply to zOffset (0 by default)
  43728. * @param force defines if states must be applied even if cache is up to date
  43729. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43730. */
  43731. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43732. /**
  43733. * Set the value of an uniform to an array of int32
  43734. * @param uniform defines the webGL uniform location where to store the value
  43735. * @param array defines the array of int32 to store
  43736. */
  43737. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43738. /**
  43739. * Set the value of an uniform to an array of int32 (stored as vec2)
  43740. * @param uniform defines the webGL uniform location where to store the value
  43741. * @param array defines the array of int32 to store
  43742. */
  43743. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43744. /**
  43745. * Set the value of an uniform to an array of int32 (stored as vec3)
  43746. * @param uniform defines the webGL uniform location where to store the value
  43747. * @param array defines the array of int32 to store
  43748. */
  43749. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43750. /**
  43751. * Set the value of an uniform to an array of int32 (stored as vec4)
  43752. * @param uniform defines the webGL uniform location where to store the value
  43753. * @param array defines the array of int32 to store
  43754. */
  43755. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43756. /**
  43757. * Set the value of an uniform to an array of float32
  43758. * @param uniform defines the webGL uniform location where to store the value
  43759. * @param array defines the array of float32 to store
  43760. */
  43761. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43762. /**
  43763. * Set the value of an uniform to an array of float32 (stored as vec2)
  43764. * @param uniform defines the webGL uniform location where to store the value
  43765. * @param array defines the array of float32 to store
  43766. */
  43767. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43768. /**
  43769. * Set the value of an uniform to an array of float32 (stored as vec3)
  43770. * @param uniform defines the webGL uniform location where to store the value
  43771. * @param array defines the array of float32 to store
  43772. */
  43773. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43774. /**
  43775. * Set the value of an uniform to an array of float32 (stored as vec4)
  43776. * @param uniform defines the webGL uniform location where to store the value
  43777. * @param array defines the array of float32 to store
  43778. */
  43779. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43780. /**
  43781. * Set the value of an uniform to an array of number
  43782. * @param uniform defines the webGL uniform location where to store the value
  43783. * @param array defines the array of number to store
  43784. */
  43785. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43786. /**
  43787. * Set the value of an uniform to an array of number (stored as vec2)
  43788. * @param uniform defines the webGL uniform location where to store the value
  43789. * @param array defines the array of number to store
  43790. */
  43791. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43792. /**
  43793. * Set the value of an uniform to an array of number (stored as vec3)
  43794. * @param uniform defines the webGL uniform location where to store the value
  43795. * @param array defines the array of number to store
  43796. */
  43797. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43798. /**
  43799. * Set the value of an uniform to an array of number (stored as vec4)
  43800. * @param uniform defines the webGL uniform location where to store the value
  43801. * @param array defines the array of number to store
  43802. */
  43803. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43804. /**
  43805. * Set the value of an uniform to an array of float32 (stored as matrices)
  43806. * @param uniform defines the webGL uniform location where to store the value
  43807. * @param matrices defines the array of float32 to store
  43808. */
  43809. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43810. /**
  43811. * Set the value of an uniform to a matrix (3x3)
  43812. * @param uniform defines the webGL uniform location where to store the value
  43813. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43814. */
  43815. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43816. /**
  43817. * Set the value of an uniform to a matrix (2x2)
  43818. * @param uniform defines the webGL uniform location where to store the value
  43819. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43820. */
  43821. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43822. /**
  43823. * Set the value of an uniform to a number (float)
  43824. * @param uniform defines the webGL uniform location where to store the value
  43825. * @param value defines the float number to store
  43826. */
  43827. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43828. /**
  43829. * Set the value of an uniform to a vec2
  43830. * @param uniform defines the webGL uniform location where to store the value
  43831. * @param x defines the 1st component of the value
  43832. * @param y defines the 2nd component of the value
  43833. */
  43834. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43835. /**
  43836. * Set the value of an uniform to a vec3
  43837. * @param uniform defines the webGL uniform location where to store the value
  43838. * @param x defines the 1st component of the value
  43839. * @param y defines the 2nd component of the value
  43840. * @param z defines the 3rd component of the value
  43841. */
  43842. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43843. /**
  43844. * Set the value of an uniform to a boolean
  43845. * @param uniform defines the webGL uniform location where to store the value
  43846. * @param bool defines the boolean to store
  43847. */
  43848. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43849. /**
  43850. * Set the value of an uniform to a vec4
  43851. * @param uniform defines the webGL uniform location where to store the value
  43852. * @param x defines the 1st component of the value
  43853. * @param y defines the 2nd component of the value
  43854. * @param z defines the 3rd component of the value
  43855. * @param w defines the 4th component of the value
  43856. */
  43857. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43858. /**
  43859. * Sets the current alpha mode
  43860. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43861. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43862. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43863. */
  43864. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43865. /**
  43866. * Bind webGl buffers directly to the webGL context
  43867. * @param vertexBuffers defines the vertex buffer to bind
  43868. * @param indexBuffer defines the index buffer to bind
  43869. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43870. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43871. * @param effect defines the effect associated with the vertex buffer
  43872. */
  43873. bindBuffers(vertexBuffers: {
  43874. [key: string]: VertexBuffer;
  43875. }, indexBuffer: DataBuffer, effect: Effect): void;
  43876. /**
  43877. * Force the entire cache to be cleared
  43878. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43879. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43880. */
  43881. wipeCaches(bruteForce?: boolean): void;
  43882. /**
  43883. * Send a draw order
  43884. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43885. * @param indexStart defines the starting index
  43886. * @param indexCount defines the number of index to draw
  43887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43888. */
  43889. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43890. /**
  43891. * Draw a list of indexed primitives
  43892. * @param fillMode defines the primitive to use
  43893. * @param indexStart defines the starting index
  43894. * @param indexCount defines the number of index to draw
  43895. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43896. */
  43897. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43898. /**
  43899. * Draw a list of unindexed primitives
  43900. * @param fillMode defines the primitive to use
  43901. * @param verticesStart defines the index of first vertex to draw
  43902. * @param verticesCount defines the count of vertices to draw
  43903. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43904. */
  43905. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43906. /** @hidden */
  43907. _createTexture(): WebGLTexture;
  43908. /** @hidden */
  43909. _releaseTexture(texture: InternalTexture): void;
  43910. /**
  43911. * Usually called from Texture.ts.
  43912. * Passed information to create a WebGLTexture
  43913. * @param urlArg defines a value which contains one of the following:
  43914. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43915. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43916. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43917. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43918. * @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)
  43919. * @param scene needed for loading to the correct scene
  43920. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43921. * @param onLoad optional callback to be called upon successful completion
  43922. * @param onError optional callback to be called upon failure
  43923. * @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
  43924. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43925. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43926. * @param forcedExtension defines the extension to use to pick the right loader
  43927. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43928. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43929. */
  43930. 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;
  43931. /**
  43932. * Creates a new render target texture
  43933. * @param size defines the size of the texture
  43934. * @param options defines the options used to create the texture
  43935. * @returns a new render target texture stored in an InternalTexture
  43936. */
  43937. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43938. /**
  43939. * Update the sampling mode of a given texture
  43940. * @param samplingMode defines the required sampling mode
  43941. * @param texture defines the texture to update
  43942. */
  43943. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43944. /**
  43945. * Binds the frame buffer to the specified texture.
  43946. * @param texture The texture to render to or null for the default canvas
  43947. * @param faceIndex The face of the texture to render to in case of cube texture
  43948. * @param requiredWidth The width of the target to render to
  43949. * @param requiredHeight The height of the target to render to
  43950. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43951. * @param depthStencilTexture The depth stencil texture to use to render
  43952. * @param lodLevel defines le lod level to bind to the frame buffer
  43953. */
  43954. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43955. /**
  43956. * Unbind the current render target texture from the webGL context
  43957. * @param texture defines the render target texture to unbind
  43958. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43959. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43960. */
  43961. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43962. /**
  43963. * Creates a dynamic vertex buffer
  43964. * @param vertices the data for the dynamic vertex buffer
  43965. * @returns the new WebGL dynamic buffer
  43966. */
  43967. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43968. /**
  43969. * Update the content of a dynamic texture
  43970. * @param texture defines the texture to update
  43971. * @param canvas defines the canvas containing the source
  43972. * @param invertY defines if data must be stored with Y axis inverted
  43973. * @param premulAlpha defines if alpha is stored as premultiplied
  43974. * @param format defines the format of the data
  43975. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43976. */
  43977. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43978. /**
  43979. * Gets a boolean indicating if all created effects are ready
  43980. * @returns true if all effects are ready
  43981. */
  43982. areAllEffectsReady(): boolean;
  43983. /**
  43984. * @hidden
  43985. * Get the current error code of the webGL context
  43986. * @returns the error code
  43987. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43988. */
  43989. getError(): number;
  43990. /** @hidden */
  43991. _getUnpackAlignement(): number;
  43992. /** @hidden */
  43993. _unpackFlipY(value: boolean): void;
  43994. /**
  43995. * Update a dynamic index buffer
  43996. * @param indexBuffer defines the target index buffer
  43997. * @param indices defines the data to update
  43998. * @param offset defines the offset in the target index buffer where update should start
  43999. */
  44000. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44001. /**
  44002. * Updates a dynamic vertex buffer.
  44003. * @param vertexBuffer the vertex buffer to update
  44004. * @param vertices the data used to update the vertex buffer
  44005. * @param byteOffset the byte offset of the data (optional)
  44006. * @param byteLength the byte length of the data (optional)
  44007. */
  44008. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44009. /** @hidden */
  44010. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44011. /** @hidden */
  44012. _bindTexture(channel: number, texture: InternalTexture): void;
  44013. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44014. /**
  44015. * 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
  44016. */
  44017. releaseEffects(): void;
  44018. displayLoadingUI(): void;
  44019. hideLoadingUI(): void;
  44020. /** @hidden */
  44021. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44022. /** @hidden */
  44023. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44024. /** @hidden */
  44025. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44026. /** @hidden */
  44027. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44028. }
  44029. }
  44030. declare module BABYLON {
  44031. /** @hidden */
  44032. export class _OcclusionDataStorage {
  44033. /** @hidden */
  44034. occlusionInternalRetryCounter: number;
  44035. /** @hidden */
  44036. isOcclusionQueryInProgress: boolean;
  44037. /** @hidden */
  44038. isOccluded: boolean;
  44039. /** @hidden */
  44040. occlusionRetryCount: number;
  44041. /** @hidden */
  44042. occlusionType: number;
  44043. /** @hidden */
  44044. occlusionQueryAlgorithmType: number;
  44045. }
  44046. interface Engine {
  44047. /**
  44048. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44049. * @return the new query
  44050. */
  44051. createQuery(): WebGLQuery;
  44052. /**
  44053. * Delete and release a webGL query
  44054. * @param query defines the query to delete
  44055. * @return the current engine
  44056. */
  44057. deleteQuery(query: WebGLQuery): Engine;
  44058. /**
  44059. * Check if a given query has resolved and got its value
  44060. * @param query defines the query to check
  44061. * @returns true if the query got its value
  44062. */
  44063. isQueryResultAvailable(query: WebGLQuery): boolean;
  44064. /**
  44065. * Gets the value of a given query
  44066. * @param query defines the query to check
  44067. * @returns the value of the query
  44068. */
  44069. getQueryResult(query: WebGLQuery): number;
  44070. /**
  44071. * Initiates an occlusion query
  44072. * @param algorithmType defines the algorithm to use
  44073. * @param query defines the query to use
  44074. * @returns the current engine
  44075. * @see http://doc.babylonjs.com/features/occlusionquery
  44076. */
  44077. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44078. /**
  44079. * Ends an occlusion query
  44080. * @see http://doc.babylonjs.com/features/occlusionquery
  44081. * @param algorithmType defines the algorithm to use
  44082. * @returns the current engine
  44083. */
  44084. endOcclusionQuery(algorithmType: number): Engine;
  44085. /**
  44086. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44087. * Please note that only one query can be issued at a time
  44088. * @returns a time token used to track the time span
  44089. */
  44090. startTimeQuery(): Nullable<_TimeToken>;
  44091. /**
  44092. * Ends a time query
  44093. * @param token defines the token used to measure the time span
  44094. * @returns the time spent (in ns)
  44095. */
  44096. endTimeQuery(token: _TimeToken): int;
  44097. /** @hidden */
  44098. _currentNonTimestampToken: Nullable<_TimeToken>;
  44099. /** @hidden */
  44100. _createTimeQuery(): WebGLQuery;
  44101. /** @hidden */
  44102. _deleteTimeQuery(query: WebGLQuery): void;
  44103. /** @hidden */
  44104. _getGlAlgorithmType(algorithmType: number): number;
  44105. /** @hidden */
  44106. _getTimeQueryResult(query: WebGLQuery): any;
  44107. /** @hidden */
  44108. _getTimeQueryAvailability(query: WebGLQuery): any;
  44109. }
  44110. interface AbstractMesh {
  44111. /**
  44112. * Backing filed
  44113. * @hidden
  44114. */
  44115. __occlusionDataStorage: _OcclusionDataStorage;
  44116. /**
  44117. * Access property
  44118. * @hidden
  44119. */
  44120. _occlusionDataStorage: _OcclusionDataStorage;
  44121. /**
  44122. * 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.
  44123. * The default value is -1 which means don't break the query and wait till the result
  44124. * @see http://doc.babylonjs.com/features/occlusionquery
  44125. */
  44126. occlusionRetryCount: number;
  44127. /**
  44128. * 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:
  44129. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44130. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44131. * * 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.
  44132. * @see http://doc.babylonjs.com/features/occlusionquery
  44133. */
  44134. occlusionType: number;
  44135. /**
  44136. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44137. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44138. * * 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.
  44139. * @see http://doc.babylonjs.com/features/occlusionquery
  44140. */
  44141. occlusionQueryAlgorithmType: number;
  44142. /**
  44143. * 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
  44144. * @see http://doc.babylonjs.com/features/occlusionquery
  44145. */
  44146. isOccluded: boolean;
  44147. /**
  44148. * Flag to check the progress status of the query
  44149. * @see http://doc.babylonjs.com/features/occlusionquery
  44150. */
  44151. isOcclusionQueryInProgress: boolean;
  44152. }
  44153. }
  44154. declare module BABYLON {
  44155. /** @hidden */
  44156. export var _forceTransformFeedbackToBundle: boolean;
  44157. interface Engine {
  44158. /**
  44159. * Creates a webGL transform feedback object
  44160. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44161. * @returns the webGL transform feedback object
  44162. */
  44163. createTransformFeedback(): WebGLTransformFeedback;
  44164. /**
  44165. * Delete a webGL transform feedback object
  44166. * @param value defines the webGL transform feedback object to delete
  44167. */
  44168. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44169. /**
  44170. * Bind a webGL transform feedback object to the webgl context
  44171. * @param value defines the webGL transform feedback object to bind
  44172. */
  44173. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44174. /**
  44175. * Begins a transform feedback operation
  44176. * @param usePoints defines if points or triangles must be used
  44177. */
  44178. beginTransformFeedback(usePoints: boolean): void;
  44179. /**
  44180. * Ends a transform feedback operation
  44181. */
  44182. endTransformFeedback(): void;
  44183. /**
  44184. * Specify the varyings to use with transform feedback
  44185. * @param program defines the associated webGL program
  44186. * @param value defines the list of strings representing the varying names
  44187. */
  44188. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44189. /**
  44190. * Bind a webGL buffer for a transform feedback operation
  44191. * @param value defines the webGL buffer to bind
  44192. */
  44193. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44194. }
  44195. }
  44196. declare module BABYLON {
  44197. /**
  44198. * Creation options of the multi render target texture.
  44199. */
  44200. export interface IMultiRenderTargetOptions {
  44201. /**
  44202. * Define if the texture needs to create mip maps after render.
  44203. */
  44204. generateMipMaps?: boolean;
  44205. /**
  44206. * Define the types of all the draw buffers we want to create
  44207. */
  44208. types?: number[];
  44209. /**
  44210. * Define the sampling modes of all the draw buffers we want to create
  44211. */
  44212. samplingModes?: number[];
  44213. /**
  44214. * Define if a depth buffer is required
  44215. */
  44216. generateDepthBuffer?: boolean;
  44217. /**
  44218. * Define if a stencil buffer is required
  44219. */
  44220. generateStencilBuffer?: boolean;
  44221. /**
  44222. * Define if a depth texture is required instead of a depth buffer
  44223. */
  44224. generateDepthTexture?: boolean;
  44225. /**
  44226. * Define the number of desired draw buffers
  44227. */
  44228. textureCount?: number;
  44229. /**
  44230. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44231. */
  44232. doNotChangeAspectRatio?: boolean;
  44233. /**
  44234. * Define the default type of the buffers we are creating
  44235. */
  44236. defaultType?: number;
  44237. }
  44238. /**
  44239. * A multi render target, like a render target provides the ability to render to a texture.
  44240. * Unlike the render target, it can render to several draw buffers in one draw.
  44241. * This is specially interesting in deferred rendering or for any effects requiring more than
  44242. * just one color from a single pass.
  44243. */
  44244. export class MultiRenderTarget extends RenderTargetTexture {
  44245. private _internalTextures;
  44246. private _textures;
  44247. private _multiRenderTargetOptions;
  44248. /**
  44249. * Get if draw buffers are currently supported by the used hardware and browser.
  44250. */
  44251. readonly isSupported: boolean;
  44252. /**
  44253. * Get the list of textures generated by the multi render target.
  44254. */
  44255. readonly textures: Texture[];
  44256. /**
  44257. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44258. */
  44259. readonly depthTexture: Texture;
  44260. /**
  44261. * Set the wrapping mode on U of all the textures we are rendering to.
  44262. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44263. */
  44264. wrapU: number;
  44265. /**
  44266. * Set the wrapping mode on V of all the textures we are rendering to.
  44267. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44268. */
  44269. wrapV: number;
  44270. /**
  44271. * Instantiate a new multi render target texture.
  44272. * A multi render target, like a render target provides the ability to render to a texture.
  44273. * Unlike the render target, it can render to several draw buffers in one draw.
  44274. * This is specially interesting in deferred rendering or for any effects requiring more than
  44275. * just one color from a single pass.
  44276. * @param name Define the name of the texture
  44277. * @param size Define the size of the buffers to render to
  44278. * @param count Define the number of target we are rendering into
  44279. * @param scene Define the scene the texture belongs to
  44280. * @param options Define the options used to create the multi render target
  44281. */
  44282. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44283. /** @hidden */
  44284. _rebuild(): void;
  44285. private _createInternalTextures;
  44286. private _createTextures;
  44287. /**
  44288. * Define the number of samples used if MSAA is enabled.
  44289. */
  44290. samples: number;
  44291. /**
  44292. * Resize all the textures in the multi render target.
  44293. * Be carrefull as it will recreate all the data in the new texture.
  44294. * @param size Define the new size
  44295. */
  44296. resize(size: any): void;
  44297. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44298. /**
  44299. * Dispose the render targets and their associated resources
  44300. */
  44301. dispose(): void;
  44302. /**
  44303. * Release all the underlying texture used as draw buffers.
  44304. */
  44305. releaseInternalTextures(): void;
  44306. }
  44307. }
  44308. declare module BABYLON {
  44309. interface ThinEngine {
  44310. /**
  44311. * Unbind a list of render target textures from the webGL context
  44312. * This is used only when drawBuffer extension or webGL2 are active
  44313. * @param textures defines the render target textures to unbind
  44314. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44315. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44316. */
  44317. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44318. /**
  44319. * Create a multi render target texture
  44320. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44321. * @param size defines the size of the texture
  44322. * @param options defines the creation options
  44323. * @returns the cube texture as an InternalTexture
  44324. */
  44325. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44326. /**
  44327. * Update the sample count for a given multiple render target texture
  44328. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44329. * @param textures defines the textures to update
  44330. * @param samples defines the sample count to set
  44331. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44332. */
  44333. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44334. }
  44335. }
  44336. declare module BABYLON {
  44337. /** @hidden */
  44338. export var rgbdEncodePixelShader: {
  44339. name: string;
  44340. shader: string;
  44341. };
  44342. }
  44343. declare module BABYLON {
  44344. /** @hidden */
  44345. export var rgbdDecodePixelShader: {
  44346. name: string;
  44347. shader: string;
  44348. };
  44349. }
  44350. declare module BABYLON {
  44351. /**
  44352. * Raw texture data and descriptor sufficient for WebGL texture upload
  44353. */
  44354. export interface EnvironmentTextureInfo {
  44355. /**
  44356. * Version of the environment map
  44357. */
  44358. version: number;
  44359. /**
  44360. * Width of image
  44361. */
  44362. width: number;
  44363. /**
  44364. * Irradiance information stored in the file.
  44365. */
  44366. irradiance: any;
  44367. /**
  44368. * Specular information stored in the file.
  44369. */
  44370. specular: any;
  44371. }
  44372. /**
  44373. * Defines One Image in the file. It requires only the position in the file
  44374. * as well as the length.
  44375. */
  44376. interface BufferImageData {
  44377. /**
  44378. * Length of the image data.
  44379. */
  44380. length: number;
  44381. /**
  44382. * Position of the data from the null terminator delimiting the end of the JSON.
  44383. */
  44384. position: number;
  44385. }
  44386. /**
  44387. * Defines the specular data enclosed in the file.
  44388. * This corresponds to the version 1 of the data.
  44389. */
  44390. export interface EnvironmentTextureSpecularInfoV1 {
  44391. /**
  44392. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44393. */
  44394. specularDataPosition?: number;
  44395. /**
  44396. * This contains all the images data needed to reconstruct the cubemap.
  44397. */
  44398. mipmaps: Array<BufferImageData>;
  44399. /**
  44400. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44401. */
  44402. lodGenerationScale: number;
  44403. }
  44404. /**
  44405. * Sets of helpers addressing the serialization and deserialization of environment texture
  44406. * stored in a BabylonJS env file.
  44407. * Those files are usually stored as .env files.
  44408. */
  44409. export class EnvironmentTextureTools {
  44410. /**
  44411. * Magic number identifying the env file.
  44412. */
  44413. private static _MagicBytes;
  44414. /**
  44415. * Gets the environment info from an env file.
  44416. * @param data The array buffer containing the .env bytes.
  44417. * @returns the environment file info (the json header) if successfully parsed.
  44418. */
  44419. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44420. /**
  44421. * Creates an environment texture from a loaded cube texture.
  44422. * @param texture defines the cube texture to convert in env file
  44423. * @return a promise containing the environment data if succesfull.
  44424. */
  44425. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44426. /**
  44427. * Creates a JSON representation of the spherical data.
  44428. * @param texture defines the texture containing the polynomials
  44429. * @return the JSON representation of the spherical info
  44430. */
  44431. private static _CreateEnvTextureIrradiance;
  44432. /**
  44433. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44434. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44435. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44436. * @return the views described by info providing access to the underlying buffer
  44437. */
  44438. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44439. /**
  44440. * Uploads the texture info contained in the env file to the GPU.
  44441. * @param texture defines the internal texture to upload to
  44442. * @param arrayBuffer defines the buffer cotaining the data to load
  44443. * @param info defines the texture info retrieved through the GetEnvInfo method
  44444. * @returns a promise
  44445. */
  44446. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44447. /**
  44448. * Uploads the levels of image data to the GPU.
  44449. * @param texture defines the internal texture to upload to
  44450. * @param imageData defines the array buffer views of image data [mipmap][face]
  44451. * @returns a promise
  44452. */
  44453. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44454. /**
  44455. * Uploads spherical polynomials information to the texture.
  44456. * @param texture defines the texture we are trying to upload the information to
  44457. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44458. */
  44459. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44460. /** @hidden */
  44461. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44462. }
  44463. }
  44464. declare module BABYLON {
  44465. /**
  44466. * Contains position and normal vectors for a vertex
  44467. */
  44468. export class PositionNormalVertex {
  44469. /** the position of the vertex (defaut: 0,0,0) */
  44470. position: Vector3;
  44471. /** the normal of the vertex (defaut: 0,1,0) */
  44472. normal: Vector3;
  44473. /**
  44474. * Creates a PositionNormalVertex
  44475. * @param position the position of the vertex (defaut: 0,0,0)
  44476. * @param normal the normal of the vertex (defaut: 0,1,0)
  44477. */
  44478. constructor(
  44479. /** the position of the vertex (defaut: 0,0,0) */
  44480. position?: Vector3,
  44481. /** the normal of the vertex (defaut: 0,1,0) */
  44482. normal?: Vector3);
  44483. /**
  44484. * Clones the PositionNormalVertex
  44485. * @returns the cloned PositionNormalVertex
  44486. */
  44487. clone(): PositionNormalVertex;
  44488. }
  44489. /**
  44490. * Contains position, normal and uv vectors for a vertex
  44491. */
  44492. export class PositionNormalTextureVertex {
  44493. /** the position of the vertex (defaut: 0,0,0) */
  44494. position: Vector3;
  44495. /** the normal of the vertex (defaut: 0,1,0) */
  44496. normal: Vector3;
  44497. /** the uv of the vertex (default: 0,0) */
  44498. uv: Vector2;
  44499. /**
  44500. * Creates a PositionNormalTextureVertex
  44501. * @param position the position of the vertex (defaut: 0,0,0)
  44502. * @param normal the normal of the vertex (defaut: 0,1,0)
  44503. * @param uv the uv of the vertex (default: 0,0)
  44504. */
  44505. constructor(
  44506. /** the position of the vertex (defaut: 0,0,0) */
  44507. position?: Vector3,
  44508. /** the normal of the vertex (defaut: 0,1,0) */
  44509. normal?: Vector3,
  44510. /** the uv of the vertex (default: 0,0) */
  44511. uv?: Vector2);
  44512. /**
  44513. * Clones the PositionNormalTextureVertex
  44514. * @returns the cloned PositionNormalTextureVertex
  44515. */
  44516. clone(): PositionNormalTextureVertex;
  44517. }
  44518. }
  44519. declare module BABYLON {
  44520. /** @hidden */
  44521. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44522. private _genericAttributeLocation;
  44523. private _varyingLocationCount;
  44524. private _varyingLocationMap;
  44525. private _replacements;
  44526. private _textureCount;
  44527. private _uniforms;
  44528. lineProcessor(line: string): string;
  44529. attributeProcessor(attribute: string): string;
  44530. varyingProcessor(varying: string, isFragment: boolean): string;
  44531. uniformProcessor(uniform: string): string;
  44532. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44533. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44534. }
  44535. }
  44536. declare module BABYLON {
  44537. /**
  44538. * Container for accessors for natively-stored mesh data buffers.
  44539. */
  44540. class NativeDataBuffer extends DataBuffer {
  44541. /**
  44542. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44543. */
  44544. nativeIndexBuffer?: any;
  44545. /**
  44546. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44547. */
  44548. nativeVertexBuffer?: any;
  44549. }
  44550. /** @hidden */
  44551. export class NativeEngine extends Engine {
  44552. private readonly _native;
  44553. getHardwareScalingLevel(): number;
  44554. constructor();
  44555. /**
  44556. * Can be used to override the current requestAnimationFrame requester.
  44557. * @hidden
  44558. */
  44559. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44560. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44561. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44562. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44563. recordVertexArrayObject(vertexBuffers: {
  44564. [key: string]: VertexBuffer;
  44565. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44566. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44567. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44568. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44569. /**
  44570. * Draw a list of indexed primitives
  44571. * @param fillMode defines the primitive to use
  44572. * @param indexStart defines the starting index
  44573. * @param indexCount defines the number of index to draw
  44574. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44575. */
  44576. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44577. /**
  44578. * Draw a list of unindexed primitives
  44579. * @param fillMode defines the primitive to use
  44580. * @param verticesStart defines the index of first vertex to draw
  44581. * @param verticesCount defines the count of vertices to draw
  44582. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44583. */
  44584. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44585. createPipelineContext(): IPipelineContext;
  44586. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44587. /** @hidden */
  44588. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44589. /** @hidden */
  44590. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44591. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44592. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44593. protected _setProgram(program: WebGLProgram): void;
  44594. _releaseEffect(effect: Effect): void;
  44595. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44596. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44597. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44598. bindSamplers(effect: Effect): void;
  44599. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44600. getRenderWidth(useScreen?: boolean): number;
  44601. getRenderHeight(useScreen?: boolean): number;
  44602. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44603. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44604. /**
  44605. * Set the z offset to apply to current rendering
  44606. * @param value defines the offset to apply
  44607. */
  44608. setZOffset(value: number): void;
  44609. /**
  44610. * Gets the current value of the zOffset
  44611. * @returns the current zOffset state
  44612. */
  44613. getZOffset(): number;
  44614. /**
  44615. * Enable or disable depth buffering
  44616. * @param enable defines the state to set
  44617. */
  44618. setDepthBuffer(enable: boolean): void;
  44619. /**
  44620. * Gets a boolean indicating if depth writing is enabled
  44621. * @returns the current depth writing state
  44622. */
  44623. getDepthWrite(): boolean;
  44624. /**
  44625. * Enable or disable depth writing
  44626. * @param enable defines the state to set
  44627. */
  44628. setDepthWrite(enable: boolean): void;
  44629. /**
  44630. * Enable or disable color writing
  44631. * @param enable defines the state to set
  44632. */
  44633. setColorWrite(enable: boolean): void;
  44634. /**
  44635. * Gets a boolean indicating if color writing is enabled
  44636. * @returns the current color writing state
  44637. */
  44638. getColorWrite(): boolean;
  44639. /**
  44640. * Sets alpha constants used by some alpha blending modes
  44641. * @param r defines the red component
  44642. * @param g defines the green component
  44643. * @param b defines the blue component
  44644. * @param a defines the alpha component
  44645. */
  44646. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44647. /**
  44648. * Sets the current alpha mode
  44649. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44650. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44651. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44652. */
  44653. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44654. /**
  44655. * Gets the current alpha mode
  44656. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44657. * @returns the current alpha mode
  44658. */
  44659. getAlphaMode(): number;
  44660. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44661. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44662. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44663. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44664. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44665. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44666. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44667. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44668. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44669. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44670. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44671. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44672. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44673. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44674. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44675. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44676. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44677. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44678. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44679. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44680. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44681. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44682. wipeCaches(bruteForce?: boolean): void;
  44683. _createTexture(): WebGLTexture;
  44684. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44685. /**
  44686. * Usually called from BABYLON.Texture.ts.
  44687. * Passed information to create a WebGLTexture
  44688. * @param urlArg defines a value which contains one of the following:
  44689. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44690. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44691. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44692. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44693. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44694. * @param scene needed for loading to the correct scene
  44695. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44696. * @param onLoad optional callback to be called upon successful completion
  44697. * @param onError optional callback to be called upon failure
  44698. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44699. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44700. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44701. * @param forcedExtension defines the extension to use to pick the right loader
  44702. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44703. */
  44704. 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;
  44705. /**
  44706. * Creates a cube texture
  44707. * @param rootUrl defines the url where the files to load is located
  44708. * @param scene defines the current scene
  44709. * @param files defines the list of files to load (1 per face)
  44710. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44711. * @param onLoad defines an optional callback raised when the texture is loaded
  44712. * @param onError defines an optional callback raised if there is an issue to load the texture
  44713. * @param format defines the format of the data
  44714. * @param forcedExtension defines the extension to use to pick the right loader
  44715. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44718. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44719. * @returns the cube texture as an InternalTexture
  44720. */
  44721. 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;
  44722. private _getSamplingFilter;
  44723. private static _GetNativeTextureFormat;
  44724. createRenderTargetTexture(size: number | {
  44725. width: number;
  44726. height: number;
  44727. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44728. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44729. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44730. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44731. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44732. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44733. /**
  44734. * Updates a dynamic vertex buffer.
  44735. * @param vertexBuffer the vertex buffer to update
  44736. * @param data the data used to update the vertex buffer
  44737. * @param byteOffset the byte offset of the data (optional)
  44738. * @param byteLength the byte length of the data (optional)
  44739. */
  44740. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44741. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44742. private _updateAnisotropicLevel;
  44743. private _getAddressMode;
  44744. /** @hidden */
  44745. _bindTexture(channel: number, texture: InternalTexture): void;
  44746. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44747. releaseEffects(): void;
  44748. /** @hidden */
  44749. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44750. /** @hidden */
  44751. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44752. /** @hidden */
  44753. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44754. /** @hidden */
  44755. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44756. }
  44757. }
  44758. declare module BABYLON {
  44759. /**
  44760. * Gather the list of clipboard event types as constants.
  44761. */
  44762. export class ClipboardEventTypes {
  44763. /**
  44764. * The clipboard event is fired when a copy command is active (pressed).
  44765. */
  44766. static readonly COPY: number;
  44767. /**
  44768. * The clipboard event is fired when a cut command is active (pressed).
  44769. */
  44770. static readonly CUT: number;
  44771. /**
  44772. * The clipboard event is fired when a paste command is active (pressed).
  44773. */
  44774. static readonly PASTE: number;
  44775. }
  44776. /**
  44777. * This class is used to store clipboard related info for the onClipboardObservable event.
  44778. */
  44779. export class ClipboardInfo {
  44780. /**
  44781. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44782. */
  44783. type: number;
  44784. /**
  44785. * Defines the related dom event
  44786. */
  44787. event: ClipboardEvent;
  44788. /**
  44789. *Creates an instance of ClipboardInfo.
  44790. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44791. * @param event Defines the related dom event
  44792. */
  44793. constructor(
  44794. /**
  44795. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44796. */
  44797. type: number,
  44798. /**
  44799. * Defines the related dom event
  44800. */
  44801. event: ClipboardEvent);
  44802. /**
  44803. * Get the clipboard event's type from the keycode.
  44804. * @param keyCode Defines the keyCode for the current keyboard event.
  44805. * @return {number}
  44806. */
  44807. static GetTypeFromCharacter(keyCode: number): number;
  44808. }
  44809. }
  44810. declare module BABYLON {
  44811. /**
  44812. * Google Daydream controller
  44813. */
  44814. export class DaydreamController extends WebVRController {
  44815. /**
  44816. * Base Url for the controller model.
  44817. */
  44818. static MODEL_BASE_URL: string;
  44819. /**
  44820. * File name for the controller model.
  44821. */
  44822. static MODEL_FILENAME: string;
  44823. /**
  44824. * Gamepad Id prefix used to identify Daydream Controller.
  44825. */
  44826. static readonly GAMEPAD_ID_PREFIX: string;
  44827. /**
  44828. * Creates a new DaydreamController from a gamepad
  44829. * @param vrGamepad the gamepad that the controller should be created from
  44830. */
  44831. constructor(vrGamepad: any);
  44832. /**
  44833. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44834. * @param scene scene in which to add meshes
  44835. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44836. */
  44837. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44838. /**
  44839. * Called once for each button that changed state since the last frame
  44840. * @param buttonIdx Which button index changed
  44841. * @param state New state of the button
  44842. * @param changes Which properties on the state changed since last frame
  44843. */
  44844. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44845. }
  44846. }
  44847. declare module BABYLON {
  44848. /**
  44849. * Gear VR Controller
  44850. */
  44851. export class GearVRController extends WebVRController {
  44852. /**
  44853. * Base Url for the controller model.
  44854. */
  44855. static MODEL_BASE_URL: string;
  44856. /**
  44857. * File name for the controller model.
  44858. */
  44859. static MODEL_FILENAME: string;
  44860. /**
  44861. * Gamepad Id prefix used to identify this controller.
  44862. */
  44863. static readonly GAMEPAD_ID_PREFIX: string;
  44864. private readonly _buttonIndexToObservableNameMap;
  44865. /**
  44866. * Creates a new GearVRController from a gamepad
  44867. * @param vrGamepad the gamepad that the controller should be created from
  44868. */
  44869. constructor(vrGamepad: any);
  44870. /**
  44871. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44872. * @param scene scene in which to add meshes
  44873. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44874. */
  44875. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44876. /**
  44877. * Called once for each button that changed state since the last frame
  44878. * @param buttonIdx Which button index changed
  44879. * @param state New state of the button
  44880. * @param changes Which properties on the state changed since last frame
  44881. */
  44882. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44883. }
  44884. }
  44885. declare module BABYLON {
  44886. /**
  44887. * Class containing static functions to help procedurally build meshes
  44888. */
  44889. export class PolyhedronBuilder {
  44890. /**
  44891. * Creates a polyhedron mesh
  44892. * * 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
  44893. * * The parameter `size` (positive float, default 1) sets the polygon size
  44894. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44895. * * 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`
  44896. * * 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
  44897. * * 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)`)
  44898. * * 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
  44899. * * 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
  44900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44901. * * 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
  44902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44903. * @param name defines the name of the mesh
  44904. * @param options defines the options used to create the mesh
  44905. * @param scene defines the hosting scene
  44906. * @returns the polyhedron mesh
  44907. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44908. */
  44909. static CreatePolyhedron(name: string, options: {
  44910. type?: number;
  44911. size?: number;
  44912. sizeX?: number;
  44913. sizeY?: number;
  44914. sizeZ?: number;
  44915. custom?: any;
  44916. faceUV?: Vector4[];
  44917. faceColors?: Color4[];
  44918. flat?: boolean;
  44919. updatable?: boolean;
  44920. sideOrientation?: number;
  44921. frontUVs?: Vector4;
  44922. backUVs?: Vector4;
  44923. }, scene?: Nullable<Scene>): Mesh;
  44924. }
  44925. }
  44926. declare module BABYLON {
  44927. /**
  44928. * Gizmo that enables scaling a mesh along 3 axis
  44929. */
  44930. export class ScaleGizmo extends Gizmo {
  44931. /**
  44932. * Internal gizmo used for interactions on the x axis
  44933. */
  44934. xGizmo: AxisScaleGizmo;
  44935. /**
  44936. * Internal gizmo used for interactions on the y axis
  44937. */
  44938. yGizmo: AxisScaleGizmo;
  44939. /**
  44940. * Internal gizmo used for interactions on the z axis
  44941. */
  44942. zGizmo: AxisScaleGizmo;
  44943. /**
  44944. * Internal gizmo used to scale all axis equally
  44945. */
  44946. uniformScaleGizmo: AxisScaleGizmo;
  44947. private _meshAttached;
  44948. private _updateGizmoRotationToMatchAttachedMesh;
  44949. private _snapDistance;
  44950. private _scaleRatio;
  44951. private _uniformScalingMesh;
  44952. private _octahedron;
  44953. /** Fires an event when any of it's sub gizmos are dragged */
  44954. onDragStartObservable: Observable<unknown>;
  44955. /** Fires an event when any of it's sub gizmos are released from dragging */
  44956. onDragEndObservable: Observable<unknown>;
  44957. attachedMesh: Nullable<AbstractMesh>;
  44958. /**
  44959. * Creates a ScaleGizmo
  44960. * @param gizmoLayer The utility layer the gizmo will be added to
  44961. */
  44962. constructor(gizmoLayer?: UtilityLayerRenderer);
  44963. updateGizmoRotationToMatchAttachedMesh: boolean;
  44964. /**
  44965. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44966. */
  44967. snapDistance: number;
  44968. /**
  44969. * Ratio for the scale of the gizmo (Default: 1)
  44970. */
  44971. scaleRatio: number;
  44972. /**
  44973. * Disposes of the gizmo
  44974. */
  44975. dispose(): void;
  44976. }
  44977. }
  44978. declare module BABYLON {
  44979. /**
  44980. * Single axis scale gizmo
  44981. */
  44982. export class AxisScaleGizmo extends Gizmo {
  44983. /**
  44984. * Drag behavior responsible for the gizmos dragging interactions
  44985. */
  44986. dragBehavior: PointerDragBehavior;
  44987. private _pointerObserver;
  44988. /**
  44989. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44990. */
  44991. snapDistance: number;
  44992. /**
  44993. * Event that fires each time the gizmo snaps to a new location.
  44994. * * snapDistance is the the change in distance
  44995. */
  44996. onSnapObservable: Observable<{
  44997. snapDistance: number;
  44998. }>;
  44999. /**
  45000. * If the scaling operation should be done on all axis (default: false)
  45001. */
  45002. uniformScaling: boolean;
  45003. private _isEnabled;
  45004. private _parent;
  45005. private _arrow;
  45006. private _coloredMaterial;
  45007. private _hoverMaterial;
  45008. /**
  45009. * Creates an AxisScaleGizmo
  45010. * @param gizmoLayer The utility layer the gizmo will be added to
  45011. * @param dragAxis The axis which the gizmo will be able to scale on
  45012. * @param color The color of the gizmo
  45013. */
  45014. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45015. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45016. /**
  45017. * If the gizmo is enabled
  45018. */
  45019. isEnabled: boolean;
  45020. /**
  45021. * Disposes of the gizmo
  45022. */
  45023. dispose(): void;
  45024. /**
  45025. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45026. * @param mesh The mesh to replace the default mesh of the gizmo
  45027. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45028. */
  45029. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45030. }
  45031. }
  45032. declare module BABYLON {
  45033. /**
  45034. * Bounding box gizmo
  45035. */
  45036. export class BoundingBoxGizmo extends Gizmo {
  45037. private _lineBoundingBox;
  45038. private _rotateSpheresParent;
  45039. private _scaleBoxesParent;
  45040. private _boundingDimensions;
  45041. private _renderObserver;
  45042. private _pointerObserver;
  45043. private _scaleDragSpeed;
  45044. private _tmpQuaternion;
  45045. private _tmpVector;
  45046. private _tmpRotationMatrix;
  45047. /**
  45048. * 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)
  45049. */
  45050. ignoreChildren: boolean;
  45051. /**
  45052. * 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)
  45053. */
  45054. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45055. /**
  45056. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45057. */
  45058. rotationSphereSize: number;
  45059. /**
  45060. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45061. */
  45062. scaleBoxSize: number;
  45063. /**
  45064. * 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)
  45065. */
  45066. fixedDragMeshScreenSize: boolean;
  45067. /**
  45068. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45069. */
  45070. fixedDragMeshScreenSizeDistanceFactor: number;
  45071. /**
  45072. * Fired when a rotation sphere or scale box is dragged
  45073. */
  45074. onDragStartObservable: Observable<{}>;
  45075. /**
  45076. * Fired when a scale box is dragged
  45077. */
  45078. onScaleBoxDragObservable: Observable<{}>;
  45079. /**
  45080. * Fired when a scale box drag is ended
  45081. */
  45082. onScaleBoxDragEndObservable: Observable<{}>;
  45083. /**
  45084. * Fired when a rotation sphere is dragged
  45085. */
  45086. onRotationSphereDragObservable: Observable<{}>;
  45087. /**
  45088. * Fired when a rotation sphere drag is ended
  45089. */
  45090. onRotationSphereDragEndObservable: Observable<{}>;
  45091. /**
  45092. * 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)
  45093. */
  45094. scalePivot: Nullable<Vector3>;
  45095. /**
  45096. * Mesh used as a pivot to rotate the attached mesh
  45097. */
  45098. private _anchorMesh;
  45099. private _existingMeshScale;
  45100. private _dragMesh;
  45101. private pointerDragBehavior;
  45102. private coloredMaterial;
  45103. private hoverColoredMaterial;
  45104. /**
  45105. * Sets the color of the bounding box gizmo
  45106. * @param color the color to set
  45107. */
  45108. setColor(color: Color3): void;
  45109. /**
  45110. * Creates an BoundingBoxGizmo
  45111. * @param gizmoLayer The utility layer the gizmo will be added to
  45112. * @param color The color of the gizmo
  45113. */
  45114. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45115. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45116. private _selectNode;
  45117. /**
  45118. * Updates the bounding box information for the Gizmo
  45119. */
  45120. updateBoundingBox(): void;
  45121. private _updateRotationSpheres;
  45122. private _updateScaleBoxes;
  45123. /**
  45124. * Enables rotation on the specified axis and disables rotation on the others
  45125. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45126. */
  45127. setEnabledRotationAxis(axis: string): void;
  45128. /**
  45129. * Enables/disables scaling
  45130. * @param enable if scaling should be enabled
  45131. */
  45132. setEnabledScaling(enable: boolean): void;
  45133. private _updateDummy;
  45134. /**
  45135. * Enables a pointer drag behavior on the bounding box of the gizmo
  45136. */
  45137. enableDragBehavior(): void;
  45138. /**
  45139. * Disposes of the gizmo
  45140. */
  45141. dispose(): void;
  45142. /**
  45143. * 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)
  45144. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45145. * @returns the bounding box mesh with the passed in mesh as a child
  45146. */
  45147. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45148. /**
  45149. * CustomMeshes are not supported by this gizmo
  45150. * @param mesh The mesh to replace the default mesh of the gizmo
  45151. */
  45152. setCustomMesh(mesh: Mesh): void;
  45153. }
  45154. }
  45155. declare module BABYLON {
  45156. /**
  45157. * Single plane rotation gizmo
  45158. */
  45159. export class PlaneRotationGizmo extends Gizmo {
  45160. /**
  45161. * Drag behavior responsible for the gizmos dragging interactions
  45162. */
  45163. dragBehavior: PointerDragBehavior;
  45164. private _pointerObserver;
  45165. /**
  45166. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45167. */
  45168. snapDistance: number;
  45169. /**
  45170. * Event that fires each time the gizmo snaps to a new location.
  45171. * * snapDistance is the the change in distance
  45172. */
  45173. onSnapObservable: Observable<{
  45174. snapDistance: number;
  45175. }>;
  45176. private _isEnabled;
  45177. private _parent;
  45178. /**
  45179. * Creates a PlaneRotationGizmo
  45180. * @param gizmoLayer The utility layer the gizmo will be added to
  45181. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45182. * @param color The color of the gizmo
  45183. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45184. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45185. */
  45186. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45187. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45188. /**
  45189. * If the gizmo is enabled
  45190. */
  45191. isEnabled: boolean;
  45192. /**
  45193. * Disposes of the gizmo
  45194. */
  45195. dispose(): void;
  45196. }
  45197. }
  45198. declare module BABYLON {
  45199. /**
  45200. * Gizmo that enables rotating a mesh along 3 axis
  45201. */
  45202. export class RotationGizmo extends Gizmo {
  45203. /**
  45204. * Internal gizmo used for interactions on the x axis
  45205. */
  45206. xGizmo: PlaneRotationGizmo;
  45207. /**
  45208. * Internal gizmo used for interactions on the y axis
  45209. */
  45210. yGizmo: PlaneRotationGizmo;
  45211. /**
  45212. * Internal gizmo used for interactions on the z axis
  45213. */
  45214. zGizmo: PlaneRotationGizmo;
  45215. /** Fires an event when any of it's sub gizmos are dragged */
  45216. onDragStartObservable: Observable<unknown>;
  45217. /** Fires an event when any of it's sub gizmos are released from dragging */
  45218. onDragEndObservable: Observable<unknown>;
  45219. private _meshAttached;
  45220. attachedMesh: Nullable<AbstractMesh>;
  45221. /**
  45222. * Creates a RotationGizmo
  45223. * @param gizmoLayer The utility layer the gizmo will be added to
  45224. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45225. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45226. */
  45227. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45228. updateGizmoRotationToMatchAttachedMesh: boolean;
  45229. /**
  45230. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45231. */
  45232. snapDistance: number;
  45233. /**
  45234. * Ratio for the scale of the gizmo (Default: 1)
  45235. */
  45236. scaleRatio: number;
  45237. /**
  45238. * Disposes of the gizmo
  45239. */
  45240. dispose(): void;
  45241. /**
  45242. * CustomMeshes are not supported by this gizmo
  45243. * @param mesh The mesh to replace the default mesh of the gizmo
  45244. */
  45245. setCustomMesh(mesh: Mesh): void;
  45246. }
  45247. }
  45248. declare module BABYLON {
  45249. /**
  45250. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45251. */
  45252. export class GizmoManager implements IDisposable {
  45253. private scene;
  45254. /**
  45255. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45256. */
  45257. gizmos: {
  45258. positionGizmo: Nullable<PositionGizmo>;
  45259. rotationGizmo: Nullable<RotationGizmo>;
  45260. scaleGizmo: Nullable<ScaleGizmo>;
  45261. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45262. };
  45263. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45264. clearGizmoOnEmptyPointerEvent: boolean;
  45265. /** Fires an event when the manager is attached to a mesh */
  45266. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45267. private _gizmosEnabled;
  45268. private _pointerObserver;
  45269. private _attachedMesh;
  45270. private _boundingBoxColor;
  45271. private _defaultUtilityLayer;
  45272. private _defaultKeepDepthUtilityLayer;
  45273. /**
  45274. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45275. */
  45276. boundingBoxDragBehavior: SixDofDragBehavior;
  45277. /**
  45278. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45279. */
  45280. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45281. /**
  45282. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45283. */
  45284. usePointerToAttachGizmos: boolean;
  45285. /**
  45286. * Utility layer that the bounding box gizmo belongs to
  45287. */
  45288. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45289. /**
  45290. * Utility layer that all gizmos besides bounding box belong to
  45291. */
  45292. readonly utilityLayer: UtilityLayerRenderer;
  45293. /**
  45294. * Instatiates a gizmo manager
  45295. * @param scene the scene to overlay the gizmos on top of
  45296. */
  45297. constructor(scene: Scene);
  45298. /**
  45299. * Attaches a set of gizmos to the specified mesh
  45300. * @param mesh The mesh the gizmo's should be attached to
  45301. */
  45302. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45303. /**
  45304. * If the position gizmo is enabled
  45305. */
  45306. positionGizmoEnabled: boolean;
  45307. /**
  45308. * If the rotation gizmo is enabled
  45309. */
  45310. rotationGizmoEnabled: boolean;
  45311. /**
  45312. * If the scale gizmo is enabled
  45313. */
  45314. scaleGizmoEnabled: boolean;
  45315. /**
  45316. * If the boundingBox gizmo is enabled
  45317. */
  45318. boundingBoxGizmoEnabled: boolean;
  45319. /**
  45320. * Disposes of the gizmo manager
  45321. */
  45322. dispose(): void;
  45323. }
  45324. }
  45325. declare module BABYLON {
  45326. /**
  45327. * A directional light is defined by a direction (what a surprise!).
  45328. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45329. * 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.
  45330. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45331. */
  45332. export class DirectionalLight extends ShadowLight {
  45333. private _shadowFrustumSize;
  45334. /**
  45335. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45336. */
  45337. /**
  45338. * Specifies a fix frustum size for the shadow generation.
  45339. */
  45340. shadowFrustumSize: number;
  45341. private _shadowOrthoScale;
  45342. /**
  45343. * Gets the shadow projection scale against the optimal computed one.
  45344. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45345. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45346. */
  45347. /**
  45348. * Sets the shadow projection scale against the optimal computed one.
  45349. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45350. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45351. */
  45352. shadowOrthoScale: number;
  45353. /**
  45354. * Automatically compute the projection matrix to best fit (including all the casters)
  45355. * on each frame.
  45356. */
  45357. autoUpdateExtends: boolean;
  45358. private _orthoLeft;
  45359. private _orthoRight;
  45360. private _orthoTop;
  45361. private _orthoBottom;
  45362. /**
  45363. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45364. * The directional light is emitted from everywhere in the given direction.
  45365. * It can cast shadows.
  45366. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45367. * @param name The friendly name of the light
  45368. * @param direction The direction of the light
  45369. * @param scene The scene the light belongs to
  45370. */
  45371. constructor(name: string, direction: Vector3, scene: Scene);
  45372. /**
  45373. * Returns the string "DirectionalLight".
  45374. * @return The class name
  45375. */
  45376. getClassName(): string;
  45377. /**
  45378. * Returns the integer 1.
  45379. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45380. */
  45381. getTypeID(): number;
  45382. /**
  45383. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45384. * Returns the DirectionalLight Shadow projection matrix.
  45385. */
  45386. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45387. /**
  45388. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45389. * Returns the DirectionalLight Shadow projection matrix.
  45390. */
  45391. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45392. /**
  45393. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45394. * Returns the DirectionalLight Shadow projection matrix.
  45395. */
  45396. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45397. protected _buildUniformLayout(): void;
  45398. /**
  45399. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45400. * @param effect The effect to update
  45401. * @param lightIndex The index of the light in the effect to update
  45402. * @returns The directional light
  45403. */
  45404. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45405. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45406. /**
  45407. * Gets the minZ used for shadow according to both the scene and the light.
  45408. *
  45409. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45410. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45411. * @param activeCamera The camera we are returning the min for
  45412. * @returns the depth min z
  45413. */
  45414. getDepthMinZ(activeCamera: Camera): number;
  45415. /**
  45416. * Gets the maxZ used for shadow according to both the scene and the light.
  45417. *
  45418. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45419. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45420. * @param activeCamera The camera we are returning the max for
  45421. * @returns the depth max z
  45422. */
  45423. getDepthMaxZ(activeCamera: Camera): number;
  45424. /**
  45425. * Prepares the list of defines specific to the light type.
  45426. * @param defines the list of defines
  45427. * @param lightIndex defines the index of the light for the effect
  45428. */
  45429. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45430. }
  45431. }
  45432. declare module BABYLON {
  45433. /**
  45434. * Class containing static functions to help procedurally build meshes
  45435. */
  45436. export class HemisphereBuilder {
  45437. /**
  45438. * Creates a hemisphere mesh
  45439. * @param name defines the name of the mesh
  45440. * @param options defines the options used to create the mesh
  45441. * @param scene defines the hosting scene
  45442. * @returns the hemisphere mesh
  45443. */
  45444. static CreateHemisphere(name: string, options: {
  45445. segments?: number;
  45446. diameter?: number;
  45447. sideOrientation?: number;
  45448. }, scene: any): Mesh;
  45449. }
  45450. }
  45451. declare module BABYLON {
  45452. /**
  45453. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45454. * These values define a cone of light starting from the position, emitting toward the direction.
  45455. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45456. * and the exponent defines the speed of the decay of the light with distance (reach).
  45457. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45458. */
  45459. export class SpotLight extends ShadowLight {
  45460. private _angle;
  45461. private _innerAngle;
  45462. private _cosHalfAngle;
  45463. private _lightAngleScale;
  45464. private _lightAngleOffset;
  45465. /**
  45466. * Gets the cone angle of the spot light in Radians.
  45467. */
  45468. /**
  45469. * Sets the cone angle of the spot light in Radians.
  45470. */
  45471. angle: number;
  45472. /**
  45473. * Only used in gltf falloff mode, this defines the angle where
  45474. * the directional falloff will start before cutting at angle which could be seen
  45475. * as outer angle.
  45476. */
  45477. /**
  45478. * Only used in gltf falloff mode, this defines the angle where
  45479. * the directional falloff will start before cutting at angle which could be seen
  45480. * as outer angle.
  45481. */
  45482. innerAngle: number;
  45483. private _shadowAngleScale;
  45484. /**
  45485. * Allows scaling the angle of the light for shadow generation only.
  45486. */
  45487. /**
  45488. * Allows scaling the angle of the light for shadow generation only.
  45489. */
  45490. shadowAngleScale: number;
  45491. /**
  45492. * The light decay speed with the distance from the emission spot.
  45493. */
  45494. exponent: number;
  45495. private _projectionTextureMatrix;
  45496. /**
  45497. * Allows reading the projecton texture
  45498. */
  45499. readonly projectionTextureMatrix: Matrix;
  45500. protected _projectionTextureLightNear: number;
  45501. /**
  45502. * Gets the near clip of the Spotlight for texture projection.
  45503. */
  45504. /**
  45505. * Sets the near clip of the Spotlight for texture projection.
  45506. */
  45507. projectionTextureLightNear: number;
  45508. protected _projectionTextureLightFar: number;
  45509. /**
  45510. * Gets the far clip of the Spotlight for texture projection.
  45511. */
  45512. /**
  45513. * Sets the far clip of the Spotlight for texture projection.
  45514. */
  45515. projectionTextureLightFar: number;
  45516. protected _projectionTextureUpDirection: Vector3;
  45517. /**
  45518. * Gets the Up vector of the Spotlight for texture projection.
  45519. */
  45520. /**
  45521. * Sets the Up vector of the Spotlight for texture projection.
  45522. */
  45523. projectionTextureUpDirection: Vector3;
  45524. private _projectionTexture;
  45525. /**
  45526. * Gets the projection texture of the light.
  45527. */
  45528. /**
  45529. * Sets the projection texture of the light.
  45530. */
  45531. projectionTexture: Nullable<BaseTexture>;
  45532. private _projectionTextureViewLightDirty;
  45533. private _projectionTextureProjectionLightDirty;
  45534. private _projectionTextureDirty;
  45535. private _projectionTextureViewTargetVector;
  45536. private _projectionTextureViewLightMatrix;
  45537. private _projectionTextureProjectionLightMatrix;
  45538. private _projectionTextureScalingMatrix;
  45539. /**
  45540. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45541. * It can cast shadows.
  45542. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45543. * @param name The light friendly name
  45544. * @param position The position of the spot light in the scene
  45545. * @param direction The direction of the light in the scene
  45546. * @param angle The cone angle of the light in Radians
  45547. * @param exponent The light decay speed with the distance from the emission spot
  45548. * @param scene The scene the lights belongs to
  45549. */
  45550. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45551. /**
  45552. * Returns the string "SpotLight".
  45553. * @returns the class name
  45554. */
  45555. getClassName(): string;
  45556. /**
  45557. * Returns the integer 2.
  45558. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45559. */
  45560. getTypeID(): number;
  45561. /**
  45562. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45563. */
  45564. protected _setDirection(value: Vector3): void;
  45565. /**
  45566. * Overrides the position setter to recompute the projection texture view light Matrix.
  45567. */
  45568. protected _setPosition(value: Vector3): void;
  45569. /**
  45570. * 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.
  45571. * Returns the SpotLight.
  45572. */
  45573. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45574. protected _computeProjectionTextureViewLightMatrix(): void;
  45575. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45576. /**
  45577. * Main function for light texture projection matrix computing.
  45578. */
  45579. protected _computeProjectionTextureMatrix(): void;
  45580. protected _buildUniformLayout(): void;
  45581. private _computeAngleValues;
  45582. /**
  45583. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45584. * @param effect The effect to update
  45585. * @param lightIndex The index of the light in the effect to update
  45586. * @returns The spot light
  45587. */
  45588. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45589. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45590. /**
  45591. * Disposes the light and the associated resources.
  45592. */
  45593. dispose(): void;
  45594. /**
  45595. * Prepares the list of defines specific to the light type.
  45596. * @param defines the list of defines
  45597. * @param lightIndex defines the index of the light for the effect
  45598. */
  45599. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45600. }
  45601. }
  45602. declare module BABYLON {
  45603. /**
  45604. * Gizmo that enables viewing a light
  45605. */
  45606. export class LightGizmo extends Gizmo {
  45607. private _lightMesh;
  45608. private _material;
  45609. private cachedPosition;
  45610. private cachedForward;
  45611. /**
  45612. * Creates a LightGizmo
  45613. * @param gizmoLayer The utility layer the gizmo will be added to
  45614. */
  45615. constructor(gizmoLayer?: UtilityLayerRenderer);
  45616. private _light;
  45617. /**
  45618. * The light that the gizmo is attached to
  45619. */
  45620. light: Nullable<Light>;
  45621. /**
  45622. * Gets the material used to render the light gizmo
  45623. */
  45624. readonly material: StandardMaterial;
  45625. /**
  45626. * @hidden
  45627. * Updates the gizmo to match the attached mesh's position/rotation
  45628. */
  45629. protected _update(): void;
  45630. private static _Scale;
  45631. /**
  45632. * Creates the lines for a light mesh
  45633. */
  45634. private static _createLightLines;
  45635. /**
  45636. * Disposes of the light gizmo
  45637. */
  45638. dispose(): void;
  45639. private static _CreateHemisphericLightMesh;
  45640. private static _CreatePointLightMesh;
  45641. private static _CreateSpotLightMesh;
  45642. private static _CreateDirectionalLightMesh;
  45643. }
  45644. }
  45645. declare module BABYLON {
  45646. /** @hidden */
  45647. export var backgroundFragmentDeclaration: {
  45648. name: string;
  45649. shader: string;
  45650. };
  45651. }
  45652. declare module BABYLON {
  45653. /** @hidden */
  45654. export var backgroundUboDeclaration: {
  45655. name: string;
  45656. shader: string;
  45657. };
  45658. }
  45659. declare module BABYLON {
  45660. /** @hidden */
  45661. export var backgroundPixelShader: {
  45662. name: string;
  45663. shader: string;
  45664. };
  45665. }
  45666. declare module BABYLON {
  45667. /** @hidden */
  45668. export var backgroundVertexDeclaration: {
  45669. name: string;
  45670. shader: string;
  45671. };
  45672. }
  45673. declare module BABYLON {
  45674. /** @hidden */
  45675. export var backgroundVertexShader: {
  45676. name: string;
  45677. shader: string;
  45678. };
  45679. }
  45680. declare module BABYLON {
  45681. /**
  45682. * Background material used to create an efficient environement around your scene.
  45683. */
  45684. export class BackgroundMaterial extends PushMaterial {
  45685. /**
  45686. * Standard reflectance value at parallel view angle.
  45687. */
  45688. static StandardReflectance0: number;
  45689. /**
  45690. * Standard reflectance value at grazing angle.
  45691. */
  45692. static StandardReflectance90: number;
  45693. protected _primaryColor: Color3;
  45694. /**
  45695. * Key light Color (multiply against the environement texture)
  45696. */
  45697. primaryColor: Color3;
  45698. protected __perceptualColor: Nullable<Color3>;
  45699. /**
  45700. * Experimental Internal Use Only.
  45701. *
  45702. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45703. * This acts as a helper to set the primary color to a more "human friendly" value.
  45704. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45705. * output color as close as possible from the chosen value.
  45706. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45707. * part of lighting setup.)
  45708. */
  45709. _perceptualColor: Nullable<Color3>;
  45710. protected _primaryColorShadowLevel: float;
  45711. /**
  45712. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45713. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45714. */
  45715. primaryColorShadowLevel: float;
  45716. protected _primaryColorHighlightLevel: float;
  45717. /**
  45718. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45719. * The primary color is used at the level chosen to define what the white area would look.
  45720. */
  45721. primaryColorHighlightLevel: float;
  45722. protected _reflectionTexture: Nullable<BaseTexture>;
  45723. /**
  45724. * Reflection Texture used in the material.
  45725. * Should be author in a specific way for the best result (refer to the documentation).
  45726. */
  45727. reflectionTexture: Nullable<BaseTexture>;
  45728. protected _reflectionBlur: float;
  45729. /**
  45730. * Reflection Texture level of blur.
  45731. *
  45732. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45733. * texture twice.
  45734. */
  45735. reflectionBlur: float;
  45736. protected _diffuseTexture: Nullable<BaseTexture>;
  45737. /**
  45738. * Diffuse Texture used in the material.
  45739. * Should be author in a specific way for the best result (refer to the documentation).
  45740. */
  45741. diffuseTexture: Nullable<BaseTexture>;
  45742. protected _shadowLights: Nullable<IShadowLight[]>;
  45743. /**
  45744. * Specify the list of lights casting shadow on the material.
  45745. * All scene shadow lights will be included if null.
  45746. */
  45747. shadowLights: Nullable<IShadowLight[]>;
  45748. protected _shadowLevel: float;
  45749. /**
  45750. * Helps adjusting the shadow to a softer level if required.
  45751. * 0 means black shadows and 1 means no shadows.
  45752. */
  45753. shadowLevel: float;
  45754. protected _sceneCenter: Vector3;
  45755. /**
  45756. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45757. * It is usually zero but might be interesting to modify according to your setup.
  45758. */
  45759. sceneCenter: Vector3;
  45760. protected _opacityFresnel: boolean;
  45761. /**
  45762. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45763. * This helps ensuring a nice transition when the camera goes under the ground.
  45764. */
  45765. opacityFresnel: boolean;
  45766. protected _reflectionFresnel: boolean;
  45767. /**
  45768. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45769. * This helps adding a mirror texture on the ground.
  45770. */
  45771. reflectionFresnel: boolean;
  45772. protected _reflectionFalloffDistance: number;
  45773. /**
  45774. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45775. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45776. */
  45777. reflectionFalloffDistance: number;
  45778. protected _reflectionAmount: number;
  45779. /**
  45780. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45781. */
  45782. reflectionAmount: number;
  45783. protected _reflectionReflectance0: number;
  45784. /**
  45785. * This specifies the weight of the reflection at grazing angle.
  45786. */
  45787. reflectionReflectance0: number;
  45788. protected _reflectionReflectance90: number;
  45789. /**
  45790. * This specifies the weight of the reflection at a perpendicular point of view.
  45791. */
  45792. reflectionReflectance90: number;
  45793. /**
  45794. * Sets the reflection reflectance fresnel values according to the default standard
  45795. * empirically know to work well :-)
  45796. */
  45797. reflectionStandardFresnelWeight: number;
  45798. protected _useRGBColor: boolean;
  45799. /**
  45800. * Helps to directly use the maps channels instead of their level.
  45801. */
  45802. useRGBColor: boolean;
  45803. protected _enableNoise: boolean;
  45804. /**
  45805. * This helps reducing the banding effect that could occur on the background.
  45806. */
  45807. enableNoise: boolean;
  45808. /**
  45809. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45810. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45811. * Recommended to be keep at 1.0 except for special cases.
  45812. */
  45813. fovMultiplier: number;
  45814. private _fovMultiplier;
  45815. /**
  45816. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45817. */
  45818. useEquirectangularFOV: boolean;
  45819. private _maxSimultaneousLights;
  45820. /**
  45821. * Number of Simultaneous lights allowed on the material.
  45822. */
  45823. maxSimultaneousLights: int;
  45824. /**
  45825. * Default configuration related to image processing available in the Background Material.
  45826. */
  45827. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45828. /**
  45829. * Keep track of the image processing observer to allow dispose and replace.
  45830. */
  45831. private _imageProcessingObserver;
  45832. /**
  45833. * Attaches a new image processing configuration to the PBR Material.
  45834. * @param configuration (if null the scene configuration will be use)
  45835. */
  45836. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45837. /**
  45838. * Gets the image processing configuration used either in this material.
  45839. */
  45840. /**
  45841. * Sets the Default image processing configuration used either in the this material.
  45842. *
  45843. * If sets to null, the scene one is in use.
  45844. */
  45845. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45846. /**
  45847. * Gets wether the color curves effect is enabled.
  45848. */
  45849. /**
  45850. * Sets wether the color curves effect is enabled.
  45851. */
  45852. cameraColorCurvesEnabled: boolean;
  45853. /**
  45854. * Gets wether the color grading effect is enabled.
  45855. */
  45856. /**
  45857. * Gets wether the color grading effect is enabled.
  45858. */
  45859. cameraColorGradingEnabled: boolean;
  45860. /**
  45861. * Gets wether tonemapping is enabled or not.
  45862. */
  45863. /**
  45864. * Sets wether tonemapping is enabled or not
  45865. */
  45866. cameraToneMappingEnabled: boolean;
  45867. /**
  45868. * The camera exposure used on this material.
  45869. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45870. * This corresponds to a photographic exposure.
  45871. */
  45872. /**
  45873. * The camera exposure used on this material.
  45874. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45875. * This corresponds to a photographic exposure.
  45876. */
  45877. cameraExposure: float;
  45878. /**
  45879. * Gets The camera contrast used on this material.
  45880. */
  45881. /**
  45882. * Sets The camera contrast used on this material.
  45883. */
  45884. cameraContrast: float;
  45885. /**
  45886. * Gets the Color Grading 2D Lookup Texture.
  45887. */
  45888. /**
  45889. * Sets the Color Grading 2D Lookup Texture.
  45890. */
  45891. cameraColorGradingTexture: Nullable<BaseTexture>;
  45892. /**
  45893. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45894. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45895. * 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;
  45896. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45897. */
  45898. /**
  45899. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45900. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45901. * 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;
  45902. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45903. */
  45904. cameraColorCurves: Nullable<ColorCurves>;
  45905. /**
  45906. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45907. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45908. */
  45909. switchToBGR: boolean;
  45910. private _renderTargets;
  45911. private _reflectionControls;
  45912. private _white;
  45913. private _primaryShadowColor;
  45914. private _primaryHighlightColor;
  45915. /**
  45916. * Instantiates a Background Material in the given scene
  45917. * @param name The friendly name of the material
  45918. * @param scene The scene to add the material to
  45919. */
  45920. constructor(name: string, scene: Scene);
  45921. /**
  45922. * Gets a boolean indicating that current material needs to register RTT
  45923. */
  45924. readonly hasRenderTargetTextures: boolean;
  45925. /**
  45926. * The entire material has been created in order to prevent overdraw.
  45927. * @returns false
  45928. */
  45929. needAlphaTesting(): boolean;
  45930. /**
  45931. * The entire material has been created in order to prevent overdraw.
  45932. * @returns true if blending is enable
  45933. */
  45934. needAlphaBlending(): boolean;
  45935. /**
  45936. * Checks wether the material is ready to be rendered for a given mesh.
  45937. * @param mesh The mesh to render
  45938. * @param subMesh The submesh to check against
  45939. * @param useInstances Specify wether or not the material is used with instances
  45940. * @returns true if all the dependencies are ready (Textures, Effects...)
  45941. */
  45942. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45943. /**
  45944. * Compute the primary color according to the chosen perceptual color.
  45945. */
  45946. private _computePrimaryColorFromPerceptualColor;
  45947. /**
  45948. * Compute the highlights and shadow colors according to their chosen levels.
  45949. */
  45950. private _computePrimaryColors;
  45951. /**
  45952. * Build the uniform buffer used in the material.
  45953. */
  45954. buildUniformLayout(): void;
  45955. /**
  45956. * Unbind the material.
  45957. */
  45958. unbind(): void;
  45959. /**
  45960. * Bind only the world matrix to the material.
  45961. * @param world The world matrix to bind.
  45962. */
  45963. bindOnlyWorldMatrix(world: Matrix): void;
  45964. /**
  45965. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45966. * @param world The world matrix to bind.
  45967. * @param subMesh The submesh to bind for.
  45968. */
  45969. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45970. /**
  45971. * Checks to see if a texture is used in the material.
  45972. * @param texture - Base texture to use.
  45973. * @returns - Boolean specifying if a texture is used in the material.
  45974. */
  45975. hasTexture(texture: BaseTexture): boolean;
  45976. /**
  45977. * Dispose the material.
  45978. * @param forceDisposeEffect Force disposal of the associated effect.
  45979. * @param forceDisposeTextures Force disposal of the associated textures.
  45980. */
  45981. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45982. /**
  45983. * Clones the material.
  45984. * @param name The cloned name.
  45985. * @returns The cloned material.
  45986. */
  45987. clone(name: string): BackgroundMaterial;
  45988. /**
  45989. * Serializes the current material to its JSON representation.
  45990. * @returns The JSON representation.
  45991. */
  45992. serialize(): any;
  45993. /**
  45994. * Gets the class name of the material
  45995. * @returns "BackgroundMaterial"
  45996. */
  45997. getClassName(): string;
  45998. /**
  45999. * Parse a JSON input to create back a background material.
  46000. * @param source The JSON data to parse
  46001. * @param scene The scene to create the parsed material in
  46002. * @param rootUrl The root url of the assets the material depends upon
  46003. * @returns the instantiated BackgroundMaterial.
  46004. */
  46005. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46006. }
  46007. }
  46008. declare module BABYLON {
  46009. /**
  46010. * Represents the different options available during the creation of
  46011. * a Environment helper.
  46012. *
  46013. * This can control the default ground, skybox and image processing setup of your scene.
  46014. */
  46015. export interface IEnvironmentHelperOptions {
  46016. /**
  46017. * Specifies wether or not to create a ground.
  46018. * True by default.
  46019. */
  46020. createGround: boolean;
  46021. /**
  46022. * Specifies the ground size.
  46023. * 15 by default.
  46024. */
  46025. groundSize: number;
  46026. /**
  46027. * The texture used on the ground for the main color.
  46028. * Comes from the BabylonJS CDN by default.
  46029. *
  46030. * Remarks: Can be either a texture or a url.
  46031. */
  46032. groundTexture: string | BaseTexture;
  46033. /**
  46034. * The color mixed in the ground texture by default.
  46035. * BabylonJS clearColor by default.
  46036. */
  46037. groundColor: Color3;
  46038. /**
  46039. * Specifies the ground opacity.
  46040. * 1 by default.
  46041. */
  46042. groundOpacity: number;
  46043. /**
  46044. * Enables the ground to receive shadows.
  46045. * True by default.
  46046. */
  46047. enableGroundShadow: boolean;
  46048. /**
  46049. * Helps preventing the shadow to be fully black on the ground.
  46050. * 0.5 by default.
  46051. */
  46052. groundShadowLevel: number;
  46053. /**
  46054. * Creates a mirror texture attach to the ground.
  46055. * false by default.
  46056. */
  46057. enableGroundMirror: boolean;
  46058. /**
  46059. * Specifies the ground mirror size ratio.
  46060. * 0.3 by default as the default kernel is 64.
  46061. */
  46062. groundMirrorSizeRatio: number;
  46063. /**
  46064. * Specifies the ground mirror blur kernel size.
  46065. * 64 by default.
  46066. */
  46067. groundMirrorBlurKernel: number;
  46068. /**
  46069. * Specifies the ground mirror visibility amount.
  46070. * 1 by default
  46071. */
  46072. groundMirrorAmount: number;
  46073. /**
  46074. * Specifies the ground mirror reflectance weight.
  46075. * This uses the standard weight of the background material to setup the fresnel effect
  46076. * of the mirror.
  46077. * 1 by default.
  46078. */
  46079. groundMirrorFresnelWeight: number;
  46080. /**
  46081. * Specifies the ground mirror Falloff distance.
  46082. * This can helps reducing the size of the reflection.
  46083. * 0 by Default.
  46084. */
  46085. groundMirrorFallOffDistance: number;
  46086. /**
  46087. * Specifies the ground mirror texture type.
  46088. * Unsigned Int by Default.
  46089. */
  46090. groundMirrorTextureType: number;
  46091. /**
  46092. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46093. * the shown objects.
  46094. */
  46095. groundYBias: number;
  46096. /**
  46097. * Specifies wether or not to create a skybox.
  46098. * True by default.
  46099. */
  46100. createSkybox: boolean;
  46101. /**
  46102. * Specifies the skybox size.
  46103. * 20 by default.
  46104. */
  46105. skyboxSize: number;
  46106. /**
  46107. * The texture used on the skybox for the main color.
  46108. * Comes from the BabylonJS CDN by default.
  46109. *
  46110. * Remarks: Can be either a texture or a url.
  46111. */
  46112. skyboxTexture: string | BaseTexture;
  46113. /**
  46114. * The color mixed in the skybox texture by default.
  46115. * BabylonJS clearColor by default.
  46116. */
  46117. skyboxColor: Color3;
  46118. /**
  46119. * The background rotation around the Y axis of the scene.
  46120. * This helps aligning the key lights of your scene with the background.
  46121. * 0 by default.
  46122. */
  46123. backgroundYRotation: number;
  46124. /**
  46125. * Compute automatically the size of the elements to best fit with the scene.
  46126. */
  46127. sizeAuto: boolean;
  46128. /**
  46129. * Default position of the rootMesh if autoSize is not true.
  46130. */
  46131. rootPosition: Vector3;
  46132. /**
  46133. * Sets up the image processing in the scene.
  46134. * true by default.
  46135. */
  46136. setupImageProcessing: boolean;
  46137. /**
  46138. * The texture used as your environment texture in the scene.
  46139. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46140. *
  46141. * Remarks: Can be either a texture or a url.
  46142. */
  46143. environmentTexture: string | BaseTexture;
  46144. /**
  46145. * The value of the exposure to apply to the scene.
  46146. * 0.6 by default if setupImageProcessing is true.
  46147. */
  46148. cameraExposure: number;
  46149. /**
  46150. * The value of the contrast to apply to the scene.
  46151. * 1.6 by default if setupImageProcessing is true.
  46152. */
  46153. cameraContrast: number;
  46154. /**
  46155. * Specifies wether or not tonemapping should be enabled in the scene.
  46156. * true by default if setupImageProcessing is true.
  46157. */
  46158. toneMappingEnabled: boolean;
  46159. }
  46160. /**
  46161. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46162. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46163. * It also helps with the default setup of your imageProcessing configuration.
  46164. */
  46165. export class EnvironmentHelper {
  46166. /**
  46167. * Default ground texture URL.
  46168. */
  46169. private static _groundTextureCDNUrl;
  46170. /**
  46171. * Default skybox texture URL.
  46172. */
  46173. private static _skyboxTextureCDNUrl;
  46174. /**
  46175. * Default environment texture URL.
  46176. */
  46177. private static _environmentTextureCDNUrl;
  46178. /**
  46179. * Creates the default options for the helper.
  46180. */
  46181. private static _getDefaultOptions;
  46182. private _rootMesh;
  46183. /**
  46184. * Gets the root mesh created by the helper.
  46185. */
  46186. readonly rootMesh: Mesh;
  46187. private _skybox;
  46188. /**
  46189. * Gets the skybox created by the helper.
  46190. */
  46191. readonly skybox: Nullable<Mesh>;
  46192. private _skyboxTexture;
  46193. /**
  46194. * Gets the skybox texture created by the helper.
  46195. */
  46196. readonly skyboxTexture: Nullable<BaseTexture>;
  46197. private _skyboxMaterial;
  46198. /**
  46199. * Gets the skybox material created by the helper.
  46200. */
  46201. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46202. private _ground;
  46203. /**
  46204. * Gets the ground mesh created by the helper.
  46205. */
  46206. readonly ground: Nullable<Mesh>;
  46207. private _groundTexture;
  46208. /**
  46209. * Gets the ground texture created by the helper.
  46210. */
  46211. readonly groundTexture: Nullable<BaseTexture>;
  46212. private _groundMirror;
  46213. /**
  46214. * Gets the ground mirror created by the helper.
  46215. */
  46216. readonly groundMirror: Nullable<MirrorTexture>;
  46217. /**
  46218. * Gets the ground mirror render list to helps pushing the meshes
  46219. * you wish in the ground reflection.
  46220. */
  46221. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46222. private _groundMaterial;
  46223. /**
  46224. * Gets the ground material created by the helper.
  46225. */
  46226. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46227. /**
  46228. * Stores the creation options.
  46229. */
  46230. private readonly _scene;
  46231. private _options;
  46232. /**
  46233. * This observable will be notified with any error during the creation of the environment,
  46234. * mainly texture creation errors.
  46235. */
  46236. onErrorObservable: Observable<{
  46237. message?: string;
  46238. exception?: any;
  46239. }>;
  46240. /**
  46241. * constructor
  46242. * @param options Defines the options we want to customize the helper
  46243. * @param scene The scene to add the material to
  46244. */
  46245. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46246. /**
  46247. * Updates the background according to the new options
  46248. * @param options
  46249. */
  46250. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46251. /**
  46252. * Sets the primary color of all the available elements.
  46253. * @param color the main color to affect to the ground and the background
  46254. */
  46255. setMainColor(color: Color3): void;
  46256. /**
  46257. * Setup the image processing according to the specified options.
  46258. */
  46259. private _setupImageProcessing;
  46260. /**
  46261. * Setup the environment texture according to the specified options.
  46262. */
  46263. private _setupEnvironmentTexture;
  46264. /**
  46265. * Setup the background according to the specified options.
  46266. */
  46267. private _setupBackground;
  46268. /**
  46269. * Get the scene sizes according to the setup.
  46270. */
  46271. private _getSceneSize;
  46272. /**
  46273. * Setup the ground according to the specified options.
  46274. */
  46275. private _setupGround;
  46276. /**
  46277. * Setup the ground material according to the specified options.
  46278. */
  46279. private _setupGroundMaterial;
  46280. /**
  46281. * Setup the ground diffuse texture according to the specified options.
  46282. */
  46283. private _setupGroundDiffuseTexture;
  46284. /**
  46285. * Setup the ground mirror texture according to the specified options.
  46286. */
  46287. private _setupGroundMirrorTexture;
  46288. /**
  46289. * Setup the ground to receive the mirror texture.
  46290. */
  46291. private _setupMirrorInGroundMaterial;
  46292. /**
  46293. * Setup the skybox according to the specified options.
  46294. */
  46295. private _setupSkybox;
  46296. /**
  46297. * Setup the skybox material according to the specified options.
  46298. */
  46299. private _setupSkyboxMaterial;
  46300. /**
  46301. * Setup the skybox reflection texture according to the specified options.
  46302. */
  46303. private _setupSkyboxReflectionTexture;
  46304. private _errorHandler;
  46305. /**
  46306. * Dispose all the elements created by the Helper.
  46307. */
  46308. dispose(): void;
  46309. }
  46310. }
  46311. declare module BABYLON {
  46312. /**
  46313. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46314. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46315. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46316. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46317. */
  46318. export class PhotoDome extends TransformNode {
  46319. /**
  46320. * Define the image as a Monoscopic panoramic 360 image.
  46321. */
  46322. static readonly MODE_MONOSCOPIC: number;
  46323. /**
  46324. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46325. */
  46326. static readonly MODE_TOPBOTTOM: number;
  46327. /**
  46328. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46329. */
  46330. static readonly MODE_SIDEBYSIDE: number;
  46331. private _useDirectMapping;
  46332. /**
  46333. * The texture being displayed on the sphere
  46334. */
  46335. protected _photoTexture: Texture;
  46336. /**
  46337. * Gets or sets the texture being displayed on the sphere
  46338. */
  46339. photoTexture: Texture;
  46340. /**
  46341. * Observable raised when an error occured while loading the 360 image
  46342. */
  46343. onLoadErrorObservable: Observable<string>;
  46344. /**
  46345. * The skybox material
  46346. */
  46347. protected _material: BackgroundMaterial;
  46348. /**
  46349. * The surface used for the skybox
  46350. */
  46351. protected _mesh: Mesh;
  46352. /**
  46353. * Gets the mesh used for the skybox.
  46354. */
  46355. readonly mesh: Mesh;
  46356. /**
  46357. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46358. * Also see the options.resolution property.
  46359. */
  46360. fovMultiplier: number;
  46361. private _imageMode;
  46362. /**
  46363. * Gets or set the current video mode for the video. It can be:
  46364. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46365. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46366. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46367. */
  46368. imageMode: number;
  46369. /**
  46370. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46371. * @param name Element's name, child elements will append suffixes for their own names.
  46372. * @param urlsOfPhoto defines the url of the photo to display
  46373. * @param options defines an object containing optional or exposed sub element properties
  46374. * @param onError defines a callback called when an error occured while loading the texture
  46375. */
  46376. constructor(name: string, urlOfPhoto: string, options: {
  46377. resolution?: number;
  46378. size?: number;
  46379. useDirectMapping?: boolean;
  46380. faceForward?: boolean;
  46381. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46382. private _onBeforeCameraRenderObserver;
  46383. private _changeImageMode;
  46384. /**
  46385. * Releases resources associated with this node.
  46386. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46387. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46388. */
  46389. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46390. }
  46391. }
  46392. declare module BABYLON {
  46393. /**
  46394. * Class used to host RGBD texture specific utilities
  46395. */
  46396. export class RGBDTextureTools {
  46397. /**
  46398. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46399. * @param texture the texture to expand.
  46400. */
  46401. static ExpandRGBDTexture(texture: Texture): void;
  46402. }
  46403. }
  46404. declare module BABYLON {
  46405. /**
  46406. * Class used to host texture specific utilities
  46407. */
  46408. export class BRDFTextureTools {
  46409. /**
  46410. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46411. * @param scene defines the hosting scene
  46412. * @returns the environment BRDF texture
  46413. */
  46414. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46415. private static _environmentBRDFBase64Texture;
  46416. }
  46417. }
  46418. declare module BABYLON {
  46419. /**
  46420. * @hidden
  46421. */
  46422. export interface IMaterialClearCoatDefines {
  46423. CLEARCOAT: boolean;
  46424. CLEARCOAT_DEFAULTIOR: boolean;
  46425. CLEARCOAT_TEXTURE: boolean;
  46426. CLEARCOAT_TEXTUREDIRECTUV: number;
  46427. CLEARCOAT_BUMP: boolean;
  46428. CLEARCOAT_BUMPDIRECTUV: number;
  46429. CLEARCOAT_TINT: boolean;
  46430. CLEARCOAT_TINT_TEXTURE: boolean;
  46431. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46432. /** @hidden */
  46433. _areTexturesDirty: boolean;
  46434. }
  46435. /**
  46436. * Define the code related to the clear coat parameters of the pbr material.
  46437. */
  46438. export class PBRClearCoatConfiguration {
  46439. /**
  46440. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46441. * The default fits with a polyurethane material.
  46442. */
  46443. private static readonly _DefaultIndexOfRefraction;
  46444. private _isEnabled;
  46445. /**
  46446. * Defines if the clear coat is enabled in the material.
  46447. */
  46448. isEnabled: boolean;
  46449. /**
  46450. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46451. */
  46452. intensity: number;
  46453. /**
  46454. * Defines the clear coat layer roughness.
  46455. */
  46456. roughness: number;
  46457. private _indexOfRefraction;
  46458. /**
  46459. * Defines the index of refraction of the clear coat.
  46460. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46461. * The default fits with a polyurethane material.
  46462. * Changing the default value is more performance intensive.
  46463. */
  46464. indexOfRefraction: number;
  46465. private _texture;
  46466. /**
  46467. * Stores the clear coat values in a texture.
  46468. */
  46469. texture: Nullable<BaseTexture>;
  46470. private _bumpTexture;
  46471. /**
  46472. * Define the clear coat specific bump texture.
  46473. */
  46474. bumpTexture: Nullable<BaseTexture>;
  46475. private _isTintEnabled;
  46476. /**
  46477. * Defines if the clear coat tint is enabled in the material.
  46478. */
  46479. isTintEnabled: boolean;
  46480. /**
  46481. * Defines the clear coat tint of the material.
  46482. * This is only use if tint is enabled
  46483. */
  46484. tintColor: Color3;
  46485. /**
  46486. * Defines the distance at which the tint color should be found in the
  46487. * clear coat media.
  46488. * This is only use if tint is enabled
  46489. */
  46490. tintColorAtDistance: number;
  46491. /**
  46492. * Defines the clear coat layer thickness.
  46493. * This is only use if tint is enabled
  46494. */
  46495. tintThickness: number;
  46496. private _tintTexture;
  46497. /**
  46498. * Stores the clear tint values in a texture.
  46499. * rgb is tint
  46500. * a is a thickness factor
  46501. */
  46502. tintTexture: Nullable<BaseTexture>;
  46503. /** @hidden */
  46504. private _internalMarkAllSubMeshesAsTexturesDirty;
  46505. /** @hidden */
  46506. _markAllSubMeshesAsTexturesDirty(): void;
  46507. /**
  46508. * Instantiate a new istance of clear coat configuration.
  46509. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46510. */
  46511. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46512. /**
  46513. * Gets wehter the submesh is ready to be used or not.
  46514. * @param defines the list of "defines" to update.
  46515. * @param scene defines the scene the material belongs to.
  46516. * @param engine defines the engine the material belongs to.
  46517. * @param disableBumpMap defines wether the material disables bump or not.
  46518. * @returns - boolean indicating that the submesh is ready or not.
  46519. */
  46520. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46521. /**
  46522. * Checks to see if a texture is used in the material.
  46523. * @param defines the list of "defines" to update.
  46524. * @param scene defines the scene to the material belongs to.
  46525. */
  46526. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46527. /**
  46528. * Binds the material data.
  46529. * @param uniformBuffer defines the Uniform buffer to fill in.
  46530. * @param scene defines the scene the material belongs to.
  46531. * @param engine defines the engine the material belongs to.
  46532. * @param disableBumpMap defines wether the material disables bump or not.
  46533. * @param isFrozen defines wether the material is frozen or not.
  46534. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46535. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46536. */
  46537. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46538. /**
  46539. * Checks to see if a texture is used in the material.
  46540. * @param texture - Base texture to use.
  46541. * @returns - Boolean specifying if a texture is used in the material.
  46542. */
  46543. hasTexture(texture: BaseTexture): boolean;
  46544. /**
  46545. * Returns an array of the actively used textures.
  46546. * @param activeTextures Array of BaseTextures
  46547. */
  46548. getActiveTextures(activeTextures: BaseTexture[]): void;
  46549. /**
  46550. * Returns the animatable textures.
  46551. * @param animatables Array of animatable textures.
  46552. */
  46553. getAnimatables(animatables: IAnimatable[]): void;
  46554. /**
  46555. * Disposes the resources of the material.
  46556. * @param forceDisposeTextures - Forces the disposal of all textures.
  46557. */
  46558. dispose(forceDisposeTextures?: boolean): void;
  46559. /**
  46560. * Get the current class name of the texture useful for serialization or dynamic coding.
  46561. * @returns "PBRClearCoatConfiguration"
  46562. */
  46563. getClassName(): string;
  46564. /**
  46565. * Add fallbacks to the effect fallbacks list.
  46566. * @param defines defines the Base texture to use.
  46567. * @param fallbacks defines the current fallback list.
  46568. * @param currentRank defines the current fallback rank.
  46569. * @returns the new fallback rank.
  46570. */
  46571. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46572. /**
  46573. * Add the required uniforms to the current list.
  46574. * @param uniforms defines the current uniform list.
  46575. */
  46576. static AddUniforms(uniforms: string[]): void;
  46577. /**
  46578. * Add the required samplers to the current list.
  46579. * @param samplers defines the current sampler list.
  46580. */
  46581. static AddSamplers(samplers: string[]): void;
  46582. /**
  46583. * Add the required uniforms to the current buffer.
  46584. * @param uniformBuffer defines the current uniform buffer.
  46585. */
  46586. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46587. /**
  46588. * Makes a duplicate of the current configuration into another one.
  46589. * @param clearCoatConfiguration define the config where to copy the info
  46590. */
  46591. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46592. /**
  46593. * Serializes this clear coat configuration.
  46594. * @returns - An object with the serialized config.
  46595. */
  46596. serialize(): any;
  46597. /**
  46598. * Parses a anisotropy Configuration from a serialized object.
  46599. * @param source - Serialized object.
  46600. * @param scene Defines the scene we are parsing for
  46601. * @param rootUrl Defines the rootUrl to load from
  46602. */
  46603. parse(source: any, scene: Scene, rootUrl: string): void;
  46604. }
  46605. }
  46606. declare module BABYLON {
  46607. /**
  46608. * @hidden
  46609. */
  46610. export interface IMaterialAnisotropicDefines {
  46611. ANISOTROPIC: boolean;
  46612. ANISOTROPIC_TEXTURE: boolean;
  46613. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46614. MAINUV1: boolean;
  46615. _areTexturesDirty: boolean;
  46616. _needUVs: boolean;
  46617. }
  46618. /**
  46619. * Define the code related to the anisotropic parameters of the pbr material.
  46620. */
  46621. export class PBRAnisotropicConfiguration {
  46622. private _isEnabled;
  46623. /**
  46624. * Defines if the anisotropy is enabled in the material.
  46625. */
  46626. isEnabled: boolean;
  46627. /**
  46628. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46629. */
  46630. intensity: number;
  46631. /**
  46632. * Defines if the effect is along the tangents, bitangents or in between.
  46633. * By default, the effect is "strectching" the highlights along the tangents.
  46634. */
  46635. direction: Vector2;
  46636. private _texture;
  46637. /**
  46638. * Stores the anisotropy values in a texture.
  46639. * rg is direction (like normal from -1 to 1)
  46640. * b is a intensity
  46641. */
  46642. texture: Nullable<BaseTexture>;
  46643. /** @hidden */
  46644. private _internalMarkAllSubMeshesAsTexturesDirty;
  46645. /** @hidden */
  46646. _markAllSubMeshesAsTexturesDirty(): void;
  46647. /**
  46648. * Instantiate a new istance of anisotropy configuration.
  46649. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46650. */
  46651. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46652. /**
  46653. * Specifies that the submesh is ready to be used.
  46654. * @param defines the list of "defines" to update.
  46655. * @param scene defines the scene the material belongs to.
  46656. * @returns - boolean indicating that the submesh is ready or not.
  46657. */
  46658. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46659. /**
  46660. * Checks to see if a texture is used in the material.
  46661. * @param defines the list of "defines" to update.
  46662. * @param mesh the mesh we are preparing the defines for.
  46663. * @param scene defines the scene the material belongs to.
  46664. */
  46665. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46666. /**
  46667. * Binds the material data.
  46668. * @param uniformBuffer defines the Uniform buffer to fill in.
  46669. * @param scene defines the scene the material belongs to.
  46670. * @param isFrozen defines wether the material is frozen or not.
  46671. */
  46672. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46673. /**
  46674. * Checks to see if a texture is used in the material.
  46675. * @param texture - Base texture to use.
  46676. * @returns - Boolean specifying if a texture is used in the material.
  46677. */
  46678. hasTexture(texture: BaseTexture): boolean;
  46679. /**
  46680. * Returns an array of the actively used textures.
  46681. * @param activeTextures Array of BaseTextures
  46682. */
  46683. getActiveTextures(activeTextures: BaseTexture[]): void;
  46684. /**
  46685. * Returns the animatable textures.
  46686. * @param animatables Array of animatable textures.
  46687. */
  46688. getAnimatables(animatables: IAnimatable[]): void;
  46689. /**
  46690. * Disposes the resources of the material.
  46691. * @param forceDisposeTextures - Forces the disposal of all textures.
  46692. */
  46693. dispose(forceDisposeTextures?: boolean): void;
  46694. /**
  46695. * Get the current class name of the texture useful for serialization or dynamic coding.
  46696. * @returns "PBRAnisotropicConfiguration"
  46697. */
  46698. getClassName(): string;
  46699. /**
  46700. * Add fallbacks to the effect fallbacks list.
  46701. * @param defines defines the Base texture to use.
  46702. * @param fallbacks defines the current fallback list.
  46703. * @param currentRank defines the current fallback rank.
  46704. * @returns the new fallback rank.
  46705. */
  46706. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46707. /**
  46708. * Add the required uniforms to the current list.
  46709. * @param uniforms defines the current uniform list.
  46710. */
  46711. static AddUniforms(uniforms: string[]): void;
  46712. /**
  46713. * Add the required uniforms to the current buffer.
  46714. * @param uniformBuffer defines the current uniform buffer.
  46715. */
  46716. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46717. /**
  46718. * Add the required samplers to the current list.
  46719. * @param samplers defines the current sampler list.
  46720. */
  46721. static AddSamplers(samplers: string[]): void;
  46722. /**
  46723. * Makes a duplicate of the current configuration into another one.
  46724. * @param anisotropicConfiguration define the config where to copy the info
  46725. */
  46726. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46727. /**
  46728. * Serializes this anisotropy configuration.
  46729. * @returns - An object with the serialized config.
  46730. */
  46731. serialize(): any;
  46732. /**
  46733. * Parses a anisotropy Configuration from a serialized object.
  46734. * @param source - Serialized object.
  46735. * @param scene Defines the scene we are parsing for
  46736. * @param rootUrl Defines the rootUrl to load from
  46737. */
  46738. parse(source: any, scene: Scene, rootUrl: string): void;
  46739. }
  46740. }
  46741. declare module BABYLON {
  46742. /**
  46743. * @hidden
  46744. */
  46745. export interface IMaterialBRDFDefines {
  46746. BRDF_V_HEIGHT_CORRELATED: boolean;
  46747. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46748. SPHERICAL_HARMONICS: boolean;
  46749. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46750. /** @hidden */
  46751. _areMiscDirty: boolean;
  46752. }
  46753. /**
  46754. * Define the code related to the BRDF parameters of the pbr material.
  46755. */
  46756. export class PBRBRDFConfiguration {
  46757. /**
  46758. * Default value used for the energy conservation.
  46759. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46760. */
  46761. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46762. /**
  46763. * Default value used for the Smith Visibility Height Correlated mode.
  46764. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46765. */
  46766. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46767. /**
  46768. * Default value used for the IBL diffuse part.
  46769. * This can help switching back to the polynomials mode globally which is a tiny bit
  46770. * less GPU intensive at the drawback of a lower quality.
  46771. */
  46772. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46773. /**
  46774. * Default value used for activating energy conservation for the specular workflow.
  46775. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46776. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46777. */
  46778. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46779. private _useEnergyConservation;
  46780. /**
  46781. * Defines if the material uses energy conservation.
  46782. */
  46783. useEnergyConservation: boolean;
  46784. private _useSmithVisibilityHeightCorrelated;
  46785. /**
  46786. * LEGACY Mode set to false
  46787. * Defines if the material uses height smith correlated visibility term.
  46788. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46789. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46790. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46791. * Not relying on height correlated will also disable energy conservation.
  46792. */
  46793. useSmithVisibilityHeightCorrelated: boolean;
  46794. private _useSphericalHarmonics;
  46795. /**
  46796. * LEGACY Mode set to false
  46797. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46798. * diffuse part of the IBL.
  46799. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46800. * to the ground truth.
  46801. */
  46802. useSphericalHarmonics: boolean;
  46803. private _useSpecularGlossinessInputEnergyConservation;
  46804. /**
  46805. * Defines if the material uses energy conservation, when the specular workflow is active.
  46806. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46807. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46808. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46809. */
  46810. useSpecularGlossinessInputEnergyConservation: boolean;
  46811. /** @hidden */
  46812. private _internalMarkAllSubMeshesAsMiscDirty;
  46813. /** @hidden */
  46814. _markAllSubMeshesAsMiscDirty(): void;
  46815. /**
  46816. * Instantiate a new istance of clear coat configuration.
  46817. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46818. */
  46819. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46820. /**
  46821. * Checks to see if a texture is used in the material.
  46822. * @param defines the list of "defines" to update.
  46823. */
  46824. prepareDefines(defines: IMaterialBRDFDefines): void;
  46825. /**
  46826. * Get the current class name of the texture useful for serialization or dynamic coding.
  46827. * @returns "PBRClearCoatConfiguration"
  46828. */
  46829. getClassName(): string;
  46830. /**
  46831. * Makes a duplicate of the current configuration into another one.
  46832. * @param brdfConfiguration define the config where to copy the info
  46833. */
  46834. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46835. /**
  46836. * Serializes this BRDF configuration.
  46837. * @returns - An object with the serialized config.
  46838. */
  46839. serialize(): any;
  46840. /**
  46841. * Parses a anisotropy Configuration from a serialized object.
  46842. * @param source - Serialized object.
  46843. * @param scene Defines the scene we are parsing for
  46844. * @param rootUrl Defines the rootUrl to load from
  46845. */
  46846. parse(source: any, scene: Scene, rootUrl: string): void;
  46847. }
  46848. }
  46849. declare module BABYLON {
  46850. /**
  46851. * @hidden
  46852. */
  46853. export interface IMaterialSheenDefines {
  46854. SHEEN: boolean;
  46855. SHEEN_TEXTURE: boolean;
  46856. SHEEN_TEXTUREDIRECTUV: number;
  46857. SHEEN_LINKWITHALBEDO: boolean;
  46858. /** @hidden */
  46859. _areTexturesDirty: boolean;
  46860. }
  46861. /**
  46862. * Define the code related to the Sheen parameters of the pbr material.
  46863. */
  46864. export class PBRSheenConfiguration {
  46865. private _isEnabled;
  46866. /**
  46867. * Defines if the material uses sheen.
  46868. */
  46869. isEnabled: boolean;
  46870. private _linkSheenWithAlbedo;
  46871. /**
  46872. * Defines if the sheen is linked to the sheen color.
  46873. */
  46874. linkSheenWithAlbedo: boolean;
  46875. /**
  46876. * Defines the sheen intensity.
  46877. */
  46878. intensity: number;
  46879. /**
  46880. * Defines the sheen color.
  46881. */
  46882. color: Color3;
  46883. private _texture;
  46884. /**
  46885. * Stores the sheen tint values in a texture.
  46886. * rgb is tint
  46887. * a is a intensity
  46888. */
  46889. texture: Nullable<BaseTexture>;
  46890. /** @hidden */
  46891. private _internalMarkAllSubMeshesAsTexturesDirty;
  46892. /** @hidden */
  46893. _markAllSubMeshesAsTexturesDirty(): void;
  46894. /**
  46895. * Instantiate a new istance of clear coat configuration.
  46896. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46897. */
  46898. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46899. /**
  46900. * Specifies that the submesh is ready to be used.
  46901. * @param defines the list of "defines" to update.
  46902. * @param scene defines the scene the material belongs to.
  46903. * @returns - boolean indicating that the submesh is ready or not.
  46904. */
  46905. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46906. /**
  46907. * Checks to see if a texture is used in the material.
  46908. * @param defines the list of "defines" to update.
  46909. * @param scene defines the scene the material belongs to.
  46910. */
  46911. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46912. /**
  46913. * Binds the material data.
  46914. * @param uniformBuffer defines the Uniform buffer to fill in.
  46915. * @param scene defines the scene the material belongs to.
  46916. * @param isFrozen defines wether the material is frozen or not.
  46917. */
  46918. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46919. /**
  46920. * Checks to see if a texture is used in the material.
  46921. * @param texture - Base texture to use.
  46922. * @returns - Boolean specifying if a texture is used in the material.
  46923. */
  46924. hasTexture(texture: BaseTexture): boolean;
  46925. /**
  46926. * Returns an array of the actively used textures.
  46927. * @param activeTextures Array of BaseTextures
  46928. */
  46929. getActiveTextures(activeTextures: BaseTexture[]): void;
  46930. /**
  46931. * Returns the animatable textures.
  46932. * @param animatables Array of animatable textures.
  46933. */
  46934. getAnimatables(animatables: IAnimatable[]): void;
  46935. /**
  46936. * Disposes the resources of the material.
  46937. * @param forceDisposeTextures - Forces the disposal of all textures.
  46938. */
  46939. dispose(forceDisposeTextures?: boolean): void;
  46940. /**
  46941. * Get the current class name of the texture useful for serialization or dynamic coding.
  46942. * @returns "PBRSheenConfiguration"
  46943. */
  46944. getClassName(): string;
  46945. /**
  46946. * Add fallbacks to the effect fallbacks list.
  46947. * @param defines defines the Base texture to use.
  46948. * @param fallbacks defines the current fallback list.
  46949. * @param currentRank defines the current fallback rank.
  46950. * @returns the new fallback rank.
  46951. */
  46952. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46953. /**
  46954. * Add the required uniforms to the current list.
  46955. * @param uniforms defines the current uniform list.
  46956. */
  46957. static AddUniforms(uniforms: string[]): void;
  46958. /**
  46959. * Add the required uniforms to the current buffer.
  46960. * @param uniformBuffer defines the current uniform buffer.
  46961. */
  46962. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46963. /**
  46964. * Add the required samplers to the current list.
  46965. * @param samplers defines the current sampler list.
  46966. */
  46967. static AddSamplers(samplers: string[]): void;
  46968. /**
  46969. * Makes a duplicate of the current configuration into another one.
  46970. * @param sheenConfiguration define the config where to copy the info
  46971. */
  46972. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46973. /**
  46974. * Serializes this BRDF configuration.
  46975. * @returns - An object with the serialized config.
  46976. */
  46977. serialize(): any;
  46978. /**
  46979. * Parses a anisotropy Configuration from a serialized object.
  46980. * @param source - Serialized object.
  46981. * @param scene Defines the scene we are parsing for
  46982. * @param rootUrl Defines the rootUrl to load from
  46983. */
  46984. parse(source: any, scene: Scene, rootUrl: string): void;
  46985. }
  46986. }
  46987. declare module BABYLON {
  46988. /**
  46989. * @hidden
  46990. */
  46991. export interface IMaterialSubSurfaceDefines {
  46992. SUBSURFACE: boolean;
  46993. SS_REFRACTION: boolean;
  46994. SS_TRANSLUCENCY: boolean;
  46995. SS_SCATERRING: boolean;
  46996. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46997. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46998. SS_REFRACTIONMAP_3D: boolean;
  46999. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47000. SS_LODINREFRACTIONALPHA: boolean;
  47001. SS_GAMMAREFRACTION: boolean;
  47002. SS_RGBDREFRACTION: boolean;
  47003. SS_LINEARSPECULARREFRACTION: boolean;
  47004. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47005. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47006. /** @hidden */
  47007. _areTexturesDirty: boolean;
  47008. }
  47009. /**
  47010. * Define the code related to the sub surface parameters of the pbr material.
  47011. */
  47012. export class PBRSubSurfaceConfiguration {
  47013. private _isRefractionEnabled;
  47014. /**
  47015. * Defines if the refraction is enabled in the material.
  47016. */
  47017. isRefractionEnabled: boolean;
  47018. private _isTranslucencyEnabled;
  47019. /**
  47020. * Defines if the translucency is enabled in the material.
  47021. */
  47022. isTranslucencyEnabled: boolean;
  47023. private _isScatteringEnabled;
  47024. /**
  47025. * Defines the refraction intensity of the material.
  47026. * The refraction when enabled replaces the Diffuse part of the material.
  47027. * The intensity helps transitionning between diffuse and refraction.
  47028. */
  47029. refractionIntensity: number;
  47030. /**
  47031. * Defines the translucency intensity of the material.
  47032. * When translucency has been enabled, this defines how much of the "translucency"
  47033. * is addded to the diffuse part of the material.
  47034. */
  47035. translucencyIntensity: number;
  47036. /**
  47037. * Defines the scattering intensity of the material.
  47038. * When scattering has been enabled, this defines how much of the "scattered light"
  47039. * is addded to the diffuse part of the material.
  47040. */
  47041. scatteringIntensity: number;
  47042. private _thicknessTexture;
  47043. /**
  47044. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47045. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47046. * 0 would mean minimumThickness
  47047. * 1 would mean maximumThickness
  47048. * The other channels might be use as a mask to vary the different effects intensity.
  47049. */
  47050. thicknessTexture: Nullable<BaseTexture>;
  47051. private _refractionTexture;
  47052. /**
  47053. * Defines the texture to use for refraction.
  47054. */
  47055. refractionTexture: Nullable<BaseTexture>;
  47056. private _indexOfRefraction;
  47057. /**
  47058. * Defines the index of refraction used in the material.
  47059. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47060. */
  47061. indexOfRefraction: number;
  47062. private _invertRefractionY;
  47063. /**
  47064. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47065. */
  47066. invertRefractionY: boolean;
  47067. private _linkRefractionWithTransparency;
  47068. /**
  47069. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47070. * Materials half opaque for instance using refraction could benefit from this control.
  47071. */
  47072. linkRefractionWithTransparency: boolean;
  47073. /**
  47074. * Defines the minimum thickness stored in the thickness map.
  47075. * If no thickness map is defined, this value will be used to simulate thickness.
  47076. */
  47077. minimumThickness: number;
  47078. /**
  47079. * Defines the maximum thickness stored in the thickness map.
  47080. */
  47081. maximumThickness: number;
  47082. /**
  47083. * Defines the volume tint of the material.
  47084. * This is used for both translucency and scattering.
  47085. */
  47086. tintColor: Color3;
  47087. /**
  47088. * Defines the distance at which the tint color should be found in the media.
  47089. * This is used for refraction only.
  47090. */
  47091. tintColorAtDistance: number;
  47092. /**
  47093. * Defines how far each channel transmit through the media.
  47094. * It is defined as a color to simplify it selection.
  47095. */
  47096. diffusionDistance: Color3;
  47097. private _useMaskFromThicknessTexture;
  47098. /**
  47099. * Stores the intensity of the different subsurface effects in the thickness texture.
  47100. * * the green channel is the translucency intensity.
  47101. * * the blue channel is the scattering intensity.
  47102. * * the alpha channel is the refraction intensity.
  47103. */
  47104. useMaskFromThicknessTexture: boolean;
  47105. /** @hidden */
  47106. private _internalMarkAllSubMeshesAsTexturesDirty;
  47107. /** @hidden */
  47108. _markAllSubMeshesAsTexturesDirty(): void;
  47109. /**
  47110. * Instantiate a new istance of sub surface configuration.
  47111. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47112. */
  47113. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47114. /**
  47115. * Gets wehter the submesh is ready to be used or not.
  47116. * @param defines the list of "defines" to update.
  47117. * @param scene defines the scene the material belongs to.
  47118. * @returns - boolean indicating that the submesh is ready or not.
  47119. */
  47120. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47121. /**
  47122. * Checks to see if a texture is used in the material.
  47123. * @param defines the list of "defines" to update.
  47124. * @param scene defines the scene to the material belongs to.
  47125. */
  47126. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47127. /**
  47128. * Binds the material data.
  47129. * @param uniformBuffer defines the Uniform buffer to fill in.
  47130. * @param scene defines the scene the material belongs to.
  47131. * @param engine defines the engine the material belongs to.
  47132. * @param isFrozen defines wether the material is frozen or not.
  47133. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47134. */
  47135. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47136. /**
  47137. * Unbinds the material from the mesh.
  47138. * @param activeEffect defines the effect that should be unbound from.
  47139. * @returns true if unbound, otherwise false
  47140. */
  47141. unbind(activeEffect: Effect): boolean;
  47142. /**
  47143. * Returns the texture used for refraction or null if none is used.
  47144. * @param scene defines the scene the material belongs to.
  47145. * @returns - Refraction texture if present. If no refraction texture and refraction
  47146. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47147. */
  47148. private _getRefractionTexture;
  47149. /**
  47150. * Returns true if alpha blending should be disabled.
  47151. */
  47152. readonly disableAlphaBlending: boolean;
  47153. /**
  47154. * Fills the list of render target textures.
  47155. * @param renderTargets the list of render targets to update
  47156. */
  47157. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47158. /**
  47159. * Checks to see if a texture is used in the material.
  47160. * @param texture - Base texture to use.
  47161. * @returns - Boolean specifying if a texture is used in the material.
  47162. */
  47163. hasTexture(texture: BaseTexture): boolean;
  47164. /**
  47165. * Gets a boolean indicating that current material needs to register RTT
  47166. * @returns true if this uses a render target otherwise false.
  47167. */
  47168. hasRenderTargetTextures(): boolean;
  47169. /**
  47170. * Returns an array of the actively used textures.
  47171. * @param activeTextures Array of BaseTextures
  47172. */
  47173. getActiveTextures(activeTextures: BaseTexture[]): void;
  47174. /**
  47175. * Returns the animatable textures.
  47176. * @param animatables Array of animatable textures.
  47177. */
  47178. getAnimatables(animatables: IAnimatable[]): void;
  47179. /**
  47180. * Disposes the resources of the material.
  47181. * @param forceDisposeTextures - Forces the disposal of all textures.
  47182. */
  47183. dispose(forceDisposeTextures?: boolean): void;
  47184. /**
  47185. * Get the current class name of the texture useful for serialization or dynamic coding.
  47186. * @returns "PBRSubSurfaceConfiguration"
  47187. */
  47188. getClassName(): string;
  47189. /**
  47190. * Add fallbacks to the effect fallbacks list.
  47191. * @param defines defines the Base texture to use.
  47192. * @param fallbacks defines the current fallback list.
  47193. * @param currentRank defines the current fallback rank.
  47194. * @returns the new fallback rank.
  47195. */
  47196. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47197. /**
  47198. * Add the required uniforms to the current list.
  47199. * @param uniforms defines the current uniform list.
  47200. */
  47201. static AddUniforms(uniforms: string[]): void;
  47202. /**
  47203. * Add the required samplers to the current list.
  47204. * @param samplers defines the current sampler list.
  47205. */
  47206. static AddSamplers(samplers: string[]): void;
  47207. /**
  47208. * Add the required uniforms to the current buffer.
  47209. * @param uniformBuffer defines the current uniform buffer.
  47210. */
  47211. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47212. /**
  47213. * Makes a duplicate of the current configuration into another one.
  47214. * @param configuration define the config where to copy the info
  47215. */
  47216. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47217. /**
  47218. * Serializes this Sub Surface configuration.
  47219. * @returns - An object with the serialized config.
  47220. */
  47221. serialize(): any;
  47222. /**
  47223. * Parses a anisotropy Configuration from a serialized object.
  47224. * @param source - Serialized object.
  47225. * @param scene Defines the scene we are parsing for
  47226. * @param rootUrl Defines the rootUrl to load from
  47227. */
  47228. parse(source: any, scene: Scene, rootUrl: string): void;
  47229. }
  47230. }
  47231. declare module BABYLON {
  47232. /** @hidden */
  47233. export var pbrFragmentDeclaration: {
  47234. name: string;
  47235. shader: string;
  47236. };
  47237. }
  47238. declare module BABYLON {
  47239. /** @hidden */
  47240. export var pbrUboDeclaration: {
  47241. name: string;
  47242. shader: string;
  47243. };
  47244. }
  47245. declare module BABYLON {
  47246. /** @hidden */
  47247. export var pbrFragmentExtraDeclaration: {
  47248. name: string;
  47249. shader: string;
  47250. };
  47251. }
  47252. declare module BABYLON {
  47253. /** @hidden */
  47254. export var pbrFragmentSamplersDeclaration: {
  47255. name: string;
  47256. shader: string;
  47257. };
  47258. }
  47259. declare module BABYLON {
  47260. /** @hidden */
  47261. export var pbrHelperFunctions: {
  47262. name: string;
  47263. shader: string;
  47264. };
  47265. }
  47266. declare module BABYLON {
  47267. /** @hidden */
  47268. export var harmonicsFunctions: {
  47269. name: string;
  47270. shader: string;
  47271. };
  47272. }
  47273. declare module BABYLON {
  47274. /** @hidden */
  47275. export var pbrDirectLightingSetupFunctions: {
  47276. name: string;
  47277. shader: string;
  47278. };
  47279. }
  47280. declare module BABYLON {
  47281. /** @hidden */
  47282. export var pbrDirectLightingFalloffFunctions: {
  47283. name: string;
  47284. shader: string;
  47285. };
  47286. }
  47287. declare module BABYLON {
  47288. /** @hidden */
  47289. export var pbrBRDFFunctions: {
  47290. name: string;
  47291. shader: string;
  47292. };
  47293. }
  47294. declare module BABYLON {
  47295. /** @hidden */
  47296. export var pbrDirectLightingFunctions: {
  47297. name: string;
  47298. shader: string;
  47299. };
  47300. }
  47301. declare module BABYLON {
  47302. /** @hidden */
  47303. export var pbrIBLFunctions: {
  47304. name: string;
  47305. shader: string;
  47306. };
  47307. }
  47308. declare module BABYLON {
  47309. /** @hidden */
  47310. export var pbrDebug: {
  47311. name: string;
  47312. shader: string;
  47313. };
  47314. }
  47315. declare module BABYLON {
  47316. /** @hidden */
  47317. export var pbrPixelShader: {
  47318. name: string;
  47319. shader: string;
  47320. };
  47321. }
  47322. declare module BABYLON {
  47323. /** @hidden */
  47324. export var pbrVertexDeclaration: {
  47325. name: string;
  47326. shader: string;
  47327. };
  47328. }
  47329. declare module BABYLON {
  47330. /** @hidden */
  47331. export var pbrVertexShader: {
  47332. name: string;
  47333. shader: string;
  47334. };
  47335. }
  47336. declare module BABYLON {
  47337. /**
  47338. * Manages the defines for the PBR Material.
  47339. * @hidden
  47340. */
  47341. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47342. PBR: boolean;
  47343. MAINUV1: boolean;
  47344. MAINUV2: boolean;
  47345. UV1: boolean;
  47346. UV2: boolean;
  47347. ALBEDO: boolean;
  47348. ALBEDODIRECTUV: number;
  47349. VERTEXCOLOR: boolean;
  47350. AMBIENT: boolean;
  47351. AMBIENTDIRECTUV: number;
  47352. AMBIENTINGRAYSCALE: boolean;
  47353. OPACITY: boolean;
  47354. VERTEXALPHA: boolean;
  47355. OPACITYDIRECTUV: number;
  47356. OPACITYRGB: boolean;
  47357. ALPHATEST: boolean;
  47358. DEPTHPREPASS: boolean;
  47359. ALPHABLEND: boolean;
  47360. ALPHAFROMALBEDO: boolean;
  47361. ALPHATESTVALUE: string;
  47362. SPECULAROVERALPHA: boolean;
  47363. RADIANCEOVERALPHA: boolean;
  47364. ALPHAFRESNEL: boolean;
  47365. LINEARALPHAFRESNEL: boolean;
  47366. PREMULTIPLYALPHA: boolean;
  47367. EMISSIVE: boolean;
  47368. EMISSIVEDIRECTUV: number;
  47369. REFLECTIVITY: boolean;
  47370. REFLECTIVITYDIRECTUV: number;
  47371. SPECULARTERM: boolean;
  47372. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47373. MICROSURFACEAUTOMATIC: boolean;
  47374. LODBASEDMICROSFURACE: boolean;
  47375. MICROSURFACEMAP: boolean;
  47376. MICROSURFACEMAPDIRECTUV: number;
  47377. METALLICWORKFLOW: boolean;
  47378. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47379. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47380. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47381. AOSTOREINMETALMAPRED: boolean;
  47382. ENVIRONMENTBRDF: boolean;
  47383. ENVIRONMENTBRDF_RGBD: boolean;
  47384. NORMAL: boolean;
  47385. TANGENT: boolean;
  47386. BUMP: boolean;
  47387. BUMPDIRECTUV: number;
  47388. OBJECTSPACE_NORMALMAP: boolean;
  47389. PARALLAX: boolean;
  47390. PARALLAXOCCLUSION: boolean;
  47391. NORMALXYSCALE: boolean;
  47392. LIGHTMAP: boolean;
  47393. LIGHTMAPDIRECTUV: number;
  47394. USELIGHTMAPASSHADOWMAP: boolean;
  47395. GAMMALIGHTMAP: boolean;
  47396. RGBDLIGHTMAP: boolean;
  47397. REFLECTION: boolean;
  47398. REFLECTIONMAP_3D: boolean;
  47399. REFLECTIONMAP_SPHERICAL: boolean;
  47400. REFLECTIONMAP_PLANAR: boolean;
  47401. REFLECTIONMAP_CUBIC: boolean;
  47402. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47403. REFLECTIONMAP_PROJECTION: boolean;
  47404. REFLECTIONMAP_SKYBOX: boolean;
  47405. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47406. REFLECTIONMAP_EXPLICIT: boolean;
  47407. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47408. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47409. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47410. INVERTCUBICMAP: boolean;
  47411. USESPHERICALFROMREFLECTIONMAP: boolean;
  47412. USEIRRADIANCEMAP: boolean;
  47413. SPHERICAL_HARMONICS: boolean;
  47414. USESPHERICALINVERTEX: boolean;
  47415. REFLECTIONMAP_OPPOSITEZ: boolean;
  47416. LODINREFLECTIONALPHA: boolean;
  47417. GAMMAREFLECTION: boolean;
  47418. RGBDREFLECTION: boolean;
  47419. LINEARSPECULARREFLECTION: boolean;
  47420. RADIANCEOCCLUSION: boolean;
  47421. HORIZONOCCLUSION: boolean;
  47422. INSTANCES: boolean;
  47423. NUM_BONE_INFLUENCERS: number;
  47424. BonesPerMesh: number;
  47425. BONETEXTURE: boolean;
  47426. NONUNIFORMSCALING: boolean;
  47427. MORPHTARGETS: boolean;
  47428. MORPHTARGETS_NORMAL: boolean;
  47429. MORPHTARGETS_TANGENT: boolean;
  47430. MORPHTARGETS_UV: boolean;
  47431. NUM_MORPH_INFLUENCERS: number;
  47432. IMAGEPROCESSING: boolean;
  47433. VIGNETTE: boolean;
  47434. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47435. VIGNETTEBLENDMODEOPAQUE: boolean;
  47436. TONEMAPPING: boolean;
  47437. TONEMAPPING_ACES: boolean;
  47438. CONTRAST: boolean;
  47439. COLORCURVES: boolean;
  47440. COLORGRADING: boolean;
  47441. COLORGRADING3D: boolean;
  47442. SAMPLER3DGREENDEPTH: boolean;
  47443. SAMPLER3DBGRMAP: boolean;
  47444. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47445. EXPOSURE: boolean;
  47446. MULTIVIEW: boolean;
  47447. USEPHYSICALLIGHTFALLOFF: boolean;
  47448. USEGLTFLIGHTFALLOFF: boolean;
  47449. TWOSIDEDLIGHTING: boolean;
  47450. SHADOWFLOAT: boolean;
  47451. CLIPPLANE: boolean;
  47452. CLIPPLANE2: boolean;
  47453. CLIPPLANE3: boolean;
  47454. CLIPPLANE4: boolean;
  47455. POINTSIZE: boolean;
  47456. FOG: boolean;
  47457. LOGARITHMICDEPTH: boolean;
  47458. FORCENORMALFORWARD: boolean;
  47459. SPECULARAA: boolean;
  47460. CLEARCOAT: boolean;
  47461. CLEARCOAT_DEFAULTIOR: boolean;
  47462. CLEARCOAT_TEXTURE: boolean;
  47463. CLEARCOAT_TEXTUREDIRECTUV: number;
  47464. CLEARCOAT_BUMP: boolean;
  47465. CLEARCOAT_BUMPDIRECTUV: number;
  47466. CLEARCOAT_TINT: boolean;
  47467. CLEARCOAT_TINT_TEXTURE: boolean;
  47468. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47469. ANISOTROPIC: boolean;
  47470. ANISOTROPIC_TEXTURE: boolean;
  47471. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47472. BRDF_V_HEIGHT_CORRELATED: boolean;
  47473. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47474. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47475. SHEEN: boolean;
  47476. SHEEN_TEXTURE: boolean;
  47477. SHEEN_TEXTUREDIRECTUV: number;
  47478. SHEEN_LINKWITHALBEDO: boolean;
  47479. SUBSURFACE: boolean;
  47480. SS_REFRACTION: boolean;
  47481. SS_TRANSLUCENCY: boolean;
  47482. SS_SCATERRING: boolean;
  47483. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47484. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47485. SS_REFRACTIONMAP_3D: boolean;
  47486. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47487. SS_LODINREFRACTIONALPHA: boolean;
  47488. SS_GAMMAREFRACTION: boolean;
  47489. SS_RGBDREFRACTION: boolean;
  47490. SS_LINEARSPECULARREFRACTION: boolean;
  47491. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47492. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47493. UNLIT: boolean;
  47494. DEBUGMODE: number;
  47495. /**
  47496. * Initializes the PBR Material defines.
  47497. */
  47498. constructor();
  47499. /**
  47500. * Resets the PBR Material defines.
  47501. */
  47502. reset(): void;
  47503. }
  47504. /**
  47505. * The Physically based material base class of BJS.
  47506. *
  47507. * This offers the main features of a standard PBR material.
  47508. * For more information, please refer to the documentation :
  47509. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47510. */
  47511. export abstract class PBRBaseMaterial extends PushMaterial {
  47512. /**
  47513. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47514. */
  47515. static readonly PBRMATERIAL_OPAQUE: number;
  47516. /**
  47517. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47518. */
  47519. static readonly PBRMATERIAL_ALPHATEST: number;
  47520. /**
  47521. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47522. */
  47523. static readonly PBRMATERIAL_ALPHABLEND: number;
  47524. /**
  47525. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47526. * They are also discarded below the alpha cutoff threshold to improve performances.
  47527. */
  47528. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47529. /**
  47530. * Defines the default value of how much AO map is occluding the analytical lights
  47531. * (point spot...).
  47532. */
  47533. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47534. /**
  47535. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47536. */
  47537. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47538. /**
  47539. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47540. * to enhance interoperability with other engines.
  47541. */
  47542. static readonly LIGHTFALLOFF_GLTF: number;
  47543. /**
  47544. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47545. * to enhance interoperability with other materials.
  47546. */
  47547. static readonly LIGHTFALLOFF_STANDARD: number;
  47548. /**
  47549. * Intensity of the direct lights e.g. the four lights available in your scene.
  47550. * This impacts both the direct diffuse and specular highlights.
  47551. */
  47552. protected _directIntensity: number;
  47553. /**
  47554. * Intensity of the emissive part of the material.
  47555. * This helps controlling the emissive effect without modifying the emissive color.
  47556. */
  47557. protected _emissiveIntensity: number;
  47558. /**
  47559. * Intensity of the environment e.g. how much the environment will light the object
  47560. * either through harmonics for rough material or through the refelction for shiny ones.
  47561. */
  47562. protected _environmentIntensity: number;
  47563. /**
  47564. * This is a special control allowing the reduction of the specular highlights coming from the
  47565. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47566. */
  47567. protected _specularIntensity: number;
  47568. /**
  47569. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47570. */
  47571. private _lightingInfos;
  47572. /**
  47573. * Debug Control allowing disabling the bump map on this material.
  47574. */
  47575. protected _disableBumpMap: boolean;
  47576. /**
  47577. * AKA Diffuse Texture in standard nomenclature.
  47578. */
  47579. protected _albedoTexture: Nullable<BaseTexture>;
  47580. /**
  47581. * AKA Occlusion Texture in other nomenclature.
  47582. */
  47583. protected _ambientTexture: Nullable<BaseTexture>;
  47584. /**
  47585. * AKA Occlusion Texture Intensity in other nomenclature.
  47586. */
  47587. protected _ambientTextureStrength: number;
  47588. /**
  47589. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47590. * 1 means it completely occludes it
  47591. * 0 mean it has no impact
  47592. */
  47593. protected _ambientTextureImpactOnAnalyticalLights: number;
  47594. /**
  47595. * Stores the alpha values in a texture.
  47596. */
  47597. protected _opacityTexture: Nullable<BaseTexture>;
  47598. /**
  47599. * Stores the reflection values in a texture.
  47600. */
  47601. protected _reflectionTexture: Nullable<BaseTexture>;
  47602. /**
  47603. * Stores the emissive values in a texture.
  47604. */
  47605. protected _emissiveTexture: Nullable<BaseTexture>;
  47606. /**
  47607. * AKA Specular texture in other nomenclature.
  47608. */
  47609. protected _reflectivityTexture: Nullable<BaseTexture>;
  47610. /**
  47611. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47612. */
  47613. protected _metallicTexture: Nullable<BaseTexture>;
  47614. /**
  47615. * Specifies the metallic scalar of the metallic/roughness workflow.
  47616. * Can also be used to scale the metalness values of the metallic texture.
  47617. */
  47618. protected _metallic: Nullable<number>;
  47619. /**
  47620. * Specifies the roughness scalar of the metallic/roughness workflow.
  47621. * Can also be used to scale the roughness values of the metallic texture.
  47622. */
  47623. protected _roughness: Nullable<number>;
  47624. /**
  47625. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47626. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47627. */
  47628. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47629. /**
  47630. * Stores surface normal data used to displace a mesh in a texture.
  47631. */
  47632. protected _bumpTexture: Nullable<BaseTexture>;
  47633. /**
  47634. * Stores the pre-calculated light information of a mesh in a texture.
  47635. */
  47636. protected _lightmapTexture: Nullable<BaseTexture>;
  47637. /**
  47638. * The color of a material in ambient lighting.
  47639. */
  47640. protected _ambientColor: Color3;
  47641. /**
  47642. * AKA Diffuse Color in other nomenclature.
  47643. */
  47644. protected _albedoColor: Color3;
  47645. /**
  47646. * AKA Specular Color in other nomenclature.
  47647. */
  47648. protected _reflectivityColor: Color3;
  47649. /**
  47650. * The color applied when light is reflected from a material.
  47651. */
  47652. protected _reflectionColor: Color3;
  47653. /**
  47654. * The color applied when light is emitted from a material.
  47655. */
  47656. protected _emissiveColor: Color3;
  47657. /**
  47658. * AKA Glossiness in other nomenclature.
  47659. */
  47660. protected _microSurface: number;
  47661. /**
  47662. * Specifies that the material will use the light map as a show map.
  47663. */
  47664. protected _useLightmapAsShadowmap: boolean;
  47665. /**
  47666. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47667. * makes the reflect vector face the model (under horizon).
  47668. */
  47669. protected _useHorizonOcclusion: boolean;
  47670. /**
  47671. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47672. * too much the area relying on ambient texture to define their ambient occlusion.
  47673. */
  47674. protected _useRadianceOcclusion: boolean;
  47675. /**
  47676. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47677. */
  47678. protected _useAlphaFromAlbedoTexture: boolean;
  47679. /**
  47680. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47681. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47682. */
  47683. protected _useSpecularOverAlpha: boolean;
  47684. /**
  47685. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47686. */
  47687. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47688. /**
  47689. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47690. */
  47691. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47692. /**
  47693. * Specifies if the metallic texture contains the roughness information in its green channel.
  47694. */
  47695. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47696. /**
  47697. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47698. */
  47699. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47700. /**
  47701. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47702. */
  47703. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47704. /**
  47705. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47706. */
  47707. protected _useAmbientInGrayScale: boolean;
  47708. /**
  47709. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47710. * The material will try to infer what glossiness each pixel should be.
  47711. */
  47712. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47713. /**
  47714. * Defines the falloff type used in this material.
  47715. * It by default is Physical.
  47716. */
  47717. protected _lightFalloff: number;
  47718. /**
  47719. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47720. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47721. */
  47722. protected _useRadianceOverAlpha: boolean;
  47723. /**
  47724. * Allows using an object space normal map (instead of tangent space).
  47725. */
  47726. protected _useObjectSpaceNormalMap: boolean;
  47727. /**
  47728. * Allows using the bump map in parallax mode.
  47729. */
  47730. protected _useParallax: boolean;
  47731. /**
  47732. * Allows using the bump map in parallax occlusion mode.
  47733. */
  47734. protected _useParallaxOcclusion: boolean;
  47735. /**
  47736. * Controls the scale bias of the parallax mode.
  47737. */
  47738. protected _parallaxScaleBias: number;
  47739. /**
  47740. * If sets to true, disables all the lights affecting the material.
  47741. */
  47742. protected _disableLighting: boolean;
  47743. /**
  47744. * Number of Simultaneous lights allowed on the material.
  47745. */
  47746. protected _maxSimultaneousLights: number;
  47747. /**
  47748. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47749. */
  47750. protected _invertNormalMapX: boolean;
  47751. /**
  47752. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47753. */
  47754. protected _invertNormalMapY: boolean;
  47755. /**
  47756. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47757. */
  47758. protected _twoSidedLighting: boolean;
  47759. /**
  47760. * Defines the alpha limits in alpha test mode.
  47761. */
  47762. protected _alphaCutOff: number;
  47763. /**
  47764. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47765. */
  47766. protected _forceAlphaTest: boolean;
  47767. /**
  47768. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47769. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47770. */
  47771. protected _useAlphaFresnel: boolean;
  47772. /**
  47773. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47774. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47775. */
  47776. protected _useLinearAlphaFresnel: boolean;
  47777. /**
  47778. * The transparency mode of the material.
  47779. */
  47780. protected _transparencyMode: Nullable<number>;
  47781. /**
  47782. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47783. * from cos thetav and roughness:
  47784. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47785. */
  47786. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47787. /**
  47788. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47789. */
  47790. protected _forceIrradianceInFragment: boolean;
  47791. /**
  47792. * Force normal to face away from face.
  47793. */
  47794. protected _forceNormalForward: boolean;
  47795. /**
  47796. * Enables specular anti aliasing in the PBR shader.
  47797. * It will both interacts on the Geometry for analytical and IBL lighting.
  47798. * It also prefilter the roughness map based on the bump values.
  47799. */
  47800. protected _enableSpecularAntiAliasing: boolean;
  47801. /**
  47802. * Default configuration related to image processing available in the PBR Material.
  47803. */
  47804. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47805. /**
  47806. * Keep track of the image processing observer to allow dispose and replace.
  47807. */
  47808. private _imageProcessingObserver;
  47809. /**
  47810. * Attaches a new image processing configuration to the PBR Material.
  47811. * @param configuration
  47812. */
  47813. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47814. /**
  47815. * Stores the available render targets.
  47816. */
  47817. private _renderTargets;
  47818. /**
  47819. * Sets the global ambient color for the material used in lighting calculations.
  47820. */
  47821. private _globalAmbientColor;
  47822. /**
  47823. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47824. */
  47825. private _useLogarithmicDepth;
  47826. /**
  47827. * If set to true, no lighting calculations will be applied.
  47828. */
  47829. private _unlit;
  47830. private _debugMode;
  47831. /**
  47832. * @hidden
  47833. * This is reserved for the inspector.
  47834. * Defines the material debug mode.
  47835. * It helps seeing only some components of the material while troubleshooting.
  47836. */
  47837. debugMode: number;
  47838. /**
  47839. * @hidden
  47840. * This is reserved for the inspector.
  47841. * Specify from where on screen the debug mode should start.
  47842. * The value goes from -1 (full screen) to 1 (not visible)
  47843. * It helps with side by side comparison against the final render
  47844. * This defaults to -1
  47845. */
  47846. private debugLimit;
  47847. /**
  47848. * @hidden
  47849. * This is reserved for the inspector.
  47850. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47851. * You can use the factor to better multiply the final value.
  47852. */
  47853. private debugFactor;
  47854. /**
  47855. * Defines the clear coat layer parameters for the material.
  47856. */
  47857. readonly clearCoat: PBRClearCoatConfiguration;
  47858. /**
  47859. * Defines the anisotropic parameters for the material.
  47860. */
  47861. readonly anisotropy: PBRAnisotropicConfiguration;
  47862. /**
  47863. * Defines the BRDF parameters for the material.
  47864. */
  47865. readonly brdf: PBRBRDFConfiguration;
  47866. /**
  47867. * Defines the Sheen parameters for the material.
  47868. */
  47869. readonly sheen: PBRSheenConfiguration;
  47870. /**
  47871. * Defines the SubSurface parameters for the material.
  47872. */
  47873. readonly subSurface: PBRSubSurfaceConfiguration;
  47874. /**
  47875. * Custom callback helping to override the default shader used in the material.
  47876. */
  47877. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47878. protected _rebuildInParallel: boolean;
  47879. /**
  47880. * Instantiates a new PBRMaterial instance.
  47881. *
  47882. * @param name The material name
  47883. * @param scene The scene the material will be use in.
  47884. */
  47885. constructor(name: string, scene: Scene);
  47886. /**
  47887. * Gets a boolean indicating that current material needs to register RTT
  47888. */
  47889. readonly hasRenderTargetTextures: boolean;
  47890. /**
  47891. * Gets the name of the material class.
  47892. */
  47893. getClassName(): string;
  47894. /**
  47895. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47896. */
  47897. /**
  47898. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47899. */
  47900. useLogarithmicDepth: boolean;
  47901. /**
  47902. * Gets the current transparency mode.
  47903. */
  47904. /**
  47905. * Sets the transparency mode of the material.
  47906. *
  47907. * | Value | Type | Description |
  47908. * | ----- | ----------------------------------- | ----------- |
  47909. * | 0 | OPAQUE | |
  47910. * | 1 | ALPHATEST | |
  47911. * | 2 | ALPHABLEND | |
  47912. * | 3 | ALPHATESTANDBLEND | |
  47913. *
  47914. */
  47915. transparencyMode: Nullable<number>;
  47916. /**
  47917. * Returns true if alpha blending should be disabled.
  47918. */
  47919. private readonly _disableAlphaBlending;
  47920. /**
  47921. * Specifies whether or not this material should be rendered in alpha blend mode.
  47922. */
  47923. needAlphaBlending(): boolean;
  47924. /**
  47925. * Specifies if the mesh will require alpha blending.
  47926. * @param mesh - BJS mesh.
  47927. */
  47928. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47929. /**
  47930. * Specifies whether or not this material should be rendered in alpha test mode.
  47931. */
  47932. needAlphaTesting(): boolean;
  47933. /**
  47934. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47935. */
  47936. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47937. /**
  47938. * Gets the texture used for the alpha test.
  47939. */
  47940. getAlphaTestTexture(): Nullable<BaseTexture>;
  47941. /**
  47942. * Specifies that the submesh is ready to be used.
  47943. * @param mesh - BJS mesh.
  47944. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47945. * @param useInstances - Specifies that instances should be used.
  47946. * @returns - boolean indicating that the submesh is ready or not.
  47947. */
  47948. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47949. /**
  47950. * Specifies if the material uses metallic roughness workflow.
  47951. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47952. */
  47953. isMetallicWorkflow(): boolean;
  47954. private _prepareEffect;
  47955. private _prepareDefines;
  47956. /**
  47957. * Force shader compilation
  47958. */
  47959. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47960. clipPlane: boolean;
  47961. }>): void;
  47962. /**
  47963. * Initializes the uniform buffer layout for the shader.
  47964. */
  47965. buildUniformLayout(): void;
  47966. /**
  47967. * Unbinds the material from the mesh
  47968. */
  47969. unbind(): void;
  47970. /**
  47971. * Binds the submesh data.
  47972. * @param world - The world matrix.
  47973. * @param mesh - The BJS mesh.
  47974. * @param subMesh - A submesh of the BJS mesh.
  47975. */
  47976. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47977. /**
  47978. * Returns the animatable textures.
  47979. * @returns - Array of animatable textures.
  47980. */
  47981. getAnimatables(): IAnimatable[];
  47982. /**
  47983. * Returns the texture used for reflections.
  47984. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47985. */
  47986. private _getReflectionTexture;
  47987. /**
  47988. * Returns an array of the actively used textures.
  47989. * @returns - Array of BaseTextures
  47990. */
  47991. getActiveTextures(): BaseTexture[];
  47992. /**
  47993. * Checks to see if a texture is used in the material.
  47994. * @param texture - Base texture to use.
  47995. * @returns - Boolean specifying if a texture is used in the material.
  47996. */
  47997. hasTexture(texture: BaseTexture): boolean;
  47998. /**
  47999. * Disposes the resources of the material.
  48000. * @param forceDisposeEffect - Forces the disposal of effects.
  48001. * @param forceDisposeTextures - Forces the disposal of all textures.
  48002. */
  48003. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48004. }
  48005. }
  48006. declare module BABYLON {
  48007. /**
  48008. * The Physically based material of BJS.
  48009. *
  48010. * This offers the main features of a standard PBR material.
  48011. * For more information, please refer to the documentation :
  48012. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48013. */
  48014. export class PBRMaterial extends PBRBaseMaterial {
  48015. /**
  48016. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48017. */
  48018. static readonly PBRMATERIAL_OPAQUE: number;
  48019. /**
  48020. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48021. */
  48022. static readonly PBRMATERIAL_ALPHATEST: number;
  48023. /**
  48024. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48025. */
  48026. static readonly PBRMATERIAL_ALPHABLEND: number;
  48027. /**
  48028. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48029. * They are also discarded below the alpha cutoff threshold to improve performances.
  48030. */
  48031. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48032. /**
  48033. * Defines the default value of how much AO map is occluding the analytical lights
  48034. * (point spot...).
  48035. */
  48036. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48037. /**
  48038. * Intensity of the direct lights e.g. the four lights available in your scene.
  48039. * This impacts both the direct diffuse and specular highlights.
  48040. */
  48041. directIntensity: number;
  48042. /**
  48043. * Intensity of the emissive part of the material.
  48044. * This helps controlling the emissive effect without modifying the emissive color.
  48045. */
  48046. emissiveIntensity: number;
  48047. /**
  48048. * Intensity of the environment e.g. how much the environment will light the object
  48049. * either through harmonics for rough material or through the refelction for shiny ones.
  48050. */
  48051. environmentIntensity: number;
  48052. /**
  48053. * This is a special control allowing the reduction of the specular highlights coming from the
  48054. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48055. */
  48056. specularIntensity: number;
  48057. /**
  48058. * Debug Control allowing disabling the bump map on this material.
  48059. */
  48060. disableBumpMap: boolean;
  48061. /**
  48062. * AKA Diffuse Texture in standard nomenclature.
  48063. */
  48064. albedoTexture: BaseTexture;
  48065. /**
  48066. * AKA Occlusion Texture in other nomenclature.
  48067. */
  48068. ambientTexture: BaseTexture;
  48069. /**
  48070. * AKA Occlusion Texture Intensity in other nomenclature.
  48071. */
  48072. ambientTextureStrength: number;
  48073. /**
  48074. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48075. * 1 means it completely occludes it
  48076. * 0 mean it has no impact
  48077. */
  48078. ambientTextureImpactOnAnalyticalLights: number;
  48079. /**
  48080. * Stores the alpha values in a texture.
  48081. */
  48082. opacityTexture: BaseTexture;
  48083. /**
  48084. * Stores the reflection values in a texture.
  48085. */
  48086. reflectionTexture: Nullable<BaseTexture>;
  48087. /**
  48088. * Stores the emissive values in a texture.
  48089. */
  48090. emissiveTexture: BaseTexture;
  48091. /**
  48092. * AKA Specular texture in other nomenclature.
  48093. */
  48094. reflectivityTexture: BaseTexture;
  48095. /**
  48096. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48097. */
  48098. metallicTexture: BaseTexture;
  48099. /**
  48100. * Specifies the metallic scalar of the metallic/roughness workflow.
  48101. * Can also be used to scale the metalness values of the metallic texture.
  48102. */
  48103. metallic: Nullable<number>;
  48104. /**
  48105. * Specifies the roughness scalar of the metallic/roughness workflow.
  48106. * Can also be used to scale the roughness values of the metallic texture.
  48107. */
  48108. roughness: Nullable<number>;
  48109. /**
  48110. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48111. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48112. */
  48113. microSurfaceTexture: BaseTexture;
  48114. /**
  48115. * Stores surface normal data used to displace a mesh in a texture.
  48116. */
  48117. bumpTexture: BaseTexture;
  48118. /**
  48119. * Stores the pre-calculated light information of a mesh in a texture.
  48120. */
  48121. lightmapTexture: BaseTexture;
  48122. /**
  48123. * Stores the refracted light information in a texture.
  48124. */
  48125. refractionTexture: Nullable<BaseTexture>;
  48126. /**
  48127. * The color of a material in ambient lighting.
  48128. */
  48129. ambientColor: Color3;
  48130. /**
  48131. * AKA Diffuse Color in other nomenclature.
  48132. */
  48133. albedoColor: Color3;
  48134. /**
  48135. * AKA Specular Color in other nomenclature.
  48136. */
  48137. reflectivityColor: Color3;
  48138. /**
  48139. * The color reflected from the material.
  48140. */
  48141. reflectionColor: Color3;
  48142. /**
  48143. * The color emitted from the material.
  48144. */
  48145. emissiveColor: Color3;
  48146. /**
  48147. * AKA Glossiness in other nomenclature.
  48148. */
  48149. microSurface: number;
  48150. /**
  48151. * source material index of refraction (IOR)' / 'destination material IOR.
  48152. */
  48153. indexOfRefraction: number;
  48154. /**
  48155. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48156. */
  48157. invertRefractionY: boolean;
  48158. /**
  48159. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48160. * Materials half opaque for instance using refraction could benefit from this control.
  48161. */
  48162. linkRefractionWithTransparency: boolean;
  48163. /**
  48164. * If true, the light map contains occlusion information instead of lighting info.
  48165. */
  48166. useLightmapAsShadowmap: boolean;
  48167. /**
  48168. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48169. */
  48170. useAlphaFromAlbedoTexture: boolean;
  48171. /**
  48172. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48173. */
  48174. forceAlphaTest: boolean;
  48175. /**
  48176. * Defines the alpha limits in alpha test mode.
  48177. */
  48178. alphaCutOff: number;
  48179. /**
  48180. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48181. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48182. */
  48183. useSpecularOverAlpha: boolean;
  48184. /**
  48185. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48186. */
  48187. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48188. /**
  48189. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48190. */
  48191. useRoughnessFromMetallicTextureAlpha: boolean;
  48192. /**
  48193. * Specifies if the metallic texture contains the roughness information in its green channel.
  48194. */
  48195. useRoughnessFromMetallicTextureGreen: boolean;
  48196. /**
  48197. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48198. */
  48199. useMetallnessFromMetallicTextureBlue: boolean;
  48200. /**
  48201. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48202. */
  48203. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48204. /**
  48205. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48206. */
  48207. useAmbientInGrayScale: boolean;
  48208. /**
  48209. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48210. * The material will try to infer what glossiness each pixel should be.
  48211. */
  48212. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48213. /**
  48214. * BJS is using an harcoded light falloff based on a manually sets up range.
  48215. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48216. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48217. */
  48218. /**
  48219. * BJS is using an harcoded light falloff based on a manually sets up range.
  48220. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48221. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48222. */
  48223. usePhysicalLightFalloff: boolean;
  48224. /**
  48225. * In order to support the falloff compatibility with gltf, a special mode has been added
  48226. * to reproduce the gltf light falloff.
  48227. */
  48228. /**
  48229. * In order to support the falloff compatibility with gltf, a special mode has been added
  48230. * to reproduce the gltf light falloff.
  48231. */
  48232. useGLTFLightFalloff: boolean;
  48233. /**
  48234. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48235. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48236. */
  48237. useRadianceOverAlpha: boolean;
  48238. /**
  48239. * Allows using an object space normal map (instead of tangent space).
  48240. */
  48241. useObjectSpaceNormalMap: boolean;
  48242. /**
  48243. * Allows using the bump map in parallax mode.
  48244. */
  48245. useParallax: boolean;
  48246. /**
  48247. * Allows using the bump map in parallax occlusion mode.
  48248. */
  48249. useParallaxOcclusion: boolean;
  48250. /**
  48251. * Controls the scale bias of the parallax mode.
  48252. */
  48253. parallaxScaleBias: number;
  48254. /**
  48255. * If sets to true, disables all the lights affecting the material.
  48256. */
  48257. disableLighting: boolean;
  48258. /**
  48259. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48260. */
  48261. forceIrradianceInFragment: boolean;
  48262. /**
  48263. * Number of Simultaneous lights allowed on the material.
  48264. */
  48265. maxSimultaneousLights: number;
  48266. /**
  48267. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48268. */
  48269. invertNormalMapX: boolean;
  48270. /**
  48271. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48272. */
  48273. invertNormalMapY: boolean;
  48274. /**
  48275. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48276. */
  48277. twoSidedLighting: boolean;
  48278. /**
  48279. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48280. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48281. */
  48282. useAlphaFresnel: boolean;
  48283. /**
  48284. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48285. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48286. */
  48287. useLinearAlphaFresnel: boolean;
  48288. /**
  48289. * Let user defines the brdf lookup texture used for IBL.
  48290. * A default 8bit version is embedded but you could point at :
  48291. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48292. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48293. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48294. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48295. */
  48296. environmentBRDFTexture: Nullable<BaseTexture>;
  48297. /**
  48298. * Force normal to face away from face.
  48299. */
  48300. forceNormalForward: boolean;
  48301. /**
  48302. * Enables specular anti aliasing in the PBR shader.
  48303. * It will both interacts on the Geometry for analytical and IBL lighting.
  48304. * It also prefilter the roughness map based on the bump values.
  48305. */
  48306. enableSpecularAntiAliasing: boolean;
  48307. /**
  48308. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48309. * makes the reflect vector face the model (under horizon).
  48310. */
  48311. useHorizonOcclusion: boolean;
  48312. /**
  48313. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48314. * too much the area relying on ambient texture to define their ambient occlusion.
  48315. */
  48316. useRadianceOcclusion: boolean;
  48317. /**
  48318. * If set to true, no lighting calculations will be applied.
  48319. */
  48320. unlit: boolean;
  48321. /**
  48322. * Gets the image processing configuration used either in this material.
  48323. */
  48324. /**
  48325. * Sets the Default image processing configuration used either in the this material.
  48326. *
  48327. * If sets to null, the scene one is in use.
  48328. */
  48329. imageProcessingConfiguration: ImageProcessingConfiguration;
  48330. /**
  48331. * Gets wether the color curves effect is enabled.
  48332. */
  48333. /**
  48334. * Sets wether the color curves effect is enabled.
  48335. */
  48336. cameraColorCurvesEnabled: boolean;
  48337. /**
  48338. * Gets wether the color grading effect is enabled.
  48339. */
  48340. /**
  48341. * Gets wether the color grading effect is enabled.
  48342. */
  48343. cameraColorGradingEnabled: boolean;
  48344. /**
  48345. * Gets wether tonemapping is enabled or not.
  48346. */
  48347. /**
  48348. * Sets wether tonemapping is enabled or not
  48349. */
  48350. cameraToneMappingEnabled: boolean;
  48351. /**
  48352. * The camera exposure used on this material.
  48353. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48354. * This corresponds to a photographic exposure.
  48355. */
  48356. /**
  48357. * The camera exposure used on this material.
  48358. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48359. * This corresponds to a photographic exposure.
  48360. */
  48361. cameraExposure: number;
  48362. /**
  48363. * Gets The camera contrast used on this material.
  48364. */
  48365. /**
  48366. * Sets The camera contrast used on this material.
  48367. */
  48368. cameraContrast: number;
  48369. /**
  48370. * Gets the Color Grading 2D Lookup Texture.
  48371. */
  48372. /**
  48373. * Sets the Color Grading 2D Lookup Texture.
  48374. */
  48375. cameraColorGradingTexture: Nullable<BaseTexture>;
  48376. /**
  48377. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48378. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48379. * 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;
  48380. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48381. */
  48382. /**
  48383. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48384. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48385. * 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;
  48386. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48387. */
  48388. cameraColorCurves: Nullable<ColorCurves>;
  48389. /**
  48390. * Instantiates a new PBRMaterial instance.
  48391. *
  48392. * @param name The material name
  48393. * @param scene The scene the material will be use in.
  48394. */
  48395. constructor(name: string, scene: Scene);
  48396. /**
  48397. * Returns the name of this material class.
  48398. */
  48399. getClassName(): string;
  48400. /**
  48401. * Makes a duplicate of the current material.
  48402. * @param name - name to use for the new material.
  48403. */
  48404. clone(name: string): PBRMaterial;
  48405. /**
  48406. * Serializes this PBR Material.
  48407. * @returns - An object with the serialized material.
  48408. */
  48409. serialize(): any;
  48410. /**
  48411. * Parses a PBR Material from a serialized object.
  48412. * @param source - Serialized object.
  48413. * @param scene - BJS scene instance.
  48414. * @param rootUrl - url for the scene object
  48415. * @returns - PBRMaterial
  48416. */
  48417. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48418. }
  48419. }
  48420. declare module BABYLON {
  48421. /**
  48422. * Direct draw surface info
  48423. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48424. */
  48425. export interface DDSInfo {
  48426. /**
  48427. * Width of the texture
  48428. */
  48429. width: number;
  48430. /**
  48431. * Width of the texture
  48432. */
  48433. height: number;
  48434. /**
  48435. * Number of Mipmaps for the texture
  48436. * @see https://en.wikipedia.org/wiki/Mipmap
  48437. */
  48438. mipmapCount: number;
  48439. /**
  48440. * If the textures format is a known fourCC format
  48441. * @see https://www.fourcc.org/
  48442. */
  48443. isFourCC: boolean;
  48444. /**
  48445. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48446. */
  48447. isRGB: boolean;
  48448. /**
  48449. * If the texture is a lumincance format
  48450. */
  48451. isLuminance: boolean;
  48452. /**
  48453. * If this is a cube texture
  48454. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48455. */
  48456. isCube: boolean;
  48457. /**
  48458. * If the texture is a compressed format eg. FOURCC_DXT1
  48459. */
  48460. isCompressed: boolean;
  48461. /**
  48462. * The dxgiFormat of the texture
  48463. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48464. */
  48465. dxgiFormat: number;
  48466. /**
  48467. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48468. */
  48469. textureType: number;
  48470. /**
  48471. * Sphericle polynomial created for the dds texture
  48472. */
  48473. sphericalPolynomial?: SphericalPolynomial;
  48474. }
  48475. /**
  48476. * Class used to provide DDS decompression tools
  48477. */
  48478. export class DDSTools {
  48479. /**
  48480. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48481. */
  48482. static StoreLODInAlphaChannel: boolean;
  48483. /**
  48484. * Gets DDS information from an array buffer
  48485. * @param arrayBuffer defines the array buffer to read data from
  48486. * @returns the DDS information
  48487. */
  48488. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48489. private static _FloatView;
  48490. private static _Int32View;
  48491. private static _ToHalfFloat;
  48492. private static _FromHalfFloat;
  48493. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48494. private static _GetHalfFloatRGBAArrayBuffer;
  48495. private static _GetFloatRGBAArrayBuffer;
  48496. private static _GetFloatAsUIntRGBAArrayBuffer;
  48497. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48498. private static _GetRGBAArrayBuffer;
  48499. private static _ExtractLongWordOrder;
  48500. private static _GetRGBArrayBuffer;
  48501. private static _GetLuminanceArrayBuffer;
  48502. /**
  48503. * Uploads DDS Levels to a Babylon Texture
  48504. * @hidden
  48505. */
  48506. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48507. }
  48508. interface ThinEngine {
  48509. /**
  48510. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48511. * @param rootUrl defines the url where the file to load is located
  48512. * @param scene defines the current scene
  48513. * @param lodScale defines scale to apply to the mip map selection
  48514. * @param lodOffset defines offset to apply to the mip map selection
  48515. * @param onLoad defines an optional callback raised when the texture is loaded
  48516. * @param onError defines an optional callback raised if there is an issue to load the texture
  48517. * @param format defines the format of the data
  48518. * @param forcedExtension defines the extension to use to pick the right loader
  48519. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48520. * @returns the cube texture as an InternalTexture
  48521. */
  48522. 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;
  48523. }
  48524. }
  48525. declare module BABYLON {
  48526. /**
  48527. * Implementation of the DDS Texture Loader.
  48528. * @hidden
  48529. */
  48530. export class _DDSTextureLoader implements IInternalTextureLoader {
  48531. /**
  48532. * Defines wether the loader supports cascade loading the different faces.
  48533. */
  48534. readonly supportCascades: boolean;
  48535. /**
  48536. * This returns if the loader support the current file information.
  48537. * @param extension defines the file extension of the file being loaded
  48538. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48539. * @param fallback defines the fallback internal texture if any
  48540. * @param isBase64 defines whether the texture is encoded as a base64
  48541. * @param isBuffer defines whether the texture data are stored as a buffer
  48542. * @returns true if the loader can load the specified file
  48543. */
  48544. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48545. /**
  48546. * Transform the url before loading if required.
  48547. * @param rootUrl the url of the texture
  48548. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48549. * @returns the transformed texture
  48550. */
  48551. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48552. /**
  48553. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48554. * @param rootUrl the url of the texture
  48555. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48556. * @returns the fallback texture
  48557. */
  48558. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48559. /**
  48560. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48561. * @param data contains the texture data
  48562. * @param texture defines the BabylonJS internal texture
  48563. * @param createPolynomials will be true if polynomials have been requested
  48564. * @param onLoad defines the callback to trigger once the texture is ready
  48565. * @param onError defines the callback to trigger in case of error
  48566. */
  48567. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48568. /**
  48569. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48570. * @param data contains the texture data
  48571. * @param texture defines the BabylonJS internal texture
  48572. * @param callback defines the method to call once ready to upload
  48573. */
  48574. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48575. }
  48576. }
  48577. declare module BABYLON {
  48578. /**
  48579. * Implementation of the ENV Texture Loader.
  48580. * @hidden
  48581. */
  48582. export class _ENVTextureLoader implements IInternalTextureLoader {
  48583. /**
  48584. * Defines wether the loader supports cascade loading the different faces.
  48585. */
  48586. readonly supportCascades: boolean;
  48587. /**
  48588. * This returns if the loader support the current file information.
  48589. * @param extension defines the file extension of the file being loaded
  48590. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48591. * @param fallback defines the fallback internal texture if any
  48592. * @param isBase64 defines whether the texture is encoded as a base64
  48593. * @param isBuffer defines whether the texture data are stored as a buffer
  48594. * @returns true if the loader can load the specified file
  48595. */
  48596. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48597. /**
  48598. * Transform the url before loading if required.
  48599. * @param rootUrl the url of the texture
  48600. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48601. * @returns the transformed texture
  48602. */
  48603. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48604. /**
  48605. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48606. * @param rootUrl the url of the texture
  48607. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48608. * @returns the fallback texture
  48609. */
  48610. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48611. /**
  48612. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48613. * @param data contains the texture data
  48614. * @param texture defines the BabylonJS internal texture
  48615. * @param createPolynomials will be true if polynomials have been requested
  48616. * @param onLoad defines the callback to trigger once the texture is ready
  48617. * @param onError defines the callback to trigger in case of error
  48618. */
  48619. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48620. /**
  48621. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48622. * @param data contains the texture data
  48623. * @param texture defines the BabylonJS internal texture
  48624. * @param callback defines the method to call once ready to upload
  48625. */
  48626. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48627. }
  48628. }
  48629. declare module BABYLON {
  48630. /**
  48631. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48632. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48633. */
  48634. export class KhronosTextureContainer {
  48635. /** contents of the KTX container file */
  48636. arrayBuffer: any;
  48637. private static HEADER_LEN;
  48638. private static COMPRESSED_2D;
  48639. private static COMPRESSED_3D;
  48640. private static TEX_2D;
  48641. private static TEX_3D;
  48642. /**
  48643. * Gets the openGL type
  48644. */
  48645. glType: number;
  48646. /**
  48647. * Gets the openGL type size
  48648. */
  48649. glTypeSize: number;
  48650. /**
  48651. * Gets the openGL format
  48652. */
  48653. glFormat: number;
  48654. /**
  48655. * Gets the openGL internal format
  48656. */
  48657. glInternalFormat: number;
  48658. /**
  48659. * Gets the base internal format
  48660. */
  48661. glBaseInternalFormat: number;
  48662. /**
  48663. * Gets image width in pixel
  48664. */
  48665. pixelWidth: number;
  48666. /**
  48667. * Gets image height in pixel
  48668. */
  48669. pixelHeight: number;
  48670. /**
  48671. * Gets image depth in pixels
  48672. */
  48673. pixelDepth: number;
  48674. /**
  48675. * Gets the number of array elements
  48676. */
  48677. numberOfArrayElements: number;
  48678. /**
  48679. * Gets the number of faces
  48680. */
  48681. numberOfFaces: number;
  48682. /**
  48683. * Gets the number of mipmap levels
  48684. */
  48685. numberOfMipmapLevels: number;
  48686. /**
  48687. * Gets the bytes of key value data
  48688. */
  48689. bytesOfKeyValueData: number;
  48690. /**
  48691. * Gets the load type
  48692. */
  48693. loadType: number;
  48694. /**
  48695. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48696. */
  48697. isInvalid: boolean;
  48698. /**
  48699. * Creates a new KhronosTextureContainer
  48700. * @param arrayBuffer contents of the KTX container file
  48701. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48702. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48703. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48704. */
  48705. constructor(
  48706. /** contents of the KTX container file */
  48707. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48708. /**
  48709. * Uploads KTX content to a Babylon Texture.
  48710. * It is assumed that the texture has already been created & is currently bound
  48711. * @hidden
  48712. */
  48713. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48714. private _upload2DCompressedLevels;
  48715. }
  48716. }
  48717. declare module BABYLON {
  48718. /**
  48719. * Implementation of the KTX Texture Loader.
  48720. * @hidden
  48721. */
  48722. export class _KTXTextureLoader implements IInternalTextureLoader {
  48723. /**
  48724. * Defines wether the loader supports cascade loading the different faces.
  48725. */
  48726. readonly supportCascades: boolean;
  48727. /**
  48728. * This returns if the loader support the current file information.
  48729. * @param extension defines the file extension of the file being loaded
  48730. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48731. * @param fallback defines the fallback internal texture if any
  48732. * @param isBase64 defines whether the texture is encoded as a base64
  48733. * @param isBuffer defines whether the texture data are stored as a buffer
  48734. * @returns true if the loader can load the specified file
  48735. */
  48736. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48737. /**
  48738. * Transform the url before loading if required.
  48739. * @param rootUrl the url of the texture
  48740. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48741. * @returns the transformed texture
  48742. */
  48743. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48744. /**
  48745. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48746. * @param rootUrl the url of the texture
  48747. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48748. * @returns the fallback texture
  48749. */
  48750. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48751. /**
  48752. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48753. * @param data contains the texture data
  48754. * @param texture defines the BabylonJS internal texture
  48755. * @param createPolynomials will be true if polynomials have been requested
  48756. * @param onLoad defines the callback to trigger once the texture is ready
  48757. * @param onError defines the callback to trigger in case of error
  48758. */
  48759. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48760. /**
  48761. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48762. * @param data contains the texture data
  48763. * @param texture defines the BabylonJS internal texture
  48764. * @param callback defines the method to call once ready to upload
  48765. */
  48766. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48767. }
  48768. }
  48769. declare module BABYLON {
  48770. /**
  48771. * Options for the default xr helper
  48772. */
  48773. export class WebXRDefaultExperienceOptions {
  48774. /**
  48775. * Floor meshes that should be used for teleporting
  48776. */
  48777. floorMeshes: Array<AbstractMesh>;
  48778. }
  48779. /**
  48780. * Default experience which provides a similar setup to the previous webVRExperience
  48781. */
  48782. export class WebXRDefaultExperience {
  48783. /**
  48784. * Base experience
  48785. */
  48786. baseExperience: WebXRExperienceHelper;
  48787. /**
  48788. * Input experience extension
  48789. */
  48790. input: WebXRInput;
  48791. /**
  48792. * Loads the controller models
  48793. */
  48794. controllerModelLoader: WebXRControllerModelLoader;
  48795. /**
  48796. * Enables laser pointer and selection
  48797. */
  48798. pointerSelection: WebXRControllerPointerSelection;
  48799. /**
  48800. * Enables teleportation
  48801. */
  48802. teleportation: WebXRControllerTeleportation;
  48803. /**
  48804. * Enables ui for enetering/exiting xr
  48805. */
  48806. enterExitUI: WebXREnterExitUI;
  48807. /**
  48808. * Default output canvas xr should render to
  48809. */
  48810. outputCanvas: WebXRManagedOutputCanvas;
  48811. /**
  48812. * Creates the default xr experience
  48813. * @param scene scene
  48814. * @param options options for basic configuration
  48815. * @returns resulting WebXRDefaultExperience
  48816. */
  48817. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48818. private constructor();
  48819. /**
  48820. * DIsposes of the experience helper
  48821. */
  48822. dispose(): void;
  48823. }
  48824. }
  48825. declare module BABYLON {
  48826. /** @hidden */
  48827. export var _forceSceneHelpersToBundle: boolean;
  48828. interface Scene {
  48829. /**
  48830. * Creates a default light for the scene.
  48831. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48832. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48833. */
  48834. createDefaultLight(replace?: boolean): void;
  48835. /**
  48836. * Creates a default camera for the scene.
  48837. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48838. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48839. * @param replace has default false, when true replaces the active camera in the scene
  48840. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48841. */
  48842. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48843. /**
  48844. * Creates a default camera and a default light.
  48845. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48846. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48847. * @param replace has the default false, when true replaces the active camera/light in the scene
  48848. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48849. */
  48850. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48851. /**
  48852. * Creates a new sky box
  48853. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48854. * @param environmentTexture defines the texture to use as environment texture
  48855. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48856. * @param scale defines the overall scale of the skybox
  48857. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48858. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48859. * @returns a new mesh holding the sky box
  48860. */
  48861. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48862. /**
  48863. * Creates a new environment
  48864. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48865. * @param options defines the options you can use to configure the environment
  48866. * @returns the new EnvironmentHelper
  48867. */
  48868. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48869. /**
  48870. * Creates a new VREXperienceHelper
  48871. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48872. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48873. * @returns a new VREXperienceHelper
  48874. */
  48875. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48876. /**
  48877. * Creates a new WebXRDefaultExperience
  48878. * @see http://doc.babylonjs.com/how_to/webxr
  48879. * @param options experience options
  48880. * @returns a promise for a new WebXRDefaultExperience
  48881. */
  48882. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48883. }
  48884. }
  48885. declare module BABYLON {
  48886. /**
  48887. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48888. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48889. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48890. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48891. */
  48892. export class VideoDome extends TransformNode {
  48893. /**
  48894. * Define the video source as a Monoscopic panoramic 360 video.
  48895. */
  48896. static readonly MODE_MONOSCOPIC: number;
  48897. /**
  48898. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48899. */
  48900. static readonly MODE_TOPBOTTOM: number;
  48901. /**
  48902. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48903. */
  48904. static readonly MODE_SIDEBYSIDE: number;
  48905. private _halfDome;
  48906. private _useDirectMapping;
  48907. /**
  48908. * The video texture being displayed on the sphere
  48909. */
  48910. protected _videoTexture: VideoTexture;
  48911. /**
  48912. * Gets the video texture being displayed on the sphere
  48913. */
  48914. readonly videoTexture: VideoTexture;
  48915. /**
  48916. * The skybox material
  48917. */
  48918. protected _material: BackgroundMaterial;
  48919. /**
  48920. * The surface used for the skybox
  48921. */
  48922. protected _mesh: Mesh;
  48923. /**
  48924. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48925. */
  48926. private _halfDomeMask;
  48927. /**
  48928. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48929. * Also see the options.resolution property.
  48930. */
  48931. fovMultiplier: number;
  48932. private _videoMode;
  48933. /**
  48934. * Gets or set the current video mode for the video. It can be:
  48935. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48936. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48937. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48938. */
  48939. videoMode: number;
  48940. /**
  48941. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48942. *
  48943. */
  48944. /**
  48945. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48946. */
  48947. halfDome: boolean;
  48948. /**
  48949. * Oberserver used in Stereoscopic VR Mode.
  48950. */
  48951. private _onBeforeCameraRenderObserver;
  48952. /**
  48953. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48954. * @param name Element's name, child elements will append suffixes for their own names.
  48955. * @param urlsOrVideo defines the url(s) or the video element to use
  48956. * @param options An object containing optional or exposed sub element properties
  48957. */
  48958. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48959. resolution?: number;
  48960. clickToPlay?: boolean;
  48961. autoPlay?: boolean;
  48962. loop?: boolean;
  48963. size?: number;
  48964. poster?: string;
  48965. faceForward?: boolean;
  48966. useDirectMapping?: boolean;
  48967. halfDomeMode?: boolean;
  48968. }, scene: Scene);
  48969. private _changeVideoMode;
  48970. /**
  48971. * Releases resources associated with this node.
  48972. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48973. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48974. */
  48975. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48976. }
  48977. }
  48978. declare module BABYLON {
  48979. /**
  48980. * This class can be used to get instrumentation data from a Babylon engine
  48981. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48982. */
  48983. export class EngineInstrumentation implements IDisposable {
  48984. /**
  48985. * Define the instrumented engine.
  48986. */
  48987. engine: Engine;
  48988. private _captureGPUFrameTime;
  48989. private _gpuFrameTimeToken;
  48990. private _gpuFrameTime;
  48991. private _captureShaderCompilationTime;
  48992. private _shaderCompilationTime;
  48993. private _onBeginFrameObserver;
  48994. private _onEndFrameObserver;
  48995. private _onBeforeShaderCompilationObserver;
  48996. private _onAfterShaderCompilationObserver;
  48997. /**
  48998. * Gets the perf counter used for GPU frame time
  48999. */
  49000. readonly gpuFrameTimeCounter: PerfCounter;
  49001. /**
  49002. * Gets the GPU frame time capture status
  49003. */
  49004. /**
  49005. * Enable or disable the GPU frame time capture
  49006. */
  49007. captureGPUFrameTime: boolean;
  49008. /**
  49009. * Gets the perf counter used for shader compilation time
  49010. */
  49011. readonly shaderCompilationTimeCounter: PerfCounter;
  49012. /**
  49013. * Gets the shader compilation time capture status
  49014. */
  49015. /**
  49016. * Enable or disable the shader compilation time capture
  49017. */
  49018. captureShaderCompilationTime: boolean;
  49019. /**
  49020. * Instantiates a new engine instrumentation.
  49021. * This class can be used to get instrumentation data from a Babylon engine
  49022. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49023. * @param engine Defines the engine to instrument
  49024. */
  49025. constructor(
  49026. /**
  49027. * Define the instrumented engine.
  49028. */
  49029. engine: Engine);
  49030. /**
  49031. * Dispose and release associated resources.
  49032. */
  49033. dispose(): void;
  49034. }
  49035. }
  49036. declare module BABYLON {
  49037. /**
  49038. * This class can be used to get instrumentation data from a Babylon engine
  49039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49040. */
  49041. export class SceneInstrumentation implements IDisposable {
  49042. /**
  49043. * Defines the scene to instrument
  49044. */
  49045. scene: Scene;
  49046. private _captureActiveMeshesEvaluationTime;
  49047. private _activeMeshesEvaluationTime;
  49048. private _captureRenderTargetsRenderTime;
  49049. private _renderTargetsRenderTime;
  49050. private _captureFrameTime;
  49051. private _frameTime;
  49052. private _captureRenderTime;
  49053. private _renderTime;
  49054. private _captureInterFrameTime;
  49055. private _interFrameTime;
  49056. private _captureParticlesRenderTime;
  49057. private _particlesRenderTime;
  49058. private _captureSpritesRenderTime;
  49059. private _spritesRenderTime;
  49060. private _capturePhysicsTime;
  49061. private _physicsTime;
  49062. private _captureAnimationsTime;
  49063. private _animationsTime;
  49064. private _captureCameraRenderTime;
  49065. private _cameraRenderTime;
  49066. private _onBeforeActiveMeshesEvaluationObserver;
  49067. private _onAfterActiveMeshesEvaluationObserver;
  49068. private _onBeforeRenderTargetsRenderObserver;
  49069. private _onAfterRenderTargetsRenderObserver;
  49070. private _onAfterRenderObserver;
  49071. private _onBeforeDrawPhaseObserver;
  49072. private _onAfterDrawPhaseObserver;
  49073. private _onBeforeAnimationsObserver;
  49074. private _onBeforeParticlesRenderingObserver;
  49075. private _onAfterParticlesRenderingObserver;
  49076. private _onBeforeSpritesRenderingObserver;
  49077. private _onAfterSpritesRenderingObserver;
  49078. private _onBeforePhysicsObserver;
  49079. private _onAfterPhysicsObserver;
  49080. private _onAfterAnimationsObserver;
  49081. private _onBeforeCameraRenderObserver;
  49082. private _onAfterCameraRenderObserver;
  49083. /**
  49084. * Gets the perf counter used for active meshes evaluation time
  49085. */
  49086. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49087. /**
  49088. * Gets the active meshes evaluation time capture status
  49089. */
  49090. /**
  49091. * Enable or disable the active meshes evaluation time capture
  49092. */
  49093. captureActiveMeshesEvaluationTime: boolean;
  49094. /**
  49095. * Gets the perf counter used for render targets render time
  49096. */
  49097. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49098. /**
  49099. * Gets the render targets render time capture status
  49100. */
  49101. /**
  49102. * Enable or disable the render targets render time capture
  49103. */
  49104. captureRenderTargetsRenderTime: boolean;
  49105. /**
  49106. * Gets the perf counter used for particles render time
  49107. */
  49108. readonly particlesRenderTimeCounter: PerfCounter;
  49109. /**
  49110. * Gets the particles render time capture status
  49111. */
  49112. /**
  49113. * Enable or disable the particles render time capture
  49114. */
  49115. captureParticlesRenderTime: boolean;
  49116. /**
  49117. * Gets the perf counter used for sprites render time
  49118. */
  49119. readonly spritesRenderTimeCounter: PerfCounter;
  49120. /**
  49121. * Gets the sprites render time capture status
  49122. */
  49123. /**
  49124. * Enable or disable the sprites render time capture
  49125. */
  49126. captureSpritesRenderTime: boolean;
  49127. /**
  49128. * Gets the perf counter used for physics time
  49129. */
  49130. readonly physicsTimeCounter: PerfCounter;
  49131. /**
  49132. * Gets the physics time capture status
  49133. */
  49134. /**
  49135. * Enable or disable the physics time capture
  49136. */
  49137. capturePhysicsTime: boolean;
  49138. /**
  49139. * Gets the perf counter used for animations time
  49140. */
  49141. readonly animationsTimeCounter: PerfCounter;
  49142. /**
  49143. * Gets the animations time capture status
  49144. */
  49145. /**
  49146. * Enable or disable the animations time capture
  49147. */
  49148. captureAnimationsTime: boolean;
  49149. /**
  49150. * Gets the perf counter used for frame time capture
  49151. */
  49152. readonly frameTimeCounter: PerfCounter;
  49153. /**
  49154. * Gets the frame time capture status
  49155. */
  49156. /**
  49157. * Enable or disable the frame time capture
  49158. */
  49159. captureFrameTime: boolean;
  49160. /**
  49161. * Gets the perf counter used for inter-frames time capture
  49162. */
  49163. readonly interFrameTimeCounter: PerfCounter;
  49164. /**
  49165. * Gets the inter-frames time capture status
  49166. */
  49167. /**
  49168. * Enable or disable the inter-frames time capture
  49169. */
  49170. captureInterFrameTime: boolean;
  49171. /**
  49172. * Gets the perf counter used for render time capture
  49173. */
  49174. readonly renderTimeCounter: PerfCounter;
  49175. /**
  49176. * Gets the render time capture status
  49177. */
  49178. /**
  49179. * Enable or disable the render time capture
  49180. */
  49181. captureRenderTime: boolean;
  49182. /**
  49183. * Gets the perf counter used for camera render time capture
  49184. */
  49185. readonly cameraRenderTimeCounter: PerfCounter;
  49186. /**
  49187. * Gets the camera render time capture status
  49188. */
  49189. /**
  49190. * Enable or disable the camera render time capture
  49191. */
  49192. captureCameraRenderTime: boolean;
  49193. /**
  49194. * Gets the perf counter used for draw calls
  49195. */
  49196. readonly drawCallsCounter: PerfCounter;
  49197. /**
  49198. * Instantiates a new scene instrumentation.
  49199. * This class can be used to get instrumentation data from a Babylon engine
  49200. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49201. * @param scene Defines the scene to instrument
  49202. */
  49203. constructor(
  49204. /**
  49205. * Defines the scene to instrument
  49206. */
  49207. scene: Scene);
  49208. /**
  49209. * Dispose and release associated resources.
  49210. */
  49211. dispose(): void;
  49212. }
  49213. }
  49214. declare module BABYLON {
  49215. /** @hidden */
  49216. export var glowMapGenerationPixelShader: {
  49217. name: string;
  49218. shader: string;
  49219. };
  49220. }
  49221. declare module BABYLON {
  49222. /** @hidden */
  49223. export var glowMapGenerationVertexShader: {
  49224. name: string;
  49225. shader: string;
  49226. };
  49227. }
  49228. declare module BABYLON {
  49229. /**
  49230. * Effect layer options. This helps customizing the behaviour
  49231. * of the effect layer.
  49232. */
  49233. export interface IEffectLayerOptions {
  49234. /**
  49235. * Multiplication factor apply to the canvas size to compute the render target size
  49236. * used to generated the objects (the smaller the faster).
  49237. */
  49238. mainTextureRatio: number;
  49239. /**
  49240. * Enforces a fixed size texture to ensure effect stability across devices.
  49241. */
  49242. mainTextureFixedSize?: number;
  49243. /**
  49244. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49245. */
  49246. alphaBlendingMode: number;
  49247. /**
  49248. * The camera attached to the layer.
  49249. */
  49250. camera: Nullable<Camera>;
  49251. /**
  49252. * The rendering group to draw the layer in.
  49253. */
  49254. renderingGroupId: number;
  49255. }
  49256. /**
  49257. * The effect layer Helps adding post process effect blended with the main pass.
  49258. *
  49259. * This can be for instance use to generate glow or higlight effects on the scene.
  49260. *
  49261. * The effect layer class can not be used directly and is intented to inherited from to be
  49262. * customized per effects.
  49263. */
  49264. export abstract class EffectLayer {
  49265. private _vertexBuffers;
  49266. private _indexBuffer;
  49267. private _cachedDefines;
  49268. private _effectLayerMapGenerationEffect;
  49269. private _effectLayerOptions;
  49270. private _mergeEffect;
  49271. protected _scene: Scene;
  49272. protected _engine: Engine;
  49273. protected _maxSize: number;
  49274. protected _mainTextureDesiredSize: ISize;
  49275. protected _mainTexture: RenderTargetTexture;
  49276. protected _shouldRender: boolean;
  49277. protected _postProcesses: PostProcess[];
  49278. protected _textures: BaseTexture[];
  49279. protected _emissiveTextureAndColor: {
  49280. texture: Nullable<BaseTexture>;
  49281. color: Color4;
  49282. };
  49283. /**
  49284. * The name of the layer
  49285. */
  49286. name: string;
  49287. /**
  49288. * The clear color of the texture used to generate the glow map.
  49289. */
  49290. neutralColor: Color4;
  49291. /**
  49292. * Specifies wether the highlight layer is enabled or not.
  49293. */
  49294. isEnabled: boolean;
  49295. /**
  49296. * Gets the camera attached to the layer.
  49297. */
  49298. readonly camera: Nullable<Camera>;
  49299. /**
  49300. * Gets the rendering group id the layer should render in.
  49301. */
  49302. renderingGroupId: number;
  49303. /**
  49304. * An event triggered when the effect layer has been disposed.
  49305. */
  49306. onDisposeObservable: Observable<EffectLayer>;
  49307. /**
  49308. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49309. */
  49310. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49311. /**
  49312. * An event triggered when the generated texture is being merged in the scene.
  49313. */
  49314. onBeforeComposeObservable: Observable<EffectLayer>;
  49315. /**
  49316. * An event triggered when the generated texture has been merged in the scene.
  49317. */
  49318. onAfterComposeObservable: Observable<EffectLayer>;
  49319. /**
  49320. * An event triggered when the efffect layer changes its size.
  49321. */
  49322. onSizeChangedObservable: Observable<EffectLayer>;
  49323. /** @hidden */
  49324. static _SceneComponentInitialization: (scene: Scene) => void;
  49325. /**
  49326. * Instantiates a new effect Layer and references it in the scene.
  49327. * @param name The name of the layer
  49328. * @param scene The scene to use the layer in
  49329. */
  49330. constructor(
  49331. /** The Friendly of the effect in the scene */
  49332. name: string, scene: Scene);
  49333. /**
  49334. * Get the effect name of the layer.
  49335. * @return The effect name
  49336. */
  49337. abstract getEffectName(): string;
  49338. /**
  49339. * Checks for the readiness of the element composing the layer.
  49340. * @param subMesh the mesh to check for
  49341. * @param useInstances specify wether or not to use instances to render the mesh
  49342. * @return true if ready otherwise, false
  49343. */
  49344. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49345. /**
  49346. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49347. * @returns true if the effect requires stencil during the main canvas render pass.
  49348. */
  49349. abstract needStencil(): boolean;
  49350. /**
  49351. * Create the merge effect. This is the shader use to blit the information back
  49352. * to the main canvas at the end of the scene rendering.
  49353. * @returns The effect containing the shader used to merge the effect on the main canvas
  49354. */
  49355. protected abstract _createMergeEffect(): Effect;
  49356. /**
  49357. * Creates the render target textures and post processes used in the effect layer.
  49358. */
  49359. protected abstract _createTextureAndPostProcesses(): void;
  49360. /**
  49361. * Implementation specific of rendering the generating effect on the main canvas.
  49362. * @param effect The effect used to render through
  49363. */
  49364. protected abstract _internalRender(effect: Effect): void;
  49365. /**
  49366. * Sets the required values for both the emissive texture and and the main color.
  49367. */
  49368. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49369. /**
  49370. * Free any resources and references associated to a mesh.
  49371. * Internal use
  49372. * @param mesh The mesh to free.
  49373. */
  49374. abstract _disposeMesh(mesh: Mesh): void;
  49375. /**
  49376. * Serializes this layer (Glow or Highlight for example)
  49377. * @returns a serialized layer object
  49378. */
  49379. abstract serialize?(): any;
  49380. /**
  49381. * Initializes the effect layer with the required options.
  49382. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49383. */
  49384. protected _init(options: Partial<IEffectLayerOptions>): void;
  49385. /**
  49386. * Generates the index buffer of the full screen quad blending to the main canvas.
  49387. */
  49388. private _generateIndexBuffer;
  49389. /**
  49390. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49391. */
  49392. private _generateVertexBuffer;
  49393. /**
  49394. * Sets the main texture desired size which is the closest power of two
  49395. * of the engine canvas size.
  49396. */
  49397. private _setMainTextureSize;
  49398. /**
  49399. * Creates the main texture for the effect layer.
  49400. */
  49401. protected _createMainTexture(): void;
  49402. /**
  49403. * Adds specific effects defines.
  49404. * @param defines The defines to add specifics to.
  49405. */
  49406. protected _addCustomEffectDefines(defines: string[]): void;
  49407. /**
  49408. * Checks for the readiness of the element composing the layer.
  49409. * @param subMesh the mesh to check for
  49410. * @param useInstances specify wether or not to use instances to render the mesh
  49411. * @param emissiveTexture the associated emissive texture used to generate the glow
  49412. * @return true if ready otherwise, false
  49413. */
  49414. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49415. /**
  49416. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49417. */
  49418. render(): void;
  49419. /**
  49420. * Determine if a given mesh will be used in the current effect.
  49421. * @param mesh mesh to test
  49422. * @returns true if the mesh will be used
  49423. */
  49424. hasMesh(mesh: AbstractMesh): boolean;
  49425. /**
  49426. * Returns true if the layer contains information to display, otherwise false.
  49427. * @returns true if the glow layer should be rendered
  49428. */
  49429. shouldRender(): boolean;
  49430. /**
  49431. * Returns true if the mesh should render, otherwise false.
  49432. * @param mesh The mesh to render
  49433. * @returns true if it should render otherwise false
  49434. */
  49435. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49436. /**
  49437. * Returns true if the mesh can be rendered, otherwise false.
  49438. * @param mesh The mesh to render
  49439. * @param material The material used on the mesh
  49440. * @returns true if it can be rendered otherwise false
  49441. */
  49442. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49443. /**
  49444. * Returns true if the mesh should render, otherwise false.
  49445. * @param mesh The mesh to render
  49446. * @returns true if it should render otherwise false
  49447. */
  49448. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49449. /**
  49450. * Renders the submesh passed in parameter to the generation map.
  49451. */
  49452. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49453. /**
  49454. * Rebuild the required buffers.
  49455. * @hidden Internal use only.
  49456. */
  49457. _rebuild(): void;
  49458. /**
  49459. * Dispose only the render target textures and post process.
  49460. */
  49461. private _disposeTextureAndPostProcesses;
  49462. /**
  49463. * Dispose the highlight layer and free resources.
  49464. */
  49465. dispose(): void;
  49466. /**
  49467. * Gets the class name of the effect layer
  49468. * @returns the string with the class name of the effect layer
  49469. */
  49470. getClassName(): string;
  49471. /**
  49472. * Creates an effect layer from parsed effect layer data
  49473. * @param parsedEffectLayer defines effect layer data
  49474. * @param scene defines the current scene
  49475. * @param rootUrl defines the root URL containing the effect layer information
  49476. * @returns a parsed effect Layer
  49477. */
  49478. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49479. }
  49480. }
  49481. declare module BABYLON {
  49482. interface AbstractScene {
  49483. /**
  49484. * The list of effect layers (highlights/glow) added to the scene
  49485. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49486. * @see http://doc.babylonjs.com/how_to/glow_layer
  49487. */
  49488. effectLayers: Array<EffectLayer>;
  49489. /**
  49490. * Removes the given effect layer from this scene.
  49491. * @param toRemove defines the effect layer to remove
  49492. * @returns the index of the removed effect layer
  49493. */
  49494. removeEffectLayer(toRemove: EffectLayer): number;
  49495. /**
  49496. * Adds the given effect layer to this scene
  49497. * @param newEffectLayer defines the effect layer to add
  49498. */
  49499. addEffectLayer(newEffectLayer: EffectLayer): void;
  49500. }
  49501. /**
  49502. * Defines the layer scene component responsible to manage any effect layers
  49503. * in a given scene.
  49504. */
  49505. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49506. /**
  49507. * The component name helpfull to identify the component in the list of scene components.
  49508. */
  49509. readonly name: string;
  49510. /**
  49511. * The scene the component belongs to.
  49512. */
  49513. scene: Scene;
  49514. private _engine;
  49515. private _renderEffects;
  49516. private _needStencil;
  49517. private _previousStencilState;
  49518. /**
  49519. * Creates a new instance of the component for the given scene
  49520. * @param scene Defines the scene to register the component in
  49521. */
  49522. constructor(scene: Scene);
  49523. /**
  49524. * Registers the component in a given scene
  49525. */
  49526. register(): void;
  49527. /**
  49528. * Rebuilds the elements related to this component in case of
  49529. * context lost for instance.
  49530. */
  49531. rebuild(): void;
  49532. /**
  49533. * Serializes the component data to the specified json object
  49534. * @param serializationObject The object to serialize to
  49535. */
  49536. serialize(serializationObject: any): void;
  49537. /**
  49538. * Adds all the elements from the container to the scene
  49539. * @param container the container holding the elements
  49540. */
  49541. addFromContainer(container: AbstractScene): void;
  49542. /**
  49543. * Removes all the elements in the container from the scene
  49544. * @param container contains the elements to remove
  49545. * @param dispose if the removed element should be disposed (default: false)
  49546. */
  49547. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49548. /**
  49549. * Disposes the component and the associated ressources.
  49550. */
  49551. dispose(): void;
  49552. private _isReadyForMesh;
  49553. private _renderMainTexture;
  49554. private _setStencil;
  49555. private _setStencilBack;
  49556. private _draw;
  49557. private _drawCamera;
  49558. private _drawRenderingGroup;
  49559. }
  49560. }
  49561. declare module BABYLON {
  49562. /** @hidden */
  49563. export var glowMapMergePixelShader: {
  49564. name: string;
  49565. shader: string;
  49566. };
  49567. }
  49568. declare module BABYLON {
  49569. /** @hidden */
  49570. export var glowMapMergeVertexShader: {
  49571. name: string;
  49572. shader: string;
  49573. };
  49574. }
  49575. declare module BABYLON {
  49576. interface AbstractScene {
  49577. /**
  49578. * Return a the first highlight layer of the scene with a given name.
  49579. * @param name The name of the highlight layer to look for.
  49580. * @return The highlight layer if found otherwise null.
  49581. */
  49582. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49583. }
  49584. /**
  49585. * Glow layer options. This helps customizing the behaviour
  49586. * of the glow layer.
  49587. */
  49588. export interface IGlowLayerOptions {
  49589. /**
  49590. * Multiplication factor apply to the canvas size to compute the render target size
  49591. * used to generated the glowing objects (the smaller the faster).
  49592. */
  49593. mainTextureRatio: number;
  49594. /**
  49595. * Enforces a fixed size texture to ensure resize independant blur.
  49596. */
  49597. mainTextureFixedSize?: number;
  49598. /**
  49599. * How big is the kernel of the blur texture.
  49600. */
  49601. blurKernelSize: number;
  49602. /**
  49603. * The camera attached to the layer.
  49604. */
  49605. camera: Nullable<Camera>;
  49606. /**
  49607. * Enable MSAA by chosing the number of samples.
  49608. */
  49609. mainTextureSamples?: number;
  49610. /**
  49611. * The rendering group to draw the layer in.
  49612. */
  49613. renderingGroupId: number;
  49614. }
  49615. /**
  49616. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49617. *
  49618. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49619. * glowy meshes to your scene.
  49620. *
  49621. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49622. */
  49623. export class GlowLayer extends EffectLayer {
  49624. /**
  49625. * Effect Name of the layer.
  49626. */
  49627. static readonly EffectName: string;
  49628. /**
  49629. * The default blur kernel size used for the glow.
  49630. */
  49631. static DefaultBlurKernelSize: number;
  49632. /**
  49633. * The default texture size ratio used for the glow.
  49634. */
  49635. static DefaultTextureRatio: number;
  49636. /**
  49637. * Sets the kernel size of the blur.
  49638. */
  49639. /**
  49640. * Gets the kernel size of the blur.
  49641. */
  49642. blurKernelSize: number;
  49643. /**
  49644. * Sets the glow intensity.
  49645. */
  49646. /**
  49647. * Gets the glow intensity.
  49648. */
  49649. intensity: number;
  49650. private _options;
  49651. private _intensity;
  49652. private _horizontalBlurPostprocess1;
  49653. private _verticalBlurPostprocess1;
  49654. private _horizontalBlurPostprocess2;
  49655. private _verticalBlurPostprocess2;
  49656. private _blurTexture1;
  49657. private _blurTexture2;
  49658. private _postProcesses1;
  49659. private _postProcesses2;
  49660. private _includedOnlyMeshes;
  49661. private _excludedMeshes;
  49662. /**
  49663. * Callback used to let the user override the color selection on a per mesh basis
  49664. */
  49665. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49666. /**
  49667. * Callback used to let the user override the texture selection on a per mesh basis
  49668. */
  49669. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49670. /**
  49671. * Instantiates a new glow Layer and references it to the scene.
  49672. * @param name The name of the layer
  49673. * @param scene The scene to use the layer in
  49674. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49675. */
  49676. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49677. /**
  49678. * Get the effect name of the layer.
  49679. * @return The effect name
  49680. */
  49681. getEffectName(): string;
  49682. /**
  49683. * Create the merge effect. This is the shader use to blit the information back
  49684. * to the main canvas at the end of the scene rendering.
  49685. */
  49686. protected _createMergeEffect(): Effect;
  49687. /**
  49688. * Creates the render target textures and post processes used in the glow layer.
  49689. */
  49690. protected _createTextureAndPostProcesses(): void;
  49691. /**
  49692. * Checks for the readiness of the element composing the layer.
  49693. * @param subMesh the mesh to check for
  49694. * @param useInstances specify wether or not to use instances to render the mesh
  49695. * @param emissiveTexture the associated emissive texture used to generate the glow
  49696. * @return true if ready otherwise, false
  49697. */
  49698. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49699. /**
  49700. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49701. */
  49702. needStencil(): boolean;
  49703. /**
  49704. * Returns true if the mesh can be rendered, otherwise false.
  49705. * @param mesh The mesh to render
  49706. * @param material The material used on the mesh
  49707. * @returns true if it can be rendered otherwise false
  49708. */
  49709. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49710. /**
  49711. * Implementation specific of rendering the generating effect on the main canvas.
  49712. * @param effect The effect used to render through
  49713. */
  49714. protected _internalRender(effect: Effect): void;
  49715. /**
  49716. * Sets the required values for both the emissive texture and and the main color.
  49717. */
  49718. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49719. /**
  49720. * Returns true if the mesh should render, otherwise false.
  49721. * @param mesh The mesh to render
  49722. * @returns true if it should render otherwise false
  49723. */
  49724. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49725. /**
  49726. * Adds specific effects defines.
  49727. * @param defines The defines to add specifics to.
  49728. */
  49729. protected _addCustomEffectDefines(defines: string[]): void;
  49730. /**
  49731. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49732. * @param mesh The mesh to exclude from the glow layer
  49733. */
  49734. addExcludedMesh(mesh: Mesh): void;
  49735. /**
  49736. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49737. * @param mesh The mesh to remove
  49738. */
  49739. removeExcludedMesh(mesh: Mesh): void;
  49740. /**
  49741. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49742. * @param mesh The mesh to include in the glow layer
  49743. */
  49744. addIncludedOnlyMesh(mesh: Mesh): void;
  49745. /**
  49746. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49747. * @param mesh The mesh to remove
  49748. */
  49749. removeIncludedOnlyMesh(mesh: Mesh): void;
  49750. /**
  49751. * Determine if a given mesh will be used in the glow layer
  49752. * @param mesh The mesh to test
  49753. * @returns true if the mesh will be highlighted by the current glow layer
  49754. */
  49755. hasMesh(mesh: AbstractMesh): boolean;
  49756. /**
  49757. * Free any resources and references associated to a mesh.
  49758. * Internal use
  49759. * @param mesh The mesh to free.
  49760. * @hidden
  49761. */
  49762. _disposeMesh(mesh: Mesh): void;
  49763. /**
  49764. * Gets the class name of the effect layer
  49765. * @returns the string with the class name of the effect layer
  49766. */
  49767. getClassName(): string;
  49768. /**
  49769. * Serializes this glow layer
  49770. * @returns a serialized glow layer object
  49771. */
  49772. serialize(): any;
  49773. /**
  49774. * Creates a Glow Layer from parsed glow layer data
  49775. * @param parsedGlowLayer defines glow layer data
  49776. * @param scene defines the current scene
  49777. * @param rootUrl defines the root URL containing the glow layer information
  49778. * @returns a parsed Glow Layer
  49779. */
  49780. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49781. }
  49782. }
  49783. declare module BABYLON {
  49784. /** @hidden */
  49785. export var glowBlurPostProcessPixelShader: {
  49786. name: string;
  49787. shader: string;
  49788. };
  49789. }
  49790. declare module BABYLON {
  49791. interface AbstractScene {
  49792. /**
  49793. * Return a the first highlight layer of the scene with a given name.
  49794. * @param name The name of the highlight layer to look for.
  49795. * @return The highlight layer if found otherwise null.
  49796. */
  49797. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49798. }
  49799. /**
  49800. * Highlight layer options. This helps customizing the behaviour
  49801. * of the highlight layer.
  49802. */
  49803. export interface IHighlightLayerOptions {
  49804. /**
  49805. * Multiplication factor apply to the canvas size to compute the render target size
  49806. * used to generated the glowing objects (the smaller the faster).
  49807. */
  49808. mainTextureRatio: number;
  49809. /**
  49810. * Enforces a fixed size texture to ensure resize independant blur.
  49811. */
  49812. mainTextureFixedSize?: number;
  49813. /**
  49814. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49815. * of the picture to blur (the smaller the faster).
  49816. */
  49817. blurTextureSizeRatio: number;
  49818. /**
  49819. * How big in texel of the blur texture is the vertical blur.
  49820. */
  49821. blurVerticalSize: number;
  49822. /**
  49823. * How big in texel of the blur texture is the horizontal blur.
  49824. */
  49825. blurHorizontalSize: number;
  49826. /**
  49827. * Alpha blending mode used to apply the blur. Default is combine.
  49828. */
  49829. alphaBlendingMode: number;
  49830. /**
  49831. * The camera attached to the layer.
  49832. */
  49833. camera: Nullable<Camera>;
  49834. /**
  49835. * Should we display highlight as a solid stroke?
  49836. */
  49837. isStroke?: boolean;
  49838. /**
  49839. * The rendering group to draw the layer in.
  49840. */
  49841. renderingGroupId: number;
  49842. }
  49843. /**
  49844. * The highlight layer Helps adding a glow effect around a mesh.
  49845. *
  49846. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49847. * glowy meshes to your scene.
  49848. *
  49849. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49850. */
  49851. export class HighlightLayer extends EffectLayer {
  49852. name: string;
  49853. /**
  49854. * Effect Name of the highlight layer.
  49855. */
  49856. static readonly EffectName: string;
  49857. /**
  49858. * The neutral color used during the preparation of the glow effect.
  49859. * This is black by default as the blend operation is a blend operation.
  49860. */
  49861. static NeutralColor: Color4;
  49862. /**
  49863. * Stencil value used for glowing meshes.
  49864. */
  49865. static GlowingMeshStencilReference: number;
  49866. /**
  49867. * Stencil value used for the other meshes in the scene.
  49868. */
  49869. static NormalMeshStencilReference: number;
  49870. /**
  49871. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49872. */
  49873. innerGlow: boolean;
  49874. /**
  49875. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49876. */
  49877. outerGlow: boolean;
  49878. /**
  49879. * Specifies the horizontal size of the blur.
  49880. */
  49881. /**
  49882. * Gets the horizontal size of the blur.
  49883. */
  49884. blurHorizontalSize: number;
  49885. /**
  49886. * Specifies the vertical size of the blur.
  49887. */
  49888. /**
  49889. * Gets the vertical size of the blur.
  49890. */
  49891. blurVerticalSize: number;
  49892. /**
  49893. * An event triggered when the highlight layer is being blurred.
  49894. */
  49895. onBeforeBlurObservable: Observable<HighlightLayer>;
  49896. /**
  49897. * An event triggered when the highlight layer has been blurred.
  49898. */
  49899. onAfterBlurObservable: Observable<HighlightLayer>;
  49900. private _instanceGlowingMeshStencilReference;
  49901. private _options;
  49902. private _downSamplePostprocess;
  49903. private _horizontalBlurPostprocess;
  49904. private _verticalBlurPostprocess;
  49905. private _blurTexture;
  49906. private _meshes;
  49907. private _excludedMeshes;
  49908. /**
  49909. * Instantiates a new highlight Layer and references it to the scene..
  49910. * @param name The name of the layer
  49911. * @param scene The scene to use the layer in
  49912. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49913. */
  49914. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49915. /**
  49916. * Get the effect name of the layer.
  49917. * @return The effect name
  49918. */
  49919. getEffectName(): string;
  49920. /**
  49921. * Create the merge effect. This is the shader use to blit the information back
  49922. * to the main canvas at the end of the scene rendering.
  49923. */
  49924. protected _createMergeEffect(): Effect;
  49925. /**
  49926. * Creates the render target textures and post processes used in the highlight layer.
  49927. */
  49928. protected _createTextureAndPostProcesses(): void;
  49929. /**
  49930. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49931. */
  49932. needStencil(): boolean;
  49933. /**
  49934. * Checks for the readiness of the element composing the layer.
  49935. * @param subMesh the mesh to check for
  49936. * @param useInstances specify wether or not to use instances to render the mesh
  49937. * @param emissiveTexture the associated emissive texture used to generate the glow
  49938. * @return true if ready otherwise, false
  49939. */
  49940. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49941. /**
  49942. * Implementation specific of rendering the generating effect on the main canvas.
  49943. * @param effect The effect used to render through
  49944. */
  49945. protected _internalRender(effect: Effect): void;
  49946. /**
  49947. * Returns true if the layer contains information to display, otherwise false.
  49948. */
  49949. shouldRender(): boolean;
  49950. /**
  49951. * Returns true if the mesh should render, otherwise false.
  49952. * @param mesh The mesh to render
  49953. * @returns true if it should render otherwise false
  49954. */
  49955. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49956. /**
  49957. * Sets the required values for both the emissive texture and and the main color.
  49958. */
  49959. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49960. /**
  49961. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49962. * @param mesh The mesh to exclude from the highlight layer
  49963. */
  49964. addExcludedMesh(mesh: Mesh): void;
  49965. /**
  49966. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49967. * @param mesh The mesh to highlight
  49968. */
  49969. removeExcludedMesh(mesh: Mesh): void;
  49970. /**
  49971. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49972. * @param mesh mesh to test
  49973. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49974. */
  49975. hasMesh(mesh: AbstractMesh): boolean;
  49976. /**
  49977. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49978. * @param mesh The mesh to highlight
  49979. * @param color The color of the highlight
  49980. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49981. */
  49982. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49983. /**
  49984. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49985. * @param mesh The mesh to highlight
  49986. */
  49987. removeMesh(mesh: Mesh): void;
  49988. /**
  49989. * Force the stencil to the normal expected value for none glowing parts
  49990. */
  49991. private _defaultStencilReference;
  49992. /**
  49993. * Free any resources and references associated to a mesh.
  49994. * Internal use
  49995. * @param mesh The mesh to free.
  49996. * @hidden
  49997. */
  49998. _disposeMesh(mesh: Mesh): void;
  49999. /**
  50000. * Dispose the highlight layer and free resources.
  50001. */
  50002. dispose(): void;
  50003. /**
  50004. * Gets the class name of the effect layer
  50005. * @returns the string with the class name of the effect layer
  50006. */
  50007. getClassName(): string;
  50008. /**
  50009. * Serializes this Highlight layer
  50010. * @returns a serialized Highlight layer object
  50011. */
  50012. serialize(): any;
  50013. /**
  50014. * Creates a Highlight layer from parsed Highlight layer data
  50015. * @param parsedHightlightLayer defines the Highlight layer data
  50016. * @param scene defines the current scene
  50017. * @param rootUrl defines the root URL containing the Highlight layer information
  50018. * @returns a parsed Highlight layer
  50019. */
  50020. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50021. }
  50022. }
  50023. declare module BABYLON {
  50024. interface AbstractScene {
  50025. /**
  50026. * The list of layers (background and foreground) of the scene
  50027. */
  50028. layers: Array<Layer>;
  50029. }
  50030. /**
  50031. * Defines the layer scene component responsible to manage any layers
  50032. * in a given scene.
  50033. */
  50034. export class LayerSceneComponent implements ISceneComponent {
  50035. /**
  50036. * The component name helpfull to identify the component in the list of scene components.
  50037. */
  50038. readonly name: string;
  50039. /**
  50040. * The scene the component belongs to.
  50041. */
  50042. scene: Scene;
  50043. private _engine;
  50044. /**
  50045. * Creates a new instance of the component for the given scene
  50046. * @param scene Defines the scene to register the component in
  50047. */
  50048. constructor(scene: Scene);
  50049. /**
  50050. * Registers the component in a given scene
  50051. */
  50052. register(): void;
  50053. /**
  50054. * Rebuilds the elements related to this component in case of
  50055. * context lost for instance.
  50056. */
  50057. rebuild(): void;
  50058. /**
  50059. * Disposes the component and the associated ressources.
  50060. */
  50061. dispose(): void;
  50062. private _draw;
  50063. private _drawCameraPredicate;
  50064. private _drawCameraBackground;
  50065. private _drawCameraForeground;
  50066. private _drawRenderTargetPredicate;
  50067. private _drawRenderTargetBackground;
  50068. private _drawRenderTargetForeground;
  50069. /**
  50070. * Adds all the elements from the container to the scene
  50071. * @param container the container holding the elements
  50072. */
  50073. addFromContainer(container: AbstractScene): void;
  50074. /**
  50075. * Removes all the elements in the container from the scene
  50076. * @param container contains the elements to remove
  50077. * @param dispose if the removed element should be disposed (default: false)
  50078. */
  50079. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50080. }
  50081. }
  50082. declare module BABYLON {
  50083. /** @hidden */
  50084. export var layerPixelShader: {
  50085. name: string;
  50086. shader: string;
  50087. };
  50088. }
  50089. declare module BABYLON {
  50090. /** @hidden */
  50091. export var layerVertexShader: {
  50092. name: string;
  50093. shader: string;
  50094. };
  50095. }
  50096. declare module BABYLON {
  50097. /**
  50098. * This represents a full screen 2d layer.
  50099. * This can be useful to display a picture in the background of your scene for instance.
  50100. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50101. */
  50102. export class Layer {
  50103. /**
  50104. * Define the name of the layer.
  50105. */
  50106. name: string;
  50107. /**
  50108. * Define the texture the layer should display.
  50109. */
  50110. texture: Nullable<Texture>;
  50111. /**
  50112. * Is the layer in background or foreground.
  50113. */
  50114. isBackground: boolean;
  50115. /**
  50116. * Define the color of the layer (instead of texture).
  50117. */
  50118. color: Color4;
  50119. /**
  50120. * Define the scale of the layer in order to zoom in out of the texture.
  50121. */
  50122. scale: Vector2;
  50123. /**
  50124. * Define an offset for the layer in order to shift the texture.
  50125. */
  50126. offset: Vector2;
  50127. /**
  50128. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50129. */
  50130. alphaBlendingMode: number;
  50131. /**
  50132. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50133. * Alpha test will not mix with the background color in case of transparency.
  50134. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50135. */
  50136. alphaTest: boolean;
  50137. /**
  50138. * Define a mask to restrict the layer to only some of the scene cameras.
  50139. */
  50140. layerMask: number;
  50141. /**
  50142. * Define the list of render target the layer is visible into.
  50143. */
  50144. renderTargetTextures: RenderTargetTexture[];
  50145. /**
  50146. * Define if the layer is only used in renderTarget or if it also
  50147. * renders in the main frame buffer of the canvas.
  50148. */
  50149. renderOnlyInRenderTargetTextures: boolean;
  50150. private _scene;
  50151. private _vertexBuffers;
  50152. private _indexBuffer;
  50153. private _effect;
  50154. private _alphaTestEffect;
  50155. /**
  50156. * An event triggered when the layer is disposed.
  50157. */
  50158. onDisposeObservable: Observable<Layer>;
  50159. private _onDisposeObserver;
  50160. /**
  50161. * Back compatibility with callback before the onDisposeObservable existed.
  50162. * The set callback will be triggered when the layer has been disposed.
  50163. */
  50164. onDispose: () => void;
  50165. /**
  50166. * An event triggered before rendering the scene
  50167. */
  50168. onBeforeRenderObservable: Observable<Layer>;
  50169. private _onBeforeRenderObserver;
  50170. /**
  50171. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50172. * The set callback will be triggered just before rendering the layer.
  50173. */
  50174. onBeforeRender: () => void;
  50175. /**
  50176. * An event triggered after rendering the scene
  50177. */
  50178. onAfterRenderObservable: Observable<Layer>;
  50179. private _onAfterRenderObserver;
  50180. /**
  50181. * Back compatibility with callback before the onAfterRenderObservable existed.
  50182. * The set callback will be triggered just after rendering the layer.
  50183. */
  50184. onAfterRender: () => void;
  50185. /**
  50186. * Instantiates a new layer.
  50187. * This represents a full screen 2d layer.
  50188. * This can be useful to display a picture in the background of your scene for instance.
  50189. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50190. * @param name Define the name of the layer in the scene
  50191. * @param imgUrl Define the url of the texture to display in the layer
  50192. * @param scene Define the scene the layer belongs to
  50193. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50194. * @param color Defines a color for the layer
  50195. */
  50196. constructor(
  50197. /**
  50198. * Define the name of the layer.
  50199. */
  50200. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50201. private _createIndexBuffer;
  50202. /** @hidden */
  50203. _rebuild(): void;
  50204. /**
  50205. * Renders the layer in the scene.
  50206. */
  50207. render(): void;
  50208. /**
  50209. * Disposes and releases the associated ressources.
  50210. */
  50211. dispose(): void;
  50212. }
  50213. }
  50214. declare module BABYLON {
  50215. /** @hidden */
  50216. export var lensFlarePixelShader: {
  50217. name: string;
  50218. shader: string;
  50219. };
  50220. }
  50221. declare module BABYLON {
  50222. /** @hidden */
  50223. export var lensFlareVertexShader: {
  50224. name: string;
  50225. shader: string;
  50226. };
  50227. }
  50228. declare module BABYLON {
  50229. /**
  50230. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50231. * It is usually composed of several `lensFlare`.
  50232. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50233. */
  50234. export class LensFlareSystem {
  50235. /**
  50236. * Define the name of the lens flare system
  50237. */
  50238. name: string;
  50239. /**
  50240. * List of lens flares used in this system.
  50241. */
  50242. lensFlares: LensFlare[];
  50243. /**
  50244. * Define a limit from the border the lens flare can be visible.
  50245. */
  50246. borderLimit: number;
  50247. /**
  50248. * Define a viewport border we do not want to see the lens flare in.
  50249. */
  50250. viewportBorder: number;
  50251. /**
  50252. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50253. */
  50254. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50255. /**
  50256. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50257. */
  50258. layerMask: number;
  50259. /**
  50260. * Define the id of the lens flare system in the scene.
  50261. * (equal to name by default)
  50262. */
  50263. id: string;
  50264. private _scene;
  50265. private _emitter;
  50266. private _vertexBuffers;
  50267. private _indexBuffer;
  50268. private _effect;
  50269. private _positionX;
  50270. private _positionY;
  50271. private _isEnabled;
  50272. /** @hidden */
  50273. static _SceneComponentInitialization: (scene: Scene) => void;
  50274. /**
  50275. * Instantiates a lens flare system.
  50276. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50277. * It is usually composed of several `lensFlare`.
  50278. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50279. * @param name Define the name of the lens flare system in the scene
  50280. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50281. * @param scene Define the scene the lens flare system belongs to
  50282. */
  50283. constructor(
  50284. /**
  50285. * Define the name of the lens flare system
  50286. */
  50287. name: string, emitter: any, scene: Scene);
  50288. /**
  50289. * Define if the lens flare system is enabled.
  50290. */
  50291. isEnabled: boolean;
  50292. /**
  50293. * Get the scene the effects belongs to.
  50294. * @returns the scene holding the lens flare system
  50295. */
  50296. getScene(): Scene;
  50297. /**
  50298. * Get the emitter of the lens flare system.
  50299. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50300. * @returns the emitter of the lens flare system
  50301. */
  50302. getEmitter(): any;
  50303. /**
  50304. * Set the emitter of the lens flare system.
  50305. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50306. * @param newEmitter Define the new emitter of the system
  50307. */
  50308. setEmitter(newEmitter: any): void;
  50309. /**
  50310. * Get the lens flare system emitter position.
  50311. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50312. * @returns the position
  50313. */
  50314. getEmitterPosition(): Vector3;
  50315. /**
  50316. * @hidden
  50317. */
  50318. computeEffectivePosition(globalViewport: Viewport): boolean;
  50319. /** @hidden */
  50320. _isVisible(): boolean;
  50321. /**
  50322. * @hidden
  50323. */
  50324. render(): boolean;
  50325. /**
  50326. * Dispose and release the lens flare with its associated resources.
  50327. */
  50328. dispose(): void;
  50329. /**
  50330. * Parse a lens flare system from a JSON repressentation
  50331. * @param parsedLensFlareSystem Define the JSON to parse
  50332. * @param scene Define the scene the parsed system should be instantiated in
  50333. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50334. * @returns the parsed system
  50335. */
  50336. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50337. /**
  50338. * Serialize the current Lens Flare System into a JSON representation.
  50339. * @returns the serialized JSON
  50340. */
  50341. serialize(): any;
  50342. }
  50343. }
  50344. declare module BABYLON {
  50345. /**
  50346. * This represents one of the lens effect in a `lensFlareSystem`.
  50347. * It controls one of the indiviual texture used in the effect.
  50348. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50349. */
  50350. export class LensFlare {
  50351. /**
  50352. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50353. */
  50354. size: number;
  50355. /**
  50356. * 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.
  50357. */
  50358. position: number;
  50359. /**
  50360. * Define the lens color.
  50361. */
  50362. color: Color3;
  50363. /**
  50364. * Define the lens texture.
  50365. */
  50366. texture: Nullable<Texture>;
  50367. /**
  50368. * Define the alpha mode to render this particular lens.
  50369. */
  50370. alphaMode: number;
  50371. private _system;
  50372. /**
  50373. * Creates a new Lens Flare.
  50374. * This represents one of the lens effect in a `lensFlareSystem`.
  50375. * It controls one of the indiviual texture used in the effect.
  50376. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50377. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50378. * @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.
  50379. * @param color Define the lens color
  50380. * @param imgUrl Define the lens texture url
  50381. * @param system Define the `lensFlareSystem` this flare is part of
  50382. * @returns The newly created Lens Flare
  50383. */
  50384. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50385. /**
  50386. * Instantiates a new Lens Flare.
  50387. * This represents one of the lens effect in a `lensFlareSystem`.
  50388. * It controls one of the indiviual texture used in the effect.
  50389. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50390. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50391. * @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.
  50392. * @param color Define the lens color
  50393. * @param imgUrl Define the lens texture url
  50394. * @param system Define the `lensFlareSystem` this flare is part of
  50395. */
  50396. constructor(
  50397. /**
  50398. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50399. */
  50400. size: number,
  50401. /**
  50402. * 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.
  50403. */
  50404. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50405. /**
  50406. * Dispose and release the lens flare with its associated resources.
  50407. */
  50408. dispose(): void;
  50409. }
  50410. }
  50411. declare module BABYLON {
  50412. interface AbstractScene {
  50413. /**
  50414. * The list of lens flare system added to the scene
  50415. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50416. */
  50417. lensFlareSystems: Array<LensFlareSystem>;
  50418. /**
  50419. * Removes the given lens flare system from this scene.
  50420. * @param toRemove The lens flare system to remove
  50421. * @returns The index of the removed lens flare system
  50422. */
  50423. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50424. /**
  50425. * Adds the given lens flare system to this scene
  50426. * @param newLensFlareSystem The lens flare system to add
  50427. */
  50428. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50429. /**
  50430. * Gets a lens flare system using its name
  50431. * @param name defines the name to look for
  50432. * @returns the lens flare system or null if not found
  50433. */
  50434. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50435. /**
  50436. * Gets a lens flare system using its id
  50437. * @param id defines the id to look for
  50438. * @returns the lens flare system or null if not found
  50439. */
  50440. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50441. }
  50442. /**
  50443. * Defines the lens flare scene component responsible to manage any lens flares
  50444. * in a given scene.
  50445. */
  50446. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50447. /**
  50448. * The component name helpfull to identify the component in the list of scene components.
  50449. */
  50450. readonly name: string;
  50451. /**
  50452. * The scene the component belongs to.
  50453. */
  50454. scene: Scene;
  50455. /**
  50456. * Creates a new instance of the component for the given scene
  50457. * @param scene Defines the scene to register the component in
  50458. */
  50459. constructor(scene: Scene);
  50460. /**
  50461. * Registers the component in a given scene
  50462. */
  50463. register(): void;
  50464. /**
  50465. * Rebuilds the elements related to this component in case of
  50466. * context lost for instance.
  50467. */
  50468. rebuild(): void;
  50469. /**
  50470. * Adds all the elements from the container to the scene
  50471. * @param container the container holding the elements
  50472. */
  50473. addFromContainer(container: AbstractScene): void;
  50474. /**
  50475. * Removes all the elements in the container from the scene
  50476. * @param container contains the elements to remove
  50477. * @param dispose if the removed element should be disposed (default: false)
  50478. */
  50479. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50480. /**
  50481. * Serializes the component data to the specified json object
  50482. * @param serializationObject The object to serialize to
  50483. */
  50484. serialize(serializationObject: any): void;
  50485. /**
  50486. * Disposes the component and the associated ressources.
  50487. */
  50488. dispose(): void;
  50489. private _draw;
  50490. }
  50491. }
  50492. declare module BABYLON {
  50493. /**
  50494. * Defines the shadow generator component responsible to manage any shadow generators
  50495. * in a given scene.
  50496. */
  50497. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50498. /**
  50499. * The component name helpfull to identify the component in the list of scene components.
  50500. */
  50501. readonly name: string;
  50502. /**
  50503. * The scene the component belongs to.
  50504. */
  50505. scene: Scene;
  50506. /**
  50507. * Creates a new instance of the component for the given scene
  50508. * @param scene Defines the scene to register the component in
  50509. */
  50510. constructor(scene: Scene);
  50511. /**
  50512. * Registers the component in a given scene
  50513. */
  50514. register(): void;
  50515. /**
  50516. * Rebuilds the elements related to this component in case of
  50517. * context lost for instance.
  50518. */
  50519. rebuild(): void;
  50520. /**
  50521. * Serializes the component data to the specified json object
  50522. * @param serializationObject The object to serialize to
  50523. */
  50524. serialize(serializationObject: any): void;
  50525. /**
  50526. * Adds all the elements from the container to the scene
  50527. * @param container the container holding the elements
  50528. */
  50529. addFromContainer(container: AbstractScene): void;
  50530. /**
  50531. * Removes all the elements in the container from the scene
  50532. * @param container contains the elements to remove
  50533. * @param dispose if the removed element should be disposed (default: false)
  50534. */
  50535. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50536. /**
  50537. * Rebuilds the elements related to this component in case of
  50538. * context lost for instance.
  50539. */
  50540. dispose(): void;
  50541. private _gatherRenderTargets;
  50542. }
  50543. }
  50544. declare module BABYLON {
  50545. /**
  50546. * A point light is a light defined by an unique point in world space.
  50547. * The light is emitted in every direction from this point.
  50548. * A good example of a point light is a standard light bulb.
  50549. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50550. */
  50551. export class PointLight extends ShadowLight {
  50552. private _shadowAngle;
  50553. /**
  50554. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50555. * This specifies what angle the shadow will use to be created.
  50556. *
  50557. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50558. */
  50559. /**
  50560. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50561. * This specifies what angle the shadow will use to be created.
  50562. *
  50563. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50564. */
  50565. shadowAngle: number;
  50566. /**
  50567. * Gets the direction if it has been set.
  50568. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50569. */
  50570. /**
  50571. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50572. */
  50573. direction: Vector3;
  50574. /**
  50575. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50576. * A PointLight emits the light in every direction.
  50577. * It can cast shadows.
  50578. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50579. * ```javascript
  50580. * var pointLight = new PointLight("pl", camera.position, scene);
  50581. * ```
  50582. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50583. * @param name The light friendly name
  50584. * @param position The position of the point light in the scene
  50585. * @param scene The scene the lights belongs to
  50586. */
  50587. constructor(name: string, position: Vector3, scene: Scene);
  50588. /**
  50589. * Returns the string "PointLight"
  50590. * @returns the class name
  50591. */
  50592. getClassName(): string;
  50593. /**
  50594. * Returns the integer 0.
  50595. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50596. */
  50597. getTypeID(): number;
  50598. /**
  50599. * Specifies wether or not the shadowmap should be a cube texture.
  50600. * @returns true if the shadowmap needs to be a cube texture.
  50601. */
  50602. needCube(): boolean;
  50603. /**
  50604. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50605. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50606. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50607. */
  50608. getShadowDirection(faceIndex?: number): Vector3;
  50609. /**
  50610. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50611. * - fov = PI / 2
  50612. * - aspect ratio : 1.0
  50613. * - z-near and far equal to the active camera minZ and maxZ.
  50614. * Returns the PointLight.
  50615. */
  50616. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50617. protected _buildUniformLayout(): void;
  50618. /**
  50619. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50620. * @param effect The effect to update
  50621. * @param lightIndex The index of the light in the effect to update
  50622. * @returns The point light
  50623. */
  50624. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50625. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50626. /**
  50627. * Prepares the list of defines specific to the light type.
  50628. * @param defines the list of defines
  50629. * @param lightIndex defines the index of the light for the effect
  50630. */
  50631. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50632. }
  50633. }
  50634. declare module BABYLON {
  50635. /**
  50636. * Header information of HDR texture files.
  50637. */
  50638. export interface HDRInfo {
  50639. /**
  50640. * The height of the texture in pixels.
  50641. */
  50642. height: number;
  50643. /**
  50644. * The width of the texture in pixels.
  50645. */
  50646. width: number;
  50647. /**
  50648. * The index of the beginning of the data in the binary file.
  50649. */
  50650. dataPosition: number;
  50651. }
  50652. /**
  50653. * This groups tools to convert HDR texture to native colors array.
  50654. */
  50655. export class HDRTools {
  50656. private static Ldexp;
  50657. private static Rgbe2float;
  50658. private static readStringLine;
  50659. /**
  50660. * Reads header information from an RGBE texture stored in a native array.
  50661. * More information on this format are available here:
  50662. * https://en.wikipedia.org/wiki/RGBE_image_format
  50663. *
  50664. * @param uint8array The binary file stored in native array.
  50665. * @return The header information.
  50666. */
  50667. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50668. /**
  50669. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50670. * This RGBE texture needs to store the information as a panorama.
  50671. *
  50672. * More information on this format are available here:
  50673. * https://en.wikipedia.org/wiki/RGBE_image_format
  50674. *
  50675. * @param buffer The binary file stored in an array buffer.
  50676. * @param size The expected size of the extracted cubemap.
  50677. * @return The Cube Map information.
  50678. */
  50679. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50680. /**
  50681. * Returns the pixels data extracted from an RGBE texture.
  50682. * This pixels will be stored left to right up to down in the R G B order in one array.
  50683. *
  50684. * More information on this format are available here:
  50685. * https://en.wikipedia.org/wiki/RGBE_image_format
  50686. *
  50687. * @param uint8array The binary file stored in an array buffer.
  50688. * @param hdrInfo The header information of the file.
  50689. * @return The pixels data in RGB right to left up to down order.
  50690. */
  50691. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50692. private static RGBE_ReadPixels_RLE;
  50693. }
  50694. }
  50695. declare module BABYLON {
  50696. /**
  50697. * This represents a texture coming from an HDR input.
  50698. *
  50699. * The only supported format is currently panorama picture stored in RGBE format.
  50700. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50701. */
  50702. export class HDRCubeTexture extends BaseTexture {
  50703. private static _facesMapping;
  50704. private _generateHarmonics;
  50705. private _noMipmap;
  50706. private _textureMatrix;
  50707. private _size;
  50708. private _onLoad;
  50709. private _onError;
  50710. /**
  50711. * The texture URL.
  50712. */
  50713. url: string;
  50714. /**
  50715. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50716. */
  50717. coordinatesMode: number;
  50718. protected _isBlocking: boolean;
  50719. /**
  50720. * Sets wether or not the texture is blocking during loading.
  50721. */
  50722. /**
  50723. * Gets wether or not the texture is blocking during loading.
  50724. */
  50725. isBlocking: boolean;
  50726. protected _rotationY: number;
  50727. /**
  50728. * Sets texture matrix rotation angle around Y axis in radians.
  50729. */
  50730. /**
  50731. * Gets texture matrix rotation angle around Y axis radians.
  50732. */
  50733. rotationY: number;
  50734. /**
  50735. * Gets or sets the center of the bounding box associated with the cube texture
  50736. * It must define where the camera used to render the texture was set
  50737. */
  50738. boundingBoxPosition: Vector3;
  50739. private _boundingBoxSize;
  50740. /**
  50741. * Gets or sets the size of the bounding box associated with the cube texture
  50742. * When defined, the cubemap will switch to local mode
  50743. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50744. * @example https://www.babylonjs-playground.com/#RNASML
  50745. */
  50746. boundingBoxSize: Vector3;
  50747. /**
  50748. * Instantiates an HDRTexture from the following parameters.
  50749. *
  50750. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50751. * @param scene The scene the texture will be used in
  50752. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50753. * @param noMipmap Forces to not generate the mipmap if true
  50754. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50755. * @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)
  50756. * @param reserved Reserved flag for internal use.
  50757. */
  50758. 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>);
  50759. /**
  50760. * Get the current class name of the texture useful for serialization or dynamic coding.
  50761. * @returns "HDRCubeTexture"
  50762. */
  50763. getClassName(): string;
  50764. /**
  50765. * Occurs when the file is raw .hdr file.
  50766. */
  50767. private loadTexture;
  50768. clone(): HDRCubeTexture;
  50769. delayLoad(): void;
  50770. /**
  50771. * Get the texture reflection matrix used to rotate/transform the reflection.
  50772. * @returns the reflection matrix
  50773. */
  50774. getReflectionTextureMatrix(): Matrix;
  50775. /**
  50776. * Set the texture reflection matrix used to rotate/transform the reflection.
  50777. * @param value Define the reflection matrix to set
  50778. */
  50779. setReflectionTextureMatrix(value: Matrix): void;
  50780. /**
  50781. * Parses a JSON representation of an HDR Texture in order to create the texture
  50782. * @param parsedTexture Define the JSON representation
  50783. * @param scene Define the scene the texture should be created in
  50784. * @param rootUrl Define the root url in case we need to load relative dependencies
  50785. * @returns the newly created texture after parsing
  50786. */
  50787. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50788. serialize(): any;
  50789. }
  50790. }
  50791. declare module BABYLON {
  50792. /**
  50793. * Class used to control physics engine
  50794. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50795. */
  50796. export class PhysicsEngine implements IPhysicsEngine {
  50797. private _physicsPlugin;
  50798. /**
  50799. * Global value used to control the smallest number supported by the simulation
  50800. */
  50801. static Epsilon: number;
  50802. private _impostors;
  50803. private _joints;
  50804. /**
  50805. * Gets the gravity vector used by the simulation
  50806. */
  50807. gravity: Vector3;
  50808. /**
  50809. * Factory used to create the default physics plugin.
  50810. * @returns The default physics plugin
  50811. */
  50812. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50813. /**
  50814. * Creates a new Physics Engine
  50815. * @param gravity defines the gravity vector used by the simulation
  50816. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50817. */
  50818. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50819. /**
  50820. * Sets the gravity vector used by the simulation
  50821. * @param gravity defines the gravity vector to use
  50822. */
  50823. setGravity(gravity: Vector3): void;
  50824. /**
  50825. * Set the time step of the physics engine.
  50826. * Default is 1/60.
  50827. * To slow it down, enter 1/600 for example.
  50828. * To speed it up, 1/30
  50829. * @param newTimeStep defines the new timestep to apply to this world.
  50830. */
  50831. setTimeStep(newTimeStep?: number): void;
  50832. /**
  50833. * Get the time step of the physics engine.
  50834. * @returns the current time step
  50835. */
  50836. getTimeStep(): number;
  50837. /**
  50838. * Release all resources
  50839. */
  50840. dispose(): void;
  50841. /**
  50842. * Gets the name of the current physics plugin
  50843. * @returns the name of the plugin
  50844. */
  50845. getPhysicsPluginName(): string;
  50846. /**
  50847. * Adding a new impostor for the impostor tracking.
  50848. * This will be done by the impostor itself.
  50849. * @param impostor the impostor to add
  50850. */
  50851. addImpostor(impostor: PhysicsImpostor): void;
  50852. /**
  50853. * Remove an impostor from the engine.
  50854. * This impostor and its mesh will not longer be updated by the physics engine.
  50855. * @param impostor the impostor to remove
  50856. */
  50857. removeImpostor(impostor: PhysicsImpostor): void;
  50858. /**
  50859. * Add a joint to the physics engine
  50860. * @param mainImpostor defines the main impostor to which the joint is added.
  50861. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50862. * @param joint defines the joint that will connect both impostors.
  50863. */
  50864. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50865. /**
  50866. * Removes a joint from the simulation
  50867. * @param mainImpostor defines the impostor used with the joint
  50868. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50869. * @param joint defines the joint to remove
  50870. */
  50871. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50872. /**
  50873. * Called by the scene. No need to call it.
  50874. * @param delta defines the timespam between frames
  50875. */
  50876. _step(delta: number): void;
  50877. /**
  50878. * Gets the current plugin used to run the simulation
  50879. * @returns current plugin
  50880. */
  50881. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50882. /**
  50883. * Gets the list of physic impostors
  50884. * @returns an array of PhysicsImpostor
  50885. */
  50886. getImpostors(): Array<PhysicsImpostor>;
  50887. /**
  50888. * Gets the impostor for a physics enabled object
  50889. * @param object defines the object impersonated by the impostor
  50890. * @returns the PhysicsImpostor or null if not found
  50891. */
  50892. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50893. /**
  50894. * Gets the impostor for a physics body object
  50895. * @param body defines physics body used by the impostor
  50896. * @returns the PhysicsImpostor or null if not found
  50897. */
  50898. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50899. /**
  50900. * Does a raycast in the physics world
  50901. * @param from when should the ray start?
  50902. * @param to when should the ray end?
  50903. * @returns PhysicsRaycastResult
  50904. */
  50905. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50906. }
  50907. }
  50908. declare module BABYLON {
  50909. /** @hidden */
  50910. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50911. private _useDeltaForWorldStep;
  50912. world: any;
  50913. name: string;
  50914. private _physicsMaterials;
  50915. private _fixedTimeStep;
  50916. private _cannonRaycastResult;
  50917. private _raycastResult;
  50918. private _physicsBodysToRemoveAfterStep;
  50919. BJSCANNON: any;
  50920. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50921. setGravity(gravity: Vector3): void;
  50922. setTimeStep(timeStep: number): void;
  50923. getTimeStep(): number;
  50924. executeStep(delta: number): void;
  50925. private _removeMarkedPhysicsBodiesFromWorld;
  50926. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50927. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50928. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50929. private _processChildMeshes;
  50930. removePhysicsBody(impostor: PhysicsImpostor): void;
  50931. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50932. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50933. private _addMaterial;
  50934. private _checkWithEpsilon;
  50935. private _createShape;
  50936. private _createHeightmap;
  50937. private _minus90X;
  50938. private _plus90X;
  50939. private _tmpPosition;
  50940. private _tmpDeltaPosition;
  50941. private _tmpUnityRotation;
  50942. private _updatePhysicsBodyTransformation;
  50943. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50944. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50945. isSupported(): boolean;
  50946. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50947. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50948. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50949. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50950. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50951. getBodyMass(impostor: PhysicsImpostor): number;
  50952. getBodyFriction(impostor: PhysicsImpostor): number;
  50953. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50954. getBodyRestitution(impostor: PhysicsImpostor): number;
  50955. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50956. sleepBody(impostor: PhysicsImpostor): void;
  50957. wakeUpBody(impostor: PhysicsImpostor): void;
  50958. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50959. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50960. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50961. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50962. getRadius(impostor: PhysicsImpostor): number;
  50963. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50964. dispose(): void;
  50965. private _extendNamespace;
  50966. /**
  50967. * Does a raycast in the physics world
  50968. * @param from when should the ray start?
  50969. * @param to when should the ray end?
  50970. * @returns PhysicsRaycastResult
  50971. */
  50972. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50973. }
  50974. }
  50975. declare module BABYLON {
  50976. /** @hidden */
  50977. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50978. world: any;
  50979. name: string;
  50980. BJSOIMO: any;
  50981. private _raycastResult;
  50982. constructor(iterations?: number, oimoInjection?: any);
  50983. setGravity(gravity: Vector3): void;
  50984. setTimeStep(timeStep: number): void;
  50985. getTimeStep(): number;
  50986. private _tmpImpostorsArray;
  50987. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50988. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50989. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50990. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50991. private _tmpPositionVector;
  50992. removePhysicsBody(impostor: PhysicsImpostor): void;
  50993. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50994. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50995. isSupported(): boolean;
  50996. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50997. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50998. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50999. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51000. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51001. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51002. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51003. getBodyMass(impostor: PhysicsImpostor): number;
  51004. getBodyFriction(impostor: PhysicsImpostor): number;
  51005. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51006. getBodyRestitution(impostor: PhysicsImpostor): number;
  51007. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51008. sleepBody(impostor: PhysicsImpostor): void;
  51009. wakeUpBody(impostor: PhysicsImpostor): void;
  51010. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51011. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51012. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51013. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51014. getRadius(impostor: PhysicsImpostor): number;
  51015. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51016. dispose(): void;
  51017. /**
  51018. * Does a raycast in the physics world
  51019. * @param from when should the ray start?
  51020. * @param to when should the ray end?
  51021. * @returns PhysicsRaycastResult
  51022. */
  51023. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51024. }
  51025. }
  51026. declare module BABYLON {
  51027. /**
  51028. * Class containing static functions to help procedurally build meshes
  51029. */
  51030. export class RibbonBuilder {
  51031. /**
  51032. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51033. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51034. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51035. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51036. * * 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
  51037. * * 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
  51038. * * 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
  51039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51040. * * 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
  51041. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51042. * * 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
  51043. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51044. * * 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
  51045. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51047. * @param name defines the name of the mesh
  51048. * @param options defines the options used to create the mesh
  51049. * @param scene defines the hosting scene
  51050. * @returns the ribbon mesh
  51051. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51052. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51053. */
  51054. static CreateRibbon(name: string, options: {
  51055. pathArray: Vector3[][];
  51056. closeArray?: boolean;
  51057. closePath?: boolean;
  51058. offset?: number;
  51059. updatable?: boolean;
  51060. sideOrientation?: number;
  51061. frontUVs?: Vector4;
  51062. backUVs?: Vector4;
  51063. instance?: Mesh;
  51064. invertUV?: boolean;
  51065. uvs?: Vector2[];
  51066. colors?: Color4[];
  51067. }, scene?: Nullable<Scene>): Mesh;
  51068. }
  51069. }
  51070. declare module BABYLON {
  51071. /**
  51072. * Class containing static functions to help procedurally build meshes
  51073. */
  51074. export class ShapeBuilder {
  51075. /**
  51076. * 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.
  51077. * * 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.
  51078. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51079. * * 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.
  51080. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51081. * * 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
  51082. * * 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
  51083. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51085. * * 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
  51086. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51088. * @param name defines the name of the mesh
  51089. * @param options defines the options used to create the mesh
  51090. * @param scene defines the hosting scene
  51091. * @returns the extruded shape mesh
  51092. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51094. */
  51095. static ExtrudeShape(name: string, options: {
  51096. shape: Vector3[];
  51097. path: Vector3[];
  51098. scale?: number;
  51099. rotation?: number;
  51100. cap?: number;
  51101. updatable?: boolean;
  51102. sideOrientation?: number;
  51103. frontUVs?: Vector4;
  51104. backUVs?: Vector4;
  51105. instance?: Mesh;
  51106. invertUV?: boolean;
  51107. }, scene?: Nullable<Scene>): Mesh;
  51108. /**
  51109. * Creates an custom extruded shape mesh.
  51110. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51111. * * 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.
  51112. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51113. * * 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
  51114. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51115. * * 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
  51116. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51117. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51118. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51119. * * 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
  51120. * * 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
  51121. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51123. * * 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
  51124. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51126. * @param name defines the name of the mesh
  51127. * @param options defines the options used to create the mesh
  51128. * @param scene defines the hosting scene
  51129. * @returns the custom extruded shape mesh
  51130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51131. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51132. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51133. */
  51134. static ExtrudeShapeCustom(name: string, options: {
  51135. shape: Vector3[];
  51136. path: Vector3[];
  51137. scaleFunction?: any;
  51138. rotationFunction?: any;
  51139. ribbonCloseArray?: boolean;
  51140. ribbonClosePath?: boolean;
  51141. cap?: number;
  51142. updatable?: boolean;
  51143. sideOrientation?: number;
  51144. frontUVs?: Vector4;
  51145. backUVs?: Vector4;
  51146. instance?: Mesh;
  51147. invertUV?: boolean;
  51148. }, scene?: Nullable<Scene>): Mesh;
  51149. private static _ExtrudeShapeGeneric;
  51150. }
  51151. }
  51152. declare module BABYLON {
  51153. /**
  51154. * AmmoJS Physics plugin
  51155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51156. * @see https://github.com/kripken/ammo.js/
  51157. */
  51158. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51159. private _useDeltaForWorldStep;
  51160. /**
  51161. * Reference to the Ammo library
  51162. */
  51163. bjsAMMO: any;
  51164. /**
  51165. * Created ammoJS world which physics bodies are added to
  51166. */
  51167. world: any;
  51168. /**
  51169. * Name of the plugin
  51170. */
  51171. name: string;
  51172. private _timeStep;
  51173. private _fixedTimeStep;
  51174. private _maxSteps;
  51175. private _tmpQuaternion;
  51176. private _tmpAmmoTransform;
  51177. private _tmpAmmoQuaternion;
  51178. private _tmpAmmoConcreteContactResultCallback;
  51179. private _collisionConfiguration;
  51180. private _dispatcher;
  51181. private _overlappingPairCache;
  51182. private _solver;
  51183. private _softBodySolver;
  51184. private _tmpAmmoVectorA;
  51185. private _tmpAmmoVectorB;
  51186. private _tmpAmmoVectorC;
  51187. private _tmpAmmoVectorD;
  51188. private _tmpContactCallbackResult;
  51189. private _tmpAmmoVectorRCA;
  51190. private _tmpAmmoVectorRCB;
  51191. private _raycastResult;
  51192. private static readonly DISABLE_COLLISION_FLAG;
  51193. private static readonly KINEMATIC_FLAG;
  51194. private static readonly DISABLE_DEACTIVATION_FLAG;
  51195. /**
  51196. * Initializes the ammoJS plugin
  51197. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51198. * @param ammoInjection can be used to inject your own ammo reference
  51199. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51200. */
  51201. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51202. /**
  51203. * Sets the gravity of the physics world (m/(s^2))
  51204. * @param gravity Gravity to set
  51205. */
  51206. setGravity(gravity: Vector3): void;
  51207. /**
  51208. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51209. * @param timeStep timestep to use in seconds
  51210. */
  51211. setTimeStep(timeStep: number): void;
  51212. /**
  51213. * 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)
  51214. * @param fixedTimeStep fixedTimeStep to use in seconds
  51215. */
  51216. setFixedTimeStep(fixedTimeStep: number): void;
  51217. /**
  51218. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51219. * @param maxSteps the maximum number of steps by the physics engine per frame
  51220. */
  51221. setMaxSteps(maxSteps: number): void;
  51222. /**
  51223. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51224. * @returns the current timestep in seconds
  51225. */
  51226. getTimeStep(): number;
  51227. private _isImpostorInContact;
  51228. private _isImpostorPairInContact;
  51229. private _stepSimulation;
  51230. /**
  51231. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51232. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51233. * After the step the babylon meshes are set to the position of the physics imposters
  51234. * @param delta amount of time to step forward
  51235. * @param impostors array of imposters to update before/after the step
  51236. */
  51237. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51238. /**
  51239. * Update babylon mesh to match physics world object
  51240. * @param impostor imposter to match
  51241. */
  51242. private _afterSoftStep;
  51243. /**
  51244. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51245. * @param impostor imposter to match
  51246. */
  51247. private _ropeStep;
  51248. /**
  51249. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51250. * @param impostor imposter to match
  51251. */
  51252. private _softbodyOrClothStep;
  51253. private _tmpVector;
  51254. private _tmpMatrix;
  51255. /**
  51256. * Applies an impulse on the imposter
  51257. * @param impostor imposter to apply impulse to
  51258. * @param force amount of force to be applied to the imposter
  51259. * @param contactPoint the location to apply the impulse on the imposter
  51260. */
  51261. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51262. /**
  51263. * Applies a force on the imposter
  51264. * @param impostor imposter to apply force
  51265. * @param force amount of force to be applied to the imposter
  51266. * @param contactPoint the location to apply the force on the imposter
  51267. */
  51268. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51269. /**
  51270. * Creates a physics body using the plugin
  51271. * @param impostor the imposter to create the physics body on
  51272. */
  51273. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51274. /**
  51275. * Removes the physics body from the imposter and disposes of the body's memory
  51276. * @param impostor imposter to remove the physics body from
  51277. */
  51278. removePhysicsBody(impostor: PhysicsImpostor): void;
  51279. /**
  51280. * Generates a joint
  51281. * @param impostorJoint the imposter joint to create the joint with
  51282. */
  51283. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51284. /**
  51285. * Removes a joint
  51286. * @param impostorJoint the imposter joint to remove the joint from
  51287. */
  51288. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51289. private _addMeshVerts;
  51290. /**
  51291. * Initialise the soft body vertices to match its object's (mesh) vertices
  51292. * Softbody vertices (nodes) are in world space and to match this
  51293. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51294. * @param impostor to create the softbody for
  51295. */
  51296. private _softVertexData;
  51297. /**
  51298. * Create an impostor's soft body
  51299. * @param impostor to create the softbody for
  51300. */
  51301. private _createSoftbody;
  51302. /**
  51303. * Create cloth for an impostor
  51304. * @param impostor to create the softbody for
  51305. */
  51306. private _createCloth;
  51307. /**
  51308. * Create rope for an impostor
  51309. * @param impostor to create the softbody for
  51310. */
  51311. private _createRope;
  51312. private _addHullVerts;
  51313. private _createShape;
  51314. /**
  51315. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51316. * @param impostor imposter containing the physics body and babylon object
  51317. */
  51318. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51319. /**
  51320. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51321. * @param impostor imposter containing the physics body and babylon object
  51322. * @param newPosition new position
  51323. * @param newRotation new rotation
  51324. */
  51325. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51326. /**
  51327. * If this plugin is supported
  51328. * @returns true if its supported
  51329. */
  51330. isSupported(): boolean;
  51331. /**
  51332. * Sets the linear velocity of the physics body
  51333. * @param impostor imposter to set the velocity on
  51334. * @param velocity velocity to set
  51335. */
  51336. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51337. /**
  51338. * Sets the angular velocity of the physics body
  51339. * @param impostor imposter to set the velocity on
  51340. * @param velocity velocity to set
  51341. */
  51342. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51343. /**
  51344. * gets the linear velocity
  51345. * @param impostor imposter to get linear velocity from
  51346. * @returns linear velocity
  51347. */
  51348. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51349. /**
  51350. * gets the angular velocity
  51351. * @param impostor imposter to get angular velocity from
  51352. * @returns angular velocity
  51353. */
  51354. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51355. /**
  51356. * Sets the mass of physics body
  51357. * @param impostor imposter to set the mass on
  51358. * @param mass mass to set
  51359. */
  51360. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51361. /**
  51362. * Gets the mass of the physics body
  51363. * @param impostor imposter to get the mass from
  51364. * @returns mass
  51365. */
  51366. getBodyMass(impostor: PhysicsImpostor): number;
  51367. /**
  51368. * Gets friction of the impostor
  51369. * @param impostor impostor to get friction from
  51370. * @returns friction value
  51371. */
  51372. getBodyFriction(impostor: PhysicsImpostor): number;
  51373. /**
  51374. * Sets friction of the impostor
  51375. * @param impostor impostor to set friction on
  51376. * @param friction friction value
  51377. */
  51378. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51379. /**
  51380. * Gets restitution of the impostor
  51381. * @param impostor impostor to get restitution from
  51382. * @returns restitution value
  51383. */
  51384. getBodyRestitution(impostor: PhysicsImpostor): number;
  51385. /**
  51386. * Sets resitution of the impostor
  51387. * @param impostor impostor to set resitution on
  51388. * @param restitution resitution value
  51389. */
  51390. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51391. /**
  51392. * Gets pressure inside the impostor
  51393. * @param impostor impostor to get pressure from
  51394. * @returns pressure value
  51395. */
  51396. getBodyPressure(impostor: PhysicsImpostor): number;
  51397. /**
  51398. * Sets pressure inside a soft body impostor
  51399. * Cloth and rope must remain 0 pressure
  51400. * @param impostor impostor to set pressure on
  51401. * @param pressure pressure value
  51402. */
  51403. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51404. /**
  51405. * Gets stiffness of the impostor
  51406. * @param impostor impostor to get stiffness from
  51407. * @returns pressure value
  51408. */
  51409. getBodyStiffness(impostor: PhysicsImpostor): number;
  51410. /**
  51411. * Sets stiffness of the impostor
  51412. * @param impostor impostor to set stiffness on
  51413. * @param stiffness stiffness value from 0 to 1
  51414. */
  51415. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51416. /**
  51417. * Gets velocityIterations of the impostor
  51418. * @param impostor impostor to get velocity iterations from
  51419. * @returns velocityIterations value
  51420. */
  51421. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51422. /**
  51423. * Sets velocityIterations of the impostor
  51424. * @param impostor impostor to set velocity iterations on
  51425. * @param velocityIterations velocityIterations value
  51426. */
  51427. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51428. /**
  51429. * Gets positionIterations of the impostor
  51430. * @param impostor impostor to get position iterations from
  51431. * @returns positionIterations value
  51432. */
  51433. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51434. /**
  51435. * Sets positionIterations of the impostor
  51436. * @param impostor impostor to set position on
  51437. * @param positionIterations positionIterations value
  51438. */
  51439. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51440. /**
  51441. * Append an anchor to a cloth object
  51442. * @param impostor is the cloth impostor to add anchor to
  51443. * @param otherImpostor is the rigid impostor to anchor to
  51444. * @param width ratio across width from 0 to 1
  51445. * @param height ratio up height from 0 to 1
  51446. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51447. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51448. */
  51449. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51450. /**
  51451. * Append an hook to a rope object
  51452. * @param impostor is the rope impostor to add hook to
  51453. * @param otherImpostor is the rigid impostor to hook to
  51454. * @param length ratio along the rope from 0 to 1
  51455. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51456. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51457. */
  51458. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51459. /**
  51460. * Sleeps the physics body and stops it from being active
  51461. * @param impostor impostor to sleep
  51462. */
  51463. sleepBody(impostor: PhysicsImpostor): void;
  51464. /**
  51465. * Activates the physics body
  51466. * @param impostor impostor to activate
  51467. */
  51468. wakeUpBody(impostor: PhysicsImpostor): void;
  51469. /**
  51470. * Updates the distance parameters of the joint
  51471. * @param joint joint to update
  51472. * @param maxDistance maximum distance of the joint
  51473. * @param minDistance minimum distance of the joint
  51474. */
  51475. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51476. /**
  51477. * Sets a motor on the joint
  51478. * @param joint joint to set motor on
  51479. * @param speed speed of the motor
  51480. * @param maxForce maximum force of the motor
  51481. * @param motorIndex index of the motor
  51482. */
  51483. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51484. /**
  51485. * Sets the motors limit
  51486. * @param joint joint to set limit on
  51487. * @param upperLimit upper limit
  51488. * @param lowerLimit lower limit
  51489. */
  51490. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51491. /**
  51492. * Syncs the position and rotation of a mesh with the impostor
  51493. * @param mesh mesh to sync
  51494. * @param impostor impostor to update the mesh with
  51495. */
  51496. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51497. /**
  51498. * Gets the radius of the impostor
  51499. * @param impostor impostor to get radius from
  51500. * @returns the radius
  51501. */
  51502. getRadius(impostor: PhysicsImpostor): number;
  51503. /**
  51504. * Gets the box size of the impostor
  51505. * @param impostor impostor to get box size from
  51506. * @param result the resulting box size
  51507. */
  51508. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51509. /**
  51510. * Disposes of the impostor
  51511. */
  51512. dispose(): void;
  51513. /**
  51514. * Does a raycast in the physics world
  51515. * @param from when should the ray start?
  51516. * @param to when should the ray end?
  51517. * @returns PhysicsRaycastResult
  51518. */
  51519. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51520. }
  51521. }
  51522. declare module BABYLON {
  51523. interface AbstractScene {
  51524. /**
  51525. * The list of reflection probes added to the scene
  51526. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51527. */
  51528. reflectionProbes: Array<ReflectionProbe>;
  51529. /**
  51530. * Removes the given reflection probe from this scene.
  51531. * @param toRemove The reflection probe to remove
  51532. * @returns The index of the removed reflection probe
  51533. */
  51534. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51535. /**
  51536. * Adds the given reflection probe to this scene.
  51537. * @param newReflectionProbe The reflection probe to add
  51538. */
  51539. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51540. }
  51541. /**
  51542. * Class used to generate realtime reflection / refraction cube textures
  51543. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51544. */
  51545. export class ReflectionProbe {
  51546. /** defines the name of the probe */
  51547. name: string;
  51548. private _scene;
  51549. private _renderTargetTexture;
  51550. private _projectionMatrix;
  51551. private _viewMatrix;
  51552. private _target;
  51553. private _add;
  51554. private _attachedMesh;
  51555. private _invertYAxis;
  51556. /** Gets or sets probe position (center of the cube map) */
  51557. position: Vector3;
  51558. /**
  51559. * Creates a new reflection probe
  51560. * @param name defines the name of the probe
  51561. * @param size defines the texture resolution (for each face)
  51562. * @param scene defines the hosting scene
  51563. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51564. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51565. */
  51566. constructor(
  51567. /** defines the name of the probe */
  51568. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51569. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51570. samples: number;
  51571. /** Gets or sets the refresh rate to use (on every frame by default) */
  51572. refreshRate: number;
  51573. /**
  51574. * Gets the hosting scene
  51575. * @returns a Scene
  51576. */
  51577. getScene(): Scene;
  51578. /** Gets the internal CubeTexture used to render to */
  51579. readonly cubeTexture: RenderTargetTexture;
  51580. /** Gets the list of meshes to render */
  51581. readonly renderList: Nullable<AbstractMesh[]>;
  51582. /**
  51583. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51584. * @param mesh defines the mesh to attach to
  51585. */
  51586. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51587. /**
  51588. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51589. * @param renderingGroupId The rendering group id corresponding to its index
  51590. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51591. */
  51592. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51593. /**
  51594. * Clean all associated resources
  51595. */
  51596. dispose(): void;
  51597. /**
  51598. * Converts the reflection probe information to a readable string for debug purpose.
  51599. * @param fullDetails Supports for multiple levels of logging within scene loading
  51600. * @returns the human readable reflection probe info
  51601. */
  51602. toString(fullDetails?: boolean): string;
  51603. /**
  51604. * Get the class name of the relfection probe.
  51605. * @returns "ReflectionProbe"
  51606. */
  51607. getClassName(): string;
  51608. /**
  51609. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51610. * @returns The JSON representation of the texture
  51611. */
  51612. serialize(): any;
  51613. /**
  51614. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51615. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51616. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51617. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51618. * @returns The parsed reflection probe if successful
  51619. */
  51620. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51621. }
  51622. }
  51623. declare module BABYLON {
  51624. /** @hidden */
  51625. export var _BabylonLoaderRegistered: boolean;
  51626. }
  51627. declare module BABYLON {
  51628. /**
  51629. * The Physically based simple base material of BJS.
  51630. *
  51631. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51632. * It is used as the base class for both the specGloss and metalRough conventions.
  51633. */
  51634. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51635. /**
  51636. * Number of Simultaneous lights allowed on the material.
  51637. */
  51638. maxSimultaneousLights: number;
  51639. /**
  51640. * If sets to true, disables all the lights affecting the material.
  51641. */
  51642. disableLighting: boolean;
  51643. /**
  51644. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51645. */
  51646. environmentTexture: BaseTexture;
  51647. /**
  51648. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51649. */
  51650. invertNormalMapX: boolean;
  51651. /**
  51652. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51653. */
  51654. invertNormalMapY: boolean;
  51655. /**
  51656. * Normal map used in the model.
  51657. */
  51658. normalTexture: BaseTexture;
  51659. /**
  51660. * Emissivie color used to self-illuminate the model.
  51661. */
  51662. emissiveColor: Color3;
  51663. /**
  51664. * Emissivie texture used to self-illuminate the model.
  51665. */
  51666. emissiveTexture: BaseTexture;
  51667. /**
  51668. * Occlusion Channel Strenght.
  51669. */
  51670. occlusionStrength: number;
  51671. /**
  51672. * Occlusion Texture of the material (adding extra occlusion effects).
  51673. */
  51674. occlusionTexture: BaseTexture;
  51675. /**
  51676. * Defines the alpha limits in alpha test mode.
  51677. */
  51678. alphaCutOff: number;
  51679. /**
  51680. * Gets the current double sided mode.
  51681. */
  51682. /**
  51683. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51684. */
  51685. doubleSided: boolean;
  51686. /**
  51687. * Stores the pre-calculated light information of a mesh in a texture.
  51688. */
  51689. lightmapTexture: BaseTexture;
  51690. /**
  51691. * If true, the light map contains occlusion information instead of lighting info.
  51692. */
  51693. useLightmapAsShadowmap: boolean;
  51694. /**
  51695. * Instantiates a new PBRMaterial instance.
  51696. *
  51697. * @param name The material name
  51698. * @param scene The scene the material will be use in.
  51699. */
  51700. constructor(name: string, scene: Scene);
  51701. getClassName(): string;
  51702. }
  51703. }
  51704. declare module BABYLON {
  51705. /**
  51706. * The PBR material of BJS following the metal roughness convention.
  51707. *
  51708. * This fits to the PBR convention in the GLTF definition:
  51709. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51710. */
  51711. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51712. /**
  51713. * The base color has two different interpretations depending on the value of metalness.
  51714. * When the material is a metal, the base color is the specific measured reflectance value
  51715. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51716. * of the material.
  51717. */
  51718. baseColor: Color3;
  51719. /**
  51720. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51721. * well as opacity information in the alpha channel.
  51722. */
  51723. baseTexture: BaseTexture;
  51724. /**
  51725. * Specifies the metallic scalar value of the material.
  51726. * Can also be used to scale the metalness values of the metallic texture.
  51727. */
  51728. metallic: number;
  51729. /**
  51730. * Specifies the roughness scalar value of the material.
  51731. * Can also be used to scale the roughness values of the metallic texture.
  51732. */
  51733. roughness: number;
  51734. /**
  51735. * Texture containing both the metallic value in the B channel and the
  51736. * roughness value in the G channel to keep better precision.
  51737. */
  51738. metallicRoughnessTexture: BaseTexture;
  51739. /**
  51740. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51741. *
  51742. * @param name The material name
  51743. * @param scene The scene the material will be use in.
  51744. */
  51745. constructor(name: string, scene: Scene);
  51746. /**
  51747. * Return the currrent class name of the material.
  51748. */
  51749. getClassName(): string;
  51750. /**
  51751. * Makes a duplicate of the current material.
  51752. * @param name - name to use for the new material.
  51753. */
  51754. clone(name: string): PBRMetallicRoughnessMaterial;
  51755. /**
  51756. * Serialize the material to a parsable JSON object.
  51757. */
  51758. serialize(): any;
  51759. /**
  51760. * Parses a JSON object correponding to the serialize function.
  51761. */
  51762. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51763. }
  51764. }
  51765. declare module BABYLON {
  51766. /**
  51767. * The PBR material of BJS following the specular glossiness convention.
  51768. *
  51769. * This fits to the PBR convention in the GLTF definition:
  51770. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51771. */
  51772. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51773. /**
  51774. * Specifies the diffuse color of the material.
  51775. */
  51776. diffuseColor: Color3;
  51777. /**
  51778. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51779. * channel.
  51780. */
  51781. diffuseTexture: BaseTexture;
  51782. /**
  51783. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51784. */
  51785. specularColor: Color3;
  51786. /**
  51787. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51788. */
  51789. glossiness: number;
  51790. /**
  51791. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51792. */
  51793. specularGlossinessTexture: BaseTexture;
  51794. /**
  51795. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51796. *
  51797. * @param name The material name
  51798. * @param scene The scene the material will be use in.
  51799. */
  51800. constructor(name: string, scene: Scene);
  51801. /**
  51802. * Return the currrent class name of the material.
  51803. */
  51804. getClassName(): string;
  51805. /**
  51806. * Makes a duplicate of the current material.
  51807. * @param name - name to use for the new material.
  51808. */
  51809. clone(name: string): PBRSpecularGlossinessMaterial;
  51810. /**
  51811. * Serialize the material to a parsable JSON object.
  51812. */
  51813. serialize(): any;
  51814. /**
  51815. * Parses a JSON object correponding to the serialize function.
  51816. */
  51817. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51818. }
  51819. }
  51820. declare module BABYLON {
  51821. /**
  51822. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51823. * It can help converting any input color in a desired output one. This can then be used to create effects
  51824. * from sepia, black and white to sixties or futuristic rendering...
  51825. *
  51826. * The only supported format is currently 3dl.
  51827. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51828. */
  51829. export class ColorGradingTexture extends BaseTexture {
  51830. /**
  51831. * The current texture matrix. (will always be identity in color grading texture)
  51832. */
  51833. private _textureMatrix;
  51834. /**
  51835. * The texture URL.
  51836. */
  51837. url: string;
  51838. /**
  51839. * Empty line regex stored for GC.
  51840. */
  51841. private static _noneEmptyLineRegex;
  51842. private _engine;
  51843. /**
  51844. * Instantiates a ColorGradingTexture from the following parameters.
  51845. *
  51846. * @param url The location of the color gradind data (currently only supporting 3dl)
  51847. * @param scene The scene the texture will be used in
  51848. */
  51849. constructor(url: string, scene: Scene);
  51850. /**
  51851. * Returns the texture matrix used in most of the material.
  51852. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51853. */
  51854. getTextureMatrix(): Matrix;
  51855. /**
  51856. * Occurs when the file being loaded is a .3dl LUT file.
  51857. */
  51858. private load3dlTexture;
  51859. /**
  51860. * Starts the loading process of the texture.
  51861. */
  51862. private loadTexture;
  51863. /**
  51864. * Clones the color gradind texture.
  51865. */
  51866. clone(): ColorGradingTexture;
  51867. /**
  51868. * Called during delayed load for textures.
  51869. */
  51870. delayLoad(): void;
  51871. /**
  51872. * Parses a color grading texture serialized by Babylon.
  51873. * @param parsedTexture The texture information being parsedTexture
  51874. * @param scene The scene to load the texture in
  51875. * @param rootUrl The root url of the data assets to load
  51876. * @return A color gradind texture
  51877. */
  51878. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51879. /**
  51880. * Serializes the LUT texture to json format.
  51881. */
  51882. serialize(): any;
  51883. }
  51884. }
  51885. declare module BABYLON {
  51886. /**
  51887. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51888. */
  51889. export class EquiRectangularCubeTexture extends BaseTexture {
  51890. /** The six faces of the cube. */
  51891. private static _FacesMapping;
  51892. private _noMipmap;
  51893. private _onLoad;
  51894. private _onError;
  51895. /** The size of the cubemap. */
  51896. private _size;
  51897. /** The buffer of the image. */
  51898. private _buffer;
  51899. /** The width of the input image. */
  51900. private _width;
  51901. /** The height of the input image. */
  51902. private _height;
  51903. /** The URL to the image. */
  51904. url: string;
  51905. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51906. coordinatesMode: number;
  51907. /**
  51908. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51909. * @param url The location of the image
  51910. * @param scene The scene the texture will be used in
  51911. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51912. * @param noMipmap Forces to not generate the mipmap if true
  51913. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51914. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51915. * @param onLoad — defines a callback called when texture is loaded
  51916. * @param onError — defines a callback called if there is an error
  51917. */
  51918. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51919. /**
  51920. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51921. */
  51922. private loadImage;
  51923. /**
  51924. * Convert the image buffer into a cubemap and create a CubeTexture.
  51925. */
  51926. private loadTexture;
  51927. /**
  51928. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51929. * @param buffer The ArrayBuffer that should be converted.
  51930. * @returns The buffer as Float32Array.
  51931. */
  51932. private getFloat32ArrayFromArrayBuffer;
  51933. /**
  51934. * Get the current class name of the texture useful for serialization or dynamic coding.
  51935. * @returns "EquiRectangularCubeTexture"
  51936. */
  51937. getClassName(): string;
  51938. /**
  51939. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51940. * @returns A clone of the current EquiRectangularCubeTexture.
  51941. */
  51942. clone(): EquiRectangularCubeTexture;
  51943. }
  51944. }
  51945. declare module BABYLON {
  51946. /**
  51947. * Based on jsTGALoader - Javascript loader for TGA file
  51948. * By Vincent Thibault
  51949. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51950. */
  51951. export class TGATools {
  51952. private static _TYPE_INDEXED;
  51953. private static _TYPE_RGB;
  51954. private static _TYPE_GREY;
  51955. private static _TYPE_RLE_INDEXED;
  51956. private static _TYPE_RLE_RGB;
  51957. private static _TYPE_RLE_GREY;
  51958. private static _ORIGIN_MASK;
  51959. private static _ORIGIN_SHIFT;
  51960. private static _ORIGIN_BL;
  51961. private static _ORIGIN_BR;
  51962. private static _ORIGIN_UL;
  51963. private static _ORIGIN_UR;
  51964. /**
  51965. * Gets the header of a TGA file
  51966. * @param data defines the TGA data
  51967. * @returns the header
  51968. */
  51969. static GetTGAHeader(data: Uint8Array): any;
  51970. /**
  51971. * Uploads TGA content to a Babylon Texture
  51972. * @hidden
  51973. */
  51974. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51975. /** @hidden */
  51976. 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;
  51977. /** @hidden */
  51978. 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;
  51979. /** @hidden */
  51980. 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;
  51981. /** @hidden */
  51982. 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;
  51983. /** @hidden */
  51984. 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;
  51985. /** @hidden */
  51986. 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;
  51987. }
  51988. }
  51989. declare module BABYLON {
  51990. /**
  51991. * Implementation of the TGA Texture Loader.
  51992. * @hidden
  51993. */
  51994. export class _TGATextureLoader implements IInternalTextureLoader {
  51995. /**
  51996. * Defines wether the loader supports cascade loading the different faces.
  51997. */
  51998. readonly supportCascades: boolean;
  51999. /**
  52000. * This returns if the loader support the current file information.
  52001. * @param extension defines the file extension of the file being loaded
  52002. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52003. * @param fallback defines the fallback internal texture if any
  52004. * @param isBase64 defines whether the texture is encoded as a base64
  52005. * @param isBuffer defines whether the texture data are stored as a buffer
  52006. * @returns true if the loader can load the specified file
  52007. */
  52008. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52009. /**
  52010. * Transform the url before loading if required.
  52011. * @param rootUrl the url of the texture
  52012. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52013. * @returns the transformed texture
  52014. */
  52015. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52016. /**
  52017. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52018. * @param rootUrl the url of the texture
  52019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52020. * @returns the fallback texture
  52021. */
  52022. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52023. /**
  52024. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52025. * @param data contains the texture data
  52026. * @param texture defines the BabylonJS internal texture
  52027. * @param createPolynomials will be true if polynomials have been requested
  52028. * @param onLoad defines the callback to trigger once the texture is ready
  52029. * @param onError defines the callback to trigger in case of error
  52030. */
  52031. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52032. /**
  52033. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52034. * @param data contains the texture data
  52035. * @param texture defines the BabylonJS internal texture
  52036. * @param callback defines the method to call once ready to upload
  52037. */
  52038. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52039. }
  52040. }
  52041. declare module BABYLON {
  52042. /**
  52043. * Info about the .basis files
  52044. */
  52045. class BasisFileInfo {
  52046. /**
  52047. * If the file has alpha
  52048. */
  52049. hasAlpha: boolean;
  52050. /**
  52051. * Info about each image of the basis file
  52052. */
  52053. images: Array<{
  52054. levels: Array<{
  52055. width: number;
  52056. height: number;
  52057. transcodedPixels: ArrayBufferView;
  52058. }>;
  52059. }>;
  52060. }
  52061. /**
  52062. * Result of transcoding a basis file
  52063. */
  52064. class TranscodeResult {
  52065. /**
  52066. * Info about the .basis file
  52067. */
  52068. fileInfo: BasisFileInfo;
  52069. /**
  52070. * Format to use when loading the file
  52071. */
  52072. format: number;
  52073. }
  52074. /**
  52075. * Configuration options for the Basis transcoder
  52076. */
  52077. export class BasisTranscodeConfiguration {
  52078. /**
  52079. * Supported compression formats used to determine the supported output format of the transcoder
  52080. */
  52081. supportedCompressionFormats?: {
  52082. /**
  52083. * etc1 compression format
  52084. */
  52085. etc1?: boolean;
  52086. /**
  52087. * s3tc compression format
  52088. */
  52089. s3tc?: boolean;
  52090. /**
  52091. * pvrtc compression format
  52092. */
  52093. pvrtc?: boolean;
  52094. /**
  52095. * etc2 compression format
  52096. */
  52097. etc2?: boolean;
  52098. };
  52099. /**
  52100. * If mipmap levels should be loaded for transcoded images (Default: true)
  52101. */
  52102. loadMipmapLevels?: boolean;
  52103. /**
  52104. * Index of a single image to load (Default: all images)
  52105. */
  52106. loadSingleImage?: number;
  52107. }
  52108. /**
  52109. * Used to load .Basis files
  52110. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52111. */
  52112. export class BasisTools {
  52113. private static _IgnoreSupportedFormats;
  52114. /**
  52115. * URL to use when loading the basis transcoder
  52116. */
  52117. static JSModuleURL: string;
  52118. /**
  52119. * URL to use when loading the wasm module for the transcoder
  52120. */
  52121. static WasmModuleURL: string;
  52122. /**
  52123. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52124. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52125. * @returns internal format corresponding to the Basis format
  52126. */
  52127. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52128. private static _WorkerPromise;
  52129. private static _Worker;
  52130. private static _actionId;
  52131. private static _CreateWorkerAsync;
  52132. /**
  52133. * Transcodes a loaded image file to compressed pixel data
  52134. * @param imageData image data to transcode
  52135. * @param config configuration options for the transcoding
  52136. * @returns a promise resulting in the transcoded image
  52137. */
  52138. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52139. /**
  52140. * Loads a texture from the transcode result
  52141. * @param texture texture load to
  52142. * @param transcodeResult the result of transcoding the basis file to load from
  52143. */
  52144. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52145. }
  52146. }
  52147. declare module BABYLON {
  52148. /**
  52149. * Loader for .basis file format
  52150. */
  52151. export class _BasisTextureLoader implements IInternalTextureLoader {
  52152. /**
  52153. * Defines whether the loader supports cascade loading the different faces.
  52154. */
  52155. readonly supportCascades: boolean;
  52156. /**
  52157. * This returns if the loader support the current file information.
  52158. * @param extension defines the file extension of the file being loaded
  52159. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52160. * @param fallback defines the fallback internal texture if any
  52161. * @param isBase64 defines whether the texture is encoded as a base64
  52162. * @param isBuffer defines whether the texture data are stored as a buffer
  52163. * @returns true if the loader can load the specified file
  52164. */
  52165. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52166. /**
  52167. * Transform the url before loading if required.
  52168. * @param rootUrl the url of the texture
  52169. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52170. * @returns the transformed texture
  52171. */
  52172. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52173. /**
  52174. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52175. * @param rootUrl the url of the texture
  52176. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52177. * @returns the fallback texture
  52178. */
  52179. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52180. /**
  52181. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52182. * @param data contains the texture data
  52183. * @param texture defines the BabylonJS internal texture
  52184. * @param createPolynomials will be true if polynomials have been requested
  52185. * @param onLoad defines the callback to trigger once the texture is ready
  52186. * @param onError defines the callback to trigger in case of error
  52187. */
  52188. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52189. /**
  52190. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52191. * @param data contains the texture data
  52192. * @param texture defines the BabylonJS internal texture
  52193. * @param callback defines the method to call once ready to upload
  52194. */
  52195. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52196. }
  52197. }
  52198. declare module BABYLON {
  52199. /**
  52200. * 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.
  52201. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52202. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52203. */
  52204. export class CustomProceduralTexture extends ProceduralTexture {
  52205. private _animate;
  52206. private _time;
  52207. private _config;
  52208. private _texturePath;
  52209. /**
  52210. * Instantiates a new Custom Procedural Texture.
  52211. * 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.
  52212. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52213. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52214. * @param name Define the name of the texture
  52215. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52216. * @param size Define the size of the texture to create
  52217. * @param scene Define the scene the texture belongs to
  52218. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52219. * @param generateMipMaps Define if the texture should creates mip maps or not
  52220. */
  52221. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52222. private _loadJson;
  52223. /**
  52224. * Is the texture ready to be used ? (rendered at least once)
  52225. * @returns true if ready, otherwise, false.
  52226. */
  52227. isReady(): boolean;
  52228. /**
  52229. * Render the texture to its associated render target.
  52230. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52231. */
  52232. render(useCameraPostProcess?: boolean): void;
  52233. /**
  52234. * Update the list of dependant textures samplers in the shader.
  52235. */
  52236. updateTextures(): void;
  52237. /**
  52238. * Update the uniform values of the procedural texture in the shader.
  52239. */
  52240. updateShaderUniforms(): void;
  52241. /**
  52242. * Define if the texture animates or not.
  52243. */
  52244. animate: boolean;
  52245. }
  52246. }
  52247. declare module BABYLON {
  52248. /** @hidden */
  52249. export var noisePixelShader: {
  52250. name: string;
  52251. shader: string;
  52252. };
  52253. }
  52254. declare module BABYLON {
  52255. /**
  52256. * Class used to generate noise procedural textures
  52257. */
  52258. export class NoiseProceduralTexture extends ProceduralTexture {
  52259. private _time;
  52260. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52261. brightness: number;
  52262. /** Defines the number of octaves to process */
  52263. octaves: number;
  52264. /** Defines the level of persistence (0.8 by default) */
  52265. persistence: number;
  52266. /** Gets or sets animation speed factor (default is 1) */
  52267. animationSpeedFactor: number;
  52268. /**
  52269. * Creates a new NoiseProceduralTexture
  52270. * @param name defines the name fo the texture
  52271. * @param size defines the size of the texture (default is 256)
  52272. * @param scene defines the hosting scene
  52273. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52274. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52275. */
  52276. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52277. private _updateShaderUniforms;
  52278. protected _getDefines(): string;
  52279. /** Generate the current state of the procedural texture */
  52280. render(useCameraPostProcess?: boolean): void;
  52281. /**
  52282. * Serializes this noise procedural texture
  52283. * @returns a serialized noise procedural texture object
  52284. */
  52285. serialize(): any;
  52286. /**
  52287. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52288. * @param parsedTexture defines parsed texture data
  52289. * @param scene defines the current scene
  52290. * @param rootUrl defines the root URL containing noise procedural texture information
  52291. * @returns a parsed NoiseProceduralTexture
  52292. */
  52293. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52294. }
  52295. }
  52296. declare module BABYLON {
  52297. /**
  52298. * Raw cube texture where the raw buffers are passed in
  52299. */
  52300. export class RawCubeTexture extends CubeTexture {
  52301. /**
  52302. * Creates a cube texture where the raw buffers are passed in.
  52303. * @param scene defines the scene the texture is attached to
  52304. * @param data defines the array of data to use to create each face
  52305. * @param size defines the size of the textures
  52306. * @param format defines the format of the data
  52307. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52308. * @param generateMipMaps defines if the engine should generate the mip levels
  52309. * @param invertY defines if data must be stored with Y axis inverted
  52310. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52311. * @param compression defines the compression used (null by default)
  52312. */
  52313. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52314. /**
  52315. * Updates the raw cube texture.
  52316. * @param data defines the data to store
  52317. * @param format defines the data format
  52318. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52319. * @param invertY defines if data must be stored with Y axis inverted
  52320. * @param compression defines the compression used (null by default)
  52321. * @param level defines which level of the texture to update
  52322. */
  52323. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52324. /**
  52325. * Updates a raw cube texture with RGBD encoded data.
  52326. * @param data defines the array of data [mipmap][face] to use to create each face
  52327. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52328. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52329. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52330. * @returns a promsie that resolves when the operation is complete
  52331. */
  52332. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52333. /**
  52334. * Clones the raw cube texture.
  52335. * @return a new cube texture
  52336. */
  52337. clone(): CubeTexture;
  52338. /** @hidden */
  52339. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52340. }
  52341. }
  52342. declare module BABYLON {
  52343. /**
  52344. * Class used to store 3D textures containing user data
  52345. */
  52346. export class RawTexture3D extends Texture {
  52347. /** Gets or sets the texture format to use */
  52348. format: number;
  52349. private _engine;
  52350. /**
  52351. * Create a new RawTexture3D
  52352. * @param data defines the data of the texture
  52353. * @param width defines the width of the texture
  52354. * @param height defines the height of the texture
  52355. * @param depth defines the depth of the texture
  52356. * @param format defines the texture format to use
  52357. * @param scene defines the hosting scene
  52358. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52359. * @param invertY defines if texture must be stored with Y axis inverted
  52360. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52361. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52362. */
  52363. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52364. /** Gets or sets the texture format to use */
  52365. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52366. /**
  52367. * Update the texture with new data
  52368. * @param data defines the data to store in the texture
  52369. */
  52370. update(data: ArrayBufferView): void;
  52371. }
  52372. }
  52373. declare module BABYLON {
  52374. /**
  52375. * Creates a refraction texture used by refraction channel of the standard material.
  52376. * It is like a mirror but to see through a material.
  52377. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52378. */
  52379. export class RefractionTexture extends RenderTargetTexture {
  52380. /**
  52381. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52382. * 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.
  52383. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52384. */
  52385. refractionPlane: Plane;
  52386. /**
  52387. * Define how deep under the surface we should see.
  52388. */
  52389. depth: number;
  52390. /**
  52391. * Creates a refraction texture used by refraction channel of the standard material.
  52392. * It is like a mirror but to see through a material.
  52393. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52394. * @param name Define the texture name
  52395. * @param size Define the size of the underlying texture
  52396. * @param scene Define the scene the refraction belongs to
  52397. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52398. */
  52399. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52400. /**
  52401. * Clone the refraction texture.
  52402. * @returns the cloned texture
  52403. */
  52404. clone(): RefractionTexture;
  52405. /**
  52406. * Serialize the texture to a JSON representation you could use in Parse later on
  52407. * @returns the serialized JSON representation
  52408. */
  52409. serialize(): any;
  52410. }
  52411. }
  52412. declare module BABYLON {
  52413. /**
  52414. * Defines the options related to the creation of an HtmlElementTexture
  52415. */
  52416. export interface IHtmlElementTextureOptions {
  52417. /**
  52418. * Defines wether mip maps should be created or not.
  52419. */
  52420. generateMipMaps?: boolean;
  52421. /**
  52422. * Defines the sampling mode of the texture.
  52423. */
  52424. samplingMode?: number;
  52425. /**
  52426. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52427. */
  52428. engine: Nullable<Engine>;
  52429. /**
  52430. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52431. */
  52432. scene: Nullable<Scene>;
  52433. }
  52434. /**
  52435. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52436. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52437. * is automatically managed.
  52438. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52439. * in your application.
  52440. *
  52441. * As the update is not automatic, you need to call them manually.
  52442. */
  52443. export class HtmlElementTexture extends BaseTexture {
  52444. /**
  52445. * The texture URL.
  52446. */
  52447. element: HTMLVideoElement | HTMLCanvasElement;
  52448. private static readonly DefaultOptions;
  52449. private _textureMatrix;
  52450. private _engine;
  52451. private _isVideo;
  52452. private _generateMipMaps;
  52453. private _samplingMode;
  52454. /**
  52455. * Instantiates a HtmlElementTexture from the following parameters.
  52456. *
  52457. * @param name Defines the name of the texture
  52458. * @param element Defines the video or canvas the texture is filled with
  52459. * @param options Defines the other none mandatory texture creation options
  52460. */
  52461. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52462. private _createInternalTexture;
  52463. /**
  52464. * Returns the texture matrix used in most of the material.
  52465. */
  52466. getTextureMatrix(): Matrix;
  52467. /**
  52468. * Updates the content of the texture.
  52469. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52470. */
  52471. update(invertY?: Nullable<boolean>): void;
  52472. }
  52473. }
  52474. declare module BABYLON {
  52475. /**
  52476. * Enum used to define the target of a block
  52477. */
  52478. export enum NodeMaterialBlockTargets {
  52479. /** Vertex shader */
  52480. Vertex = 1,
  52481. /** Fragment shader */
  52482. Fragment = 2,
  52483. /** Neutral */
  52484. Neutral = 4,
  52485. /** Vertex and Fragment */
  52486. VertexAndFragment = 3
  52487. }
  52488. }
  52489. declare module BABYLON {
  52490. /**
  52491. * Defines the kind of connection point for node based material
  52492. */
  52493. export enum NodeMaterialBlockConnectionPointTypes {
  52494. /** Float */
  52495. Float = 1,
  52496. /** Int */
  52497. Int = 2,
  52498. /** Vector2 */
  52499. Vector2 = 4,
  52500. /** Vector3 */
  52501. Vector3 = 8,
  52502. /** Vector4 */
  52503. Vector4 = 16,
  52504. /** Color3 */
  52505. Color3 = 32,
  52506. /** Color4 */
  52507. Color4 = 64,
  52508. /** Matrix */
  52509. Matrix = 128,
  52510. /** Detect type based on connection */
  52511. AutoDetect = 1024,
  52512. /** Output type that will be defined by input type */
  52513. BasedOnInput = 2048
  52514. }
  52515. }
  52516. declare module BABYLON {
  52517. /**
  52518. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52519. */
  52520. export enum NodeMaterialBlockConnectionPointMode {
  52521. /** Value is an uniform */
  52522. Uniform = 0,
  52523. /** Value is a mesh attribute */
  52524. Attribute = 1,
  52525. /** Value is a varying between vertex and fragment shaders */
  52526. Varying = 2,
  52527. /** Mode is undefined */
  52528. Undefined = 3
  52529. }
  52530. }
  52531. declare module BABYLON {
  52532. /**
  52533. * Enum used to define system values e.g. values automatically provided by the system
  52534. */
  52535. export enum NodeMaterialSystemValues {
  52536. /** World */
  52537. World = 1,
  52538. /** View */
  52539. View = 2,
  52540. /** Projection */
  52541. Projection = 3,
  52542. /** ViewProjection */
  52543. ViewProjection = 4,
  52544. /** WorldView */
  52545. WorldView = 5,
  52546. /** WorldViewProjection */
  52547. WorldViewProjection = 6,
  52548. /** CameraPosition */
  52549. CameraPosition = 7,
  52550. /** Fog Color */
  52551. FogColor = 8,
  52552. /** Delta time */
  52553. DeltaTime = 9
  52554. }
  52555. }
  52556. declare module BABYLON {
  52557. /**
  52558. * Root class for all node material optimizers
  52559. */
  52560. export class NodeMaterialOptimizer {
  52561. /**
  52562. * Function used to optimize a NodeMaterial graph
  52563. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52564. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52565. */
  52566. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52567. }
  52568. }
  52569. declare module BABYLON {
  52570. /**
  52571. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52572. */
  52573. export class TransformBlock extends NodeMaterialBlock {
  52574. /**
  52575. * Defines the value to use to complement W value to transform it to a Vector4
  52576. */
  52577. complementW: number;
  52578. /**
  52579. * Defines the value to use to complement z value to transform it to a Vector4
  52580. */
  52581. complementZ: number;
  52582. /**
  52583. * Creates a new TransformBlock
  52584. * @param name defines the block name
  52585. */
  52586. constructor(name: string);
  52587. /**
  52588. * Gets the current class name
  52589. * @returns the class name
  52590. */
  52591. getClassName(): string;
  52592. /**
  52593. * Gets the vector input
  52594. */
  52595. readonly vector: NodeMaterialConnectionPoint;
  52596. /**
  52597. * Gets the output component
  52598. */
  52599. readonly output: NodeMaterialConnectionPoint;
  52600. /**
  52601. * Gets the matrix transform input
  52602. */
  52603. readonly transform: NodeMaterialConnectionPoint;
  52604. protected _buildBlock(state: NodeMaterialBuildState): this;
  52605. serialize(): any;
  52606. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52607. protected _dumpPropertiesCode(): string;
  52608. }
  52609. }
  52610. declare module BABYLON {
  52611. /**
  52612. * Block used to output the vertex position
  52613. */
  52614. export class VertexOutputBlock extends NodeMaterialBlock {
  52615. /**
  52616. * Creates a new VertexOutputBlock
  52617. * @param name defines the block name
  52618. */
  52619. constructor(name: string);
  52620. /**
  52621. * Gets the current class name
  52622. * @returns the class name
  52623. */
  52624. getClassName(): string;
  52625. /**
  52626. * Gets the vector input component
  52627. */
  52628. readonly vector: NodeMaterialConnectionPoint;
  52629. protected _buildBlock(state: NodeMaterialBuildState): this;
  52630. }
  52631. }
  52632. declare module BABYLON {
  52633. /**
  52634. * Block used to output the final color
  52635. */
  52636. export class FragmentOutputBlock extends NodeMaterialBlock {
  52637. /**
  52638. * Create a new FragmentOutputBlock
  52639. * @param name defines the block name
  52640. */
  52641. constructor(name: string);
  52642. /**
  52643. * Gets the current class name
  52644. * @returns the class name
  52645. */
  52646. getClassName(): string;
  52647. /**
  52648. * Gets the rgba input component
  52649. */
  52650. readonly rgba: NodeMaterialConnectionPoint;
  52651. /**
  52652. * Gets the rgb input component
  52653. */
  52654. readonly rgb: NodeMaterialConnectionPoint;
  52655. /**
  52656. * Gets the a input component
  52657. */
  52658. readonly a: NodeMaterialConnectionPoint;
  52659. protected _buildBlock(state: NodeMaterialBuildState): this;
  52660. }
  52661. }
  52662. declare module BABYLON {
  52663. /**
  52664. * Block used to read a reflection texture from a sampler
  52665. */
  52666. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52667. private _define3DName;
  52668. private _defineCubicName;
  52669. private _defineExplicitName;
  52670. private _defineProjectionName;
  52671. private _defineLocalCubicName;
  52672. private _defineSphericalName;
  52673. private _definePlanarName;
  52674. private _defineEquirectangularName;
  52675. private _defineMirroredEquirectangularFixedName;
  52676. private _defineEquirectangularFixedName;
  52677. private _defineSkyboxName;
  52678. private _cubeSamplerName;
  52679. private _2DSamplerName;
  52680. private _positionUVWName;
  52681. private _directionWName;
  52682. private _reflectionCoordsName;
  52683. private _reflection2DCoordsName;
  52684. private _reflectionColorName;
  52685. private _reflectionMatrixName;
  52686. /**
  52687. * Gets or sets the texture associated with the node
  52688. */
  52689. texture: Nullable<BaseTexture>;
  52690. /**
  52691. * Create a new TextureBlock
  52692. * @param name defines the block name
  52693. */
  52694. constructor(name: string);
  52695. /**
  52696. * Gets the current class name
  52697. * @returns the class name
  52698. */
  52699. getClassName(): string;
  52700. /**
  52701. * Gets the world position input component
  52702. */
  52703. readonly position: NodeMaterialConnectionPoint;
  52704. /**
  52705. * Gets the world position input component
  52706. */
  52707. readonly worldPosition: NodeMaterialConnectionPoint;
  52708. /**
  52709. * Gets the world normal input component
  52710. */
  52711. readonly worldNormal: NodeMaterialConnectionPoint;
  52712. /**
  52713. * Gets the world input component
  52714. */
  52715. readonly world: NodeMaterialConnectionPoint;
  52716. /**
  52717. * Gets the camera (or eye) position component
  52718. */
  52719. readonly cameraPosition: NodeMaterialConnectionPoint;
  52720. /**
  52721. * Gets the view input component
  52722. */
  52723. readonly view: NodeMaterialConnectionPoint;
  52724. /**
  52725. * Gets the rgb output component
  52726. */
  52727. readonly rgb: NodeMaterialConnectionPoint;
  52728. /**
  52729. * Gets the r output component
  52730. */
  52731. readonly r: NodeMaterialConnectionPoint;
  52732. /**
  52733. * Gets the g output component
  52734. */
  52735. readonly g: NodeMaterialConnectionPoint;
  52736. /**
  52737. * Gets the b output component
  52738. */
  52739. readonly b: NodeMaterialConnectionPoint;
  52740. autoConfigure(material: NodeMaterial): void;
  52741. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52742. isReady(): boolean;
  52743. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52744. private _injectVertexCode;
  52745. private _writeOutput;
  52746. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52747. serialize(): any;
  52748. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52749. }
  52750. }
  52751. declare module BABYLON {
  52752. /**
  52753. * Interface used to configure the node material editor
  52754. */
  52755. export interface INodeMaterialEditorOptions {
  52756. /** Define the URl to load node editor script */
  52757. editorURL?: string;
  52758. }
  52759. /** @hidden */
  52760. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52761. /** BONES */
  52762. NUM_BONE_INFLUENCERS: number;
  52763. BonesPerMesh: number;
  52764. BONETEXTURE: boolean;
  52765. /** MORPH TARGETS */
  52766. MORPHTARGETS: boolean;
  52767. MORPHTARGETS_NORMAL: boolean;
  52768. MORPHTARGETS_TANGENT: boolean;
  52769. MORPHTARGETS_UV: boolean;
  52770. NUM_MORPH_INFLUENCERS: number;
  52771. /** IMAGE PROCESSING */
  52772. IMAGEPROCESSING: boolean;
  52773. VIGNETTE: boolean;
  52774. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52775. VIGNETTEBLENDMODEOPAQUE: boolean;
  52776. TONEMAPPING: boolean;
  52777. TONEMAPPING_ACES: boolean;
  52778. CONTRAST: boolean;
  52779. EXPOSURE: boolean;
  52780. COLORCURVES: boolean;
  52781. COLORGRADING: boolean;
  52782. COLORGRADING3D: boolean;
  52783. SAMPLER3DGREENDEPTH: boolean;
  52784. SAMPLER3DBGRMAP: boolean;
  52785. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52786. /** MISC. */
  52787. BUMPDIRECTUV: number;
  52788. constructor();
  52789. setValue(name: string, value: boolean): void;
  52790. }
  52791. /**
  52792. * Class used to configure NodeMaterial
  52793. */
  52794. export interface INodeMaterialOptions {
  52795. /**
  52796. * Defines if blocks should emit comments
  52797. */
  52798. emitComments: boolean;
  52799. }
  52800. /**
  52801. * Class used to create a node based material built by assembling shader blocks
  52802. */
  52803. export class NodeMaterial extends PushMaterial {
  52804. private static _BuildIdGenerator;
  52805. private _options;
  52806. private _vertexCompilationState;
  52807. private _fragmentCompilationState;
  52808. private _sharedData;
  52809. private _buildId;
  52810. private _buildWasSuccessful;
  52811. private _cachedWorldViewMatrix;
  52812. private _cachedWorldViewProjectionMatrix;
  52813. private _optimizers;
  52814. private _animationFrame;
  52815. /** Define the URl to load node editor script */
  52816. static EditorURL: string;
  52817. private BJSNODEMATERIALEDITOR;
  52818. /** Get the inspector from bundle or global */
  52819. private _getGlobalNodeMaterialEditor;
  52820. /**
  52821. * 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)
  52822. */
  52823. ignoreAlpha: boolean;
  52824. /**
  52825. * Defines the maximum number of lights that can be used in the material
  52826. */
  52827. maxSimultaneousLights: number;
  52828. /**
  52829. * Observable raised when the material is built
  52830. */
  52831. onBuildObservable: Observable<NodeMaterial>;
  52832. /**
  52833. * Gets or sets the root nodes of the material vertex shader
  52834. */
  52835. _vertexOutputNodes: NodeMaterialBlock[];
  52836. /**
  52837. * Gets or sets the root nodes of the material fragment (pixel) shader
  52838. */
  52839. _fragmentOutputNodes: NodeMaterialBlock[];
  52840. /** Gets or sets options to control the node material overall behavior */
  52841. options: INodeMaterialOptions;
  52842. /**
  52843. * Default configuration related to image processing available in the standard Material.
  52844. */
  52845. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52846. /**
  52847. * Gets the image processing configuration used either in this material.
  52848. */
  52849. /**
  52850. * Sets the Default image processing configuration used either in the this material.
  52851. *
  52852. * If sets to null, the scene one is in use.
  52853. */
  52854. imageProcessingConfiguration: ImageProcessingConfiguration;
  52855. /**
  52856. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52857. */
  52858. attachedBlocks: NodeMaterialBlock[];
  52859. /**
  52860. * Create a new node based material
  52861. * @param name defines the material name
  52862. * @param scene defines the hosting scene
  52863. * @param options defines creation option
  52864. */
  52865. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52866. /**
  52867. * Gets the current class name of the material e.g. "NodeMaterial"
  52868. * @returns the class name
  52869. */
  52870. getClassName(): string;
  52871. /**
  52872. * Keep track of the image processing observer to allow dispose and replace.
  52873. */
  52874. private _imageProcessingObserver;
  52875. /**
  52876. * Attaches a new image processing configuration to the Standard Material.
  52877. * @param configuration
  52878. */
  52879. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52880. /**
  52881. * Get a block by its name
  52882. * @param name defines the name of the block to retrieve
  52883. * @returns the required block or null if not found
  52884. */
  52885. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52886. /**
  52887. * Get a block by its name
  52888. * @param predicate defines the predicate used to find the good candidate
  52889. * @returns the required block or null if not found
  52890. */
  52891. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52892. /**
  52893. * Get an input block by its name
  52894. * @param predicate defines the predicate used to find the good candidate
  52895. * @returns the required input block or null if not found
  52896. */
  52897. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52898. /**
  52899. * Gets the list of input blocks attached to this material
  52900. * @returns an array of InputBlocks
  52901. */
  52902. getInputBlocks(): InputBlock[];
  52903. /**
  52904. * Adds a new optimizer to the list of optimizers
  52905. * @param optimizer defines the optimizers to add
  52906. * @returns the current material
  52907. */
  52908. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52909. /**
  52910. * Remove an optimizer from the list of optimizers
  52911. * @param optimizer defines the optimizers to remove
  52912. * @returns the current material
  52913. */
  52914. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52915. /**
  52916. * Add a new block to the list of output nodes
  52917. * @param node defines the node to add
  52918. * @returns the current material
  52919. */
  52920. addOutputNode(node: NodeMaterialBlock): this;
  52921. /**
  52922. * Remove a block from the list of root nodes
  52923. * @param node defines the node to remove
  52924. * @returns the current material
  52925. */
  52926. removeOutputNode(node: NodeMaterialBlock): this;
  52927. private _addVertexOutputNode;
  52928. private _removeVertexOutputNode;
  52929. private _addFragmentOutputNode;
  52930. private _removeFragmentOutputNode;
  52931. /**
  52932. * Specifies if the material will require alpha blending
  52933. * @returns a boolean specifying if alpha blending is needed
  52934. */
  52935. needAlphaBlending(): boolean;
  52936. /**
  52937. * Specifies if this material should be rendered in alpha test mode
  52938. * @returns a boolean specifying if an alpha test is needed.
  52939. */
  52940. needAlphaTesting(): boolean;
  52941. private _initializeBlock;
  52942. private _resetDualBlocks;
  52943. /**
  52944. * Build the material and generates the inner effect
  52945. * @param verbose defines if the build should log activity
  52946. */
  52947. build(verbose?: boolean): void;
  52948. /**
  52949. * Runs an otpimization phase to try to improve the shader code
  52950. */
  52951. optimize(): void;
  52952. private _prepareDefinesForAttributes;
  52953. /**
  52954. * Get if the submesh is ready to be used and all its information available.
  52955. * Child classes can use it to update shaders
  52956. * @param mesh defines the mesh to check
  52957. * @param subMesh defines which submesh to check
  52958. * @param useInstances specifies that instances should be used
  52959. * @returns a boolean indicating that the submesh is ready or not
  52960. */
  52961. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52962. /**
  52963. * Get a string representing the shaders built by the current node graph
  52964. */
  52965. readonly compiledShaders: string;
  52966. /**
  52967. * Binds the world matrix to the material
  52968. * @param world defines the world transformation matrix
  52969. */
  52970. bindOnlyWorldMatrix(world: Matrix): void;
  52971. /**
  52972. * Binds the submesh to this material by preparing the effect and shader to draw
  52973. * @param world defines the world transformation matrix
  52974. * @param mesh defines the mesh containing the submesh
  52975. * @param subMesh defines the submesh to bind the material to
  52976. */
  52977. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52978. /**
  52979. * Gets the active textures from the material
  52980. * @returns an array of textures
  52981. */
  52982. getActiveTextures(): BaseTexture[];
  52983. /**
  52984. * Gets the list of texture blocks
  52985. * @returns an array of texture blocks
  52986. */
  52987. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52988. /**
  52989. * Specifies if the material uses a texture
  52990. * @param texture defines the texture to check against the material
  52991. * @returns a boolean specifying if the material uses the texture
  52992. */
  52993. hasTexture(texture: BaseTexture): boolean;
  52994. /**
  52995. * Disposes the material
  52996. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52997. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52998. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52999. */
  53000. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53001. /** Creates the node editor window. */
  53002. private _createNodeEditor;
  53003. /**
  53004. * Launch the node material editor
  53005. * @param config Define the configuration of the editor
  53006. * @return a promise fulfilled when the node editor is visible
  53007. */
  53008. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53009. /**
  53010. * Clear the current material
  53011. */
  53012. clear(): void;
  53013. /**
  53014. * Clear the current material and set it to a default state
  53015. */
  53016. setToDefault(): void;
  53017. /**
  53018. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53019. * @param url defines the url to load from
  53020. * @returns a promise that will fullfil when the material is fully loaded
  53021. */
  53022. loadAsync(url: string): Promise<unknown>;
  53023. private _gatherBlocks;
  53024. /**
  53025. * Generate a string containing the code declaration required to create an equivalent of this material
  53026. * @returns a string
  53027. */
  53028. generateCode(): string;
  53029. /**
  53030. * Serializes this material in a JSON representation
  53031. * @returns the serialized material object
  53032. */
  53033. serialize(): any;
  53034. private _restoreConnections;
  53035. /**
  53036. * Clear the current graph and load a new one from a serialization object
  53037. * @param source defines the JSON representation of the material
  53038. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53039. */
  53040. loadFromSerialization(source: any, rootUrl?: string): void;
  53041. /**
  53042. * Creates a node material from parsed material data
  53043. * @param source defines the JSON representation of the material
  53044. * @param scene defines the hosting scene
  53045. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53046. * @returns a new node material
  53047. */
  53048. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53049. /**
  53050. * Creates a new node material set to default basic configuration
  53051. * @param name defines the name of the material
  53052. * @param scene defines the hosting scene
  53053. * @returns a new NodeMaterial
  53054. */
  53055. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53056. }
  53057. }
  53058. declare module BABYLON {
  53059. /**
  53060. * Block used to read a texture from a sampler
  53061. */
  53062. export class TextureBlock extends NodeMaterialBlock {
  53063. private _defineName;
  53064. private _linearDefineName;
  53065. private _samplerName;
  53066. private _transformedUVName;
  53067. private _textureTransformName;
  53068. private _textureInfoName;
  53069. private _mainUVName;
  53070. private _mainUVDefineName;
  53071. /**
  53072. * Gets or sets the texture associated with the node
  53073. */
  53074. texture: Nullable<Texture>;
  53075. /**
  53076. * Create a new TextureBlock
  53077. * @param name defines the block name
  53078. */
  53079. constructor(name: string);
  53080. /**
  53081. * Gets the current class name
  53082. * @returns the class name
  53083. */
  53084. getClassName(): string;
  53085. /**
  53086. * Gets the uv input component
  53087. */
  53088. readonly uv: NodeMaterialConnectionPoint;
  53089. /**
  53090. * Gets the rgba output component
  53091. */
  53092. readonly rgba: NodeMaterialConnectionPoint;
  53093. /**
  53094. * Gets the rgb output component
  53095. */
  53096. readonly rgb: NodeMaterialConnectionPoint;
  53097. /**
  53098. * Gets the r output component
  53099. */
  53100. readonly r: NodeMaterialConnectionPoint;
  53101. /**
  53102. * Gets the g output component
  53103. */
  53104. readonly g: NodeMaterialConnectionPoint;
  53105. /**
  53106. * Gets the b output component
  53107. */
  53108. readonly b: NodeMaterialConnectionPoint;
  53109. /**
  53110. * Gets the a output component
  53111. */
  53112. readonly a: NodeMaterialConnectionPoint;
  53113. readonly target: NodeMaterialBlockTargets;
  53114. autoConfigure(material: NodeMaterial): void;
  53115. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53116. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53117. isReady(): boolean;
  53118. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53119. private readonly _isMixed;
  53120. private _injectVertexCode;
  53121. private _writeOutput;
  53122. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53123. protected _dumpPropertiesCode(): string;
  53124. serialize(): any;
  53125. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53126. }
  53127. }
  53128. declare module BABYLON {
  53129. /**
  53130. * Class used to store shared data between 2 NodeMaterialBuildState
  53131. */
  53132. export class NodeMaterialBuildStateSharedData {
  53133. /**
  53134. * Gets the list of emitted varyings
  53135. */
  53136. temps: string[];
  53137. /**
  53138. * Gets the list of emitted varyings
  53139. */
  53140. varyings: string[];
  53141. /**
  53142. * Gets the varying declaration string
  53143. */
  53144. varyingDeclaration: string;
  53145. /**
  53146. * Input blocks
  53147. */
  53148. inputBlocks: InputBlock[];
  53149. /**
  53150. * Input blocks
  53151. */
  53152. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53153. /**
  53154. * Bindable blocks (Blocks that need to set data to the effect)
  53155. */
  53156. bindableBlocks: NodeMaterialBlock[];
  53157. /**
  53158. * List of blocks that can provide a compilation fallback
  53159. */
  53160. blocksWithFallbacks: NodeMaterialBlock[];
  53161. /**
  53162. * List of blocks that can provide a define update
  53163. */
  53164. blocksWithDefines: NodeMaterialBlock[];
  53165. /**
  53166. * List of blocks that can provide a repeatable content
  53167. */
  53168. repeatableContentBlocks: NodeMaterialBlock[];
  53169. /**
  53170. * List of blocks that can provide a dynamic list of uniforms
  53171. */
  53172. dynamicUniformBlocks: NodeMaterialBlock[];
  53173. /**
  53174. * List of blocks that can block the isReady function for the material
  53175. */
  53176. blockingBlocks: NodeMaterialBlock[];
  53177. /**
  53178. * Gets the list of animated inputs
  53179. */
  53180. animatedInputs: InputBlock[];
  53181. /**
  53182. * Build Id used to avoid multiple recompilations
  53183. */
  53184. buildId: number;
  53185. /** List of emitted variables */
  53186. variableNames: {
  53187. [key: string]: number;
  53188. };
  53189. /** List of emitted defines */
  53190. defineNames: {
  53191. [key: string]: number;
  53192. };
  53193. /** Should emit comments? */
  53194. emitComments: boolean;
  53195. /** Emit build activity */
  53196. verbose: boolean;
  53197. /** Gets or sets the hosting scene */
  53198. scene: Scene;
  53199. /**
  53200. * Gets the compilation hints emitted at compilation time
  53201. */
  53202. hints: {
  53203. needWorldViewMatrix: boolean;
  53204. needWorldViewProjectionMatrix: boolean;
  53205. needAlphaBlending: boolean;
  53206. needAlphaTesting: boolean;
  53207. };
  53208. /**
  53209. * List of compilation checks
  53210. */
  53211. checks: {
  53212. emitVertex: boolean;
  53213. emitFragment: boolean;
  53214. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53215. };
  53216. /** Creates a new shared data */
  53217. constructor();
  53218. /**
  53219. * Emits console errors and exceptions if there is a failing check
  53220. */
  53221. emitErrors(): void;
  53222. }
  53223. }
  53224. declare module BABYLON {
  53225. /**
  53226. * Class used to store node based material build state
  53227. */
  53228. export class NodeMaterialBuildState {
  53229. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53230. supportUniformBuffers: boolean;
  53231. /**
  53232. * Gets the list of emitted attributes
  53233. */
  53234. attributes: string[];
  53235. /**
  53236. * Gets the list of emitted uniforms
  53237. */
  53238. uniforms: string[];
  53239. /**
  53240. * Gets the list of emitted constants
  53241. */
  53242. constants: string[];
  53243. /**
  53244. * Gets the list of emitted uniform buffers
  53245. */
  53246. uniformBuffers: string[];
  53247. /**
  53248. * Gets the list of emitted samplers
  53249. */
  53250. samplers: string[];
  53251. /**
  53252. * Gets the list of emitted functions
  53253. */
  53254. functions: {
  53255. [key: string]: string;
  53256. };
  53257. /**
  53258. * Gets the list of emitted extensions
  53259. */
  53260. extensions: {
  53261. [key: string]: string;
  53262. };
  53263. /**
  53264. * Gets the target of the compilation state
  53265. */
  53266. target: NodeMaterialBlockTargets;
  53267. /**
  53268. * Gets the list of emitted counters
  53269. */
  53270. counters: {
  53271. [key: string]: number;
  53272. };
  53273. /**
  53274. * Shared data between multiple NodeMaterialBuildState instances
  53275. */
  53276. sharedData: NodeMaterialBuildStateSharedData;
  53277. /** @hidden */
  53278. _vertexState: NodeMaterialBuildState;
  53279. /** @hidden */
  53280. _attributeDeclaration: string;
  53281. /** @hidden */
  53282. _uniformDeclaration: string;
  53283. /** @hidden */
  53284. _constantDeclaration: string;
  53285. /** @hidden */
  53286. _samplerDeclaration: string;
  53287. /** @hidden */
  53288. _varyingTransfer: string;
  53289. private _repeatableContentAnchorIndex;
  53290. /** @hidden */
  53291. _builtCompilationString: string;
  53292. /**
  53293. * Gets the emitted compilation strings
  53294. */
  53295. compilationString: string;
  53296. /**
  53297. * Finalize the compilation strings
  53298. * @param state defines the current compilation state
  53299. */
  53300. finalize(state: NodeMaterialBuildState): void;
  53301. /** @hidden */
  53302. readonly _repeatableContentAnchor: string;
  53303. /** @hidden */
  53304. _getFreeVariableName(prefix: string): string;
  53305. /** @hidden */
  53306. _getFreeDefineName(prefix: string): string;
  53307. /** @hidden */
  53308. _excludeVariableName(name: string): void;
  53309. /** @hidden */
  53310. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53311. /** @hidden */
  53312. _emitExtension(name: string, extension: string): void;
  53313. /** @hidden */
  53314. _emitFunction(name: string, code: string, comments: string): void;
  53315. /** @hidden */
  53316. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53317. replaceStrings?: {
  53318. search: RegExp;
  53319. replace: string;
  53320. }[];
  53321. repeatKey?: string;
  53322. }): string;
  53323. /** @hidden */
  53324. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53325. repeatKey?: string;
  53326. removeAttributes?: boolean;
  53327. removeUniforms?: boolean;
  53328. removeVaryings?: boolean;
  53329. removeIfDef?: boolean;
  53330. replaceStrings?: {
  53331. search: RegExp;
  53332. replace: string;
  53333. }[];
  53334. }, storeKey?: string): void;
  53335. /** @hidden */
  53336. _registerTempVariable(name: string): boolean;
  53337. /** @hidden */
  53338. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53339. /** @hidden */
  53340. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53341. /** @hidden */
  53342. _emitFloat(value: number): string;
  53343. }
  53344. }
  53345. declare module BABYLON {
  53346. /**
  53347. * Defines a block that can be used inside a node based material
  53348. */
  53349. export class NodeMaterialBlock {
  53350. private _buildId;
  53351. private _buildTarget;
  53352. private _target;
  53353. private _isFinalMerger;
  53354. private _isInput;
  53355. /** @hidden */
  53356. _codeVariableName: string;
  53357. /** @hidden */
  53358. _inputs: NodeMaterialConnectionPoint[];
  53359. /** @hidden */
  53360. _outputs: NodeMaterialConnectionPoint[];
  53361. /** @hidden */
  53362. _preparationId: number;
  53363. /**
  53364. * Gets or sets the name of the block
  53365. */
  53366. name: string;
  53367. /**
  53368. * Gets or sets the unique id of the node
  53369. */
  53370. uniqueId: number;
  53371. /**
  53372. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53373. */
  53374. readonly isFinalMerger: boolean;
  53375. /**
  53376. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53377. */
  53378. readonly isInput: boolean;
  53379. /**
  53380. * Gets or sets the build Id
  53381. */
  53382. buildId: number;
  53383. /**
  53384. * Gets or sets the target of the block
  53385. */
  53386. target: NodeMaterialBlockTargets;
  53387. /**
  53388. * Gets the list of input points
  53389. */
  53390. readonly inputs: NodeMaterialConnectionPoint[];
  53391. /** Gets the list of output points */
  53392. readonly outputs: NodeMaterialConnectionPoint[];
  53393. /**
  53394. * Find an input by its name
  53395. * @param name defines the name of the input to look for
  53396. * @returns the input or null if not found
  53397. */
  53398. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53399. /**
  53400. * Find an output by its name
  53401. * @param name defines the name of the outputto look for
  53402. * @returns the output or null if not found
  53403. */
  53404. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53405. /**
  53406. * Creates a new NodeMaterialBlock
  53407. * @param name defines the block name
  53408. * @param target defines the target of that block (Vertex by default)
  53409. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53410. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53411. */
  53412. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53413. /**
  53414. * Initialize the block and prepare the context for build
  53415. * @param state defines the state that will be used for the build
  53416. */
  53417. initialize(state: NodeMaterialBuildState): void;
  53418. /**
  53419. * Bind data to effect. Will only be called for blocks with isBindable === true
  53420. * @param effect defines the effect to bind data to
  53421. * @param nodeMaterial defines the hosting NodeMaterial
  53422. * @param mesh defines the mesh that will be rendered
  53423. */
  53424. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53425. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53426. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53427. protected _writeFloat(value: number): string;
  53428. /**
  53429. * Gets the current class name e.g. "NodeMaterialBlock"
  53430. * @returns the class name
  53431. */
  53432. getClassName(): string;
  53433. /**
  53434. * Register a new input. Must be called inside a block constructor
  53435. * @param name defines the connection point name
  53436. * @param type defines the connection point type
  53437. * @param isOptional defines a boolean indicating that this input can be omitted
  53438. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53439. * @returns the current block
  53440. */
  53441. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53442. /**
  53443. * Register a new output. Must be called inside a block constructor
  53444. * @param name defines the connection point name
  53445. * @param type defines the connection point type
  53446. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53447. * @returns the current block
  53448. */
  53449. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53450. /**
  53451. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53452. * @param forOutput defines an optional connection point to check compatibility with
  53453. * @returns the first available input or null
  53454. */
  53455. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53456. /**
  53457. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53458. * @param forBlock defines an optional block to check compatibility with
  53459. * @returns the first available input or null
  53460. */
  53461. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53462. /**
  53463. * Gets the sibling of the given output
  53464. * @param current defines the current output
  53465. * @returns the next output in the list or null
  53466. */
  53467. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53468. /**
  53469. * Connect current block with another block
  53470. * @param other defines the block to connect with
  53471. * @param options define the various options to help pick the right connections
  53472. * @returns the current block
  53473. */
  53474. connectTo(other: NodeMaterialBlock, options?: {
  53475. input?: string;
  53476. output?: string;
  53477. outputSwizzle?: string;
  53478. }): this | undefined;
  53479. protected _buildBlock(state: NodeMaterialBuildState): void;
  53480. /**
  53481. * Add uniforms, samplers and uniform buffers at compilation time
  53482. * @param state defines the state to update
  53483. * @param nodeMaterial defines the node material requesting the update
  53484. * @param defines defines the material defines to update
  53485. */
  53486. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53487. /**
  53488. * Add potential fallbacks if shader compilation fails
  53489. * @param mesh defines the mesh to be rendered
  53490. * @param fallbacks defines the current prioritized list of fallbacks
  53491. */
  53492. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53493. /**
  53494. * Initialize defines for shader compilation
  53495. * @param mesh defines the mesh to be rendered
  53496. * @param nodeMaterial defines the node material requesting the update
  53497. * @param defines defines the material defines to update
  53498. * @param useInstances specifies that instances should be used
  53499. */
  53500. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53501. /**
  53502. * Update defines for shader compilation
  53503. * @param mesh defines the mesh to be rendered
  53504. * @param nodeMaterial defines the node material requesting the update
  53505. * @param defines defines the material defines to update
  53506. * @param useInstances specifies that instances should be used
  53507. */
  53508. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53509. /**
  53510. * Lets the block try to connect some inputs automatically
  53511. * @param material defines the hosting NodeMaterial
  53512. */
  53513. autoConfigure(material: NodeMaterial): void;
  53514. /**
  53515. * Function called when a block is declared as repeatable content generator
  53516. * @param vertexShaderState defines the current compilation state for the vertex shader
  53517. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53518. * @param mesh defines the mesh to be rendered
  53519. * @param defines defines the material defines to update
  53520. */
  53521. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53522. /**
  53523. * Checks if the block is ready
  53524. * @param mesh defines the mesh to be rendered
  53525. * @param nodeMaterial defines the node material requesting the update
  53526. * @param defines defines the material defines to update
  53527. * @param useInstances specifies that instances should be used
  53528. * @returns true if the block is ready
  53529. */
  53530. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53531. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53532. private _processBuild;
  53533. /**
  53534. * Compile the current node and generate the shader code
  53535. * @param state defines the current compilation state (uniforms, samplers, current string)
  53536. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53537. * @returns true if already built
  53538. */
  53539. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53540. protected _inputRename(name: string): string;
  53541. protected _outputRename(name: string): string;
  53542. protected _dumpPropertiesCode(): string;
  53543. /** @hidden */
  53544. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53545. /**
  53546. * Clone the current block to a new identical block
  53547. * @param scene defines the hosting scene
  53548. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53549. * @returns a copy of the current block
  53550. */
  53551. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53552. /**
  53553. * Serializes this block in a JSON representation
  53554. * @returns the serialized block object
  53555. */
  53556. serialize(): any;
  53557. /** @hidden */
  53558. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53559. }
  53560. }
  53561. declare module BABYLON {
  53562. /**
  53563. * Enum defining the type of animations supported by InputBlock
  53564. */
  53565. export enum AnimatedInputBlockTypes {
  53566. /** No animation */
  53567. None = 0,
  53568. /** Time based animation. Will only work for floats */
  53569. Time = 1
  53570. }
  53571. }
  53572. declare module BABYLON {
  53573. /**
  53574. * Block used to expose an input value
  53575. */
  53576. export class InputBlock extends NodeMaterialBlock {
  53577. private _mode;
  53578. private _associatedVariableName;
  53579. private _storedValue;
  53580. private _valueCallback;
  53581. private _type;
  53582. private _animationType;
  53583. /** Gets or set a value used to limit the range of float values */
  53584. min: number;
  53585. /** Gets or set a value used to limit the range of float values */
  53586. max: number;
  53587. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53588. matrixMode: number;
  53589. /** @hidden */
  53590. _systemValue: Nullable<NodeMaterialSystemValues>;
  53591. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53592. visibleInInspector: boolean;
  53593. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53594. isConstant: boolean;
  53595. /**
  53596. * Gets or sets the connection point type (default is float)
  53597. */
  53598. readonly type: NodeMaterialBlockConnectionPointTypes;
  53599. /**
  53600. * Creates a new InputBlock
  53601. * @param name defines the block name
  53602. * @param target defines the target of that block (Vertex by default)
  53603. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53604. */
  53605. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53606. /**
  53607. * Gets the output component
  53608. */
  53609. readonly output: NodeMaterialConnectionPoint;
  53610. /**
  53611. * Set the source of this connection point to a vertex attribute
  53612. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53613. * @returns the current connection point
  53614. */
  53615. setAsAttribute(attributeName?: string): InputBlock;
  53616. /**
  53617. * Set the source of this connection point to a system value
  53618. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53619. * @returns the current connection point
  53620. */
  53621. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53622. /**
  53623. * Gets or sets the value of that point.
  53624. * Please note that this value will be ignored if valueCallback is defined
  53625. */
  53626. value: any;
  53627. /**
  53628. * Gets or sets a callback used to get the value of that point.
  53629. * Please note that setting this value will force the connection point to ignore the value property
  53630. */
  53631. valueCallback: () => any;
  53632. /**
  53633. * Gets or sets the associated variable name in the shader
  53634. */
  53635. associatedVariableName: string;
  53636. /** Gets or sets the type of animation applied to the input */
  53637. animationType: AnimatedInputBlockTypes;
  53638. /**
  53639. * Gets a boolean indicating that this connection point not defined yet
  53640. */
  53641. readonly isUndefined: boolean;
  53642. /**
  53643. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53644. * In this case the connection point name must be the name of the uniform to use.
  53645. * Can only be set on inputs
  53646. */
  53647. isUniform: boolean;
  53648. /**
  53649. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53650. * In this case the connection point name must be the name of the attribute to use
  53651. * Can only be set on inputs
  53652. */
  53653. isAttribute: boolean;
  53654. /**
  53655. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53656. * Can only be set on exit points
  53657. */
  53658. isVarying: boolean;
  53659. /**
  53660. * Gets a boolean indicating that the current connection point is a system value
  53661. */
  53662. readonly isSystemValue: boolean;
  53663. /**
  53664. * Gets or sets the current well known value or null if not defined as a system value
  53665. */
  53666. systemValue: Nullable<NodeMaterialSystemValues>;
  53667. /**
  53668. * Gets the current class name
  53669. * @returns the class name
  53670. */
  53671. getClassName(): string;
  53672. /**
  53673. * Animate the input if animationType !== None
  53674. * @param scene defines the rendering scene
  53675. */
  53676. animate(scene: Scene): void;
  53677. private _emitDefine;
  53678. initialize(state: NodeMaterialBuildState): void;
  53679. /**
  53680. * Set the input block to its default value (based on its type)
  53681. */
  53682. setDefaultValue(): void;
  53683. private _emitConstant;
  53684. private _emit;
  53685. /** @hidden */
  53686. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53687. /** @hidden */
  53688. _transmit(effect: Effect, scene: Scene): void;
  53689. protected _buildBlock(state: NodeMaterialBuildState): void;
  53690. protected _dumpPropertiesCode(): string;
  53691. serialize(): any;
  53692. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53693. }
  53694. }
  53695. declare module BABYLON {
  53696. /**
  53697. * Defines a connection point for a block
  53698. */
  53699. export class NodeMaterialConnectionPoint {
  53700. /** @hidden */
  53701. _ownerBlock: NodeMaterialBlock;
  53702. /** @hidden */
  53703. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53704. private _endpoints;
  53705. private _associatedVariableName;
  53706. /** @hidden */
  53707. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53708. /** @hidden */
  53709. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53710. private _type;
  53711. /** @hidden */
  53712. _enforceAssociatedVariableName: boolean;
  53713. /**
  53714. * Gets or sets the additional types supported by this connection point
  53715. */
  53716. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53717. /**
  53718. * Gets or sets the additional types excluded by this connection point
  53719. */
  53720. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53721. /**
  53722. * Gets or sets the associated variable name in the shader
  53723. */
  53724. associatedVariableName: string;
  53725. /**
  53726. * Gets or sets the connection point type (default is float)
  53727. */
  53728. type: NodeMaterialBlockConnectionPointTypes;
  53729. /**
  53730. * Gets or sets the connection point name
  53731. */
  53732. name: string;
  53733. /**
  53734. * Gets or sets a boolean indicating that this connection point can be omitted
  53735. */
  53736. isOptional: boolean;
  53737. /**
  53738. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53739. */
  53740. define: string;
  53741. /** Gets or sets the target of that connection point */
  53742. target: NodeMaterialBlockTargets;
  53743. /**
  53744. * Gets a boolean indicating that the current point is connected
  53745. */
  53746. readonly isConnected: boolean;
  53747. /**
  53748. * Gets a boolean indicating that the current point is connected to an input block
  53749. */
  53750. readonly isConnectedToInputBlock: boolean;
  53751. /**
  53752. * Gets a the connected input block (if any)
  53753. */
  53754. readonly connectInputBlock: Nullable<InputBlock>;
  53755. /** Get the other side of the connection (if any) */
  53756. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53757. /** Get the block that owns this connection point */
  53758. readonly ownerBlock: NodeMaterialBlock;
  53759. /** Get the block connected on the other side of this connection (if any) */
  53760. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53761. /** Get the block connected on the endpoints of this connection (if any) */
  53762. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53763. /** Gets the list of connected endpoints */
  53764. readonly endpoints: NodeMaterialConnectionPoint[];
  53765. /** Gets a boolean indicating if that output point is connected to at least one input */
  53766. readonly hasEndpoints: boolean;
  53767. /**
  53768. * Creates a new connection point
  53769. * @param name defines the connection point name
  53770. * @param ownerBlock defines the block hosting this connection point
  53771. */
  53772. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53773. /**
  53774. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53775. * @returns the class name
  53776. */
  53777. getClassName(): string;
  53778. /**
  53779. * Gets an boolean indicating if the current point can be connected to another point
  53780. * @param connectionPoint defines the other connection point
  53781. * @returns true if the connection is possible
  53782. */
  53783. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53784. /**
  53785. * Connect this point to another connection point
  53786. * @param connectionPoint defines the other connection point
  53787. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53788. * @returns the current connection point
  53789. */
  53790. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53791. /**
  53792. * Disconnect this point from one of his endpoint
  53793. * @param endpoint defines the other connection point
  53794. * @returns the current connection point
  53795. */
  53796. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53797. /**
  53798. * Serializes this point in a JSON representation
  53799. * @returns the serialized point object
  53800. */
  53801. serialize(): any;
  53802. }
  53803. }
  53804. declare module BABYLON {
  53805. /**
  53806. * Block used to add support for vertex skinning (bones)
  53807. */
  53808. export class BonesBlock extends NodeMaterialBlock {
  53809. /**
  53810. * Creates a new BonesBlock
  53811. * @param name defines the block name
  53812. */
  53813. constructor(name: string);
  53814. /**
  53815. * Initialize the block and prepare the context for build
  53816. * @param state defines the state that will be used for the build
  53817. */
  53818. initialize(state: NodeMaterialBuildState): void;
  53819. /**
  53820. * Gets the current class name
  53821. * @returns the class name
  53822. */
  53823. getClassName(): string;
  53824. /**
  53825. * Gets the matrix indices input component
  53826. */
  53827. readonly matricesIndices: NodeMaterialConnectionPoint;
  53828. /**
  53829. * Gets the matrix weights input component
  53830. */
  53831. readonly matricesWeights: NodeMaterialConnectionPoint;
  53832. /**
  53833. * Gets the extra matrix indices input component
  53834. */
  53835. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53836. /**
  53837. * Gets the extra matrix weights input component
  53838. */
  53839. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53840. /**
  53841. * Gets the world input component
  53842. */
  53843. readonly world: NodeMaterialConnectionPoint;
  53844. /**
  53845. * Gets the output component
  53846. */
  53847. readonly output: NodeMaterialConnectionPoint;
  53848. autoConfigure(material: NodeMaterial): void;
  53849. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53850. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53851. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53852. protected _buildBlock(state: NodeMaterialBuildState): this;
  53853. }
  53854. }
  53855. declare module BABYLON {
  53856. /**
  53857. * Block used to add support for instances
  53858. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53859. */
  53860. export class InstancesBlock extends NodeMaterialBlock {
  53861. /**
  53862. * Creates a new InstancesBlock
  53863. * @param name defines the block name
  53864. */
  53865. constructor(name: string);
  53866. /**
  53867. * Gets the current class name
  53868. * @returns the class name
  53869. */
  53870. getClassName(): string;
  53871. /**
  53872. * Gets the first world row input component
  53873. */
  53874. readonly world0: NodeMaterialConnectionPoint;
  53875. /**
  53876. * Gets the second world row input component
  53877. */
  53878. readonly world1: NodeMaterialConnectionPoint;
  53879. /**
  53880. * Gets the third world row input component
  53881. */
  53882. readonly world2: NodeMaterialConnectionPoint;
  53883. /**
  53884. * Gets the forth world row input component
  53885. */
  53886. readonly world3: NodeMaterialConnectionPoint;
  53887. /**
  53888. * Gets the world input component
  53889. */
  53890. readonly world: NodeMaterialConnectionPoint;
  53891. /**
  53892. * Gets the output component
  53893. */
  53894. readonly output: NodeMaterialConnectionPoint;
  53895. autoConfigure(material: NodeMaterial): void;
  53896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53897. protected _buildBlock(state: NodeMaterialBuildState): this;
  53898. }
  53899. }
  53900. declare module BABYLON {
  53901. /**
  53902. * Block used to add morph targets support to vertex shader
  53903. */
  53904. export class MorphTargetsBlock extends NodeMaterialBlock {
  53905. private _repeatableContentAnchor;
  53906. private _repeatebleContentGenerated;
  53907. /**
  53908. * Create a new MorphTargetsBlock
  53909. * @param name defines the block name
  53910. */
  53911. constructor(name: string);
  53912. /**
  53913. * Gets the current class name
  53914. * @returns the class name
  53915. */
  53916. getClassName(): string;
  53917. /**
  53918. * Gets the position input component
  53919. */
  53920. readonly position: NodeMaterialConnectionPoint;
  53921. /**
  53922. * Gets the normal input component
  53923. */
  53924. readonly normal: NodeMaterialConnectionPoint;
  53925. /**
  53926. * Gets the tangent input component
  53927. */
  53928. readonly tangent: NodeMaterialConnectionPoint;
  53929. /**
  53930. * Gets the tangent input component
  53931. */
  53932. readonly uv: NodeMaterialConnectionPoint;
  53933. /**
  53934. * Gets the position output component
  53935. */
  53936. readonly positionOutput: NodeMaterialConnectionPoint;
  53937. /**
  53938. * Gets the normal output component
  53939. */
  53940. readonly normalOutput: NodeMaterialConnectionPoint;
  53941. /**
  53942. * Gets the tangent output component
  53943. */
  53944. readonly tangentOutput: NodeMaterialConnectionPoint;
  53945. /**
  53946. * Gets the tangent output component
  53947. */
  53948. readonly uvOutput: NodeMaterialConnectionPoint;
  53949. initialize(state: NodeMaterialBuildState): void;
  53950. autoConfigure(material: NodeMaterial): void;
  53951. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53952. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53953. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53954. protected _buildBlock(state: NodeMaterialBuildState): this;
  53955. }
  53956. }
  53957. declare module BABYLON {
  53958. /**
  53959. * Block used to get data information from a light
  53960. */
  53961. export class LightInformationBlock extends NodeMaterialBlock {
  53962. private _lightDataUniformName;
  53963. private _lightColorUniformName;
  53964. private _lightTypeDefineName;
  53965. /**
  53966. * Gets or sets the light associated with this block
  53967. */
  53968. light: Nullable<Light>;
  53969. /**
  53970. * Creates a new LightInformationBlock
  53971. * @param name defines the block name
  53972. */
  53973. constructor(name: string);
  53974. /**
  53975. * Gets the current class name
  53976. * @returns the class name
  53977. */
  53978. getClassName(): string;
  53979. /**
  53980. * Gets the world position input component
  53981. */
  53982. readonly worldPosition: NodeMaterialConnectionPoint;
  53983. /**
  53984. * Gets the direction output component
  53985. */
  53986. readonly direction: NodeMaterialConnectionPoint;
  53987. /**
  53988. * Gets the direction output component
  53989. */
  53990. readonly color: NodeMaterialConnectionPoint;
  53991. /**
  53992. * Gets the direction output component
  53993. */
  53994. readonly intensity: NodeMaterialConnectionPoint;
  53995. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53996. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53997. protected _buildBlock(state: NodeMaterialBuildState): this;
  53998. serialize(): any;
  53999. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54000. }
  54001. }
  54002. declare module BABYLON {
  54003. /**
  54004. * Block used to add image processing support to fragment shader
  54005. */
  54006. export class ImageProcessingBlock extends NodeMaterialBlock {
  54007. /**
  54008. * Create a new ImageProcessingBlock
  54009. * @param name defines the block name
  54010. */
  54011. constructor(name: string);
  54012. /**
  54013. * Gets the current class name
  54014. * @returns the class name
  54015. */
  54016. getClassName(): string;
  54017. /**
  54018. * Gets the color input component
  54019. */
  54020. readonly color: NodeMaterialConnectionPoint;
  54021. /**
  54022. * Gets the output component
  54023. */
  54024. readonly output: NodeMaterialConnectionPoint;
  54025. /**
  54026. * Initialize the block and prepare the context for build
  54027. * @param state defines the state that will be used for the build
  54028. */
  54029. initialize(state: NodeMaterialBuildState): void;
  54030. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54031. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54032. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54033. protected _buildBlock(state: NodeMaterialBuildState): this;
  54034. }
  54035. }
  54036. declare module BABYLON {
  54037. /**
  54038. * Block used to pertub normals based on a normal map
  54039. */
  54040. export class PerturbNormalBlock extends NodeMaterialBlock {
  54041. private _tangentSpaceParameterName;
  54042. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54043. invertX: boolean;
  54044. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54045. invertY: boolean;
  54046. /**
  54047. * Create a new PerturbNormalBlock
  54048. * @param name defines the block name
  54049. */
  54050. constructor(name: string);
  54051. /**
  54052. * Gets the current class name
  54053. * @returns the class name
  54054. */
  54055. getClassName(): string;
  54056. /**
  54057. * Gets the world position input component
  54058. */
  54059. readonly worldPosition: NodeMaterialConnectionPoint;
  54060. /**
  54061. * Gets the world normal input component
  54062. */
  54063. readonly worldNormal: NodeMaterialConnectionPoint;
  54064. /**
  54065. * Gets the uv input component
  54066. */
  54067. readonly uv: NodeMaterialConnectionPoint;
  54068. /**
  54069. * Gets the normal map color input component
  54070. */
  54071. readonly normalMapColor: NodeMaterialConnectionPoint;
  54072. /**
  54073. * Gets the strength input component
  54074. */
  54075. readonly strength: NodeMaterialConnectionPoint;
  54076. /**
  54077. * Gets the output component
  54078. */
  54079. readonly output: NodeMaterialConnectionPoint;
  54080. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54081. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54082. autoConfigure(material: NodeMaterial): void;
  54083. protected _buildBlock(state: NodeMaterialBuildState): this;
  54084. protected _dumpPropertiesCode(): string;
  54085. serialize(): any;
  54086. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54087. }
  54088. }
  54089. declare module BABYLON {
  54090. /**
  54091. * Block used to discard a pixel if a value is smaller than a cutoff
  54092. */
  54093. export class DiscardBlock extends NodeMaterialBlock {
  54094. /**
  54095. * Create a new DiscardBlock
  54096. * @param name defines the block name
  54097. */
  54098. constructor(name: string);
  54099. /**
  54100. * Gets the current class name
  54101. * @returns the class name
  54102. */
  54103. getClassName(): string;
  54104. /**
  54105. * Gets the color input component
  54106. */
  54107. readonly value: NodeMaterialConnectionPoint;
  54108. /**
  54109. * Gets the cutoff input component
  54110. */
  54111. readonly cutoff: NodeMaterialConnectionPoint;
  54112. protected _buildBlock(state: NodeMaterialBuildState): this;
  54113. }
  54114. }
  54115. declare module BABYLON {
  54116. /**
  54117. * Block used to add support for scene fog
  54118. */
  54119. export class FogBlock extends NodeMaterialBlock {
  54120. private _fogDistanceName;
  54121. private _fogParameters;
  54122. /**
  54123. * Create a new FogBlock
  54124. * @param name defines the block name
  54125. */
  54126. constructor(name: string);
  54127. /**
  54128. * Gets the current class name
  54129. * @returns the class name
  54130. */
  54131. getClassName(): string;
  54132. /**
  54133. * Gets the world position input component
  54134. */
  54135. readonly worldPosition: NodeMaterialConnectionPoint;
  54136. /**
  54137. * Gets the view input component
  54138. */
  54139. readonly view: NodeMaterialConnectionPoint;
  54140. /**
  54141. * Gets the color input component
  54142. */
  54143. readonly input: NodeMaterialConnectionPoint;
  54144. /**
  54145. * Gets the fog color input component
  54146. */
  54147. readonly fogColor: NodeMaterialConnectionPoint;
  54148. /**
  54149. * Gets the output component
  54150. */
  54151. readonly output: NodeMaterialConnectionPoint;
  54152. autoConfigure(material: NodeMaterial): void;
  54153. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54154. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54155. protected _buildBlock(state: NodeMaterialBuildState): this;
  54156. }
  54157. }
  54158. declare module BABYLON {
  54159. /**
  54160. * Block used to add light in the fragment shader
  54161. */
  54162. export class LightBlock extends NodeMaterialBlock {
  54163. private _lightId;
  54164. /**
  54165. * Gets or sets the light associated with this block
  54166. */
  54167. light: Nullable<Light>;
  54168. /**
  54169. * Create a new LightBlock
  54170. * @param name defines the block name
  54171. */
  54172. constructor(name: string);
  54173. /**
  54174. * Gets the current class name
  54175. * @returns the class name
  54176. */
  54177. getClassName(): string;
  54178. /**
  54179. * Gets the world position input component
  54180. */
  54181. readonly worldPosition: NodeMaterialConnectionPoint;
  54182. /**
  54183. * Gets the world normal input component
  54184. */
  54185. readonly worldNormal: NodeMaterialConnectionPoint;
  54186. /**
  54187. * Gets the camera (or eye) position component
  54188. */
  54189. readonly cameraPosition: NodeMaterialConnectionPoint;
  54190. /**
  54191. * Gets the glossiness component
  54192. */
  54193. readonly glossiness: NodeMaterialConnectionPoint;
  54194. /**
  54195. * Gets the glossinness power component
  54196. */
  54197. readonly glossPower: NodeMaterialConnectionPoint;
  54198. /**
  54199. * Gets the diffuse color component
  54200. */
  54201. readonly diffuseColor: NodeMaterialConnectionPoint;
  54202. /**
  54203. * Gets the specular color component
  54204. */
  54205. readonly specularColor: NodeMaterialConnectionPoint;
  54206. /**
  54207. * Gets the diffuse output component
  54208. */
  54209. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54210. /**
  54211. * Gets the specular output component
  54212. */
  54213. readonly specularOutput: NodeMaterialConnectionPoint;
  54214. autoConfigure(material: NodeMaterial): void;
  54215. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54216. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54217. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54218. private _injectVertexCode;
  54219. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54220. serialize(): any;
  54221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54222. }
  54223. }
  54224. declare module BABYLON {
  54225. /**
  54226. * Block used to multiply 2 values
  54227. */
  54228. export class MultiplyBlock extends NodeMaterialBlock {
  54229. /**
  54230. * Creates a new MultiplyBlock
  54231. * @param name defines the block name
  54232. */
  54233. constructor(name: string);
  54234. /**
  54235. * Gets the current class name
  54236. * @returns the class name
  54237. */
  54238. getClassName(): string;
  54239. /**
  54240. * Gets the left operand input component
  54241. */
  54242. readonly left: NodeMaterialConnectionPoint;
  54243. /**
  54244. * Gets the right operand input component
  54245. */
  54246. readonly right: NodeMaterialConnectionPoint;
  54247. /**
  54248. * Gets the output component
  54249. */
  54250. readonly output: NodeMaterialConnectionPoint;
  54251. protected _buildBlock(state: NodeMaterialBuildState): this;
  54252. }
  54253. }
  54254. declare module BABYLON {
  54255. /**
  54256. * Block used to add 2 vectors
  54257. */
  54258. export class AddBlock extends NodeMaterialBlock {
  54259. /**
  54260. * Creates a new AddBlock
  54261. * @param name defines the block name
  54262. */
  54263. constructor(name: string);
  54264. /**
  54265. * Gets the current class name
  54266. * @returns the class name
  54267. */
  54268. getClassName(): string;
  54269. /**
  54270. * Gets the left operand input component
  54271. */
  54272. readonly left: NodeMaterialConnectionPoint;
  54273. /**
  54274. * Gets the right operand input component
  54275. */
  54276. readonly right: NodeMaterialConnectionPoint;
  54277. /**
  54278. * Gets the output component
  54279. */
  54280. readonly output: NodeMaterialConnectionPoint;
  54281. protected _buildBlock(state: NodeMaterialBuildState): this;
  54282. }
  54283. }
  54284. declare module BABYLON {
  54285. /**
  54286. * Block used to scale a vector by a float
  54287. */
  54288. export class ScaleBlock extends NodeMaterialBlock {
  54289. /**
  54290. * Creates a new ScaleBlock
  54291. * @param name defines the block name
  54292. */
  54293. constructor(name: string);
  54294. /**
  54295. * Gets the current class name
  54296. * @returns the class name
  54297. */
  54298. getClassName(): string;
  54299. /**
  54300. * Gets the input component
  54301. */
  54302. readonly input: NodeMaterialConnectionPoint;
  54303. /**
  54304. * Gets the factor input component
  54305. */
  54306. readonly factor: NodeMaterialConnectionPoint;
  54307. /**
  54308. * Gets the output component
  54309. */
  54310. readonly output: NodeMaterialConnectionPoint;
  54311. protected _buildBlock(state: NodeMaterialBuildState): this;
  54312. }
  54313. }
  54314. declare module BABYLON {
  54315. /**
  54316. * Block used to clamp a float
  54317. */
  54318. export class ClampBlock extends NodeMaterialBlock {
  54319. /** Gets or sets the minimum range */
  54320. minimum: number;
  54321. /** Gets or sets the maximum range */
  54322. maximum: number;
  54323. /**
  54324. * Creates a new ClampBlock
  54325. * @param name defines the block name
  54326. */
  54327. constructor(name: string);
  54328. /**
  54329. * Gets the current class name
  54330. * @returns the class name
  54331. */
  54332. getClassName(): string;
  54333. /**
  54334. * Gets the value input component
  54335. */
  54336. readonly value: NodeMaterialConnectionPoint;
  54337. /**
  54338. * Gets the output component
  54339. */
  54340. readonly output: NodeMaterialConnectionPoint;
  54341. protected _buildBlock(state: NodeMaterialBuildState): this;
  54342. protected _dumpPropertiesCode(): string;
  54343. serialize(): any;
  54344. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54345. }
  54346. }
  54347. declare module BABYLON {
  54348. /**
  54349. * Block used to apply a cross product between 2 vectors
  54350. */
  54351. export class CrossBlock extends NodeMaterialBlock {
  54352. /**
  54353. * Creates a new CrossBlock
  54354. * @param name defines the block name
  54355. */
  54356. constructor(name: string);
  54357. /**
  54358. * Gets the current class name
  54359. * @returns the class name
  54360. */
  54361. getClassName(): string;
  54362. /**
  54363. * Gets the left operand input component
  54364. */
  54365. readonly left: NodeMaterialConnectionPoint;
  54366. /**
  54367. * Gets the right operand input component
  54368. */
  54369. readonly right: NodeMaterialConnectionPoint;
  54370. /**
  54371. * Gets the output component
  54372. */
  54373. readonly output: NodeMaterialConnectionPoint;
  54374. protected _buildBlock(state: NodeMaterialBuildState): this;
  54375. }
  54376. }
  54377. declare module BABYLON {
  54378. /**
  54379. * Block used to apply a dot product between 2 vectors
  54380. */
  54381. export class DotBlock extends NodeMaterialBlock {
  54382. /**
  54383. * Creates a new DotBlock
  54384. * @param name defines the block name
  54385. */
  54386. constructor(name: string);
  54387. /**
  54388. * Gets the current class name
  54389. * @returns the class name
  54390. */
  54391. getClassName(): string;
  54392. /**
  54393. * Gets the left operand input component
  54394. */
  54395. readonly left: NodeMaterialConnectionPoint;
  54396. /**
  54397. * Gets the right operand input component
  54398. */
  54399. readonly right: NodeMaterialConnectionPoint;
  54400. /**
  54401. * Gets the output component
  54402. */
  54403. readonly output: NodeMaterialConnectionPoint;
  54404. protected _buildBlock(state: NodeMaterialBuildState): this;
  54405. }
  54406. }
  54407. declare module BABYLON {
  54408. /**
  54409. * Block used to remap a float from a range to a new one
  54410. */
  54411. export class RemapBlock extends NodeMaterialBlock {
  54412. /**
  54413. * Gets or sets the source range
  54414. */
  54415. sourceRange: Vector2;
  54416. /**
  54417. * Gets or sets the target range
  54418. */
  54419. targetRange: Vector2;
  54420. /**
  54421. * Creates a new RemapBlock
  54422. * @param name defines the block name
  54423. */
  54424. constructor(name: string);
  54425. /**
  54426. * Gets the current class name
  54427. * @returns the class name
  54428. */
  54429. getClassName(): string;
  54430. /**
  54431. * Gets the input component
  54432. */
  54433. readonly input: NodeMaterialConnectionPoint;
  54434. /**
  54435. * Gets the source min input component
  54436. */
  54437. readonly sourceMin: NodeMaterialConnectionPoint;
  54438. /**
  54439. * Gets the source max input component
  54440. */
  54441. readonly sourceMax: NodeMaterialConnectionPoint;
  54442. /**
  54443. * Gets the target min input component
  54444. */
  54445. readonly targetMin: NodeMaterialConnectionPoint;
  54446. /**
  54447. * Gets the target max input component
  54448. */
  54449. readonly targetMax: NodeMaterialConnectionPoint;
  54450. /**
  54451. * Gets the output component
  54452. */
  54453. readonly output: NodeMaterialConnectionPoint;
  54454. protected _buildBlock(state: NodeMaterialBuildState): this;
  54455. protected _dumpPropertiesCode(): string;
  54456. serialize(): any;
  54457. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54458. }
  54459. }
  54460. declare module BABYLON {
  54461. /**
  54462. * Block used to normalize a vector
  54463. */
  54464. export class NormalizeBlock extends NodeMaterialBlock {
  54465. /**
  54466. * Creates a new NormalizeBlock
  54467. * @param name defines the block name
  54468. */
  54469. constructor(name: string);
  54470. /**
  54471. * Gets the current class name
  54472. * @returns the class name
  54473. */
  54474. getClassName(): string;
  54475. /**
  54476. * Gets the input component
  54477. */
  54478. readonly input: NodeMaterialConnectionPoint;
  54479. /**
  54480. * Gets the output component
  54481. */
  54482. readonly output: NodeMaterialConnectionPoint;
  54483. protected _buildBlock(state: NodeMaterialBuildState): this;
  54484. }
  54485. }
  54486. declare module BABYLON {
  54487. /**
  54488. * Operations supported by the Trigonometry block
  54489. */
  54490. export enum TrigonometryBlockOperations {
  54491. /** Cos */
  54492. Cos = 0,
  54493. /** Sin */
  54494. Sin = 1,
  54495. /** Abs */
  54496. Abs = 2,
  54497. /** Exp */
  54498. Exp = 3,
  54499. /** Exp2 */
  54500. Exp2 = 4,
  54501. /** Round */
  54502. Round = 5,
  54503. /** Floor */
  54504. Floor = 6,
  54505. /** Ceiling */
  54506. Ceiling = 7,
  54507. /** Square root */
  54508. Sqrt = 8,
  54509. /** Log */
  54510. Log = 9,
  54511. /** Tangent */
  54512. Tan = 10,
  54513. /** Arc tangent */
  54514. ArcTan = 11,
  54515. /** Arc cosinus */
  54516. ArcCos = 12,
  54517. /** Arc sinus */
  54518. ArcSin = 13,
  54519. /** Fraction */
  54520. Fract = 14,
  54521. /** Sign */
  54522. Sign = 15,
  54523. /** To radians (from degrees) */
  54524. Radians = 16,
  54525. /** To degrees (from radians) */
  54526. Degrees = 17
  54527. }
  54528. /**
  54529. * Block used to apply trigonometry operation to floats
  54530. */
  54531. export class TrigonometryBlock extends NodeMaterialBlock {
  54532. /**
  54533. * Gets or sets the operation applied by the block
  54534. */
  54535. operation: TrigonometryBlockOperations;
  54536. /**
  54537. * Creates a new TrigonometryBlock
  54538. * @param name defines the block name
  54539. */
  54540. constructor(name: string);
  54541. /**
  54542. * Gets the current class name
  54543. * @returns the class name
  54544. */
  54545. getClassName(): string;
  54546. /**
  54547. * Gets the input component
  54548. */
  54549. readonly input: NodeMaterialConnectionPoint;
  54550. /**
  54551. * Gets the output component
  54552. */
  54553. readonly output: NodeMaterialConnectionPoint;
  54554. protected _buildBlock(state: NodeMaterialBuildState): this;
  54555. serialize(): any;
  54556. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54557. }
  54558. }
  54559. declare module BABYLON {
  54560. /**
  54561. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54562. */
  54563. export class ColorMergerBlock extends NodeMaterialBlock {
  54564. /**
  54565. * Create a new ColorMergerBlock
  54566. * @param name defines the block name
  54567. */
  54568. constructor(name: string);
  54569. /**
  54570. * Gets the current class name
  54571. * @returns the class name
  54572. */
  54573. getClassName(): string;
  54574. /**
  54575. * Gets the r component (input)
  54576. */
  54577. readonly r: NodeMaterialConnectionPoint;
  54578. /**
  54579. * Gets the g component (input)
  54580. */
  54581. readonly g: NodeMaterialConnectionPoint;
  54582. /**
  54583. * Gets the b component (input)
  54584. */
  54585. readonly b: NodeMaterialConnectionPoint;
  54586. /**
  54587. * Gets the a component (input)
  54588. */
  54589. readonly a: NodeMaterialConnectionPoint;
  54590. /**
  54591. * Gets the rgba component (output)
  54592. */
  54593. readonly rgba: NodeMaterialConnectionPoint;
  54594. /**
  54595. * Gets the rgb component (output)
  54596. */
  54597. readonly rgb: NodeMaterialConnectionPoint;
  54598. protected _buildBlock(state: NodeMaterialBuildState): this;
  54599. }
  54600. }
  54601. declare module BABYLON {
  54602. /**
  54603. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54604. */
  54605. export class VectorMergerBlock extends NodeMaterialBlock {
  54606. /**
  54607. * Create a new VectorMergerBlock
  54608. * @param name defines the block name
  54609. */
  54610. constructor(name: string);
  54611. /**
  54612. * Gets the current class name
  54613. * @returns the class name
  54614. */
  54615. getClassName(): string;
  54616. /**
  54617. * Gets the x component (input)
  54618. */
  54619. readonly x: NodeMaterialConnectionPoint;
  54620. /**
  54621. * Gets the y component (input)
  54622. */
  54623. readonly y: NodeMaterialConnectionPoint;
  54624. /**
  54625. * Gets the z component (input)
  54626. */
  54627. readonly z: NodeMaterialConnectionPoint;
  54628. /**
  54629. * Gets the w component (input)
  54630. */
  54631. readonly w: NodeMaterialConnectionPoint;
  54632. /**
  54633. * Gets the xyzw component (output)
  54634. */
  54635. readonly xyzw: NodeMaterialConnectionPoint;
  54636. /**
  54637. * Gets the xyz component (output)
  54638. */
  54639. readonly xyz: NodeMaterialConnectionPoint;
  54640. /**
  54641. * Gets the xy component (output)
  54642. */
  54643. readonly xy: NodeMaterialConnectionPoint;
  54644. protected _buildBlock(state: NodeMaterialBuildState): this;
  54645. }
  54646. }
  54647. declare module BABYLON {
  54648. /**
  54649. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54650. */
  54651. export class ColorSplitterBlock extends NodeMaterialBlock {
  54652. /**
  54653. * Create a new ColorSplitterBlock
  54654. * @param name defines the block name
  54655. */
  54656. constructor(name: string);
  54657. /**
  54658. * Gets the current class name
  54659. * @returns the class name
  54660. */
  54661. getClassName(): string;
  54662. /**
  54663. * Gets the rgba component (input)
  54664. */
  54665. readonly rgba: NodeMaterialConnectionPoint;
  54666. /**
  54667. * Gets the rgb component (input)
  54668. */
  54669. readonly rgbIn: NodeMaterialConnectionPoint;
  54670. /**
  54671. * Gets the rgb component (output)
  54672. */
  54673. readonly rgbOut: NodeMaterialConnectionPoint;
  54674. /**
  54675. * Gets the r component (output)
  54676. */
  54677. readonly r: NodeMaterialConnectionPoint;
  54678. /**
  54679. * Gets the g component (output)
  54680. */
  54681. readonly g: NodeMaterialConnectionPoint;
  54682. /**
  54683. * Gets the b component (output)
  54684. */
  54685. readonly b: NodeMaterialConnectionPoint;
  54686. /**
  54687. * Gets the a component (output)
  54688. */
  54689. readonly a: NodeMaterialConnectionPoint;
  54690. protected _inputRename(name: string): string;
  54691. protected _outputRename(name: string): string;
  54692. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54693. }
  54694. }
  54695. declare module BABYLON {
  54696. /**
  54697. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54698. */
  54699. export class VectorSplitterBlock extends NodeMaterialBlock {
  54700. /**
  54701. * Create a new VectorSplitterBlock
  54702. * @param name defines the block name
  54703. */
  54704. constructor(name: string);
  54705. /**
  54706. * Gets the current class name
  54707. * @returns the class name
  54708. */
  54709. getClassName(): string;
  54710. /**
  54711. * Gets the xyzw component (input)
  54712. */
  54713. readonly xyzw: NodeMaterialConnectionPoint;
  54714. /**
  54715. * Gets the xyz component (input)
  54716. */
  54717. readonly xyzIn: NodeMaterialConnectionPoint;
  54718. /**
  54719. * Gets the xy component (input)
  54720. */
  54721. readonly xyIn: NodeMaterialConnectionPoint;
  54722. /**
  54723. * Gets the xyz component (output)
  54724. */
  54725. readonly xyzOut: NodeMaterialConnectionPoint;
  54726. /**
  54727. * Gets the xy component (output)
  54728. */
  54729. readonly xyOut: NodeMaterialConnectionPoint;
  54730. /**
  54731. * Gets the x component (output)
  54732. */
  54733. readonly x: NodeMaterialConnectionPoint;
  54734. /**
  54735. * Gets the y component (output)
  54736. */
  54737. readonly y: NodeMaterialConnectionPoint;
  54738. /**
  54739. * Gets the z component (output)
  54740. */
  54741. readonly z: NodeMaterialConnectionPoint;
  54742. /**
  54743. * Gets the w component (output)
  54744. */
  54745. readonly w: NodeMaterialConnectionPoint;
  54746. protected _inputRename(name: string): string;
  54747. protected _outputRename(name: string): string;
  54748. protected _buildBlock(state: NodeMaterialBuildState): this;
  54749. }
  54750. }
  54751. declare module BABYLON {
  54752. /**
  54753. * Block used to lerp between 2 values
  54754. */
  54755. export class LerpBlock extends NodeMaterialBlock {
  54756. /**
  54757. * Creates a new LerpBlock
  54758. * @param name defines the block name
  54759. */
  54760. constructor(name: string);
  54761. /**
  54762. * Gets the current class name
  54763. * @returns the class name
  54764. */
  54765. getClassName(): string;
  54766. /**
  54767. * Gets the left operand input component
  54768. */
  54769. readonly left: NodeMaterialConnectionPoint;
  54770. /**
  54771. * Gets the right operand input component
  54772. */
  54773. readonly right: NodeMaterialConnectionPoint;
  54774. /**
  54775. * Gets the gradient operand input component
  54776. */
  54777. readonly gradient: NodeMaterialConnectionPoint;
  54778. /**
  54779. * Gets the output component
  54780. */
  54781. readonly output: NodeMaterialConnectionPoint;
  54782. protected _buildBlock(state: NodeMaterialBuildState): this;
  54783. }
  54784. }
  54785. declare module BABYLON {
  54786. /**
  54787. * Block used to divide 2 vectors
  54788. */
  54789. export class DivideBlock extends NodeMaterialBlock {
  54790. /**
  54791. * Creates a new DivideBlock
  54792. * @param name defines the block name
  54793. */
  54794. constructor(name: string);
  54795. /**
  54796. * Gets the current class name
  54797. * @returns the class name
  54798. */
  54799. getClassName(): string;
  54800. /**
  54801. * Gets the left operand input component
  54802. */
  54803. readonly left: NodeMaterialConnectionPoint;
  54804. /**
  54805. * Gets the right operand input component
  54806. */
  54807. readonly right: NodeMaterialConnectionPoint;
  54808. /**
  54809. * Gets the output component
  54810. */
  54811. readonly output: NodeMaterialConnectionPoint;
  54812. protected _buildBlock(state: NodeMaterialBuildState): this;
  54813. }
  54814. }
  54815. declare module BABYLON {
  54816. /**
  54817. * Block used to subtract 2 vectors
  54818. */
  54819. export class SubtractBlock extends NodeMaterialBlock {
  54820. /**
  54821. * Creates a new SubtractBlock
  54822. * @param name defines the block name
  54823. */
  54824. constructor(name: string);
  54825. /**
  54826. * Gets the current class name
  54827. * @returns the class name
  54828. */
  54829. getClassName(): string;
  54830. /**
  54831. * Gets the left operand input component
  54832. */
  54833. readonly left: NodeMaterialConnectionPoint;
  54834. /**
  54835. * Gets the right operand input component
  54836. */
  54837. readonly right: NodeMaterialConnectionPoint;
  54838. /**
  54839. * Gets the output component
  54840. */
  54841. readonly output: NodeMaterialConnectionPoint;
  54842. protected _buildBlock(state: NodeMaterialBuildState): this;
  54843. }
  54844. }
  54845. declare module BABYLON {
  54846. /**
  54847. * Block used to step a value
  54848. */
  54849. export class StepBlock extends NodeMaterialBlock {
  54850. /**
  54851. * Creates a new StepBlock
  54852. * @param name defines the block name
  54853. */
  54854. constructor(name: string);
  54855. /**
  54856. * Gets the current class name
  54857. * @returns the class name
  54858. */
  54859. getClassName(): string;
  54860. /**
  54861. * Gets the value operand input component
  54862. */
  54863. readonly value: NodeMaterialConnectionPoint;
  54864. /**
  54865. * Gets the edge operand input component
  54866. */
  54867. readonly edge: NodeMaterialConnectionPoint;
  54868. /**
  54869. * Gets the output component
  54870. */
  54871. readonly output: NodeMaterialConnectionPoint;
  54872. protected _buildBlock(state: NodeMaterialBuildState): this;
  54873. }
  54874. }
  54875. declare module BABYLON {
  54876. /**
  54877. * Block used to get the opposite (1 - x) of a value
  54878. */
  54879. export class OneMinusBlock extends NodeMaterialBlock {
  54880. /**
  54881. * Creates a new OneMinusBlock
  54882. * @param name defines the block name
  54883. */
  54884. constructor(name: string);
  54885. /**
  54886. * Gets the current class name
  54887. * @returns the class name
  54888. */
  54889. getClassName(): string;
  54890. /**
  54891. * Gets the input component
  54892. */
  54893. readonly input: NodeMaterialConnectionPoint;
  54894. /**
  54895. * Gets the output component
  54896. */
  54897. readonly output: NodeMaterialConnectionPoint;
  54898. protected _buildBlock(state: NodeMaterialBuildState): this;
  54899. }
  54900. }
  54901. declare module BABYLON {
  54902. /**
  54903. * Block used to get the view direction
  54904. */
  54905. export class ViewDirectionBlock extends NodeMaterialBlock {
  54906. /**
  54907. * Creates a new ViewDirectionBlock
  54908. * @param name defines the block name
  54909. */
  54910. constructor(name: string);
  54911. /**
  54912. * Gets the current class name
  54913. * @returns the class name
  54914. */
  54915. getClassName(): string;
  54916. /**
  54917. * Gets the world position component
  54918. */
  54919. readonly worldPosition: NodeMaterialConnectionPoint;
  54920. /**
  54921. * Gets the camera position component
  54922. */
  54923. readonly cameraPosition: NodeMaterialConnectionPoint;
  54924. /**
  54925. * Gets the output component
  54926. */
  54927. readonly output: NodeMaterialConnectionPoint;
  54928. autoConfigure(material: NodeMaterial): void;
  54929. protected _buildBlock(state: NodeMaterialBuildState): this;
  54930. }
  54931. }
  54932. declare module BABYLON {
  54933. /**
  54934. * Block used to compute fresnel value
  54935. */
  54936. export class FresnelBlock extends NodeMaterialBlock {
  54937. /**
  54938. * Create a new FresnelBlock
  54939. * @param name defines the block name
  54940. */
  54941. constructor(name: string);
  54942. /**
  54943. * Gets the current class name
  54944. * @returns the class name
  54945. */
  54946. getClassName(): string;
  54947. /**
  54948. * Gets the world normal input component
  54949. */
  54950. readonly worldNormal: NodeMaterialConnectionPoint;
  54951. /**
  54952. * Gets the view direction input component
  54953. */
  54954. readonly viewDirection: NodeMaterialConnectionPoint;
  54955. /**
  54956. * Gets the bias input component
  54957. */
  54958. readonly bias: NodeMaterialConnectionPoint;
  54959. /**
  54960. * Gets the camera (or eye) position component
  54961. */
  54962. readonly power: NodeMaterialConnectionPoint;
  54963. /**
  54964. * Gets the fresnel output component
  54965. */
  54966. readonly fresnel: NodeMaterialConnectionPoint;
  54967. autoConfigure(material: NodeMaterial): void;
  54968. protected _buildBlock(state: NodeMaterialBuildState): this;
  54969. }
  54970. }
  54971. declare module BABYLON {
  54972. /**
  54973. * Block used to get the max of 2 values
  54974. */
  54975. export class MaxBlock extends NodeMaterialBlock {
  54976. /**
  54977. * Creates a new MaxBlock
  54978. * @param name defines the block name
  54979. */
  54980. constructor(name: string);
  54981. /**
  54982. * Gets the current class name
  54983. * @returns the class name
  54984. */
  54985. getClassName(): string;
  54986. /**
  54987. * Gets the left operand input component
  54988. */
  54989. readonly left: NodeMaterialConnectionPoint;
  54990. /**
  54991. * Gets the right operand input component
  54992. */
  54993. readonly right: NodeMaterialConnectionPoint;
  54994. /**
  54995. * Gets the output component
  54996. */
  54997. readonly output: NodeMaterialConnectionPoint;
  54998. protected _buildBlock(state: NodeMaterialBuildState): this;
  54999. }
  55000. }
  55001. declare module BABYLON {
  55002. /**
  55003. * Block used to get the min of 2 values
  55004. */
  55005. export class MinBlock extends NodeMaterialBlock {
  55006. /**
  55007. * Creates a new MinBlock
  55008. * @param name defines the block name
  55009. */
  55010. constructor(name: string);
  55011. /**
  55012. * Gets the current class name
  55013. * @returns the class name
  55014. */
  55015. getClassName(): string;
  55016. /**
  55017. * Gets the left operand input component
  55018. */
  55019. readonly left: NodeMaterialConnectionPoint;
  55020. /**
  55021. * Gets the right operand input component
  55022. */
  55023. readonly right: NodeMaterialConnectionPoint;
  55024. /**
  55025. * Gets the output component
  55026. */
  55027. readonly output: NodeMaterialConnectionPoint;
  55028. protected _buildBlock(state: NodeMaterialBuildState): this;
  55029. }
  55030. }
  55031. declare module BABYLON {
  55032. /**
  55033. * Block used to get the distance between 2 values
  55034. */
  55035. export class DistanceBlock extends NodeMaterialBlock {
  55036. /**
  55037. * Creates a new DistanceBlock
  55038. * @param name defines the block name
  55039. */
  55040. constructor(name: string);
  55041. /**
  55042. * Gets the current class name
  55043. * @returns the class name
  55044. */
  55045. getClassName(): string;
  55046. /**
  55047. * Gets the left operand input component
  55048. */
  55049. readonly left: NodeMaterialConnectionPoint;
  55050. /**
  55051. * Gets the right operand input component
  55052. */
  55053. readonly right: NodeMaterialConnectionPoint;
  55054. /**
  55055. * Gets the output component
  55056. */
  55057. readonly output: NodeMaterialConnectionPoint;
  55058. protected _buildBlock(state: NodeMaterialBuildState): this;
  55059. }
  55060. }
  55061. declare module BABYLON {
  55062. /**
  55063. * Block used to get the length of a vector
  55064. */
  55065. export class LengthBlock extends NodeMaterialBlock {
  55066. /**
  55067. * Creates a new LengthBlock
  55068. * @param name defines the block name
  55069. */
  55070. constructor(name: string);
  55071. /**
  55072. * Gets the current class name
  55073. * @returns the class name
  55074. */
  55075. getClassName(): string;
  55076. /**
  55077. * Gets the value input component
  55078. */
  55079. readonly value: NodeMaterialConnectionPoint;
  55080. /**
  55081. * Gets the output component
  55082. */
  55083. readonly output: NodeMaterialConnectionPoint;
  55084. protected _buildBlock(state: NodeMaterialBuildState): this;
  55085. }
  55086. }
  55087. declare module BABYLON {
  55088. /**
  55089. * Block used to get negative version of a value (i.e. x * -1)
  55090. */
  55091. export class NegateBlock extends NodeMaterialBlock {
  55092. /**
  55093. * Creates a new NegateBlock
  55094. * @param name defines the block name
  55095. */
  55096. constructor(name: string);
  55097. /**
  55098. * Gets the current class name
  55099. * @returns the class name
  55100. */
  55101. getClassName(): string;
  55102. /**
  55103. * Gets the value input component
  55104. */
  55105. readonly value: NodeMaterialConnectionPoint;
  55106. /**
  55107. * Gets the output component
  55108. */
  55109. readonly output: NodeMaterialConnectionPoint;
  55110. protected _buildBlock(state: NodeMaterialBuildState): this;
  55111. }
  55112. }
  55113. declare module BABYLON {
  55114. /**
  55115. * Block used to get the value of the first parameter raised to the power of the second
  55116. */
  55117. export class PowBlock extends NodeMaterialBlock {
  55118. /**
  55119. * Creates a new PowBlock
  55120. * @param name defines the block name
  55121. */
  55122. constructor(name: string);
  55123. /**
  55124. * Gets the current class name
  55125. * @returns the class name
  55126. */
  55127. getClassName(): string;
  55128. /**
  55129. * Gets the value operand input component
  55130. */
  55131. readonly value: NodeMaterialConnectionPoint;
  55132. /**
  55133. * Gets the power operand input component
  55134. */
  55135. readonly power: NodeMaterialConnectionPoint;
  55136. /**
  55137. * Gets the output component
  55138. */
  55139. readonly output: NodeMaterialConnectionPoint;
  55140. protected _buildBlock(state: NodeMaterialBuildState): this;
  55141. }
  55142. }
  55143. declare module BABYLON {
  55144. /**
  55145. * Block used to get a random number
  55146. */
  55147. export class RandomNumberBlock extends NodeMaterialBlock {
  55148. /**
  55149. * Creates a new RandomNumberBlock
  55150. * @param name defines the block name
  55151. */
  55152. constructor(name: string);
  55153. /**
  55154. * Gets the current class name
  55155. * @returns the class name
  55156. */
  55157. getClassName(): string;
  55158. /**
  55159. * Gets the seed input component
  55160. */
  55161. readonly seed: NodeMaterialConnectionPoint;
  55162. /**
  55163. * Gets the output component
  55164. */
  55165. readonly output: NodeMaterialConnectionPoint;
  55166. protected _buildBlock(state: NodeMaterialBuildState): this;
  55167. }
  55168. }
  55169. declare module BABYLON {
  55170. /**
  55171. * Block used to compute arc tangent of 2 values
  55172. */
  55173. export class ArcTan2Block extends NodeMaterialBlock {
  55174. /**
  55175. * Creates a new ArcTan2Block
  55176. * @param name defines the block name
  55177. */
  55178. constructor(name: string);
  55179. /**
  55180. * Gets the current class name
  55181. * @returns the class name
  55182. */
  55183. getClassName(): string;
  55184. /**
  55185. * Gets the x operand input component
  55186. */
  55187. readonly x: NodeMaterialConnectionPoint;
  55188. /**
  55189. * Gets the y operand input component
  55190. */
  55191. readonly y: NodeMaterialConnectionPoint;
  55192. /**
  55193. * Gets the output component
  55194. */
  55195. readonly output: NodeMaterialConnectionPoint;
  55196. protected _buildBlock(state: NodeMaterialBuildState): this;
  55197. }
  55198. }
  55199. declare module BABYLON {
  55200. /**
  55201. * Block used to smooth step a value
  55202. */
  55203. export class SmoothStepBlock extends NodeMaterialBlock {
  55204. /**
  55205. * Creates a new SmoothStepBlock
  55206. * @param name defines the block name
  55207. */
  55208. constructor(name: string);
  55209. /**
  55210. * Gets the current class name
  55211. * @returns the class name
  55212. */
  55213. getClassName(): string;
  55214. /**
  55215. * Gets the value operand input component
  55216. */
  55217. readonly value: NodeMaterialConnectionPoint;
  55218. /**
  55219. * Gets the first edge operand input component
  55220. */
  55221. readonly edge0: NodeMaterialConnectionPoint;
  55222. /**
  55223. * Gets the second edge operand input component
  55224. */
  55225. readonly edge1: NodeMaterialConnectionPoint;
  55226. /**
  55227. * Gets the output component
  55228. */
  55229. readonly output: NodeMaterialConnectionPoint;
  55230. protected _buildBlock(state: NodeMaterialBuildState): this;
  55231. }
  55232. }
  55233. declare module BABYLON {
  55234. /**
  55235. * Block used to get the reciprocal (1 / x) of a value
  55236. */
  55237. export class ReciprocalBlock extends NodeMaterialBlock {
  55238. /**
  55239. * Creates a new ReciprocalBlock
  55240. * @param name defines the block name
  55241. */
  55242. constructor(name: string);
  55243. /**
  55244. * Gets the current class name
  55245. * @returns the class name
  55246. */
  55247. getClassName(): string;
  55248. /**
  55249. * Gets the input component
  55250. */
  55251. readonly input: NodeMaterialConnectionPoint;
  55252. /**
  55253. * Gets the output component
  55254. */
  55255. readonly output: NodeMaterialConnectionPoint;
  55256. protected _buildBlock(state: NodeMaterialBuildState): this;
  55257. }
  55258. }
  55259. declare module BABYLON {
  55260. /**
  55261. * Block used to replace a color by another one
  55262. */
  55263. export class ReplaceColorBlock extends NodeMaterialBlock {
  55264. /**
  55265. * Creates a new ReplaceColorBlock
  55266. * @param name defines the block name
  55267. */
  55268. constructor(name: string);
  55269. /**
  55270. * Gets the current class name
  55271. * @returns the class name
  55272. */
  55273. getClassName(): string;
  55274. /**
  55275. * Gets the value input component
  55276. */
  55277. readonly value: NodeMaterialConnectionPoint;
  55278. /**
  55279. * Gets the reference input component
  55280. */
  55281. readonly reference: NodeMaterialConnectionPoint;
  55282. /**
  55283. * Gets the distance input component
  55284. */
  55285. readonly distance: NodeMaterialConnectionPoint;
  55286. /**
  55287. * Gets the replacement input component
  55288. */
  55289. readonly replacement: NodeMaterialConnectionPoint;
  55290. /**
  55291. * Gets the output component
  55292. */
  55293. readonly output: NodeMaterialConnectionPoint;
  55294. protected _buildBlock(state: NodeMaterialBuildState): this;
  55295. }
  55296. }
  55297. declare module BABYLON {
  55298. /**
  55299. * Block used to posterize a value
  55300. * @see https://en.wikipedia.org/wiki/Posterization
  55301. */
  55302. export class PosterizeBlock extends NodeMaterialBlock {
  55303. /**
  55304. * Creates a new PosterizeBlock
  55305. * @param name defines the block name
  55306. */
  55307. constructor(name: string);
  55308. /**
  55309. * Gets the current class name
  55310. * @returns the class name
  55311. */
  55312. getClassName(): string;
  55313. /**
  55314. * Gets the value input component
  55315. */
  55316. readonly value: NodeMaterialConnectionPoint;
  55317. /**
  55318. * Gets the steps input component
  55319. */
  55320. readonly steps: NodeMaterialConnectionPoint;
  55321. /**
  55322. * Gets the output component
  55323. */
  55324. readonly output: NodeMaterialConnectionPoint;
  55325. protected _buildBlock(state: NodeMaterialBuildState): this;
  55326. }
  55327. }
  55328. declare module BABYLON {
  55329. /**
  55330. * Operations supported by the Wave block
  55331. */
  55332. export enum WaveBlockKind {
  55333. /** SawTooth */
  55334. SawTooth = 0,
  55335. /** Square */
  55336. Square = 1,
  55337. /** Triangle */
  55338. Triangle = 2
  55339. }
  55340. /**
  55341. * Block used to apply wave operation to floats
  55342. */
  55343. export class WaveBlock extends NodeMaterialBlock {
  55344. /**
  55345. * Gets or sets the kibnd of wave to be applied by the block
  55346. */
  55347. kind: WaveBlockKind;
  55348. /**
  55349. * Creates a new WaveBlock
  55350. * @param name defines the block name
  55351. */
  55352. constructor(name: string);
  55353. /**
  55354. * Gets the current class name
  55355. * @returns the class name
  55356. */
  55357. getClassName(): string;
  55358. /**
  55359. * Gets the input component
  55360. */
  55361. readonly input: NodeMaterialConnectionPoint;
  55362. /**
  55363. * Gets the output component
  55364. */
  55365. readonly output: NodeMaterialConnectionPoint;
  55366. protected _buildBlock(state: NodeMaterialBuildState): this;
  55367. serialize(): any;
  55368. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55369. }
  55370. }
  55371. declare module BABYLON {
  55372. /**
  55373. * Class used to store a color step for the GradientBlock
  55374. */
  55375. export class GradientBlockColorStep {
  55376. /**
  55377. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55378. */
  55379. step: number;
  55380. /**
  55381. * Gets or sets the color associated with this step
  55382. */
  55383. color: Color3;
  55384. /**
  55385. * Creates a new GradientBlockColorStep
  55386. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  55387. * @param color defines the color associated with this step
  55388. */
  55389. constructor(
  55390. /**
  55391. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55392. */
  55393. step: number,
  55394. /**
  55395. * Gets or sets the color associated with this step
  55396. */
  55397. color: Color3);
  55398. }
  55399. /**
  55400. * Block used to return a color from a gradient based on an input value between 0 and 1
  55401. */
  55402. export class GradientBlock extends NodeMaterialBlock {
  55403. /**
  55404. * Gets or sets the list of color steps
  55405. */
  55406. colorSteps: GradientBlockColorStep[];
  55407. /**
  55408. * Creates a new GradientBlock
  55409. * @param name defines the block name
  55410. */
  55411. constructor(name: string);
  55412. /**
  55413. * Gets the current class name
  55414. * @returns the class name
  55415. */
  55416. getClassName(): string;
  55417. /**
  55418. * Gets the gradient input component
  55419. */
  55420. readonly gradient: NodeMaterialConnectionPoint;
  55421. /**
  55422. * Gets the output component
  55423. */
  55424. readonly output: NodeMaterialConnectionPoint;
  55425. private _writeColorConstant;
  55426. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55427. serialize(): any;
  55428. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55429. protected _dumpPropertiesCode(): string;
  55430. }
  55431. }
  55432. declare module BABYLON {
  55433. /**
  55434. * Block used to normalize lerp between 2 values
  55435. */
  55436. export class NLerpBlock extends NodeMaterialBlock {
  55437. /**
  55438. * Creates a new NLerpBlock
  55439. * @param name defines the block name
  55440. */
  55441. constructor(name: string);
  55442. /**
  55443. * Gets the current class name
  55444. * @returns the class name
  55445. */
  55446. getClassName(): string;
  55447. /**
  55448. * Gets the left operand input component
  55449. */
  55450. readonly left: NodeMaterialConnectionPoint;
  55451. /**
  55452. * Gets the right operand input component
  55453. */
  55454. readonly right: NodeMaterialConnectionPoint;
  55455. /**
  55456. * Gets the gradient operand input component
  55457. */
  55458. readonly gradient: NodeMaterialConnectionPoint;
  55459. /**
  55460. * Gets the output component
  55461. */
  55462. readonly output: NodeMaterialConnectionPoint;
  55463. protected _buildBlock(state: NodeMaterialBuildState): this;
  55464. }
  55465. }
  55466. declare module BABYLON {
  55467. /**
  55468. * Effect Render Options
  55469. */
  55470. export interface IEffectRendererOptions {
  55471. /**
  55472. * Defines the vertices positions.
  55473. */
  55474. positions?: number[];
  55475. /**
  55476. * Defines the indices.
  55477. */
  55478. indices?: number[];
  55479. }
  55480. /**
  55481. * Helper class to render one or more effects
  55482. */
  55483. export class EffectRenderer {
  55484. private engine;
  55485. private static _DefaultOptions;
  55486. private _vertexBuffers;
  55487. private _indexBuffer;
  55488. private _ringBufferIndex;
  55489. private _ringScreenBuffer;
  55490. private _fullscreenViewport;
  55491. private _getNextFrameBuffer;
  55492. /**
  55493. * Creates an effect renderer
  55494. * @param engine the engine to use for rendering
  55495. * @param options defines the options of the effect renderer
  55496. */
  55497. constructor(engine: Engine, options?: IEffectRendererOptions);
  55498. /**
  55499. * Sets the current viewport in normalized coordinates 0-1
  55500. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55501. */
  55502. setViewport(viewport?: Viewport): void;
  55503. /**
  55504. * Binds the embedded attributes buffer to the effect.
  55505. * @param effect Defines the effect to bind the attributes for
  55506. */
  55507. bindBuffers(effect: Effect): void;
  55508. /**
  55509. * Sets the current effect wrapper to use during draw.
  55510. * The effect needs to be ready before calling this api.
  55511. * This also sets the default full screen position attribute.
  55512. * @param effectWrapper Defines the effect to draw with
  55513. */
  55514. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55515. /**
  55516. * Draws a full screen quad.
  55517. */
  55518. draw(): void;
  55519. /**
  55520. * renders one or more effects to a specified texture
  55521. * @param effectWrappers list of effects to renderer
  55522. * @param outputTexture texture to draw to, if null it will render to the screen
  55523. */
  55524. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55525. /**
  55526. * Disposes of the effect renderer
  55527. */
  55528. dispose(): void;
  55529. }
  55530. /**
  55531. * Options to create an EffectWrapper
  55532. */
  55533. interface EffectWrapperCreationOptions {
  55534. /**
  55535. * Engine to use to create the effect
  55536. */
  55537. engine: Engine;
  55538. /**
  55539. * Fragment shader for the effect
  55540. */
  55541. fragmentShader: string;
  55542. /**
  55543. * Vertex shader for the effect
  55544. */
  55545. vertexShader?: string;
  55546. /**
  55547. * Attributes to use in the shader
  55548. */
  55549. attributeNames?: Array<string>;
  55550. /**
  55551. * Uniforms to use in the shader
  55552. */
  55553. uniformNames?: Array<string>;
  55554. /**
  55555. * Texture sampler names to use in the shader
  55556. */
  55557. samplerNames?: Array<string>;
  55558. /**
  55559. * The friendly name of the effect displayed in Spector.
  55560. */
  55561. name?: string;
  55562. }
  55563. /**
  55564. * Wraps an effect to be used for rendering
  55565. */
  55566. export class EffectWrapper {
  55567. /**
  55568. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55569. */
  55570. onApplyObservable: Observable<{}>;
  55571. /**
  55572. * The underlying effect
  55573. */
  55574. effect: Effect;
  55575. /**
  55576. * Creates an effect to be renderer
  55577. * @param creationOptions options to create the effect
  55578. */
  55579. constructor(creationOptions: EffectWrapperCreationOptions);
  55580. /**
  55581. * Disposes of the effect wrapper
  55582. */
  55583. dispose(): void;
  55584. }
  55585. }
  55586. declare module BABYLON {
  55587. /**
  55588. * Helper class to push actions to a pool of workers.
  55589. */
  55590. export class WorkerPool implements IDisposable {
  55591. private _workerInfos;
  55592. private _pendingActions;
  55593. /**
  55594. * Constructor
  55595. * @param workers Array of workers to use for actions
  55596. */
  55597. constructor(workers: Array<Worker>);
  55598. /**
  55599. * Terminates all workers and clears any pending actions.
  55600. */
  55601. dispose(): void;
  55602. /**
  55603. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55604. * pended until a worker has completed its action.
  55605. * @param action The action to perform. Call onComplete when the action is complete.
  55606. */
  55607. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55608. private _execute;
  55609. }
  55610. }
  55611. declare module BABYLON {
  55612. /**
  55613. * Configuration for Draco compression
  55614. */
  55615. export interface IDracoCompressionConfiguration {
  55616. /**
  55617. * Configuration for the decoder.
  55618. */
  55619. decoder: {
  55620. /**
  55621. * The url to the WebAssembly module.
  55622. */
  55623. wasmUrl?: string;
  55624. /**
  55625. * The url to the WebAssembly binary.
  55626. */
  55627. wasmBinaryUrl?: string;
  55628. /**
  55629. * The url to the fallback JavaScript module.
  55630. */
  55631. fallbackUrl?: string;
  55632. };
  55633. }
  55634. /**
  55635. * Draco compression (https://google.github.io/draco/)
  55636. *
  55637. * This class wraps the Draco module.
  55638. *
  55639. * **Encoder**
  55640. *
  55641. * The encoder is not currently implemented.
  55642. *
  55643. * **Decoder**
  55644. *
  55645. * 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.
  55646. *
  55647. * To update the configuration, use the following code:
  55648. * ```javascript
  55649. * DracoCompression.Configuration = {
  55650. * decoder: {
  55651. * wasmUrl: "<url to the WebAssembly library>",
  55652. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55653. * fallbackUrl: "<url to the fallback JavaScript library>",
  55654. * }
  55655. * };
  55656. * ```
  55657. *
  55658. * 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.
  55659. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55660. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55661. *
  55662. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55663. * ```javascript
  55664. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55665. * ```
  55666. *
  55667. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55668. */
  55669. export class DracoCompression implements IDisposable {
  55670. private _workerPoolPromise?;
  55671. private _decoderModulePromise?;
  55672. /**
  55673. * The configuration. Defaults to the following urls:
  55674. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55675. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55676. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55677. */
  55678. static Configuration: IDracoCompressionConfiguration;
  55679. /**
  55680. * Returns true if the decoder configuration is available.
  55681. */
  55682. static readonly DecoderAvailable: boolean;
  55683. /**
  55684. * Default number of workers to create when creating the draco compression object.
  55685. */
  55686. static DefaultNumWorkers: number;
  55687. private static GetDefaultNumWorkers;
  55688. private static _Default;
  55689. /**
  55690. * Default instance for the draco compression object.
  55691. */
  55692. static readonly Default: DracoCompression;
  55693. /**
  55694. * Constructor
  55695. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55696. */
  55697. constructor(numWorkers?: number);
  55698. /**
  55699. * Stop all async operations and release resources.
  55700. */
  55701. dispose(): void;
  55702. /**
  55703. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55704. * @returns a promise that resolves when ready
  55705. */
  55706. whenReadyAsync(): Promise<void>;
  55707. /**
  55708. * Decode Draco compressed mesh data to vertex data.
  55709. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55710. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55711. * @returns A promise that resolves with the decoded vertex data
  55712. */
  55713. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55714. [kind: string]: number;
  55715. }): Promise<VertexData>;
  55716. }
  55717. }
  55718. declare module BABYLON {
  55719. /**
  55720. * Class for building Constructive Solid Geometry
  55721. */
  55722. export class CSG {
  55723. private polygons;
  55724. /**
  55725. * The world matrix
  55726. */
  55727. matrix: Matrix;
  55728. /**
  55729. * Stores the position
  55730. */
  55731. position: Vector3;
  55732. /**
  55733. * Stores the rotation
  55734. */
  55735. rotation: Vector3;
  55736. /**
  55737. * Stores the rotation quaternion
  55738. */
  55739. rotationQuaternion: Nullable<Quaternion>;
  55740. /**
  55741. * Stores the scaling vector
  55742. */
  55743. scaling: Vector3;
  55744. /**
  55745. * Convert the Mesh to CSG
  55746. * @param mesh The Mesh to convert to CSG
  55747. * @returns A new CSG from the Mesh
  55748. */
  55749. static FromMesh(mesh: Mesh): CSG;
  55750. /**
  55751. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55752. * @param polygons Polygons used to construct a CSG solid
  55753. */
  55754. private static FromPolygons;
  55755. /**
  55756. * Clones, or makes a deep copy, of the CSG
  55757. * @returns A new CSG
  55758. */
  55759. clone(): CSG;
  55760. /**
  55761. * Unions this CSG with another CSG
  55762. * @param csg The CSG to union against this CSG
  55763. * @returns The unioned CSG
  55764. */
  55765. union(csg: CSG): CSG;
  55766. /**
  55767. * Unions this CSG with another CSG in place
  55768. * @param csg The CSG to union against this CSG
  55769. */
  55770. unionInPlace(csg: CSG): void;
  55771. /**
  55772. * Subtracts this CSG with another CSG
  55773. * @param csg The CSG to subtract against this CSG
  55774. * @returns A new CSG
  55775. */
  55776. subtract(csg: CSG): CSG;
  55777. /**
  55778. * Subtracts this CSG with another CSG in place
  55779. * @param csg The CSG to subtact against this CSG
  55780. */
  55781. subtractInPlace(csg: CSG): void;
  55782. /**
  55783. * Intersect this CSG with another CSG
  55784. * @param csg The CSG to intersect against this CSG
  55785. * @returns A new CSG
  55786. */
  55787. intersect(csg: CSG): CSG;
  55788. /**
  55789. * Intersects this CSG with another CSG in place
  55790. * @param csg The CSG to intersect against this CSG
  55791. */
  55792. intersectInPlace(csg: CSG): void;
  55793. /**
  55794. * Return a new CSG solid with solid and empty space switched. This solid is
  55795. * not modified.
  55796. * @returns A new CSG solid with solid and empty space switched
  55797. */
  55798. inverse(): CSG;
  55799. /**
  55800. * Inverses the CSG in place
  55801. */
  55802. inverseInPlace(): void;
  55803. /**
  55804. * This is used to keep meshes transformations so they can be restored
  55805. * when we build back a Babylon Mesh
  55806. * NB : All CSG operations are performed in world coordinates
  55807. * @param csg The CSG to copy the transform attributes from
  55808. * @returns This CSG
  55809. */
  55810. copyTransformAttributes(csg: CSG): CSG;
  55811. /**
  55812. * Build Raw mesh from CSG
  55813. * Coordinates here are in world space
  55814. * @param name The name of the mesh geometry
  55815. * @param scene The Scene
  55816. * @param keepSubMeshes Specifies if the submeshes should be kept
  55817. * @returns A new Mesh
  55818. */
  55819. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55820. /**
  55821. * Build Mesh from CSG taking material and transforms into account
  55822. * @param name The name of the Mesh
  55823. * @param material The material of the Mesh
  55824. * @param scene The Scene
  55825. * @param keepSubMeshes Specifies if submeshes should be kept
  55826. * @returns The new Mesh
  55827. */
  55828. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55829. }
  55830. }
  55831. declare module BABYLON {
  55832. /**
  55833. * Class used to create a trail following a mesh
  55834. */
  55835. export class TrailMesh extends Mesh {
  55836. private _generator;
  55837. private _autoStart;
  55838. private _running;
  55839. private _diameter;
  55840. private _length;
  55841. private _sectionPolygonPointsCount;
  55842. private _sectionVectors;
  55843. private _sectionNormalVectors;
  55844. private _beforeRenderObserver;
  55845. /**
  55846. * @constructor
  55847. * @param name The value used by scene.getMeshByName() to do a lookup.
  55848. * @param generator The mesh to generate a trail.
  55849. * @param scene The scene to add this mesh to.
  55850. * @param diameter Diameter of trailing mesh. Default is 1.
  55851. * @param length Length of trailing mesh. Default is 60.
  55852. * @param autoStart Automatically start trailing mesh. Default true.
  55853. */
  55854. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55855. /**
  55856. * "TrailMesh"
  55857. * @returns "TrailMesh"
  55858. */
  55859. getClassName(): string;
  55860. private _createMesh;
  55861. /**
  55862. * Start trailing mesh.
  55863. */
  55864. start(): void;
  55865. /**
  55866. * Stop trailing mesh.
  55867. */
  55868. stop(): void;
  55869. /**
  55870. * Update trailing mesh geometry.
  55871. */
  55872. update(): void;
  55873. /**
  55874. * Returns a new TrailMesh object.
  55875. * @param name is a string, the name given to the new mesh
  55876. * @param newGenerator use new generator object for cloned trail mesh
  55877. * @returns a new mesh
  55878. */
  55879. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55880. /**
  55881. * Serializes this trail mesh
  55882. * @param serializationObject object to write serialization to
  55883. */
  55884. serialize(serializationObject: any): void;
  55885. /**
  55886. * Parses a serialized trail mesh
  55887. * @param parsedMesh the serialized mesh
  55888. * @param scene the scene to create the trail mesh in
  55889. * @returns the created trail mesh
  55890. */
  55891. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55892. }
  55893. }
  55894. declare module BABYLON {
  55895. /**
  55896. * Class containing static functions to help procedurally build meshes
  55897. */
  55898. export class TiledBoxBuilder {
  55899. /**
  55900. * Creates a box mesh
  55901. * 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)
  55902. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55904. * * 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
  55905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55906. * @param name defines the name of the mesh
  55907. * @param options defines the options used to create the mesh
  55908. * @param scene defines the hosting scene
  55909. * @returns the box mesh
  55910. */
  55911. static CreateTiledBox(name: string, options: {
  55912. pattern?: number;
  55913. width?: number;
  55914. height?: number;
  55915. depth?: number;
  55916. tileSize?: number;
  55917. tileWidth?: number;
  55918. tileHeight?: number;
  55919. alignHorizontal?: number;
  55920. alignVertical?: number;
  55921. faceUV?: Vector4[];
  55922. faceColors?: Color4[];
  55923. sideOrientation?: number;
  55924. updatable?: boolean;
  55925. }, scene?: Nullable<Scene>): Mesh;
  55926. }
  55927. }
  55928. declare module BABYLON {
  55929. /**
  55930. * Class containing static functions to help procedurally build meshes
  55931. */
  55932. export class TorusKnotBuilder {
  55933. /**
  55934. * Creates a torus knot mesh
  55935. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55936. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55937. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55938. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55940. * * 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
  55941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55942. * @param name defines the name of the mesh
  55943. * @param options defines the options used to create the mesh
  55944. * @param scene defines the hosting scene
  55945. * @returns the torus knot mesh
  55946. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55947. */
  55948. static CreateTorusKnot(name: string, options: {
  55949. radius?: number;
  55950. tube?: number;
  55951. radialSegments?: number;
  55952. tubularSegments?: number;
  55953. p?: number;
  55954. q?: number;
  55955. updatable?: boolean;
  55956. sideOrientation?: number;
  55957. frontUVs?: Vector4;
  55958. backUVs?: Vector4;
  55959. }, scene: any): Mesh;
  55960. }
  55961. }
  55962. declare module BABYLON {
  55963. /**
  55964. * Polygon
  55965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55966. */
  55967. export class Polygon {
  55968. /**
  55969. * Creates a rectangle
  55970. * @param xmin bottom X coord
  55971. * @param ymin bottom Y coord
  55972. * @param xmax top X coord
  55973. * @param ymax top Y coord
  55974. * @returns points that make the resulting rectation
  55975. */
  55976. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55977. /**
  55978. * Creates a circle
  55979. * @param radius radius of circle
  55980. * @param cx scale in x
  55981. * @param cy scale in y
  55982. * @param numberOfSides number of sides that make up the circle
  55983. * @returns points that make the resulting circle
  55984. */
  55985. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55986. /**
  55987. * Creates a polygon from input string
  55988. * @param input Input polygon data
  55989. * @returns the parsed points
  55990. */
  55991. static Parse(input: string): Vector2[];
  55992. /**
  55993. * Starts building a polygon from x and y coordinates
  55994. * @param x x coordinate
  55995. * @param y y coordinate
  55996. * @returns the started path2
  55997. */
  55998. static StartingAt(x: number, y: number): Path2;
  55999. }
  56000. /**
  56001. * Builds a polygon
  56002. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56003. */
  56004. export class PolygonMeshBuilder {
  56005. private _points;
  56006. private _outlinepoints;
  56007. private _holes;
  56008. private _name;
  56009. private _scene;
  56010. private _epoints;
  56011. private _eholes;
  56012. private _addToepoint;
  56013. /**
  56014. * Babylon reference to the earcut plugin.
  56015. */
  56016. bjsEarcut: any;
  56017. /**
  56018. * Creates a PolygonMeshBuilder
  56019. * @param name name of the builder
  56020. * @param contours Path of the polygon
  56021. * @param scene scene to add to when creating the mesh
  56022. * @param earcutInjection can be used to inject your own earcut reference
  56023. */
  56024. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56025. /**
  56026. * Adds a whole within the polygon
  56027. * @param hole Array of points defining the hole
  56028. * @returns this
  56029. */
  56030. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56031. /**
  56032. * Creates the polygon
  56033. * @param updatable If the mesh should be updatable
  56034. * @param depth The depth of the mesh created
  56035. * @returns the created mesh
  56036. */
  56037. build(updatable?: boolean, depth?: number): Mesh;
  56038. /**
  56039. * Creates the polygon
  56040. * @param depth The depth of the mesh created
  56041. * @returns the created VertexData
  56042. */
  56043. buildVertexData(depth?: number): VertexData;
  56044. /**
  56045. * Adds a side to the polygon
  56046. * @param positions points that make the polygon
  56047. * @param normals normals of the polygon
  56048. * @param uvs uvs of the polygon
  56049. * @param indices indices of the polygon
  56050. * @param bounds bounds of the polygon
  56051. * @param points points of the polygon
  56052. * @param depth depth of the polygon
  56053. * @param flip flip of the polygon
  56054. */
  56055. private addSide;
  56056. }
  56057. }
  56058. declare module BABYLON {
  56059. /**
  56060. * Class containing static functions to help procedurally build meshes
  56061. */
  56062. export class PolygonBuilder {
  56063. /**
  56064. * Creates a polygon mesh
  56065. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56066. * * 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
  56067. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56069. * * 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)
  56070. * * Remember you can only change the shape positions, not their number when updating a polygon
  56071. * @param name defines the name of the mesh
  56072. * @param options defines the options used to create the mesh
  56073. * @param scene defines the hosting scene
  56074. * @param earcutInjection can be used to inject your own earcut reference
  56075. * @returns the polygon mesh
  56076. */
  56077. static CreatePolygon(name: string, options: {
  56078. shape: Vector3[];
  56079. holes?: Vector3[][];
  56080. depth?: number;
  56081. faceUV?: Vector4[];
  56082. faceColors?: Color4[];
  56083. updatable?: boolean;
  56084. sideOrientation?: number;
  56085. frontUVs?: Vector4;
  56086. backUVs?: Vector4;
  56087. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56088. /**
  56089. * Creates an extruded polygon mesh, with depth in the Y direction.
  56090. * * 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)
  56091. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56092. * @param name defines the name of the mesh
  56093. * @param options defines the options used to create the mesh
  56094. * @param scene defines the hosting scene
  56095. * @param earcutInjection can be used to inject your own earcut reference
  56096. * @returns the polygon mesh
  56097. */
  56098. static ExtrudePolygon(name: string, options: {
  56099. shape: Vector3[];
  56100. holes?: Vector3[][];
  56101. depth?: number;
  56102. faceUV?: Vector4[];
  56103. faceColors?: Color4[];
  56104. updatable?: boolean;
  56105. sideOrientation?: number;
  56106. frontUVs?: Vector4;
  56107. backUVs?: Vector4;
  56108. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56109. }
  56110. }
  56111. declare module BABYLON {
  56112. /**
  56113. * Class containing static functions to help procedurally build meshes
  56114. */
  56115. export class LatheBuilder {
  56116. /**
  56117. * Creates lathe mesh.
  56118. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56119. * * 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
  56120. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56121. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56122. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56123. * * 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
  56124. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56125. * * 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
  56126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56127. * * 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
  56128. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56130. * @param name defines the name of the mesh
  56131. * @param options defines the options used to create the mesh
  56132. * @param scene defines the hosting scene
  56133. * @returns the lathe mesh
  56134. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56135. */
  56136. static CreateLathe(name: string, options: {
  56137. shape: Vector3[];
  56138. radius?: number;
  56139. tessellation?: number;
  56140. clip?: number;
  56141. arc?: number;
  56142. closed?: boolean;
  56143. updatable?: boolean;
  56144. sideOrientation?: number;
  56145. frontUVs?: Vector4;
  56146. backUVs?: Vector4;
  56147. cap?: number;
  56148. invertUV?: boolean;
  56149. }, scene?: Nullable<Scene>): Mesh;
  56150. }
  56151. }
  56152. declare module BABYLON {
  56153. /**
  56154. * Class containing static functions to help procedurally build meshes
  56155. */
  56156. export class TiledPlaneBuilder {
  56157. /**
  56158. * Creates a tiled plane mesh
  56159. * * The parameter `pattern` will, depending on value, do nothing or
  56160. * * * flip (reflect about central vertical) alternate tiles across and up
  56161. * * * flip every tile on alternate rows
  56162. * * * rotate (180 degs) alternate tiles across and up
  56163. * * * rotate every tile on alternate rows
  56164. * * * flip and rotate alternate tiles across and up
  56165. * * * flip and rotate every tile on alternate rows
  56166. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56167. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56168. * * 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
  56169. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56170. * * 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)
  56171. * * 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)
  56172. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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. * @returns the box mesh
  56177. */
  56178. static CreateTiledPlane(name: string, options: {
  56179. pattern?: number;
  56180. tileSize?: number;
  56181. tileWidth?: number;
  56182. tileHeight?: number;
  56183. size?: number;
  56184. width?: number;
  56185. height?: number;
  56186. alignHorizontal?: number;
  56187. alignVertical?: number;
  56188. sideOrientation?: number;
  56189. frontUVs?: Vector4;
  56190. backUVs?: Vector4;
  56191. updatable?: boolean;
  56192. }, scene?: Nullable<Scene>): Mesh;
  56193. }
  56194. }
  56195. declare module BABYLON {
  56196. /**
  56197. * Class containing static functions to help procedurally build meshes
  56198. */
  56199. export class TubeBuilder {
  56200. /**
  56201. * Creates a tube mesh.
  56202. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56203. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56204. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56205. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56206. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56207. * * 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)
  56208. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56209. * * 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
  56210. * * 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
  56211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56212. * * 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
  56213. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56215. * @param name defines the name of the mesh
  56216. * @param options defines the options used to create the mesh
  56217. * @param scene defines the hosting scene
  56218. * @returns the tube mesh
  56219. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56220. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56221. */
  56222. static CreateTube(name: string, options: {
  56223. path: Vector3[];
  56224. radius?: number;
  56225. tessellation?: number;
  56226. radiusFunction?: {
  56227. (i: number, distance: number): number;
  56228. };
  56229. cap?: number;
  56230. arc?: number;
  56231. updatable?: boolean;
  56232. sideOrientation?: number;
  56233. frontUVs?: Vector4;
  56234. backUVs?: Vector4;
  56235. instance?: Mesh;
  56236. invertUV?: boolean;
  56237. }, scene?: Nullable<Scene>): Mesh;
  56238. }
  56239. }
  56240. declare module BABYLON {
  56241. /**
  56242. * Class containing static functions to help procedurally build meshes
  56243. */
  56244. export class IcoSphereBuilder {
  56245. /**
  56246. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56247. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56248. * * 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`)
  56249. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56250. * * 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
  56251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56252. * * 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
  56253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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 icosahedron mesh
  56258. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56259. */
  56260. static CreateIcoSphere(name: string, options: {
  56261. radius?: number;
  56262. radiusX?: number;
  56263. radiusY?: number;
  56264. radiusZ?: number;
  56265. flat?: boolean;
  56266. subdivisions?: number;
  56267. sideOrientation?: number;
  56268. frontUVs?: Vector4;
  56269. backUVs?: Vector4;
  56270. updatable?: boolean;
  56271. }, scene?: Nullable<Scene>): Mesh;
  56272. }
  56273. }
  56274. declare module BABYLON {
  56275. /**
  56276. * Class containing static functions to help procedurally build meshes
  56277. */
  56278. export class DecalBuilder {
  56279. /**
  56280. * Creates a decal mesh.
  56281. * 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
  56282. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56283. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56284. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56285. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56286. * @param name defines the name of the mesh
  56287. * @param sourceMesh defines the mesh where the decal must be applied
  56288. * @param options defines the options used to create the mesh
  56289. * @param scene defines the hosting scene
  56290. * @returns the decal mesh
  56291. * @see https://doc.babylonjs.com/how_to/decals
  56292. */
  56293. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56294. position?: Vector3;
  56295. normal?: Vector3;
  56296. size?: Vector3;
  56297. angle?: number;
  56298. }): Mesh;
  56299. }
  56300. }
  56301. declare module BABYLON {
  56302. /**
  56303. * Class containing static functions to help procedurally build meshes
  56304. */
  56305. export class MeshBuilder {
  56306. /**
  56307. * Creates a box mesh
  56308. * * The parameter `size` sets the size (float) of each box side (default 1)
  56309. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56310. * * 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)
  56311. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56313. * * 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
  56314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56315. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56316. * @param name defines the name of the mesh
  56317. * @param options defines the options used to create the mesh
  56318. * @param scene defines the hosting scene
  56319. * @returns the box mesh
  56320. */
  56321. static CreateBox(name: string, options: {
  56322. size?: number;
  56323. width?: number;
  56324. height?: number;
  56325. depth?: number;
  56326. faceUV?: Vector4[];
  56327. faceColors?: Color4[];
  56328. sideOrientation?: number;
  56329. frontUVs?: Vector4;
  56330. backUVs?: Vector4;
  56331. updatable?: boolean;
  56332. }, scene?: Nullable<Scene>): Mesh;
  56333. /**
  56334. * Creates a tiled box mesh
  56335. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56337. * @param name defines the name of the mesh
  56338. * @param options defines the options used to create the mesh
  56339. * @param scene defines the hosting scene
  56340. * @returns the tiled box mesh
  56341. */
  56342. static CreateTiledBox(name: string, options: {
  56343. pattern?: number;
  56344. size?: number;
  56345. width?: number;
  56346. height?: number;
  56347. depth: number;
  56348. tileSize?: number;
  56349. tileWidth?: number;
  56350. tileHeight?: number;
  56351. faceUV?: Vector4[];
  56352. faceColors?: Color4[];
  56353. alignHorizontal?: number;
  56354. alignVertical?: number;
  56355. sideOrientation?: number;
  56356. updatable?: boolean;
  56357. }, scene?: Nullable<Scene>): Mesh;
  56358. /**
  56359. * Creates a sphere mesh
  56360. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56361. * * 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`)
  56362. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56363. * * 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
  56364. * * 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)
  56365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56366. * * 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
  56367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56368. * @param name defines the name of the mesh
  56369. * @param options defines the options used to create the mesh
  56370. * @param scene defines the hosting scene
  56371. * @returns the sphere mesh
  56372. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56373. */
  56374. static CreateSphere(name: string, options: {
  56375. segments?: number;
  56376. diameter?: number;
  56377. diameterX?: number;
  56378. diameterY?: number;
  56379. diameterZ?: number;
  56380. arc?: number;
  56381. slice?: number;
  56382. sideOrientation?: number;
  56383. frontUVs?: Vector4;
  56384. backUVs?: Vector4;
  56385. updatable?: boolean;
  56386. }, scene?: Nullable<Scene>): Mesh;
  56387. /**
  56388. * Creates a plane polygonal mesh. By default, this is a disc
  56389. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56390. * * 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
  56391. * * 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
  56392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56393. * * 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
  56394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56395. * @param name defines the name of the mesh
  56396. * @param options defines the options used to create the mesh
  56397. * @param scene defines the hosting scene
  56398. * @returns the plane polygonal mesh
  56399. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56400. */
  56401. static CreateDisc(name: string, options: {
  56402. radius?: number;
  56403. tessellation?: number;
  56404. arc?: number;
  56405. updatable?: boolean;
  56406. sideOrientation?: number;
  56407. frontUVs?: Vector4;
  56408. backUVs?: Vector4;
  56409. }, scene?: Nullable<Scene>): Mesh;
  56410. /**
  56411. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56412. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56413. * * 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`)
  56414. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56415. * * 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
  56416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56417. * * 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
  56418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56419. * @param name defines the name of the mesh
  56420. * @param options defines the options used to create the mesh
  56421. * @param scene defines the hosting scene
  56422. * @returns the icosahedron mesh
  56423. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56424. */
  56425. static CreateIcoSphere(name: string, options: {
  56426. radius?: number;
  56427. radiusX?: number;
  56428. radiusY?: number;
  56429. radiusZ?: number;
  56430. flat?: boolean;
  56431. subdivisions?: number;
  56432. sideOrientation?: number;
  56433. frontUVs?: Vector4;
  56434. backUVs?: Vector4;
  56435. updatable?: boolean;
  56436. }, scene?: Nullable<Scene>): Mesh;
  56437. /**
  56438. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56439. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56440. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56441. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56442. * * 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
  56443. * * 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
  56444. * * 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
  56445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56446. * * 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
  56447. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56448. * * 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
  56449. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56450. * * 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
  56451. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56453. * @param name defines the name of the mesh
  56454. * @param options defines the options used to create the mesh
  56455. * @param scene defines the hosting scene
  56456. * @returns the ribbon mesh
  56457. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56458. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56459. */
  56460. static CreateRibbon(name: string, options: {
  56461. pathArray: Vector3[][];
  56462. closeArray?: boolean;
  56463. closePath?: boolean;
  56464. offset?: number;
  56465. updatable?: boolean;
  56466. sideOrientation?: number;
  56467. frontUVs?: Vector4;
  56468. backUVs?: Vector4;
  56469. instance?: Mesh;
  56470. invertUV?: boolean;
  56471. uvs?: Vector2[];
  56472. colors?: Color4[];
  56473. }, scene?: Nullable<Scene>): Mesh;
  56474. /**
  56475. * Creates a cylinder or a cone mesh
  56476. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56477. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56478. * * 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.
  56479. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56480. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56481. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56482. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56483. * * 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).
  56484. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56485. * * 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).
  56486. * * 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
  56487. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56488. * * 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
  56489. * * 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.
  56490. * * If `enclose` is false, a ring surface is one element.
  56491. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56492. * * 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
  56493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56494. * * 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
  56495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56496. * @param name defines the name of the mesh
  56497. * @param options defines the options used to create the mesh
  56498. * @param scene defines the hosting scene
  56499. * @returns the cylinder mesh
  56500. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56501. */
  56502. static CreateCylinder(name: string, options: {
  56503. height?: number;
  56504. diameterTop?: number;
  56505. diameterBottom?: number;
  56506. diameter?: number;
  56507. tessellation?: number;
  56508. subdivisions?: number;
  56509. arc?: number;
  56510. faceColors?: Color4[];
  56511. faceUV?: Vector4[];
  56512. updatable?: boolean;
  56513. hasRings?: boolean;
  56514. enclose?: boolean;
  56515. cap?: number;
  56516. sideOrientation?: number;
  56517. frontUVs?: Vector4;
  56518. backUVs?: Vector4;
  56519. }, scene?: Nullable<Scene>): Mesh;
  56520. /**
  56521. * Creates a torus mesh
  56522. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56523. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56524. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56526. * * 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
  56527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56528. * @param name defines the name of the mesh
  56529. * @param options defines the options used to create the mesh
  56530. * @param scene defines the hosting scene
  56531. * @returns the torus mesh
  56532. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56533. */
  56534. static CreateTorus(name: string, options: {
  56535. diameter?: number;
  56536. thickness?: number;
  56537. tessellation?: number;
  56538. updatable?: boolean;
  56539. sideOrientation?: number;
  56540. frontUVs?: Vector4;
  56541. backUVs?: Vector4;
  56542. }, scene?: Nullable<Scene>): Mesh;
  56543. /**
  56544. * Creates a torus knot mesh
  56545. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56546. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56547. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56548. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56550. * * 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
  56551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56552. * @param name defines the name of the mesh
  56553. * @param options defines the options used to create the mesh
  56554. * @param scene defines the hosting scene
  56555. * @returns the torus knot mesh
  56556. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56557. */
  56558. static CreateTorusKnot(name: string, options: {
  56559. radius?: number;
  56560. tube?: number;
  56561. radialSegments?: number;
  56562. tubularSegments?: number;
  56563. p?: number;
  56564. q?: number;
  56565. updatable?: boolean;
  56566. sideOrientation?: number;
  56567. frontUVs?: Vector4;
  56568. backUVs?: Vector4;
  56569. }, scene?: Nullable<Scene>): Mesh;
  56570. /**
  56571. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56572. * * 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
  56573. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56574. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56575. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56576. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56577. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56578. * * 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
  56579. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56582. * @param name defines the name of the new line system
  56583. * @param options defines the options used to create the line system
  56584. * @param scene defines the hosting scene
  56585. * @returns a new line system mesh
  56586. */
  56587. static CreateLineSystem(name: string, options: {
  56588. lines: Vector3[][];
  56589. updatable?: boolean;
  56590. instance?: Nullable<LinesMesh>;
  56591. colors?: Nullable<Color4[][]>;
  56592. useVertexAlpha?: boolean;
  56593. }, scene: Nullable<Scene>): LinesMesh;
  56594. /**
  56595. * Creates a line mesh
  56596. * 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
  56597. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56598. * * The parameter `points` is an array successive Vector3
  56599. * * 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
  56600. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56601. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56602. * * When updating an instance, remember that only point positions can change, not the number of points
  56603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56605. * @param name defines the name of the new line system
  56606. * @param options defines the options used to create the line system
  56607. * @param scene defines the hosting scene
  56608. * @returns a new line mesh
  56609. */
  56610. static CreateLines(name: string, options: {
  56611. points: Vector3[];
  56612. updatable?: boolean;
  56613. instance?: Nullable<LinesMesh>;
  56614. colors?: Color4[];
  56615. useVertexAlpha?: boolean;
  56616. }, scene?: Nullable<Scene>): LinesMesh;
  56617. /**
  56618. * Creates a dashed line mesh
  56619. * * 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
  56620. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56621. * * The parameter `points` is an array successive Vector3
  56622. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56623. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56624. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56625. * * 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
  56626. * * When updating an instance, remember that only point positions can change, not the number of points
  56627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56628. * @param name defines the name of the mesh
  56629. * @param options defines the options used to create the mesh
  56630. * @param scene defines the hosting scene
  56631. * @returns the dashed line mesh
  56632. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56633. */
  56634. static CreateDashedLines(name: string, options: {
  56635. points: Vector3[];
  56636. dashSize?: number;
  56637. gapSize?: number;
  56638. dashNb?: number;
  56639. updatable?: boolean;
  56640. instance?: LinesMesh;
  56641. }, scene?: Nullable<Scene>): LinesMesh;
  56642. /**
  56643. * 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.
  56644. * * 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.
  56645. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56646. * * 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.
  56647. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56648. * * 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
  56649. * * 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
  56650. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56652. * * 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
  56653. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56655. * @param name defines the name of the mesh
  56656. * @param options defines the options used to create the mesh
  56657. * @param scene defines the hosting scene
  56658. * @returns the extruded shape mesh
  56659. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56660. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56661. */
  56662. static ExtrudeShape(name: string, options: {
  56663. shape: Vector3[];
  56664. path: Vector3[];
  56665. scale?: number;
  56666. rotation?: number;
  56667. cap?: number;
  56668. updatable?: boolean;
  56669. sideOrientation?: number;
  56670. frontUVs?: Vector4;
  56671. backUVs?: Vector4;
  56672. instance?: Mesh;
  56673. invertUV?: boolean;
  56674. }, scene?: Nullable<Scene>): Mesh;
  56675. /**
  56676. * Creates an custom extruded shape mesh.
  56677. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56678. * * 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.
  56679. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56680. * * 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
  56681. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56682. * * 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
  56683. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56684. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56685. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56686. * * 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
  56687. * * 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
  56688. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56690. * * 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
  56691. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56693. * @param name defines the name of the mesh
  56694. * @param options defines the options used to create the mesh
  56695. * @param scene defines the hosting scene
  56696. * @returns the custom extruded shape mesh
  56697. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56698. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56699. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56700. */
  56701. static ExtrudeShapeCustom(name: string, options: {
  56702. shape: Vector3[];
  56703. path: Vector3[];
  56704. scaleFunction?: any;
  56705. rotationFunction?: any;
  56706. ribbonCloseArray?: boolean;
  56707. ribbonClosePath?: boolean;
  56708. cap?: number;
  56709. updatable?: boolean;
  56710. sideOrientation?: number;
  56711. frontUVs?: Vector4;
  56712. backUVs?: Vector4;
  56713. instance?: Mesh;
  56714. invertUV?: boolean;
  56715. }, scene?: Nullable<Scene>): Mesh;
  56716. /**
  56717. * Creates lathe mesh.
  56718. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56719. * * 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
  56720. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56721. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56722. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56723. * * 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
  56724. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56725. * * 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
  56726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56727. * * 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
  56728. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56730. * @param name defines the name of the mesh
  56731. * @param options defines the options used to create the mesh
  56732. * @param scene defines the hosting scene
  56733. * @returns the lathe mesh
  56734. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56735. */
  56736. static CreateLathe(name: string, options: {
  56737. shape: Vector3[];
  56738. radius?: number;
  56739. tessellation?: number;
  56740. clip?: number;
  56741. arc?: number;
  56742. closed?: boolean;
  56743. updatable?: boolean;
  56744. sideOrientation?: number;
  56745. frontUVs?: Vector4;
  56746. backUVs?: Vector4;
  56747. cap?: number;
  56748. invertUV?: boolean;
  56749. }, scene?: Nullable<Scene>): Mesh;
  56750. /**
  56751. * Creates a tiled plane mesh
  56752. * * You can set a limited pattern arrangement with the tiles
  56753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56754. * * 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
  56755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56756. * @param name defines the name of the mesh
  56757. * @param options defines the options used to create the mesh
  56758. * @param scene defines the hosting scene
  56759. * @returns the plane mesh
  56760. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56761. */
  56762. static CreateTiledPlane(name: string, options: {
  56763. pattern?: number;
  56764. tileSize?: number;
  56765. tileWidth?: number;
  56766. tileHeight?: number;
  56767. size?: number;
  56768. width?: number;
  56769. height?: number;
  56770. alignHorizontal?: number;
  56771. alignVertical?: number;
  56772. sideOrientation?: number;
  56773. frontUVs?: Vector4;
  56774. backUVs?: Vector4;
  56775. updatable?: boolean;
  56776. }, scene?: Nullable<Scene>): Mesh;
  56777. /**
  56778. * Creates a plane mesh
  56779. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56780. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56781. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56783. * * 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
  56784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56785. * @param name defines the name of the mesh
  56786. * @param options defines the options used to create the mesh
  56787. * @param scene defines the hosting scene
  56788. * @returns the plane mesh
  56789. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56790. */
  56791. static CreatePlane(name: string, options: {
  56792. size?: number;
  56793. width?: number;
  56794. height?: number;
  56795. sideOrientation?: number;
  56796. frontUVs?: Vector4;
  56797. backUVs?: Vector4;
  56798. updatable?: boolean;
  56799. sourcePlane?: Plane;
  56800. }, scene?: Nullable<Scene>): Mesh;
  56801. /**
  56802. * Creates a ground mesh
  56803. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56804. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56806. * @param name defines the name of the mesh
  56807. * @param options defines the options used to create the mesh
  56808. * @param scene defines the hosting scene
  56809. * @returns the ground mesh
  56810. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56811. */
  56812. static CreateGround(name: string, options: {
  56813. width?: number;
  56814. height?: number;
  56815. subdivisions?: number;
  56816. subdivisionsX?: number;
  56817. subdivisionsY?: number;
  56818. updatable?: boolean;
  56819. }, scene?: Nullable<Scene>): Mesh;
  56820. /**
  56821. * Creates a tiled ground mesh
  56822. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56823. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56824. * * 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
  56825. * * 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
  56826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56827. * @param name defines the name of the mesh
  56828. * @param options defines the options used to create the mesh
  56829. * @param scene defines the hosting scene
  56830. * @returns the tiled ground mesh
  56831. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56832. */
  56833. static CreateTiledGround(name: string, options: {
  56834. xmin: number;
  56835. zmin: number;
  56836. xmax: number;
  56837. zmax: number;
  56838. subdivisions?: {
  56839. w: number;
  56840. h: number;
  56841. };
  56842. precision?: {
  56843. w: number;
  56844. h: number;
  56845. };
  56846. updatable?: boolean;
  56847. }, scene?: Nullable<Scene>): Mesh;
  56848. /**
  56849. * Creates a ground mesh from a height map
  56850. * * The parameter `url` sets the URL of the height map image resource.
  56851. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56852. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56853. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56854. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56855. * * 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.
  56856. * * 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).
  56857. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56859. * @param name defines the name of the mesh
  56860. * @param url defines the url to the height map
  56861. * @param options defines the options used to create the mesh
  56862. * @param scene defines the hosting scene
  56863. * @returns the ground mesh
  56864. * @see https://doc.babylonjs.com/babylon101/height_map
  56865. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56866. */
  56867. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56868. width?: number;
  56869. height?: number;
  56870. subdivisions?: number;
  56871. minHeight?: number;
  56872. maxHeight?: number;
  56873. colorFilter?: Color3;
  56874. alphaFilter?: number;
  56875. updatable?: boolean;
  56876. onReady?: (mesh: GroundMesh) => void;
  56877. }, scene?: Nullable<Scene>): GroundMesh;
  56878. /**
  56879. * Creates a polygon mesh
  56880. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56881. * * 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
  56882. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56884. * * 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)
  56885. * * Remember you can only change the shape positions, not their number when updating a polygon
  56886. * @param name defines the name of the mesh
  56887. * @param options defines the options used to create the mesh
  56888. * @param scene defines the hosting scene
  56889. * @param earcutInjection can be used to inject your own earcut reference
  56890. * @returns the polygon mesh
  56891. */
  56892. static CreatePolygon(name: string, options: {
  56893. shape: Vector3[];
  56894. holes?: Vector3[][];
  56895. depth?: number;
  56896. faceUV?: Vector4[];
  56897. faceColors?: Color4[];
  56898. updatable?: boolean;
  56899. sideOrientation?: number;
  56900. frontUVs?: Vector4;
  56901. backUVs?: Vector4;
  56902. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56903. /**
  56904. * Creates an extruded polygon mesh, with depth in the Y direction.
  56905. * * 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)
  56906. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56907. * @param name defines the name of the mesh
  56908. * @param options defines the options used to create the mesh
  56909. * @param scene defines the hosting scene
  56910. * @param earcutInjection can be used to inject your own earcut reference
  56911. * @returns the polygon mesh
  56912. */
  56913. static ExtrudePolygon(name: string, options: {
  56914. shape: Vector3[];
  56915. holes?: Vector3[][];
  56916. depth?: number;
  56917. faceUV?: Vector4[];
  56918. faceColors?: Color4[];
  56919. updatable?: boolean;
  56920. sideOrientation?: number;
  56921. frontUVs?: Vector4;
  56922. backUVs?: Vector4;
  56923. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56924. /**
  56925. * Creates a tube mesh.
  56926. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56927. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56928. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56929. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56930. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56931. * * 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)
  56932. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56933. * * 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
  56934. * * 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
  56935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56936. * * 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
  56937. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56939. * @param name defines the name of the mesh
  56940. * @param options defines the options used to create the mesh
  56941. * @param scene defines the hosting scene
  56942. * @returns the tube mesh
  56943. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56944. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56945. */
  56946. static CreateTube(name: string, options: {
  56947. path: Vector3[];
  56948. radius?: number;
  56949. tessellation?: number;
  56950. radiusFunction?: {
  56951. (i: number, distance: number): number;
  56952. };
  56953. cap?: number;
  56954. arc?: number;
  56955. updatable?: boolean;
  56956. sideOrientation?: number;
  56957. frontUVs?: Vector4;
  56958. backUVs?: Vector4;
  56959. instance?: Mesh;
  56960. invertUV?: boolean;
  56961. }, scene?: Nullable<Scene>): Mesh;
  56962. /**
  56963. * Creates a polyhedron mesh
  56964. * * 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
  56965. * * The parameter `size` (positive float, default 1) sets the polygon size
  56966. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56967. * * 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`
  56968. * * 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
  56969. * * 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)`)
  56970. * * 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
  56971. * * 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
  56972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56975. * @param name defines the name of the mesh
  56976. * @param options defines the options used to create the mesh
  56977. * @param scene defines the hosting scene
  56978. * @returns the polyhedron mesh
  56979. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56980. */
  56981. static CreatePolyhedron(name: string, options: {
  56982. type?: number;
  56983. size?: number;
  56984. sizeX?: number;
  56985. sizeY?: number;
  56986. sizeZ?: number;
  56987. custom?: any;
  56988. faceUV?: Vector4[];
  56989. faceColors?: Color4[];
  56990. flat?: boolean;
  56991. updatable?: boolean;
  56992. sideOrientation?: number;
  56993. frontUVs?: Vector4;
  56994. backUVs?: Vector4;
  56995. }, scene?: Nullable<Scene>): Mesh;
  56996. /**
  56997. * Creates a decal mesh.
  56998. * 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
  56999. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57000. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57001. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57002. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57003. * @param name defines the name of the mesh
  57004. * @param sourceMesh defines the mesh where the decal must be applied
  57005. * @param options defines the options used to create the mesh
  57006. * @param scene defines the hosting scene
  57007. * @returns the decal mesh
  57008. * @see https://doc.babylonjs.com/how_to/decals
  57009. */
  57010. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57011. position?: Vector3;
  57012. normal?: Vector3;
  57013. size?: Vector3;
  57014. angle?: number;
  57015. }): Mesh;
  57016. }
  57017. }
  57018. declare module BABYLON {
  57019. /**
  57020. * A simplifier interface for future simplification implementations
  57021. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57022. */
  57023. export interface ISimplifier {
  57024. /**
  57025. * Simplification of a given mesh according to the given settings.
  57026. * Since this requires computation, it is assumed that the function runs async.
  57027. * @param settings The settings of the simplification, including quality and distance
  57028. * @param successCallback A callback that will be called after the mesh was simplified.
  57029. * @param errorCallback in case of an error, this callback will be called. optional.
  57030. */
  57031. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57032. }
  57033. /**
  57034. * Expected simplification settings.
  57035. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57036. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57037. */
  57038. export interface ISimplificationSettings {
  57039. /**
  57040. * Gets or sets the expected quality
  57041. */
  57042. quality: number;
  57043. /**
  57044. * Gets or sets the distance when this optimized version should be used
  57045. */
  57046. distance: number;
  57047. /**
  57048. * Gets an already optimized mesh
  57049. */
  57050. optimizeMesh?: boolean;
  57051. }
  57052. /**
  57053. * Class used to specify simplification options
  57054. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57055. */
  57056. export class SimplificationSettings implements ISimplificationSettings {
  57057. /** expected quality */
  57058. quality: number;
  57059. /** distance when this optimized version should be used */
  57060. distance: number;
  57061. /** already optimized mesh */
  57062. optimizeMesh?: boolean | undefined;
  57063. /**
  57064. * Creates a SimplificationSettings
  57065. * @param quality expected quality
  57066. * @param distance distance when this optimized version should be used
  57067. * @param optimizeMesh already optimized mesh
  57068. */
  57069. constructor(
  57070. /** expected quality */
  57071. quality: number,
  57072. /** distance when this optimized version should be used */
  57073. distance: number,
  57074. /** already optimized mesh */
  57075. optimizeMesh?: boolean | undefined);
  57076. }
  57077. /**
  57078. * Interface used to define a simplification task
  57079. */
  57080. export interface ISimplificationTask {
  57081. /**
  57082. * Array of settings
  57083. */
  57084. settings: Array<ISimplificationSettings>;
  57085. /**
  57086. * Simplification type
  57087. */
  57088. simplificationType: SimplificationType;
  57089. /**
  57090. * Mesh to simplify
  57091. */
  57092. mesh: Mesh;
  57093. /**
  57094. * Callback called on success
  57095. */
  57096. successCallback?: () => void;
  57097. /**
  57098. * Defines if parallel processing can be used
  57099. */
  57100. parallelProcessing: boolean;
  57101. }
  57102. /**
  57103. * Queue used to order the simplification tasks
  57104. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57105. */
  57106. export class SimplificationQueue {
  57107. private _simplificationArray;
  57108. /**
  57109. * Gets a boolean indicating that the process is still running
  57110. */
  57111. running: boolean;
  57112. /**
  57113. * Creates a new queue
  57114. */
  57115. constructor();
  57116. /**
  57117. * Adds a new simplification task
  57118. * @param task defines a task to add
  57119. */
  57120. addTask(task: ISimplificationTask): void;
  57121. /**
  57122. * Execute next task
  57123. */
  57124. executeNext(): void;
  57125. /**
  57126. * Execute a simplification task
  57127. * @param task defines the task to run
  57128. */
  57129. runSimplification(task: ISimplificationTask): void;
  57130. private getSimplifier;
  57131. }
  57132. /**
  57133. * The implemented types of simplification
  57134. * At the moment only Quadratic Error Decimation is implemented
  57135. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57136. */
  57137. export enum SimplificationType {
  57138. /** Quadratic error decimation */
  57139. QUADRATIC = 0
  57140. }
  57141. }
  57142. declare module BABYLON {
  57143. interface Scene {
  57144. /** @hidden (Backing field) */
  57145. _simplificationQueue: SimplificationQueue;
  57146. /**
  57147. * Gets or sets the simplification queue attached to the scene
  57148. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57149. */
  57150. simplificationQueue: SimplificationQueue;
  57151. }
  57152. interface Mesh {
  57153. /**
  57154. * Simplify the mesh according to the given array of settings.
  57155. * Function will return immediately and will simplify async
  57156. * @param settings a collection of simplification settings
  57157. * @param parallelProcessing should all levels calculate parallel or one after the other
  57158. * @param simplificationType the type of simplification to run
  57159. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57160. * @returns the current mesh
  57161. */
  57162. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57163. }
  57164. /**
  57165. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57166. * created in a scene
  57167. */
  57168. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57169. /**
  57170. * The component name helpfull to identify the component in the list of scene components.
  57171. */
  57172. readonly name: string;
  57173. /**
  57174. * The scene the component belongs to.
  57175. */
  57176. scene: Scene;
  57177. /**
  57178. * Creates a new instance of the component for the given scene
  57179. * @param scene Defines the scene to register the component in
  57180. */
  57181. constructor(scene: Scene);
  57182. /**
  57183. * Registers the component in a given scene
  57184. */
  57185. register(): void;
  57186. /**
  57187. * Rebuilds the elements related to this component in case of
  57188. * context lost for instance.
  57189. */
  57190. rebuild(): void;
  57191. /**
  57192. * Disposes the component and the associated ressources
  57193. */
  57194. dispose(): void;
  57195. private _beforeCameraUpdate;
  57196. }
  57197. }
  57198. declare module BABYLON {
  57199. /**
  57200. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57201. */
  57202. export interface INavigationEnginePlugin {
  57203. /**
  57204. * plugin name
  57205. */
  57206. name: string;
  57207. /**
  57208. * Creates a navigation mesh
  57209. * @param meshes array of all the geometry used to compute the navigatio mesh
  57210. * @param parameters bunch of parameters used to filter geometry
  57211. */
  57212. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57213. /**
  57214. * Create a navigation mesh debug mesh
  57215. * @param scene is where the mesh will be added
  57216. * @returns debug display mesh
  57217. */
  57218. createDebugNavMesh(scene: Scene): Mesh;
  57219. /**
  57220. * Get a navigation mesh constrained position, closest to the parameter position
  57221. * @param position world position
  57222. * @returns the closest point to position constrained by the navigation mesh
  57223. */
  57224. getClosestPoint(position: Vector3): Vector3;
  57225. /**
  57226. * Get a navigation mesh constrained position, within a particular radius
  57227. * @param position world position
  57228. * @param maxRadius the maximum distance to the constrained world position
  57229. * @returns the closest point to position constrained by the navigation mesh
  57230. */
  57231. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57232. /**
  57233. * Compute the final position from a segment made of destination-position
  57234. * @param position world position
  57235. * @param destination world position
  57236. * @returns the resulting point along the navmesh
  57237. */
  57238. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57239. /**
  57240. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57241. * @param start world position
  57242. * @param end world position
  57243. * @returns array containing world position composing the path
  57244. */
  57245. computePath(start: Vector3, end: Vector3): Vector3[];
  57246. /**
  57247. * If this plugin is supported
  57248. * @returns true if plugin is supported
  57249. */
  57250. isSupported(): boolean;
  57251. /**
  57252. * Create a new Crowd so you can add agents
  57253. * @param maxAgents the maximum agent count in the crowd
  57254. * @param maxAgentRadius the maximum radius an agent can have
  57255. * @param scene to attach the crowd to
  57256. * @returns the crowd you can add agents to
  57257. */
  57258. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57259. /**
  57260. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57261. * The queries will try to find a solution within those bounds
  57262. * default is (1,1,1)
  57263. * @param extent x,y,z value that define the extent around the queries point of reference
  57264. */
  57265. setDefaultQueryExtent(extent: Vector3): void;
  57266. /**
  57267. * Get the Bounding box extent specified by setDefaultQueryExtent
  57268. * @returns the box extent values
  57269. */
  57270. getDefaultQueryExtent(): Vector3;
  57271. /**
  57272. * Release all resources
  57273. */
  57274. dispose(): void;
  57275. }
  57276. /**
  57277. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57278. */
  57279. export interface ICrowd {
  57280. /**
  57281. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57282. * You can attach anything to that node. The node position is updated in the scene update tick.
  57283. * @param pos world position that will be constrained by the navigation mesh
  57284. * @param parameters agent parameters
  57285. * @param transform hooked to the agent that will be update by the scene
  57286. * @returns agent index
  57287. */
  57288. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57289. /**
  57290. * Returns the agent position in world space
  57291. * @param index agent index returned by addAgent
  57292. * @returns world space position
  57293. */
  57294. getAgentPosition(index: number): Vector3;
  57295. /**
  57296. * Gets the agent velocity in world space
  57297. * @param index agent index returned by addAgent
  57298. * @returns world space velocity
  57299. */
  57300. getAgentVelocity(index: number): Vector3;
  57301. /**
  57302. * remove a particular agent previously created
  57303. * @param index agent index returned by addAgent
  57304. */
  57305. removeAgent(index: number): void;
  57306. /**
  57307. * get the list of all agents attached to this crowd
  57308. * @returns list of agent indices
  57309. */
  57310. getAgents(): number[];
  57311. /**
  57312. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57313. * @param deltaTime in seconds
  57314. */
  57315. update(deltaTime: number): void;
  57316. /**
  57317. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57318. * @param index agent index returned by addAgent
  57319. * @param destination targeted world position
  57320. */
  57321. agentGoto(index: number, destination: Vector3): void;
  57322. /**
  57323. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57324. * The queries will try to find a solution within those bounds
  57325. * default is (1,1,1)
  57326. * @param extent x,y,z value that define the extent around the queries point of reference
  57327. */
  57328. setDefaultQueryExtent(extent: Vector3): void;
  57329. /**
  57330. * Get the Bounding box extent specified by setDefaultQueryExtent
  57331. * @returns the box extent values
  57332. */
  57333. getDefaultQueryExtent(): Vector3;
  57334. /**
  57335. * Release all resources
  57336. */
  57337. dispose(): void;
  57338. }
  57339. /**
  57340. * Configures an agent
  57341. */
  57342. export interface IAgentParameters {
  57343. /**
  57344. * Agent radius. [Limit: >= 0]
  57345. */
  57346. radius: number;
  57347. /**
  57348. * Agent height. [Limit: > 0]
  57349. */
  57350. height: number;
  57351. /**
  57352. * Maximum allowed acceleration. [Limit: >= 0]
  57353. */
  57354. maxAcceleration: number;
  57355. /**
  57356. * Maximum allowed speed. [Limit: >= 0]
  57357. */
  57358. maxSpeed: number;
  57359. /**
  57360. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57361. */
  57362. collisionQueryRange: number;
  57363. /**
  57364. * The path visibility optimization range. [Limit: > 0]
  57365. */
  57366. pathOptimizationRange: number;
  57367. /**
  57368. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57369. */
  57370. separationWeight: number;
  57371. }
  57372. /**
  57373. * Configures the navigation mesh creation
  57374. */
  57375. export interface INavMeshParameters {
  57376. /**
  57377. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57378. */
  57379. cs: number;
  57380. /**
  57381. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57382. */
  57383. ch: number;
  57384. /**
  57385. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57386. */
  57387. walkableSlopeAngle: number;
  57388. /**
  57389. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57390. * be considered walkable. [Limit: >= 3] [Units: vx]
  57391. */
  57392. walkableHeight: number;
  57393. /**
  57394. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57395. */
  57396. walkableClimb: number;
  57397. /**
  57398. * The distance to erode/shrink the walkable area of the heightfield away from
  57399. * obstructions. [Limit: >=0] [Units: vx]
  57400. */
  57401. walkableRadius: number;
  57402. /**
  57403. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57404. */
  57405. maxEdgeLen: number;
  57406. /**
  57407. * The maximum distance a simplfied contour's border edges should deviate
  57408. * the original raw contour. [Limit: >=0] [Units: vx]
  57409. */
  57410. maxSimplificationError: number;
  57411. /**
  57412. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57413. */
  57414. minRegionArea: number;
  57415. /**
  57416. * Any regions with a span count smaller than this value will, if possible,
  57417. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57418. */
  57419. mergeRegionArea: number;
  57420. /**
  57421. * The maximum number of vertices allowed for polygons generated during the
  57422. * contour to polygon conversion process. [Limit: >= 3]
  57423. */
  57424. maxVertsPerPoly: number;
  57425. /**
  57426. * Sets the sampling distance to use when generating the detail mesh.
  57427. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57428. */
  57429. detailSampleDist: number;
  57430. /**
  57431. * The maximum distance the detail mesh surface should deviate from heightfield
  57432. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57433. */
  57434. detailSampleMaxError: number;
  57435. }
  57436. }
  57437. declare module BABYLON {
  57438. /**
  57439. * RecastJS navigation plugin
  57440. */
  57441. export class RecastJSPlugin implements INavigationEnginePlugin {
  57442. /**
  57443. * Reference to the Recast library
  57444. */
  57445. bjsRECAST: any;
  57446. /**
  57447. * plugin name
  57448. */
  57449. name: string;
  57450. /**
  57451. * the first navmesh created. We might extend this to support multiple navmeshes
  57452. */
  57453. navMesh: any;
  57454. /**
  57455. * Initializes the recastJS plugin
  57456. * @param recastInjection can be used to inject your own recast reference
  57457. */
  57458. constructor(recastInjection?: any);
  57459. /**
  57460. * Creates a navigation mesh
  57461. * @param meshes array of all the geometry used to compute the navigatio mesh
  57462. * @param parameters bunch of parameters used to filter geometry
  57463. */
  57464. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57465. /**
  57466. * Create a navigation mesh debug mesh
  57467. * @param scene is where the mesh will be added
  57468. * @returns debug display mesh
  57469. */
  57470. createDebugNavMesh(scene: Scene): Mesh;
  57471. /**
  57472. * Get a navigation mesh constrained position, closest to the parameter position
  57473. * @param position world position
  57474. * @returns the closest point to position constrained by the navigation mesh
  57475. */
  57476. getClosestPoint(position: Vector3): Vector3;
  57477. /**
  57478. * Get a navigation mesh constrained position, within a particular radius
  57479. * @param position world position
  57480. * @param maxRadius the maximum distance to the constrained world position
  57481. * @returns the closest point to position constrained by the navigation mesh
  57482. */
  57483. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57484. /**
  57485. * Compute the final position from a segment made of destination-position
  57486. * @param position world position
  57487. * @param destination world position
  57488. * @returns the resulting point along the navmesh
  57489. */
  57490. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57491. /**
  57492. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57493. * @param start world position
  57494. * @param end world position
  57495. * @returns array containing world position composing the path
  57496. */
  57497. computePath(start: Vector3, end: Vector3): Vector3[];
  57498. /**
  57499. * Create a new Crowd so you can add agents
  57500. * @param maxAgents the maximum agent count in the crowd
  57501. * @param maxAgentRadius the maximum radius an agent can have
  57502. * @param scene to attach the crowd to
  57503. * @returns the crowd you can add agents to
  57504. */
  57505. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57506. /**
  57507. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57508. * The queries will try to find a solution within those bounds
  57509. * default is (1,1,1)
  57510. * @param extent x,y,z value that define the extent around the queries point of reference
  57511. */
  57512. setDefaultQueryExtent(extent: Vector3): void;
  57513. /**
  57514. * Get the Bounding box extent specified by setDefaultQueryExtent
  57515. * @returns the box extent values
  57516. */
  57517. getDefaultQueryExtent(): Vector3;
  57518. /**
  57519. * Disposes
  57520. */
  57521. dispose(): void;
  57522. /**
  57523. * If this plugin is supported
  57524. * @returns true if plugin is supported
  57525. */
  57526. isSupported(): boolean;
  57527. }
  57528. /**
  57529. * Recast detour crowd implementation
  57530. */
  57531. export class RecastJSCrowd implements ICrowd {
  57532. /**
  57533. * Recast/detour plugin
  57534. */
  57535. bjsRECASTPlugin: RecastJSPlugin;
  57536. /**
  57537. * Link to the detour crowd
  57538. */
  57539. recastCrowd: any;
  57540. /**
  57541. * One transform per agent
  57542. */
  57543. transforms: TransformNode[];
  57544. /**
  57545. * All agents created
  57546. */
  57547. agents: number[];
  57548. /**
  57549. * Link to the scene is kept to unregister the crowd from the scene
  57550. */
  57551. private _scene;
  57552. /**
  57553. * Observer for crowd updates
  57554. */
  57555. private _onBeforeAnimationsObserver;
  57556. /**
  57557. * Constructor
  57558. * @param plugin recastJS plugin
  57559. * @param maxAgents the maximum agent count in the crowd
  57560. * @param maxAgentRadius the maximum radius an agent can have
  57561. * @param scene to attach the crowd to
  57562. * @returns the crowd you can add agents to
  57563. */
  57564. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57565. /**
  57566. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57567. * You can attach anything to that node. The node position is updated in the scene update tick.
  57568. * @param pos world position that will be constrained by the navigation mesh
  57569. * @param parameters agent parameters
  57570. * @param transform hooked to the agent that will be update by the scene
  57571. * @returns agent index
  57572. */
  57573. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57574. /**
  57575. * Returns the agent position in world space
  57576. * @param index agent index returned by addAgent
  57577. * @returns world space position
  57578. */
  57579. getAgentPosition(index: number): Vector3;
  57580. /**
  57581. * Returns the agent velocity in world space
  57582. * @param index agent index returned by addAgent
  57583. * @returns world space velocity
  57584. */
  57585. getAgentVelocity(index: number): Vector3;
  57586. /**
  57587. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57588. * @param index agent index returned by addAgent
  57589. * @param destination targeted world position
  57590. */
  57591. agentGoto(index: number, destination: Vector3): void;
  57592. /**
  57593. * remove a particular agent previously created
  57594. * @param index agent index returned by addAgent
  57595. */
  57596. removeAgent(index: number): void;
  57597. /**
  57598. * get the list of all agents attached to this crowd
  57599. * @returns list of agent indices
  57600. */
  57601. getAgents(): number[];
  57602. /**
  57603. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57604. * @param deltaTime in seconds
  57605. */
  57606. update(deltaTime: number): void;
  57607. /**
  57608. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57609. * The queries will try to find a solution within those bounds
  57610. * default is (1,1,1)
  57611. * @param extent x,y,z value that define the extent around the queries point of reference
  57612. */
  57613. setDefaultQueryExtent(extent: Vector3): void;
  57614. /**
  57615. * Get the Bounding box extent specified by setDefaultQueryExtent
  57616. * @returns the box extent values
  57617. */
  57618. getDefaultQueryExtent(): Vector3;
  57619. /**
  57620. * Release all resources
  57621. */
  57622. dispose(): void;
  57623. }
  57624. }
  57625. declare module BABYLON {
  57626. /**
  57627. * Class used to enable access to IndexedDB
  57628. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57629. */
  57630. export class Database implements IOfflineProvider {
  57631. private _callbackManifestChecked;
  57632. private _currentSceneUrl;
  57633. private _db;
  57634. private _enableSceneOffline;
  57635. private _enableTexturesOffline;
  57636. private _manifestVersionFound;
  57637. private _mustUpdateRessources;
  57638. private _hasReachedQuota;
  57639. private _isSupported;
  57640. private _idbFactory;
  57641. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57642. private static IsUASupportingBlobStorage;
  57643. /**
  57644. * Gets a boolean indicating if Database storate is enabled (off by default)
  57645. */
  57646. static IDBStorageEnabled: boolean;
  57647. /**
  57648. * Gets a boolean indicating if scene must be saved in the database
  57649. */
  57650. readonly enableSceneOffline: boolean;
  57651. /**
  57652. * Gets a boolean indicating if textures must be saved in the database
  57653. */
  57654. readonly enableTexturesOffline: boolean;
  57655. /**
  57656. * Creates a new Database
  57657. * @param urlToScene defines the url to load the scene
  57658. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57659. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57660. */
  57661. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57662. private static _ParseURL;
  57663. private static _ReturnFullUrlLocation;
  57664. private _checkManifestFile;
  57665. /**
  57666. * Open the database and make it available
  57667. * @param successCallback defines the callback to call on success
  57668. * @param errorCallback defines the callback to call on error
  57669. */
  57670. open(successCallback: () => void, errorCallback: () => void): void;
  57671. /**
  57672. * Loads an image from the database
  57673. * @param url defines the url to load from
  57674. * @param image defines the target DOM image
  57675. */
  57676. loadImage(url: string, image: HTMLImageElement): void;
  57677. private _loadImageFromDBAsync;
  57678. private _saveImageIntoDBAsync;
  57679. private _checkVersionFromDB;
  57680. private _loadVersionFromDBAsync;
  57681. private _saveVersionIntoDBAsync;
  57682. /**
  57683. * Loads a file from database
  57684. * @param url defines the URL to load from
  57685. * @param sceneLoaded defines a callback to call on success
  57686. * @param progressCallBack defines a callback to call when progress changed
  57687. * @param errorCallback defines a callback to call on error
  57688. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57689. */
  57690. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57691. private _loadFileAsync;
  57692. private _saveFileAsync;
  57693. /**
  57694. * Validates if xhr data is correct
  57695. * @param xhr defines the request to validate
  57696. * @param dataType defines the expected data type
  57697. * @returns true if data is correct
  57698. */
  57699. private static _ValidateXHRData;
  57700. }
  57701. }
  57702. declare module BABYLON {
  57703. /** @hidden */
  57704. export var gpuUpdateParticlesPixelShader: {
  57705. name: string;
  57706. shader: string;
  57707. };
  57708. }
  57709. declare module BABYLON {
  57710. /** @hidden */
  57711. export var gpuUpdateParticlesVertexShader: {
  57712. name: string;
  57713. shader: string;
  57714. };
  57715. }
  57716. declare module BABYLON {
  57717. /** @hidden */
  57718. export var clipPlaneFragmentDeclaration2: {
  57719. name: string;
  57720. shader: string;
  57721. };
  57722. }
  57723. declare module BABYLON {
  57724. /** @hidden */
  57725. export var gpuRenderParticlesPixelShader: {
  57726. name: string;
  57727. shader: string;
  57728. };
  57729. }
  57730. declare module BABYLON {
  57731. /** @hidden */
  57732. export var clipPlaneVertexDeclaration2: {
  57733. name: string;
  57734. shader: string;
  57735. };
  57736. }
  57737. declare module BABYLON {
  57738. /** @hidden */
  57739. export var gpuRenderParticlesVertexShader: {
  57740. name: string;
  57741. shader: string;
  57742. };
  57743. }
  57744. declare module BABYLON {
  57745. /**
  57746. * This represents a GPU particle system in Babylon
  57747. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57748. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57749. */
  57750. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57751. /**
  57752. * The layer mask we are rendering the particles through.
  57753. */
  57754. layerMask: number;
  57755. private _capacity;
  57756. private _activeCount;
  57757. private _currentActiveCount;
  57758. private _accumulatedCount;
  57759. private _renderEffect;
  57760. private _updateEffect;
  57761. private _buffer0;
  57762. private _buffer1;
  57763. private _spriteBuffer;
  57764. private _updateVAO;
  57765. private _renderVAO;
  57766. private _targetIndex;
  57767. private _sourceBuffer;
  57768. private _targetBuffer;
  57769. private _engine;
  57770. private _currentRenderId;
  57771. private _started;
  57772. private _stopped;
  57773. private _timeDelta;
  57774. private _randomTexture;
  57775. private _randomTexture2;
  57776. private _attributesStrideSize;
  57777. private _updateEffectOptions;
  57778. private _randomTextureSize;
  57779. private _actualFrame;
  57780. private readonly _rawTextureWidth;
  57781. /**
  57782. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57783. */
  57784. static readonly IsSupported: boolean;
  57785. /**
  57786. * An event triggered when the system is disposed.
  57787. */
  57788. onDisposeObservable: Observable<GPUParticleSystem>;
  57789. /**
  57790. * Gets the maximum number of particles active at the same time.
  57791. * @returns The max number of active particles.
  57792. */
  57793. getCapacity(): number;
  57794. /**
  57795. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57796. * to override the particles.
  57797. */
  57798. forceDepthWrite: boolean;
  57799. /**
  57800. * Gets or set the number of active particles
  57801. */
  57802. activeParticleCount: number;
  57803. private _preWarmDone;
  57804. /**
  57805. * Is this system ready to be used/rendered
  57806. * @return true if the system is ready
  57807. */
  57808. isReady(): boolean;
  57809. /**
  57810. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57811. * @returns True if it has been started, otherwise false.
  57812. */
  57813. isStarted(): boolean;
  57814. /**
  57815. * Starts the particle system and begins to emit
  57816. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57817. */
  57818. start(delay?: number): void;
  57819. /**
  57820. * Stops the particle system.
  57821. */
  57822. stop(): void;
  57823. /**
  57824. * Remove all active particles
  57825. */
  57826. reset(): void;
  57827. /**
  57828. * Returns the string "GPUParticleSystem"
  57829. * @returns a string containing the class name
  57830. */
  57831. getClassName(): string;
  57832. private _colorGradientsTexture;
  57833. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57834. /**
  57835. * Adds a new color gradient
  57836. * @param gradient defines the gradient to use (between 0 and 1)
  57837. * @param color1 defines the color to affect to the specified gradient
  57838. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57839. * @returns the current particle system
  57840. */
  57841. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57842. /**
  57843. * Remove a specific color gradient
  57844. * @param gradient defines the gradient to remove
  57845. * @returns the current particle system
  57846. */
  57847. removeColorGradient(gradient: number): GPUParticleSystem;
  57848. private _angularSpeedGradientsTexture;
  57849. private _sizeGradientsTexture;
  57850. private _velocityGradientsTexture;
  57851. private _limitVelocityGradientsTexture;
  57852. private _dragGradientsTexture;
  57853. private _addFactorGradient;
  57854. /**
  57855. * Adds a new size gradient
  57856. * @param gradient defines the gradient to use (between 0 and 1)
  57857. * @param factor defines the size factor to affect to the specified gradient
  57858. * @returns the current particle system
  57859. */
  57860. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57861. /**
  57862. * Remove a specific size gradient
  57863. * @param gradient defines the gradient to remove
  57864. * @returns the current particle system
  57865. */
  57866. removeSizeGradient(gradient: number): GPUParticleSystem;
  57867. /**
  57868. * Adds a new angular speed gradient
  57869. * @param gradient defines the gradient to use (between 0 and 1)
  57870. * @param factor defines the angular speed to affect to the specified gradient
  57871. * @returns the current particle system
  57872. */
  57873. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57874. /**
  57875. * Remove a specific angular speed gradient
  57876. * @param gradient defines the gradient to remove
  57877. * @returns the current particle system
  57878. */
  57879. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57880. /**
  57881. * Adds a new velocity gradient
  57882. * @param gradient defines the gradient to use (between 0 and 1)
  57883. * @param factor defines the velocity to affect to the specified gradient
  57884. * @returns the current particle system
  57885. */
  57886. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57887. /**
  57888. * Remove a specific velocity gradient
  57889. * @param gradient defines the gradient to remove
  57890. * @returns the current particle system
  57891. */
  57892. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57893. /**
  57894. * Adds a new limit velocity gradient
  57895. * @param gradient defines the gradient to use (between 0 and 1)
  57896. * @param factor defines the limit velocity value to affect to the specified gradient
  57897. * @returns the current particle system
  57898. */
  57899. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57900. /**
  57901. * Remove a specific limit velocity gradient
  57902. * @param gradient defines the gradient to remove
  57903. * @returns the current particle system
  57904. */
  57905. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57906. /**
  57907. * Adds a new drag gradient
  57908. * @param gradient defines the gradient to use (between 0 and 1)
  57909. * @param factor defines the drag value to affect to the specified gradient
  57910. * @returns the current particle system
  57911. */
  57912. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57913. /**
  57914. * Remove a specific drag gradient
  57915. * @param gradient defines the gradient to remove
  57916. * @returns the current particle system
  57917. */
  57918. removeDragGradient(gradient: number): GPUParticleSystem;
  57919. /**
  57920. * Not supported by GPUParticleSystem
  57921. * @param gradient defines the gradient to use (between 0 and 1)
  57922. * @param factor defines the emit rate value to affect to the specified gradient
  57923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57924. * @returns the current particle system
  57925. */
  57926. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57927. /**
  57928. * Not supported by GPUParticleSystem
  57929. * @param gradient defines the gradient to remove
  57930. * @returns the current particle system
  57931. */
  57932. removeEmitRateGradient(gradient: number): IParticleSystem;
  57933. /**
  57934. * Not supported by GPUParticleSystem
  57935. * @param gradient defines the gradient to use (between 0 and 1)
  57936. * @param factor defines the start size value to affect to the specified gradient
  57937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57938. * @returns the current particle system
  57939. */
  57940. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57941. /**
  57942. * Not supported by GPUParticleSystem
  57943. * @param gradient defines the gradient to remove
  57944. * @returns the current particle system
  57945. */
  57946. removeStartSizeGradient(gradient: number): IParticleSystem;
  57947. /**
  57948. * Not supported by GPUParticleSystem
  57949. * @param gradient defines the gradient to use (between 0 and 1)
  57950. * @param min defines the color remap minimal range
  57951. * @param max defines the color remap maximal range
  57952. * @returns the current particle system
  57953. */
  57954. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57955. /**
  57956. * Not supported by GPUParticleSystem
  57957. * @param gradient defines the gradient to remove
  57958. * @returns the current particle system
  57959. */
  57960. removeColorRemapGradient(): IParticleSystem;
  57961. /**
  57962. * Not supported by GPUParticleSystem
  57963. * @param gradient defines the gradient to use (between 0 and 1)
  57964. * @param min defines the alpha remap minimal range
  57965. * @param max defines the alpha remap maximal range
  57966. * @returns the current particle system
  57967. */
  57968. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57969. /**
  57970. * Not supported by GPUParticleSystem
  57971. * @param gradient defines the gradient to remove
  57972. * @returns the current particle system
  57973. */
  57974. removeAlphaRemapGradient(): IParticleSystem;
  57975. /**
  57976. * Not supported by GPUParticleSystem
  57977. * @param gradient defines the gradient to use (between 0 and 1)
  57978. * @param color defines the color to affect to the specified gradient
  57979. * @returns the current particle system
  57980. */
  57981. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57982. /**
  57983. * Not supported by GPUParticleSystem
  57984. * @param gradient defines the gradient to remove
  57985. * @returns the current particle system
  57986. */
  57987. removeRampGradient(): IParticleSystem;
  57988. /**
  57989. * Not supported by GPUParticleSystem
  57990. * @returns the list of ramp gradients
  57991. */
  57992. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57993. /**
  57994. * Not supported by GPUParticleSystem
  57995. * Gets or sets a boolean indicating that ramp gradients must be used
  57996. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57997. */
  57998. useRampGradients: boolean;
  57999. /**
  58000. * Not supported by GPUParticleSystem
  58001. * @param gradient defines the gradient to use (between 0 and 1)
  58002. * @param factor defines the life time factor to affect to the specified gradient
  58003. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58004. * @returns the current particle system
  58005. */
  58006. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58007. /**
  58008. * Not supported by GPUParticleSystem
  58009. * @param gradient defines the gradient to remove
  58010. * @returns the current particle system
  58011. */
  58012. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58013. /**
  58014. * Instantiates a GPU particle system.
  58015. * 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.
  58016. * @param name The name of the particle system
  58017. * @param options The options used to create the system
  58018. * @param scene The scene the particle system belongs to
  58019. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58020. */
  58021. constructor(name: string, options: Partial<{
  58022. capacity: number;
  58023. randomTextureSize: number;
  58024. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58025. protected _reset(): void;
  58026. private _createUpdateVAO;
  58027. private _createRenderVAO;
  58028. private _initialize;
  58029. /** @hidden */
  58030. _recreateUpdateEffect(): void;
  58031. /** @hidden */
  58032. _recreateRenderEffect(): void;
  58033. /**
  58034. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58035. * @param preWarm defines if we are in the pre-warmimg phase
  58036. */
  58037. animate(preWarm?: boolean): void;
  58038. private _createFactorGradientTexture;
  58039. private _createSizeGradientTexture;
  58040. private _createAngularSpeedGradientTexture;
  58041. private _createVelocityGradientTexture;
  58042. private _createLimitVelocityGradientTexture;
  58043. private _createDragGradientTexture;
  58044. private _createColorGradientTexture;
  58045. /**
  58046. * Renders the particle system in its current state
  58047. * @param preWarm defines if the system should only update the particles but not render them
  58048. * @returns the current number of particles
  58049. */
  58050. render(preWarm?: boolean): number;
  58051. /**
  58052. * Rebuilds the particle system
  58053. */
  58054. rebuild(): void;
  58055. private _releaseBuffers;
  58056. private _releaseVAOs;
  58057. /**
  58058. * Disposes the particle system and free the associated resources
  58059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58060. */
  58061. dispose(disposeTexture?: boolean): void;
  58062. /**
  58063. * Clones the particle system.
  58064. * @param name The name of the cloned object
  58065. * @param newEmitter The new emitter to use
  58066. * @returns the cloned particle system
  58067. */
  58068. clone(name: string, newEmitter: any): GPUParticleSystem;
  58069. /**
  58070. * Serializes the particle system to a JSON object.
  58071. * @returns the JSON object
  58072. */
  58073. serialize(): any;
  58074. /**
  58075. * Parses a JSON object to create a GPU particle system.
  58076. * @param parsedParticleSystem The JSON object to parse
  58077. * @param scene The scene to create the particle system in
  58078. * @param rootUrl The root url to use to load external dependencies like texture
  58079. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58080. * @returns the parsed GPU particle system
  58081. */
  58082. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58083. }
  58084. }
  58085. declare module BABYLON {
  58086. /**
  58087. * Represents a set of particle systems working together to create a specific effect
  58088. */
  58089. export class ParticleSystemSet implements IDisposable {
  58090. private _emitterCreationOptions;
  58091. private _emitterNode;
  58092. /**
  58093. * Gets the particle system list
  58094. */
  58095. systems: IParticleSystem[];
  58096. /**
  58097. * Gets the emitter node used with this set
  58098. */
  58099. readonly emitterNode: Nullable<TransformNode>;
  58100. /**
  58101. * Creates a new emitter mesh as a sphere
  58102. * @param options defines the options used to create the sphere
  58103. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58104. * @param scene defines the hosting scene
  58105. */
  58106. setEmitterAsSphere(options: {
  58107. diameter: number;
  58108. segments: number;
  58109. color: Color3;
  58110. }, renderingGroupId: number, scene: Scene): void;
  58111. /**
  58112. * Starts all particle systems of the set
  58113. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58114. */
  58115. start(emitter?: AbstractMesh): void;
  58116. /**
  58117. * Release all associated resources
  58118. */
  58119. dispose(): void;
  58120. /**
  58121. * Serialize the set into a JSON compatible object
  58122. * @returns a JSON compatible representation of the set
  58123. */
  58124. serialize(): any;
  58125. /**
  58126. * Parse a new ParticleSystemSet from a serialized source
  58127. * @param data defines a JSON compatible representation of the set
  58128. * @param scene defines the hosting scene
  58129. * @param gpu defines if we want GPU particles or CPU particles
  58130. * @returns a new ParticleSystemSet
  58131. */
  58132. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58133. }
  58134. }
  58135. declare module BABYLON {
  58136. /**
  58137. * This class is made for on one-liner static method to help creating particle system set.
  58138. */
  58139. export class ParticleHelper {
  58140. /**
  58141. * Gets or sets base Assets URL
  58142. */
  58143. static BaseAssetsUrl: string;
  58144. /**
  58145. * Create a default particle system that you can tweak
  58146. * @param emitter defines the emitter to use
  58147. * @param capacity defines the system capacity (default is 500 particles)
  58148. * @param scene defines the hosting scene
  58149. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58150. * @returns the new Particle system
  58151. */
  58152. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58153. /**
  58154. * This is the main static method (one-liner) of this helper to create different particle systems
  58155. * @param type This string represents the type to the particle system to create
  58156. * @param scene The scene where the particle system should live
  58157. * @param gpu If the system will use gpu
  58158. * @returns the ParticleSystemSet created
  58159. */
  58160. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58161. /**
  58162. * Static function used to export a particle system to a ParticleSystemSet variable.
  58163. * Please note that the emitter shape is not exported
  58164. * @param systems defines the particle systems to export
  58165. * @returns the created particle system set
  58166. */
  58167. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58168. }
  58169. }
  58170. declare module BABYLON {
  58171. interface Engine {
  58172. /**
  58173. * Create an effect to use with particle systems.
  58174. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58175. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58176. * @param uniformsNames defines a list of attribute names
  58177. * @param samplers defines an array of string used to represent textures
  58178. * @param defines defines the string containing the defines to use to compile the shaders
  58179. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58180. * @param onCompiled defines a function to call when the effect creation is successful
  58181. * @param onError defines a function to call when the effect creation has failed
  58182. * @returns the new Effect
  58183. */
  58184. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58185. }
  58186. interface Mesh {
  58187. /**
  58188. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58189. * @returns an array of IParticleSystem
  58190. */
  58191. getEmittedParticleSystems(): IParticleSystem[];
  58192. /**
  58193. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58194. * @returns an array of IParticleSystem
  58195. */
  58196. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58197. }
  58198. /**
  58199. * @hidden
  58200. */
  58201. export var _IDoNeedToBeInTheBuild: number;
  58202. }
  58203. declare module BABYLON {
  58204. interface Scene {
  58205. /** @hidden (Backing field) */
  58206. _physicsEngine: Nullable<IPhysicsEngine>;
  58207. /**
  58208. * Gets the current physics engine
  58209. * @returns a IPhysicsEngine or null if none attached
  58210. */
  58211. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58212. /**
  58213. * Enables physics to the current scene
  58214. * @param gravity defines the scene's gravity for the physics engine
  58215. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58216. * @return a boolean indicating if the physics engine was initialized
  58217. */
  58218. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58219. /**
  58220. * Disables and disposes the physics engine associated with the scene
  58221. */
  58222. disablePhysicsEngine(): void;
  58223. /**
  58224. * Gets a boolean indicating if there is an active physics engine
  58225. * @returns a boolean indicating if there is an active physics engine
  58226. */
  58227. isPhysicsEnabled(): boolean;
  58228. /**
  58229. * Deletes a physics compound impostor
  58230. * @param compound defines the compound to delete
  58231. */
  58232. deleteCompoundImpostor(compound: any): void;
  58233. /**
  58234. * An event triggered when physic simulation is about to be run
  58235. */
  58236. onBeforePhysicsObservable: Observable<Scene>;
  58237. /**
  58238. * An event triggered when physic simulation has been done
  58239. */
  58240. onAfterPhysicsObservable: Observable<Scene>;
  58241. }
  58242. interface AbstractMesh {
  58243. /** @hidden */
  58244. _physicsImpostor: Nullable<PhysicsImpostor>;
  58245. /**
  58246. * Gets or sets impostor used for physic simulation
  58247. * @see http://doc.babylonjs.com/features/physics_engine
  58248. */
  58249. physicsImpostor: Nullable<PhysicsImpostor>;
  58250. /**
  58251. * Gets the current physics impostor
  58252. * @see http://doc.babylonjs.com/features/physics_engine
  58253. * @returns a physics impostor or null
  58254. */
  58255. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58256. /** Apply a physic impulse to the mesh
  58257. * @param force defines the force to apply
  58258. * @param contactPoint defines where to apply the force
  58259. * @returns the current mesh
  58260. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58261. */
  58262. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58263. /**
  58264. * Creates a physic joint between two meshes
  58265. * @param otherMesh defines the other mesh to use
  58266. * @param pivot1 defines the pivot to use on this mesh
  58267. * @param pivot2 defines the pivot to use on the other mesh
  58268. * @param options defines additional options (can be plugin dependent)
  58269. * @returns the current mesh
  58270. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58271. */
  58272. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58273. /** @hidden */
  58274. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58275. }
  58276. /**
  58277. * Defines the physics engine scene component responsible to manage a physics engine
  58278. */
  58279. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58280. /**
  58281. * The component name helpful to identify the component in the list of scene components.
  58282. */
  58283. readonly name: string;
  58284. /**
  58285. * The scene the component belongs to.
  58286. */
  58287. scene: Scene;
  58288. /**
  58289. * Creates a new instance of the component for the given scene
  58290. * @param scene Defines the scene to register the component in
  58291. */
  58292. constructor(scene: Scene);
  58293. /**
  58294. * Registers the component in a given scene
  58295. */
  58296. register(): void;
  58297. /**
  58298. * Rebuilds the elements related to this component in case of
  58299. * context lost for instance.
  58300. */
  58301. rebuild(): void;
  58302. /**
  58303. * Disposes the component and the associated ressources
  58304. */
  58305. dispose(): void;
  58306. }
  58307. }
  58308. declare module BABYLON {
  58309. /**
  58310. * A helper for physics simulations
  58311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58312. */
  58313. export class PhysicsHelper {
  58314. private _scene;
  58315. private _physicsEngine;
  58316. /**
  58317. * Initializes the Physics helper
  58318. * @param scene Babylon.js scene
  58319. */
  58320. constructor(scene: Scene);
  58321. /**
  58322. * Applies a radial explosion impulse
  58323. * @param origin the origin of the explosion
  58324. * @param radiusOrEventOptions the radius or the options of radial explosion
  58325. * @param strength the explosion strength
  58326. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58327. * @returns A physics radial explosion event, or null
  58328. */
  58329. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58330. /**
  58331. * Applies a radial explosion force
  58332. * @param origin the origin of the explosion
  58333. * @param radiusOrEventOptions the radius or the options of radial explosion
  58334. * @param strength the explosion strength
  58335. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58336. * @returns A physics radial explosion event, or null
  58337. */
  58338. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58339. /**
  58340. * Creates a gravitational field
  58341. * @param origin the origin of the explosion
  58342. * @param radiusOrEventOptions the radius or the options of radial explosion
  58343. * @param strength the explosion strength
  58344. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58345. * @returns A physics gravitational field event, or null
  58346. */
  58347. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58348. /**
  58349. * Creates a physics updraft event
  58350. * @param origin the origin of the updraft
  58351. * @param radiusOrEventOptions the radius or the options of the updraft
  58352. * @param strength the strength of the updraft
  58353. * @param height the height of the updraft
  58354. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58355. * @returns A physics updraft event, or null
  58356. */
  58357. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58358. /**
  58359. * Creates a physics vortex event
  58360. * @param origin the of the vortex
  58361. * @param radiusOrEventOptions the radius or the options of the vortex
  58362. * @param strength the strength of the vortex
  58363. * @param height the height of the vortex
  58364. * @returns a Physics vortex event, or null
  58365. * A physics vortex event or null
  58366. */
  58367. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58368. }
  58369. /**
  58370. * Represents a physics radial explosion event
  58371. */
  58372. class PhysicsRadialExplosionEvent {
  58373. private _scene;
  58374. private _options;
  58375. private _sphere;
  58376. private _dataFetched;
  58377. /**
  58378. * Initializes a radial explosioin event
  58379. * @param _scene BabylonJS scene
  58380. * @param _options The options for the vortex event
  58381. */
  58382. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58383. /**
  58384. * Returns the data related to the radial explosion event (sphere).
  58385. * @returns The radial explosion event data
  58386. */
  58387. getData(): PhysicsRadialExplosionEventData;
  58388. /**
  58389. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58390. * @param impostor A physics imposter
  58391. * @param origin the origin of the explosion
  58392. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58393. */
  58394. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58395. /**
  58396. * Triggers affecterd impostors callbacks
  58397. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58398. */
  58399. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58400. /**
  58401. * Disposes the sphere.
  58402. * @param force Specifies if the sphere should be disposed by force
  58403. */
  58404. dispose(force?: boolean): void;
  58405. /*** Helpers ***/
  58406. private _prepareSphere;
  58407. private _intersectsWithSphere;
  58408. }
  58409. /**
  58410. * Represents a gravitational field event
  58411. */
  58412. class PhysicsGravitationalFieldEvent {
  58413. private _physicsHelper;
  58414. private _scene;
  58415. private _origin;
  58416. private _options;
  58417. private _tickCallback;
  58418. private _sphere;
  58419. private _dataFetched;
  58420. /**
  58421. * Initializes the physics gravitational field event
  58422. * @param _physicsHelper A physics helper
  58423. * @param _scene BabylonJS scene
  58424. * @param _origin The origin position of the gravitational field event
  58425. * @param _options The options for the vortex event
  58426. */
  58427. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58428. /**
  58429. * Returns the data related to the gravitational field event (sphere).
  58430. * @returns A gravitational field event
  58431. */
  58432. getData(): PhysicsGravitationalFieldEventData;
  58433. /**
  58434. * Enables the gravitational field.
  58435. */
  58436. enable(): void;
  58437. /**
  58438. * Disables the gravitational field.
  58439. */
  58440. disable(): void;
  58441. /**
  58442. * Disposes the sphere.
  58443. * @param force The force to dispose from the gravitational field event
  58444. */
  58445. dispose(force?: boolean): void;
  58446. private _tick;
  58447. }
  58448. /**
  58449. * Represents a physics updraft event
  58450. */
  58451. class PhysicsUpdraftEvent {
  58452. private _scene;
  58453. private _origin;
  58454. private _options;
  58455. private _physicsEngine;
  58456. private _originTop;
  58457. private _originDirection;
  58458. private _tickCallback;
  58459. private _cylinder;
  58460. private _cylinderPosition;
  58461. private _dataFetched;
  58462. /**
  58463. * Initializes the physics updraft event
  58464. * @param _scene BabylonJS scene
  58465. * @param _origin The origin position of the updraft
  58466. * @param _options The options for the updraft event
  58467. */
  58468. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58469. /**
  58470. * Returns the data related to the updraft event (cylinder).
  58471. * @returns A physics updraft event
  58472. */
  58473. getData(): PhysicsUpdraftEventData;
  58474. /**
  58475. * Enables the updraft.
  58476. */
  58477. enable(): void;
  58478. /**
  58479. * Disables the updraft.
  58480. */
  58481. disable(): void;
  58482. /**
  58483. * Disposes the cylinder.
  58484. * @param force Specifies if the updraft should be disposed by force
  58485. */
  58486. dispose(force?: boolean): void;
  58487. private getImpostorHitData;
  58488. private _tick;
  58489. /*** Helpers ***/
  58490. private _prepareCylinder;
  58491. private _intersectsWithCylinder;
  58492. }
  58493. /**
  58494. * Represents a physics vortex event
  58495. */
  58496. class PhysicsVortexEvent {
  58497. private _scene;
  58498. private _origin;
  58499. private _options;
  58500. private _physicsEngine;
  58501. private _originTop;
  58502. private _tickCallback;
  58503. private _cylinder;
  58504. private _cylinderPosition;
  58505. private _dataFetched;
  58506. /**
  58507. * Initializes the physics vortex event
  58508. * @param _scene The BabylonJS scene
  58509. * @param _origin The origin position of the vortex
  58510. * @param _options The options for the vortex event
  58511. */
  58512. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58513. /**
  58514. * Returns the data related to the vortex event (cylinder).
  58515. * @returns The physics vortex event data
  58516. */
  58517. getData(): PhysicsVortexEventData;
  58518. /**
  58519. * Enables the vortex.
  58520. */
  58521. enable(): void;
  58522. /**
  58523. * Disables the cortex.
  58524. */
  58525. disable(): void;
  58526. /**
  58527. * Disposes the sphere.
  58528. * @param force
  58529. */
  58530. dispose(force?: boolean): void;
  58531. private getImpostorHitData;
  58532. private _tick;
  58533. /*** Helpers ***/
  58534. private _prepareCylinder;
  58535. private _intersectsWithCylinder;
  58536. }
  58537. /**
  58538. * Options fot the radial explosion event
  58539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58540. */
  58541. export class PhysicsRadialExplosionEventOptions {
  58542. /**
  58543. * The radius of the sphere for the radial explosion.
  58544. */
  58545. radius: number;
  58546. /**
  58547. * The strenth of the explosion.
  58548. */
  58549. strength: number;
  58550. /**
  58551. * The strenght of the force in correspondence to the distance of the affected object
  58552. */
  58553. falloff: PhysicsRadialImpulseFalloff;
  58554. /**
  58555. * Sphere options for the radial explosion.
  58556. */
  58557. sphere: {
  58558. segments: number;
  58559. diameter: number;
  58560. };
  58561. /**
  58562. * Sphere options for the radial explosion.
  58563. */
  58564. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58565. }
  58566. /**
  58567. * Options fot the updraft event
  58568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58569. */
  58570. export class PhysicsUpdraftEventOptions {
  58571. /**
  58572. * The radius of the cylinder for the vortex
  58573. */
  58574. radius: number;
  58575. /**
  58576. * The strenth of the updraft.
  58577. */
  58578. strength: number;
  58579. /**
  58580. * The height of the cylinder for the updraft.
  58581. */
  58582. height: number;
  58583. /**
  58584. * The mode for the the updraft.
  58585. */
  58586. updraftMode: PhysicsUpdraftMode;
  58587. }
  58588. /**
  58589. * Options fot the vortex event
  58590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58591. */
  58592. export class PhysicsVortexEventOptions {
  58593. /**
  58594. * The radius of the cylinder for the vortex
  58595. */
  58596. radius: number;
  58597. /**
  58598. * The strenth of the vortex.
  58599. */
  58600. strength: number;
  58601. /**
  58602. * The height of the cylinder for the vortex.
  58603. */
  58604. height: number;
  58605. /**
  58606. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58607. */
  58608. centripetalForceThreshold: number;
  58609. /**
  58610. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58611. */
  58612. centripetalForceMultiplier: number;
  58613. /**
  58614. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58615. */
  58616. centrifugalForceMultiplier: number;
  58617. /**
  58618. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58619. */
  58620. updraftForceMultiplier: number;
  58621. }
  58622. /**
  58623. * The strenght of the force in correspondence to the distance of the affected object
  58624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58625. */
  58626. export enum PhysicsRadialImpulseFalloff {
  58627. /** Defines that impulse is constant in strength across it's whole radius */
  58628. Constant = 0,
  58629. /** Defines that impulse gets weaker if it's further from the origin */
  58630. Linear = 1
  58631. }
  58632. /**
  58633. * The strength of the force in correspondence to the distance of the affected object
  58634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58635. */
  58636. export enum PhysicsUpdraftMode {
  58637. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58638. Center = 0,
  58639. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58640. Perpendicular = 1
  58641. }
  58642. /**
  58643. * Interface for a physics hit data
  58644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58645. */
  58646. export interface PhysicsHitData {
  58647. /**
  58648. * The force applied at the contact point
  58649. */
  58650. force: Vector3;
  58651. /**
  58652. * The contact point
  58653. */
  58654. contactPoint: Vector3;
  58655. /**
  58656. * The distance from the origin to the contact point
  58657. */
  58658. distanceFromOrigin: number;
  58659. }
  58660. /**
  58661. * Interface for radial explosion event data
  58662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58663. */
  58664. export interface PhysicsRadialExplosionEventData {
  58665. /**
  58666. * A sphere used for the radial explosion event
  58667. */
  58668. sphere: Mesh;
  58669. }
  58670. /**
  58671. * Interface for gravitational field event data
  58672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58673. */
  58674. export interface PhysicsGravitationalFieldEventData {
  58675. /**
  58676. * A sphere mesh used for the gravitational field event
  58677. */
  58678. sphere: Mesh;
  58679. }
  58680. /**
  58681. * Interface for updraft event data
  58682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58683. */
  58684. export interface PhysicsUpdraftEventData {
  58685. /**
  58686. * A cylinder used for the updraft event
  58687. */
  58688. cylinder: Mesh;
  58689. }
  58690. /**
  58691. * Interface for vortex event data
  58692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58693. */
  58694. export interface PhysicsVortexEventData {
  58695. /**
  58696. * A cylinder used for the vortex event
  58697. */
  58698. cylinder: Mesh;
  58699. }
  58700. /**
  58701. * Interface for an affected physics impostor
  58702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58703. */
  58704. export interface PhysicsAffectedImpostorWithData {
  58705. /**
  58706. * The impostor affected by the effect
  58707. */
  58708. impostor: PhysicsImpostor;
  58709. /**
  58710. * The data about the hit/horce from the explosion
  58711. */
  58712. hitData: PhysicsHitData;
  58713. }
  58714. }
  58715. declare module BABYLON {
  58716. /** @hidden */
  58717. export var blackAndWhitePixelShader: {
  58718. name: string;
  58719. shader: string;
  58720. };
  58721. }
  58722. declare module BABYLON {
  58723. /**
  58724. * Post process used to render in black and white
  58725. */
  58726. export class BlackAndWhitePostProcess extends PostProcess {
  58727. /**
  58728. * Linear about to convert he result to black and white (default: 1)
  58729. */
  58730. degree: number;
  58731. /**
  58732. * Creates a black and white post process
  58733. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58734. * @param name The name of the effect.
  58735. * @param options The required width/height ratio to downsize to before computing the render pass.
  58736. * @param camera The camera to apply the render pass to.
  58737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58738. * @param engine The engine which the post process will be applied. (default: current engine)
  58739. * @param reusable If the post process can be reused on the same frame. (default: false)
  58740. */
  58741. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58742. }
  58743. }
  58744. declare module BABYLON {
  58745. /**
  58746. * This represents a set of one or more post processes in Babylon.
  58747. * A post process can be used to apply a shader to a texture after it is rendered.
  58748. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58749. */
  58750. export class PostProcessRenderEffect {
  58751. private _postProcesses;
  58752. private _getPostProcesses;
  58753. private _singleInstance;
  58754. private _cameras;
  58755. private _indicesForCamera;
  58756. /**
  58757. * Name of the effect
  58758. * @hidden
  58759. */
  58760. _name: string;
  58761. /**
  58762. * Instantiates a post process render effect.
  58763. * A post process can be used to apply a shader to a texture after it is rendered.
  58764. * @param engine The engine the effect is tied to
  58765. * @param name The name of the effect
  58766. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58767. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58768. */
  58769. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58770. /**
  58771. * Checks if all the post processes in the effect are supported.
  58772. */
  58773. readonly isSupported: boolean;
  58774. /**
  58775. * Updates the current state of the effect
  58776. * @hidden
  58777. */
  58778. _update(): void;
  58779. /**
  58780. * Attaches the effect on cameras
  58781. * @param cameras The camera to attach to.
  58782. * @hidden
  58783. */
  58784. _attachCameras(cameras: Camera): void;
  58785. /**
  58786. * Attaches the effect on cameras
  58787. * @param cameras The camera to attach to.
  58788. * @hidden
  58789. */
  58790. _attachCameras(cameras: Camera[]): void;
  58791. /**
  58792. * Detaches the effect on cameras
  58793. * @param cameras The camera to detatch from.
  58794. * @hidden
  58795. */
  58796. _detachCameras(cameras: Camera): void;
  58797. /**
  58798. * Detatches the effect on cameras
  58799. * @param cameras The camera to detatch from.
  58800. * @hidden
  58801. */
  58802. _detachCameras(cameras: Camera[]): void;
  58803. /**
  58804. * Enables the effect on given cameras
  58805. * @param cameras The camera to enable.
  58806. * @hidden
  58807. */
  58808. _enable(cameras: Camera): void;
  58809. /**
  58810. * Enables the effect on given cameras
  58811. * @param cameras The camera to enable.
  58812. * @hidden
  58813. */
  58814. _enable(cameras: Nullable<Camera[]>): void;
  58815. /**
  58816. * Disables the effect on the given cameras
  58817. * @param cameras The camera to disable.
  58818. * @hidden
  58819. */
  58820. _disable(cameras: Camera): void;
  58821. /**
  58822. * Disables the effect on the given cameras
  58823. * @param cameras The camera to disable.
  58824. * @hidden
  58825. */
  58826. _disable(cameras: Nullable<Camera[]>): void;
  58827. /**
  58828. * Gets a list of the post processes contained in the effect.
  58829. * @param camera The camera to get the post processes on.
  58830. * @returns The list of the post processes in the effect.
  58831. */
  58832. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58833. }
  58834. }
  58835. declare module BABYLON {
  58836. /** @hidden */
  58837. export var extractHighlightsPixelShader: {
  58838. name: string;
  58839. shader: string;
  58840. };
  58841. }
  58842. declare module BABYLON {
  58843. /**
  58844. * 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.
  58845. */
  58846. export class ExtractHighlightsPostProcess extends PostProcess {
  58847. /**
  58848. * The luminance threshold, pixels below this value will be set to black.
  58849. */
  58850. threshold: number;
  58851. /** @hidden */
  58852. _exposure: number;
  58853. /**
  58854. * Post process which has the input texture to be used when performing highlight extraction
  58855. * @hidden
  58856. */
  58857. _inputPostProcess: Nullable<PostProcess>;
  58858. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58859. }
  58860. }
  58861. declare module BABYLON {
  58862. /** @hidden */
  58863. export var bloomMergePixelShader: {
  58864. name: string;
  58865. shader: string;
  58866. };
  58867. }
  58868. declare module BABYLON {
  58869. /**
  58870. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58871. */
  58872. export class BloomMergePostProcess extends PostProcess {
  58873. /** Weight of the bloom to be added to the original input. */
  58874. weight: number;
  58875. /**
  58876. * Creates a new instance of @see BloomMergePostProcess
  58877. * @param name The name of the effect.
  58878. * @param originalFromInput Post process which's input will be used for the merge.
  58879. * @param blurred Blurred highlights post process which's output will be used.
  58880. * @param weight Weight of the bloom to be added to the original input.
  58881. * @param options The required width/height ratio to downsize to before computing the render pass.
  58882. * @param camera The camera to apply the render pass to.
  58883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58884. * @param engine The engine which the post process will be applied. (default: current engine)
  58885. * @param reusable If the post process can be reused on the same frame. (default: false)
  58886. * @param textureType Type of textures used when performing the post process. (default: 0)
  58887. * @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)
  58888. */
  58889. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58890. /** Weight of the bloom to be added to the original input. */
  58891. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58892. }
  58893. }
  58894. declare module BABYLON {
  58895. /**
  58896. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58897. */
  58898. export class BloomEffect extends PostProcessRenderEffect {
  58899. private bloomScale;
  58900. /**
  58901. * @hidden Internal
  58902. */
  58903. _effects: Array<PostProcess>;
  58904. /**
  58905. * @hidden Internal
  58906. */
  58907. _downscale: ExtractHighlightsPostProcess;
  58908. private _blurX;
  58909. private _blurY;
  58910. private _merge;
  58911. /**
  58912. * The luminance threshold to find bright areas of the image to bloom.
  58913. */
  58914. threshold: number;
  58915. /**
  58916. * The strength of the bloom.
  58917. */
  58918. weight: number;
  58919. /**
  58920. * Specifies the size of the bloom blur kernel, relative to the final output size
  58921. */
  58922. kernel: number;
  58923. /**
  58924. * Creates a new instance of @see BloomEffect
  58925. * @param scene The scene the effect belongs to.
  58926. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58927. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58928. * @param bloomWeight The the strength of bloom.
  58929. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58930. * @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)
  58931. */
  58932. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58933. /**
  58934. * Disposes each of the internal effects for a given camera.
  58935. * @param camera The camera to dispose the effect on.
  58936. */
  58937. disposeEffects(camera: Camera): void;
  58938. /**
  58939. * @hidden Internal
  58940. */
  58941. _updateEffects(): void;
  58942. /**
  58943. * Internal
  58944. * @returns if all the contained post processes are ready.
  58945. * @hidden
  58946. */
  58947. _isReady(): boolean;
  58948. }
  58949. }
  58950. declare module BABYLON {
  58951. /** @hidden */
  58952. export var chromaticAberrationPixelShader: {
  58953. name: string;
  58954. shader: string;
  58955. };
  58956. }
  58957. declare module BABYLON {
  58958. /**
  58959. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58960. */
  58961. export class ChromaticAberrationPostProcess extends PostProcess {
  58962. /**
  58963. * The amount of seperation of rgb channels (default: 30)
  58964. */
  58965. aberrationAmount: number;
  58966. /**
  58967. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58968. */
  58969. radialIntensity: number;
  58970. /**
  58971. * 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))
  58972. */
  58973. direction: Vector2;
  58974. /**
  58975. * 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))
  58976. */
  58977. centerPosition: Vector2;
  58978. /**
  58979. * Creates a new instance ChromaticAberrationPostProcess
  58980. * @param name The name of the effect.
  58981. * @param screenWidth The width of the screen to apply the effect on.
  58982. * @param screenHeight The height of the screen to apply the effect on.
  58983. * @param options The required width/height ratio to downsize to before computing the render pass.
  58984. * @param camera The camera to apply the render pass to.
  58985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58986. * @param engine The engine which the post process will be applied. (default: current engine)
  58987. * @param reusable If the post process can be reused on the same frame. (default: false)
  58988. * @param textureType Type of textures used when performing the post process. (default: 0)
  58989. * @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)
  58990. */
  58991. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58992. }
  58993. }
  58994. declare module BABYLON {
  58995. /** @hidden */
  58996. export var circleOfConfusionPixelShader: {
  58997. name: string;
  58998. shader: string;
  58999. };
  59000. }
  59001. declare module BABYLON {
  59002. /**
  59003. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59004. */
  59005. export class CircleOfConfusionPostProcess extends PostProcess {
  59006. /**
  59007. * 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.
  59008. */
  59009. lensSize: number;
  59010. /**
  59011. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59012. */
  59013. fStop: number;
  59014. /**
  59015. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59016. */
  59017. focusDistance: number;
  59018. /**
  59019. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59020. */
  59021. focalLength: number;
  59022. private _depthTexture;
  59023. /**
  59024. * Creates a new instance CircleOfConfusionPostProcess
  59025. * @param name The name of the effect.
  59026. * @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.
  59027. * @param options The required width/height ratio to downsize to before computing the render pass.
  59028. * @param camera The camera to apply the render pass to.
  59029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59030. * @param engine The engine which the post process will be applied. (default: current engine)
  59031. * @param reusable If the post process can be reused on the same frame. (default: false)
  59032. * @param textureType Type of textures used when performing the post process. (default: 0)
  59033. * @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)
  59034. */
  59035. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59036. /**
  59037. * 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.
  59038. */
  59039. depthTexture: RenderTargetTexture;
  59040. }
  59041. }
  59042. declare module BABYLON {
  59043. /** @hidden */
  59044. export var colorCorrectionPixelShader: {
  59045. name: string;
  59046. shader: string;
  59047. };
  59048. }
  59049. declare module BABYLON {
  59050. /**
  59051. *
  59052. * This post-process allows the modification of rendered colors by using
  59053. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59054. *
  59055. * The object needs to be provided an url to a texture containing the color
  59056. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59057. * Use an image editing software to tweak the LUT to match your needs.
  59058. *
  59059. * For an example of a color LUT, see here:
  59060. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59061. * For explanations on color grading, see here:
  59062. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59063. *
  59064. */
  59065. export class ColorCorrectionPostProcess extends PostProcess {
  59066. private _colorTableTexture;
  59067. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59068. }
  59069. }
  59070. declare module BABYLON {
  59071. /** @hidden */
  59072. export var convolutionPixelShader: {
  59073. name: string;
  59074. shader: string;
  59075. };
  59076. }
  59077. declare module BABYLON {
  59078. /**
  59079. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59080. * input texture to perform effects such as edge detection or sharpening
  59081. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59082. */
  59083. export class ConvolutionPostProcess extends PostProcess {
  59084. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59085. kernel: number[];
  59086. /**
  59087. * Creates a new instance ConvolutionPostProcess
  59088. * @param name The name of the effect.
  59089. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59090. * @param options The required width/height ratio to downsize to before computing the render pass.
  59091. * @param camera The camera to apply the render pass to.
  59092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59093. * @param engine The engine which the post process will be applied. (default: current engine)
  59094. * @param reusable If the post process can be reused on the same frame. (default: false)
  59095. * @param textureType Type of textures used when performing the post process. (default: 0)
  59096. */
  59097. constructor(name: string,
  59098. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59099. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59100. /**
  59101. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59102. */
  59103. static EdgeDetect0Kernel: number[];
  59104. /**
  59105. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59106. */
  59107. static EdgeDetect1Kernel: number[];
  59108. /**
  59109. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59110. */
  59111. static EdgeDetect2Kernel: number[];
  59112. /**
  59113. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59114. */
  59115. static SharpenKernel: number[];
  59116. /**
  59117. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59118. */
  59119. static EmbossKernel: number[];
  59120. /**
  59121. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59122. */
  59123. static GaussianKernel: number[];
  59124. }
  59125. }
  59126. declare module BABYLON {
  59127. /**
  59128. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59129. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59130. * based on samples that have a large difference in distance than the center pixel.
  59131. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59132. */
  59133. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59134. direction: Vector2;
  59135. /**
  59136. * Creates a new instance CircleOfConfusionPostProcess
  59137. * @param name The name of the effect.
  59138. * @param scene The scene the effect belongs to.
  59139. * @param direction The direction the blur should be applied.
  59140. * @param kernel The size of the kernel used to blur.
  59141. * @param options The required width/height ratio to downsize to before computing the render pass.
  59142. * @param camera The camera to apply the render pass to.
  59143. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59144. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59146. * @param engine The engine which the post process will be applied. (default: current engine)
  59147. * @param reusable If the post process can be reused on the same frame. (default: false)
  59148. * @param textureType Type of textures used when performing the post process. (default: 0)
  59149. * @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)
  59150. */
  59151. 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);
  59152. }
  59153. }
  59154. declare module BABYLON {
  59155. /** @hidden */
  59156. export var depthOfFieldMergePixelShader: {
  59157. name: string;
  59158. shader: string;
  59159. };
  59160. }
  59161. declare module BABYLON {
  59162. /**
  59163. * Options to be set when merging outputs from the default pipeline.
  59164. */
  59165. export class DepthOfFieldMergePostProcessOptions {
  59166. /**
  59167. * The original image to merge on top of
  59168. */
  59169. originalFromInput: PostProcess;
  59170. /**
  59171. * Parameters to perform the merge of the depth of field effect
  59172. */
  59173. depthOfField?: {
  59174. circleOfConfusion: PostProcess;
  59175. blurSteps: Array<PostProcess>;
  59176. };
  59177. /**
  59178. * Parameters to perform the merge of bloom effect
  59179. */
  59180. bloom?: {
  59181. blurred: PostProcess;
  59182. weight: number;
  59183. };
  59184. }
  59185. /**
  59186. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59187. */
  59188. export class DepthOfFieldMergePostProcess extends PostProcess {
  59189. private blurSteps;
  59190. /**
  59191. * Creates a new instance of DepthOfFieldMergePostProcess
  59192. * @param name The name of the effect.
  59193. * @param originalFromInput Post process which's input will be used for the merge.
  59194. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59195. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59196. * @param options The required width/height ratio to downsize to before computing the render pass.
  59197. * @param camera The camera to apply the render pass to.
  59198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59199. * @param engine The engine which the post process will be applied. (default: current engine)
  59200. * @param reusable If the post process can be reused on the same frame. (default: false)
  59201. * @param textureType Type of textures used when performing the post process. (default: 0)
  59202. * @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)
  59203. */
  59204. 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);
  59205. /**
  59206. * Updates the effect with the current post process compile time values and recompiles the shader.
  59207. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59208. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59209. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59210. * @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
  59211. * @param onCompiled Called when the shader has been compiled.
  59212. * @param onError Called if there is an error when compiling a shader.
  59213. */
  59214. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59215. }
  59216. }
  59217. declare module BABYLON {
  59218. /**
  59219. * Specifies the level of max blur that should be applied when using the depth of field effect
  59220. */
  59221. export enum DepthOfFieldEffectBlurLevel {
  59222. /**
  59223. * Subtle blur
  59224. */
  59225. Low = 0,
  59226. /**
  59227. * Medium blur
  59228. */
  59229. Medium = 1,
  59230. /**
  59231. * Large blur
  59232. */
  59233. High = 2
  59234. }
  59235. /**
  59236. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59237. */
  59238. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59239. private _circleOfConfusion;
  59240. /**
  59241. * @hidden Internal, blurs from high to low
  59242. */
  59243. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59244. private _depthOfFieldBlurY;
  59245. private _dofMerge;
  59246. /**
  59247. * @hidden Internal post processes in depth of field effect
  59248. */
  59249. _effects: Array<PostProcess>;
  59250. /**
  59251. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59252. */
  59253. focalLength: number;
  59254. /**
  59255. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59256. */
  59257. fStop: number;
  59258. /**
  59259. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59260. */
  59261. focusDistance: number;
  59262. /**
  59263. * 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.
  59264. */
  59265. lensSize: number;
  59266. /**
  59267. * Creates a new instance DepthOfFieldEffect
  59268. * @param scene The scene the effect belongs to.
  59269. * @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.
  59270. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59271. * @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)
  59272. */
  59273. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59274. /**
  59275. * Get the current class name of the current effet
  59276. * @returns "DepthOfFieldEffect"
  59277. */
  59278. getClassName(): string;
  59279. /**
  59280. * 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.
  59281. */
  59282. depthTexture: RenderTargetTexture;
  59283. /**
  59284. * Disposes each of the internal effects for a given camera.
  59285. * @param camera The camera to dispose the effect on.
  59286. */
  59287. disposeEffects(camera: Camera): void;
  59288. /**
  59289. * @hidden Internal
  59290. */
  59291. _updateEffects(): void;
  59292. /**
  59293. * Internal
  59294. * @returns if all the contained post processes are ready.
  59295. * @hidden
  59296. */
  59297. _isReady(): boolean;
  59298. }
  59299. }
  59300. declare module BABYLON {
  59301. /** @hidden */
  59302. export var displayPassPixelShader: {
  59303. name: string;
  59304. shader: string;
  59305. };
  59306. }
  59307. declare module BABYLON {
  59308. /**
  59309. * DisplayPassPostProcess which produces an output the same as it's input
  59310. */
  59311. export class DisplayPassPostProcess extends PostProcess {
  59312. /**
  59313. * Creates the DisplayPassPostProcess
  59314. * @param name The name of the effect.
  59315. * @param options The required width/height ratio to downsize to before computing the render pass.
  59316. * @param camera The camera to apply the render pass to.
  59317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59318. * @param engine The engine which the post process will be applied. (default: current engine)
  59319. * @param reusable If the post process can be reused on the same frame. (default: false)
  59320. */
  59321. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59322. }
  59323. }
  59324. declare module BABYLON {
  59325. /** @hidden */
  59326. export var filterPixelShader: {
  59327. name: string;
  59328. shader: string;
  59329. };
  59330. }
  59331. declare module BABYLON {
  59332. /**
  59333. * Applies a kernel filter to the image
  59334. */
  59335. export class FilterPostProcess extends PostProcess {
  59336. /** The matrix to be applied to the image */
  59337. kernelMatrix: Matrix;
  59338. /**
  59339. *
  59340. * @param name The name of the effect.
  59341. * @param kernelMatrix The matrix to be applied to the image
  59342. * @param options The required width/height ratio to downsize to before computing the render pass.
  59343. * @param camera The camera to apply the render pass to.
  59344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59345. * @param engine The engine which the post process will be applied. (default: current engine)
  59346. * @param reusable If the post process can be reused on the same frame. (default: false)
  59347. */
  59348. constructor(name: string,
  59349. /** The matrix to be applied to the image */
  59350. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59351. }
  59352. }
  59353. declare module BABYLON {
  59354. /** @hidden */
  59355. export var fxaaPixelShader: {
  59356. name: string;
  59357. shader: string;
  59358. };
  59359. }
  59360. declare module BABYLON {
  59361. /** @hidden */
  59362. export var fxaaVertexShader: {
  59363. name: string;
  59364. shader: string;
  59365. };
  59366. }
  59367. declare module BABYLON {
  59368. /**
  59369. * Fxaa post process
  59370. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59371. */
  59372. export class FxaaPostProcess extends PostProcess {
  59373. /** @hidden */
  59374. texelWidth: number;
  59375. /** @hidden */
  59376. texelHeight: number;
  59377. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59378. private _getDefines;
  59379. }
  59380. }
  59381. declare module BABYLON {
  59382. /** @hidden */
  59383. export var grainPixelShader: {
  59384. name: string;
  59385. shader: string;
  59386. };
  59387. }
  59388. declare module BABYLON {
  59389. /**
  59390. * The GrainPostProcess adds noise to the image at mid luminance levels
  59391. */
  59392. export class GrainPostProcess extends PostProcess {
  59393. /**
  59394. * The intensity of the grain added (default: 30)
  59395. */
  59396. intensity: number;
  59397. /**
  59398. * If the grain should be randomized on every frame
  59399. */
  59400. animated: boolean;
  59401. /**
  59402. * Creates a new instance of @see GrainPostProcess
  59403. * @param name The name of the effect.
  59404. * @param options The required width/height ratio to downsize to before computing the render pass.
  59405. * @param camera The camera to apply the render pass to.
  59406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59407. * @param engine The engine which the post process will be applied. (default: current engine)
  59408. * @param reusable If the post process can be reused on the same frame. (default: false)
  59409. * @param textureType Type of textures used when performing the post process. (default: 0)
  59410. * @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)
  59411. */
  59412. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59413. }
  59414. }
  59415. declare module BABYLON {
  59416. /** @hidden */
  59417. export var highlightsPixelShader: {
  59418. name: string;
  59419. shader: string;
  59420. };
  59421. }
  59422. declare module BABYLON {
  59423. /**
  59424. * Extracts highlights from the image
  59425. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59426. */
  59427. export class HighlightsPostProcess extends PostProcess {
  59428. /**
  59429. * Extracts highlights from the image
  59430. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59431. * @param name The name of the effect.
  59432. * @param options The required width/height ratio to downsize to before computing the render pass.
  59433. * @param camera The camera to apply the render pass to.
  59434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59435. * @param engine The engine which the post process will be applied. (default: current engine)
  59436. * @param reusable If the post process can be reused on the same frame. (default: false)
  59437. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59438. */
  59439. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59440. }
  59441. }
  59442. declare module BABYLON {
  59443. /** @hidden */
  59444. export var mrtFragmentDeclaration: {
  59445. name: string;
  59446. shader: string;
  59447. };
  59448. }
  59449. declare module BABYLON {
  59450. /** @hidden */
  59451. export var geometryPixelShader: {
  59452. name: string;
  59453. shader: string;
  59454. };
  59455. }
  59456. declare module BABYLON {
  59457. /** @hidden */
  59458. export var geometryVertexShader: {
  59459. name: string;
  59460. shader: string;
  59461. };
  59462. }
  59463. declare module BABYLON {
  59464. /** @hidden */
  59465. interface ISavedTransformationMatrix {
  59466. world: Matrix;
  59467. viewProjection: Matrix;
  59468. }
  59469. /**
  59470. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59471. */
  59472. export class GeometryBufferRenderer {
  59473. /**
  59474. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59475. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59476. */
  59477. static readonly POSITION_TEXTURE_TYPE: number;
  59478. /**
  59479. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59480. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59481. */
  59482. static readonly VELOCITY_TEXTURE_TYPE: number;
  59483. /**
  59484. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59485. * in order to compute objects velocities when enableVelocity is set to "true"
  59486. * @hidden
  59487. */
  59488. _previousTransformationMatrices: {
  59489. [index: number]: ISavedTransformationMatrix;
  59490. };
  59491. /**
  59492. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59493. * in order to compute objects velocities when enableVelocity is set to "true"
  59494. * @hidden
  59495. */
  59496. _previousBonesTransformationMatrices: {
  59497. [index: number]: Float32Array;
  59498. };
  59499. /**
  59500. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59501. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59502. */
  59503. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59504. private _scene;
  59505. private _multiRenderTarget;
  59506. private _ratio;
  59507. private _enablePosition;
  59508. private _enableVelocity;
  59509. private _positionIndex;
  59510. private _velocityIndex;
  59511. protected _effect: Effect;
  59512. protected _cachedDefines: string;
  59513. /**
  59514. * Set the render list (meshes to be rendered) used in the G buffer.
  59515. */
  59516. renderList: Mesh[];
  59517. /**
  59518. * Gets wether or not G buffer are supported by the running hardware.
  59519. * This requires draw buffer supports
  59520. */
  59521. readonly isSupported: boolean;
  59522. /**
  59523. * Returns the index of the given texture type in the G-Buffer textures array
  59524. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59525. * @returns the index of the given texture type in the G-Buffer textures array
  59526. */
  59527. getTextureIndex(textureType: number): number;
  59528. /**
  59529. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59530. */
  59531. /**
  59532. * Sets whether or not objects positions are enabled for the G buffer.
  59533. */
  59534. enablePosition: boolean;
  59535. /**
  59536. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59537. */
  59538. /**
  59539. * Sets wether or not objects velocities are enabled for the G buffer.
  59540. */
  59541. enableVelocity: boolean;
  59542. /**
  59543. * Gets the scene associated with the buffer.
  59544. */
  59545. readonly scene: Scene;
  59546. /**
  59547. * Gets the ratio used by the buffer during its creation.
  59548. * How big is the buffer related to the main canvas.
  59549. */
  59550. readonly ratio: number;
  59551. /** @hidden */
  59552. static _SceneComponentInitialization: (scene: Scene) => void;
  59553. /**
  59554. * Creates a new G Buffer for the scene
  59555. * @param scene The scene the buffer belongs to
  59556. * @param ratio How big is the buffer related to the main canvas.
  59557. */
  59558. constructor(scene: Scene, ratio?: number);
  59559. /**
  59560. * Checks wether everything is ready to render a submesh to the G buffer.
  59561. * @param subMesh the submesh to check readiness for
  59562. * @param useInstances is the mesh drawn using instance or not
  59563. * @returns true if ready otherwise false
  59564. */
  59565. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59566. /**
  59567. * Gets the current underlying G Buffer.
  59568. * @returns the buffer
  59569. */
  59570. getGBuffer(): MultiRenderTarget;
  59571. /**
  59572. * Gets the number of samples used to render the buffer (anti aliasing).
  59573. */
  59574. /**
  59575. * Sets the number of samples used to render the buffer (anti aliasing).
  59576. */
  59577. samples: number;
  59578. /**
  59579. * Disposes the renderer and frees up associated resources.
  59580. */
  59581. dispose(): void;
  59582. protected _createRenderTargets(): void;
  59583. private _copyBonesTransformationMatrices;
  59584. }
  59585. }
  59586. declare module BABYLON {
  59587. interface Scene {
  59588. /** @hidden (Backing field) */
  59589. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59590. /**
  59591. * Gets or Sets the current geometry buffer associated to the scene.
  59592. */
  59593. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59594. /**
  59595. * Enables a GeometryBufferRender and associates it with the scene
  59596. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59597. * @returns the GeometryBufferRenderer
  59598. */
  59599. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59600. /**
  59601. * Disables the GeometryBufferRender associated with the scene
  59602. */
  59603. disableGeometryBufferRenderer(): void;
  59604. }
  59605. /**
  59606. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59607. * in several rendering techniques.
  59608. */
  59609. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59610. /**
  59611. * The component name helpful to identify the component in the list of scene components.
  59612. */
  59613. readonly name: string;
  59614. /**
  59615. * The scene the component belongs to.
  59616. */
  59617. scene: Scene;
  59618. /**
  59619. * Creates a new instance of the component for the given scene
  59620. * @param scene Defines the scene to register the component in
  59621. */
  59622. constructor(scene: Scene);
  59623. /**
  59624. * Registers the component in a given scene
  59625. */
  59626. register(): void;
  59627. /**
  59628. * Rebuilds the elements related to this component in case of
  59629. * context lost for instance.
  59630. */
  59631. rebuild(): void;
  59632. /**
  59633. * Disposes the component and the associated ressources
  59634. */
  59635. dispose(): void;
  59636. private _gatherRenderTargets;
  59637. }
  59638. }
  59639. declare module BABYLON {
  59640. /** @hidden */
  59641. export var motionBlurPixelShader: {
  59642. name: string;
  59643. shader: string;
  59644. };
  59645. }
  59646. declare module BABYLON {
  59647. /**
  59648. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59649. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59650. * As an example, all you have to do is to create the post-process:
  59651. * var mb = new BABYLON.MotionBlurPostProcess(
  59652. * 'mb', // The name of the effect.
  59653. * scene, // The scene containing the objects to blur according to their velocity.
  59654. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59655. * camera // The camera to apply the render pass to.
  59656. * );
  59657. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59658. */
  59659. export class MotionBlurPostProcess extends PostProcess {
  59660. /**
  59661. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59662. */
  59663. motionStrength: number;
  59664. /**
  59665. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59666. */
  59667. /**
  59668. * Sets the number of iterations to be used for motion blur quality
  59669. */
  59670. motionBlurSamples: number;
  59671. private _motionBlurSamples;
  59672. private _geometryBufferRenderer;
  59673. /**
  59674. * Creates a new instance MotionBlurPostProcess
  59675. * @param name The name of the effect.
  59676. * @param scene The scene containing the objects to blur according to their velocity.
  59677. * @param options The required width/height ratio to downsize to before computing the render pass.
  59678. * @param camera The camera to apply the render pass to.
  59679. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59680. * @param engine The engine which the post process will be applied. (default: current engine)
  59681. * @param reusable If the post process can be reused on the same frame. (default: false)
  59682. * @param textureType Type of textures used when performing the post process. (default: 0)
  59683. * @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)
  59684. */
  59685. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59686. /**
  59687. * Excludes the given skinned mesh from computing bones velocities.
  59688. * 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.
  59689. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59690. */
  59691. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59692. /**
  59693. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59694. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59695. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59696. */
  59697. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59698. /**
  59699. * Disposes the post process.
  59700. * @param camera The camera to dispose the post process on.
  59701. */
  59702. dispose(camera?: Camera): void;
  59703. }
  59704. }
  59705. declare module BABYLON {
  59706. /** @hidden */
  59707. export var refractionPixelShader: {
  59708. name: string;
  59709. shader: string;
  59710. };
  59711. }
  59712. declare module BABYLON {
  59713. /**
  59714. * Post process which applies a refractin texture
  59715. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59716. */
  59717. export class RefractionPostProcess extends PostProcess {
  59718. /** the base color of the refraction (used to taint the rendering) */
  59719. color: Color3;
  59720. /** simulated refraction depth */
  59721. depth: number;
  59722. /** the coefficient of the base color (0 to remove base color tainting) */
  59723. colorLevel: number;
  59724. private _refTexture;
  59725. private _ownRefractionTexture;
  59726. /**
  59727. * Gets or sets the refraction texture
  59728. * Please note that you are responsible for disposing the texture if you set it manually
  59729. */
  59730. refractionTexture: Texture;
  59731. /**
  59732. * Initializes the RefractionPostProcess
  59733. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59734. * @param name The name of the effect.
  59735. * @param refractionTextureUrl Url of the refraction texture to use
  59736. * @param color the base color of the refraction (used to taint the rendering)
  59737. * @param depth simulated refraction depth
  59738. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59739. * @param camera The camera to apply the render pass to.
  59740. * @param options The required width/height ratio to downsize to before computing the render pass.
  59741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59742. * @param engine The engine which the post process will be applied. (default: current engine)
  59743. * @param reusable If the post process can be reused on the same frame. (default: false)
  59744. */
  59745. constructor(name: string, refractionTextureUrl: string,
  59746. /** the base color of the refraction (used to taint the rendering) */
  59747. color: Color3,
  59748. /** simulated refraction depth */
  59749. depth: number,
  59750. /** the coefficient of the base color (0 to remove base color tainting) */
  59751. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59752. /**
  59753. * Disposes of the post process
  59754. * @param camera Camera to dispose post process on
  59755. */
  59756. dispose(camera: Camera): void;
  59757. }
  59758. }
  59759. declare module BABYLON {
  59760. /** @hidden */
  59761. export var sharpenPixelShader: {
  59762. name: string;
  59763. shader: string;
  59764. };
  59765. }
  59766. declare module BABYLON {
  59767. /**
  59768. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59769. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59770. */
  59771. export class SharpenPostProcess extends PostProcess {
  59772. /**
  59773. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59774. */
  59775. colorAmount: number;
  59776. /**
  59777. * How much sharpness should be applied (default: 0.3)
  59778. */
  59779. edgeAmount: number;
  59780. /**
  59781. * Creates a new instance ConvolutionPostProcess
  59782. * @param name The name of the effect.
  59783. * @param options The required width/height ratio to downsize to before computing the render pass.
  59784. * @param camera The camera to apply the render pass to.
  59785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59786. * @param engine The engine which the post process will be applied. (default: current engine)
  59787. * @param reusable If the post process can be reused on the same frame. (default: false)
  59788. * @param textureType Type of textures used when performing the post process. (default: 0)
  59789. * @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)
  59790. */
  59791. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59792. }
  59793. }
  59794. declare module BABYLON {
  59795. /**
  59796. * PostProcessRenderPipeline
  59797. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59798. */
  59799. export class PostProcessRenderPipeline {
  59800. private engine;
  59801. private _renderEffects;
  59802. private _renderEffectsForIsolatedPass;
  59803. /**
  59804. * List of inspectable custom properties (used by the Inspector)
  59805. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59806. */
  59807. inspectableCustomProperties: IInspectable[];
  59808. /**
  59809. * @hidden
  59810. */
  59811. protected _cameras: Camera[];
  59812. /** @hidden */
  59813. _name: string;
  59814. /**
  59815. * Gets pipeline name
  59816. */
  59817. readonly name: string;
  59818. /**
  59819. * Initializes a PostProcessRenderPipeline
  59820. * @param engine engine to add the pipeline to
  59821. * @param name name of the pipeline
  59822. */
  59823. constructor(engine: Engine, name: string);
  59824. /**
  59825. * Gets the class name
  59826. * @returns "PostProcessRenderPipeline"
  59827. */
  59828. getClassName(): string;
  59829. /**
  59830. * If all the render effects in the pipeline are supported
  59831. */
  59832. readonly isSupported: boolean;
  59833. /**
  59834. * Adds an effect to the pipeline
  59835. * @param renderEffect the effect to add
  59836. */
  59837. addEffect(renderEffect: PostProcessRenderEffect): void;
  59838. /** @hidden */
  59839. _rebuild(): void;
  59840. /** @hidden */
  59841. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59842. /** @hidden */
  59843. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59844. /** @hidden */
  59845. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59846. /** @hidden */
  59847. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59848. /** @hidden */
  59849. _attachCameras(cameras: Camera, unique: boolean): void;
  59850. /** @hidden */
  59851. _attachCameras(cameras: Camera[], unique: boolean): void;
  59852. /** @hidden */
  59853. _detachCameras(cameras: Camera): void;
  59854. /** @hidden */
  59855. _detachCameras(cameras: Nullable<Camera[]>): void;
  59856. /** @hidden */
  59857. _update(): void;
  59858. /** @hidden */
  59859. _reset(): void;
  59860. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59861. /**
  59862. * Disposes of the pipeline
  59863. */
  59864. dispose(): void;
  59865. }
  59866. }
  59867. declare module BABYLON {
  59868. /**
  59869. * PostProcessRenderPipelineManager class
  59870. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59871. */
  59872. export class PostProcessRenderPipelineManager {
  59873. private _renderPipelines;
  59874. /**
  59875. * Initializes a PostProcessRenderPipelineManager
  59876. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59877. */
  59878. constructor();
  59879. /**
  59880. * Gets the list of supported render pipelines
  59881. */
  59882. readonly supportedPipelines: PostProcessRenderPipeline[];
  59883. /**
  59884. * Adds a pipeline to the manager
  59885. * @param renderPipeline The pipeline to add
  59886. */
  59887. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59888. /**
  59889. * Attaches a camera to the pipeline
  59890. * @param renderPipelineName The name of the pipeline to attach to
  59891. * @param cameras the camera to attach
  59892. * @param unique if the camera can be attached multiple times to the pipeline
  59893. */
  59894. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59895. /**
  59896. * Detaches a camera from the pipeline
  59897. * @param renderPipelineName The name of the pipeline to detach from
  59898. * @param cameras the camera to detach
  59899. */
  59900. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59901. /**
  59902. * Enables an effect by name on a pipeline
  59903. * @param renderPipelineName the name of the pipeline to enable the effect in
  59904. * @param renderEffectName the name of the effect to enable
  59905. * @param cameras the cameras that the effect should be enabled on
  59906. */
  59907. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59908. /**
  59909. * Disables an effect by name on a pipeline
  59910. * @param renderPipelineName the name of the pipeline to disable the effect in
  59911. * @param renderEffectName the name of the effect to disable
  59912. * @param cameras the cameras that the effect should be disabled on
  59913. */
  59914. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59915. /**
  59916. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59917. */
  59918. update(): void;
  59919. /** @hidden */
  59920. _rebuild(): void;
  59921. /**
  59922. * Disposes of the manager and pipelines
  59923. */
  59924. dispose(): void;
  59925. }
  59926. }
  59927. declare module BABYLON {
  59928. interface Scene {
  59929. /** @hidden (Backing field) */
  59930. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59931. /**
  59932. * Gets the postprocess render pipeline manager
  59933. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59934. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59935. */
  59936. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59937. }
  59938. /**
  59939. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59940. */
  59941. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59942. /**
  59943. * The component name helpfull to identify the component in the list of scene components.
  59944. */
  59945. readonly name: string;
  59946. /**
  59947. * The scene the component belongs to.
  59948. */
  59949. scene: Scene;
  59950. /**
  59951. * Creates a new instance of the component for the given scene
  59952. * @param scene Defines the scene to register the component in
  59953. */
  59954. constructor(scene: Scene);
  59955. /**
  59956. * Registers the component in a given scene
  59957. */
  59958. register(): void;
  59959. /**
  59960. * Rebuilds the elements related to this component in case of
  59961. * context lost for instance.
  59962. */
  59963. rebuild(): void;
  59964. /**
  59965. * Disposes the component and the associated ressources
  59966. */
  59967. dispose(): void;
  59968. private _gatherRenderTargets;
  59969. }
  59970. }
  59971. declare module BABYLON {
  59972. /**
  59973. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59974. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59975. */
  59976. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59977. private _scene;
  59978. private _camerasToBeAttached;
  59979. /**
  59980. * ID of the sharpen post process,
  59981. */
  59982. private readonly SharpenPostProcessId;
  59983. /**
  59984. * @ignore
  59985. * ID of the image processing post process;
  59986. */
  59987. readonly ImageProcessingPostProcessId: string;
  59988. /**
  59989. * @ignore
  59990. * ID of the Fast Approximate Anti-Aliasing post process;
  59991. */
  59992. readonly FxaaPostProcessId: string;
  59993. /**
  59994. * ID of the chromatic aberration post process,
  59995. */
  59996. private readonly ChromaticAberrationPostProcessId;
  59997. /**
  59998. * ID of the grain post process
  59999. */
  60000. private readonly GrainPostProcessId;
  60001. /**
  60002. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60003. */
  60004. sharpen: SharpenPostProcess;
  60005. private _sharpenEffect;
  60006. private bloom;
  60007. /**
  60008. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60009. */
  60010. depthOfField: DepthOfFieldEffect;
  60011. /**
  60012. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60013. */
  60014. fxaa: FxaaPostProcess;
  60015. /**
  60016. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60017. */
  60018. imageProcessing: ImageProcessingPostProcess;
  60019. /**
  60020. * Chromatic aberration post process which will shift rgb colors in the image
  60021. */
  60022. chromaticAberration: ChromaticAberrationPostProcess;
  60023. private _chromaticAberrationEffect;
  60024. /**
  60025. * Grain post process which add noise to the image
  60026. */
  60027. grain: GrainPostProcess;
  60028. private _grainEffect;
  60029. /**
  60030. * Glow post process which adds a glow to emissive areas of the image
  60031. */
  60032. private _glowLayer;
  60033. /**
  60034. * Animations which can be used to tweak settings over a period of time
  60035. */
  60036. animations: Animation[];
  60037. private _imageProcessingConfigurationObserver;
  60038. private _sharpenEnabled;
  60039. private _bloomEnabled;
  60040. private _depthOfFieldEnabled;
  60041. private _depthOfFieldBlurLevel;
  60042. private _fxaaEnabled;
  60043. private _imageProcessingEnabled;
  60044. private _defaultPipelineTextureType;
  60045. private _bloomScale;
  60046. private _chromaticAberrationEnabled;
  60047. private _grainEnabled;
  60048. private _buildAllowed;
  60049. /**
  60050. * Gets active scene
  60051. */
  60052. readonly scene: Scene;
  60053. /**
  60054. * Enable or disable the sharpen process from the pipeline
  60055. */
  60056. sharpenEnabled: boolean;
  60057. private _resizeObserver;
  60058. private _hardwareScaleLevel;
  60059. private _bloomKernel;
  60060. /**
  60061. * Specifies the size of the bloom blur kernel, relative to the final output size
  60062. */
  60063. bloomKernel: number;
  60064. /**
  60065. * Specifies the weight of the bloom in the final rendering
  60066. */
  60067. private _bloomWeight;
  60068. /**
  60069. * Specifies the luma threshold for the area that will be blurred by the bloom
  60070. */
  60071. private _bloomThreshold;
  60072. private _hdr;
  60073. /**
  60074. * The strength of the bloom.
  60075. */
  60076. bloomWeight: number;
  60077. /**
  60078. * The strength of the bloom.
  60079. */
  60080. bloomThreshold: number;
  60081. /**
  60082. * The scale of the bloom, lower value will provide better performance.
  60083. */
  60084. bloomScale: number;
  60085. /**
  60086. * Enable or disable the bloom from the pipeline
  60087. */
  60088. bloomEnabled: boolean;
  60089. private _rebuildBloom;
  60090. /**
  60091. * If the depth of field is enabled.
  60092. */
  60093. depthOfFieldEnabled: boolean;
  60094. /**
  60095. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60096. */
  60097. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60098. /**
  60099. * If the anti aliasing is enabled.
  60100. */
  60101. fxaaEnabled: boolean;
  60102. private _samples;
  60103. /**
  60104. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60105. */
  60106. samples: number;
  60107. /**
  60108. * If image processing is enabled.
  60109. */
  60110. imageProcessingEnabled: boolean;
  60111. /**
  60112. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60113. */
  60114. glowLayerEnabled: boolean;
  60115. /**
  60116. * Gets the glow layer (or null if not defined)
  60117. */
  60118. readonly glowLayer: Nullable<GlowLayer>;
  60119. /**
  60120. * Enable or disable the chromaticAberration process from the pipeline
  60121. */
  60122. chromaticAberrationEnabled: boolean;
  60123. /**
  60124. * Enable or disable the grain process from the pipeline
  60125. */
  60126. grainEnabled: boolean;
  60127. /**
  60128. * @constructor
  60129. * @param name - The rendering pipeline name (default: "")
  60130. * @param hdr - If high dynamic range textures should be used (default: true)
  60131. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60132. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60133. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60134. */
  60135. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60136. /**
  60137. * Get the class name
  60138. * @returns "DefaultRenderingPipeline"
  60139. */
  60140. getClassName(): string;
  60141. /**
  60142. * Force the compilation of the entire pipeline.
  60143. */
  60144. prepare(): void;
  60145. private _hasCleared;
  60146. private _prevPostProcess;
  60147. private _prevPrevPostProcess;
  60148. private _setAutoClearAndTextureSharing;
  60149. private _depthOfFieldSceneObserver;
  60150. private _buildPipeline;
  60151. private _disposePostProcesses;
  60152. /**
  60153. * Adds a camera to the pipeline
  60154. * @param camera the camera to be added
  60155. */
  60156. addCamera(camera: Camera): void;
  60157. /**
  60158. * Removes a camera from the pipeline
  60159. * @param camera the camera to remove
  60160. */
  60161. removeCamera(camera: Camera): void;
  60162. /**
  60163. * Dispose of the pipeline and stop all post processes
  60164. */
  60165. dispose(): void;
  60166. /**
  60167. * Serialize the rendering pipeline (Used when exporting)
  60168. * @returns the serialized object
  60169. */
  60170. serialize(): any;
  60171. /**
  60172. * Parse the serialized pipeline
  60173. * @param source Source pipeline.
  60174. * @param scene The scene to load the pipeline to.
  60175. * @param rootUrl The URL of the serialized pipeline.
  60176. * @returns An instantiated pipeline from the serialized object.
  60177. */
  60178. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60179. }
  60180. }
  60181. declare module BABYLON {
  60182. /** @hidden */
  60183. export var lensHighlightsPixelShader: {
  60184. name: string;
  60185. shader: string;
  60186. };
  60187. }
  60188. declare module BABYLON {
  60189. /** @hidden */
  60190. export var depthOfFieldPixelShader: {
  60191. name: string;
  60192. shader: string;
  60193. };
  60194. }
  60195. declare module BABYLON {
  60196. /**
  60197. * BABYLON.JS Chromatic Aberration GLSL Shader
  60198. * Author: Olivier Guyot
  60199. * Separates very slightly R, G and B colors on the edges of the screen
  60200. * Inspired by Francois Tarlier & Martins Upitis
  60201. */
  60202. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60203. /**
  60204. * @ignore
  60205. * The chromatic aberration PostProcess id in the pipeline
  60206. */
  60207. LensChromaticAberrationEffect: string;
  60208. /**
  60209. * @ignore
  60210. * The highlights enhancing PostProcess id in the pipeline
  60211. */
  60212. HighlightsEnhancingEffect: string;
  60213. /**
  60214. * @ignore
  60215. * The depth-of-field PostProcess id in the pipeline
  60216. */
  60217. LensDepthOfFieldEffect: string;
  60218. private _scene;
  60219. private _depthTexture;
  60220. private _grainTexture;
  60221. private _chromaticAberrationPostProcess;
  60222. private _highlightsPostProcess;
  60223. private _depthOfFieldPostProcess;
  60224. private _edgeBlur;
  60225. private _grainAmount;
  60226. private _chromaticAberration;
  60227. private _distortion;
  60228. private _highlightsGain;
  60229. private _highlightsThreshold;
  60230. private _dofDistance;
  60231. private _dofAperture;
  60232. private _dofDarken;
  60233. private _dofPentagon;
  60234. private _blurNoise;
  60235. /**
  60236. * @constructor
  60237. *
  60238. * Effect parameters are as follow:
  60239. * {
  60240. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60241. * edge_blur: number; // from 0 to x (1 for realism)
  60242. * distortion: number; // from 0 to x (1 for realism)
  60243. * grain_amount: number; // from 0 to 1
  60244. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60245. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60246. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60247. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60248. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60249. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60250. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60251. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60252. * }
  60253. * Note: if an effect parameter is unset, effect is disabled
  60254. *
  60255. * @param name The rendering pipeline name
  60256. * @param parameters - An object containing all parameters (see above)
  60257. * @param scene The scene linked to this pipeline
  60258. * @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)
  60259. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60260. */
  60261. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60262. /**
  60263. * Get the class name
  60264. * @returns "LensRenderingPipeline"
  60265. */
  60266. getClassName(): string;
  60267. /**
  60268. * Gets associated scene
  60269. */
  60270. readonly scene: Scene;
  60271. /**
  60272. * Gets or sets the edge blur
  60273. */
  60274. edgeBlur: number;
  60275. /**
  60276. * Gets or sets the grain amount
  60277. */
  60278. grainAmount: number;
  60279. /**
  60280. * Gets or sets the chromatic aberration amount
  60281. */
  60282. chromaticAberration: number;
  60283. /**
  60284. * Gets or sets the depth of field aperture
  60285. */
  60286. dofAperture: number;
  60287. /**
  60288. * Gets or sets the edge distortion
  60289. */
  60290. edgeDistortion: number;
  60291. /**
  60292. * Gets or sets the depth of field distortion
  60293. */
  60294. dofDistortion: number;
  60295. /**
  60296. * Gets or sets the darken out of focus amount
  60297. */
  60298. darkenOutOfFocus: number;
  60299. /**
  60300. * Gets or sets a boolean indicating if blur noise is enabled
  60301. */
  60302. blurNoise: boolean;
  60303. /**
  60304. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60305. */
  60306. pentagonBokeh: boolean;
  60307. /**
  60308. * Gets or sets the highlight grain amount
  60309. */
  60310. highlightsGain: number;
  60311. /**
  60312. * Gets or sets the highlight threshold
  60313. */
  60314. highlightsThreshold: number;
  60315. /**
  60316. * Sets the amount of blur at the edges
  60317. * @param amount blur amount
  60318. */
  60319. setEdgeBlur(amount: number): void;
  60320. /**
  60321. * Sets edge blur to 0
  60322. */
  60323. disableEdgeBlur(): void;
  60324. /**
  60325. * Sets the amout of grain
  60326. * @param amount Amount of grain
  60327. */
  60328. setGrainAmount(amount: number): void;
  60329. /**
  60330. * Set grain amount to 0
  60331. */
  60332. disableGrain(): void;
  60333. /**
  60334. * Sets the chromatic aberration amount
  60335. * @param amount amount of chromatic aberration
  60336. */
  60337. setChromaticAberration(amount: number): void;
  60338. /**
  60339. * Sets chromatic aberration amount to 0
  60340. */
  60341. disableChromaticAberration(): void;
  60342. /**
  60343. * Sets the EdgeDistortion amount
  60344. * @param amount amount of EdgeDistortion
  60345. */
  60346. setEdgeDistortion(amount: number): void;
  60347. /**
  60348. * Sets edge distortion to 0
  60349. */
  60350. disableEdgeDistortion(): void;
  60351. /**
  60352. * Sets the FocusDistance amount
  60353. * @param amount amount of FocusDistance
  60354. */
  60355. setFocusDistance(amount: number): void;
  60356. /**
  60357. * Disables depth of field
  60358. */
  60359. disableDepthOfField(): void;
  60360. /**
  60361. * Sets the Aperture amount
  60362. * @param amount amount of Aperture
  60363. */
  60364. setAperture(amount: number): void;
  60365. /**
  60366. * Sets the DarkenOutOfFocus amount
  60367. * @param amount amount of DarkenOutOfFocus
  60368. */
  60369. setDarkenOutOfFocus(amount: number): void;
  60370. private _pentagonBokehIsEnabled;
  60371. /**
  60372. * Creates a pentagon bokeh effect
  60373. */
  60374. enablePentagonBokeh(): void;
  60375. /**
  60376. * Disables the pentagon bokeh effect
  60377. */
  60378. disablePentagonBokeh(): void;
  60379. /**
  60380. * Enables noise blur
  60381. */
  60382. enableNoiseBlur(): void;
  60383. /**
  60384. * Disables noise blur
  60385. */
  60386. disableNoiseBlur(): void;
  60387. /**
  60388. * Sets the HighlightsGain amount
  60389. * @param amount amount of HighlightsGain
  60390. */
  60391. setHighlightsGain(amount: number): void;
  60392. /**
  60393. * Sets the HighlightsThreshold amount
  60394. * @param amount amount of HighlightsThreshold
  60395. */
  60396. setHighlightsThreshold(amount: number): void;
  60397. /**
  60398. * Disables highlights
  60399. */
  60400. disableHighlights(): void;
  60401. /**
  60402. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60403. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60404. */
  60405. dispose(disableDepthRender?: boolean): void;
  60406. private _createChromaticAberrationPostProcess;
  60407. private _createHighlightsPostProcess;
  60408. private _createDepthOfFieldPostProcess;
  60409. private _createGrainTexture;
  60410. }
  60411. }
  60412. declare module BABYLON {
  60413. /** @hidden */
  60414. export var ssao2PixelShader: {
  60415. name: string;
  60416. shader: string;
  60417. };
  60418. }
  60419. declare module BABYLON {
  60420. /** @hidden */
  60421. export var ssaoCombinePixelShader: {
  60422. name: string;
  60423. shader: string;
  60424. };
  60425. }
  60426. declare module BABYLON {
  60427. /**
  60428. * Render pipeline to produce ssao effect
  60429. */
  60430. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60431. /**
  60432. * @ignore
  60433. * The PassPostProcess id in the pipeline that contains the original scene color
  60434. */
  60435. SSAOOriginalSceneColorEffect: string;
  60436. /**
  60437. * @ignore
  60438. * The SSAO PostProcess id in the pipeline
  60439. */
  60440. SSAORenderEffect: string;
  60441. /**
  60442. * @ignore
  60443. * The horizontal blur PostProcess id in the pipeline
  60444. */
  60445. SSAOBlurHRenderEffect: string;
  60446. /**
  60447. * @ignore
  60448. * The vertical blur PostProcess id in the pipeline
  60449. */
  60450. SSAOBlurVRenderEffect: string;
  60451. /**
  60452. * @ignore
  60453. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60454. */
  60455. SSAOCombineRenderEffect: string;
  60456. /**
  60457. * The output strength of the SSAO post-process. Default value is 1.0.
  60458. */
  60459. totalStrength: number;
  60460. /**
  60461. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60462. */
  60463. maxZ: number;
  60464. /**
  60465. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60466. */
  60467. minZAspect: number;
  60468. private _samples;
  60469. /**
  60470. * Number of samples used for the SSAO calculations. Default value is 8
  60471. */
  60472. samples: number;
  60473. private _textureSamples;
  60474. /**
  60475. * Number of samples to use for antialiasing
  60476. */
  60477. textureSamples: number;
  60478. /**
  60479. * Ratio object used for SSAO ratio and blur ratio
  60480. */
  60481. private _ratio;
  60482. /**
  60483. * Dynamically generated sphere sampler.
  60484. */
  60485. private _sampleSphere;
  60486. /**
  60487. * Blur filter offsets
  60488. */
  60489. private _samplerOffsets;
  60490. private _expensiveBlur;
  60491. /**
  60492. * If bilateral blur should be used
  60493. */
  60494. expensiveBlur: boolean;
  60495. /**
  60496. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60497. */
  60498. radius: number;
  60499. /**
  60500. * The base color of the SSAO post-process
  60501. * The final result is "base + ssao" between [0, 1]
  60502. */
  60503. base: number;
  60504. /**
  60505. * Support test.
  60506. */
  60507. static readonly IsSupported: boolean;
  60508. private _scene;
  60509. private _depthTexture;
  60510. private _normalTexture;
  60511. private _randomTexture;
  60512. private _originalColorPostProcess;
  60513. private _ssaoPostProcess;
  60514. private _blurHPostProcess;
  60515. private _blurVPostProcess;
  60516. private _ssaoCombinePostProcess;
  60517. private _firstUpdate;
  60518. /**
  60519. * Gets active scene
  60520. */
  60521. readonly scene: Scene;
  60522. /**
  60523. * @constructor
  60524. * @param name The rendering pipeline name
  60525. * @param scene The scene linked to this pipeline
  60526. * @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 }
  60527. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60528. */
  60529. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60530. /**
  60531. * Get the class name
  60532. * @returns "SSAO2RenderingPipeline"
  60533. */
  60534. getClassName(): string;
  60535. /**
  60536. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60537. */
  60538. dispose(disableGeometryBufferRenderer?: boolean): void;
  60539. private _createBlurPostProcess;
  60540. /** @hidden */
  60541. _rebuild(): void;
  60542. private _bits;
  60543. private _radicalInverse_VdC;
  60544. private _hammersley;
  60545. private _hemisphereSample_uniform;
  60546. private _generateHemisphere;
  60547. private _createSSAOPostProcess;
  60548. private _createSSAOCombinePostProcess;
  60549. private _createRandomTexture;
  60550. /**
  60551. * Serialize the rendering pipeline (Used when exporting)
  60552. * @returns the serialized object
  60553. */
  60554. serialize(): any;
  60555. /**
  60556. * Parse the serialized pipeline
  60557. * @param source Source pipeline.
  60558. * @param scene The scene to load the pipeline to.
  60559. * @param rootUrl The URL of the serialized pipeline.
  60560. * @returns An instantiated pipeline from the serialized object.
  60561. */
  60562. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60563. }
  60564. }
  60565. declare module BABYLON {
  60566. /** @hidden */
  60567. export var ssaoPixelShader: {
  60568. name: string;
  60569. shader: string;
  60570. };
  60571. }
  60572. declare module BABYLON {
  60573. /**
  60574. * Render pipeline to produce ssao effect
  60575. */
  60576. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60577. /**
  60578. * @ignore
  60579. * The PassPostProcess id in the pipeline that contains the original scene color
  60580. */
  60581. SSAOOriginalSceneColorEffect: string;
  60582. /**
  60583. * @ignore
  60584. * The SSAO PostProcess id in the pipeline
  60585. */
  60586. SSAORenderEffect: string;
  60587. /**
  60588. * @ignore
  60589. * The horizontal blur PostProcess id in the pipeline
  60590. */
  60591. SSAOBlurHRenderEffect: string;
  60592. /**
  60593. * @ignore
  60594. * The vertical blur PostProcess id in the pipeline
  60595. */
  60596. SSAOBlurVRenderEffect: string;
  60597. /**
  60598. * @ignore
  60599. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60600. */
  60601. SSAOCombineRenderEffect: string;
  60602. /**
  60603. * The output strength of the SSAO post-process. Default value is 1.0.
  60604. */
  60605. totalStrength: number;
  60606. /**
  60607. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60608. */
  60609. radius: number;
  60610. /**
  60611. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60612. * Must not be equal to fallOff and superior to fallOff.
  60613. * Default value is 0.0075
  60614. */
  60615. area: number;
  60616. /**
  60617. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60618. * Must not be equal to area and inferior to area.
  60619. * Default value is 0.000001
  60620. */
  60621. fallOff: number;
  60622. /**
  60623. * The base color of the SSAO post-process
  60624. * The final result is "base + ssao" between [0, 1]
  60625. */
  60626. base: number;
  60627. private _scene;
  60628. private _depthTexture;
  60629. private _randomTexture;
  60630. private _originalColorPostProcess;
  60631. private _ssaoPostProcess;
  60632. private _blurHPostProcess;
  60633. private _blurVPostProcess;
  60634. private _ssaoCombinePostProcess;
  60635. private _firstUpdate;
  60636. /**
  60637. * Gets active scene
  60638. */
  60639. readonly scene: Scene;
  60640. /**
  60641. * @constructor
  60642. * @param name - The rendering pipeline name
  60643. * @param scene - The scene linked to this pipeline
  60644. * @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 }
  60645. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60646. */
  60647. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60648. /**
  60649. * Get the class name
  60650. * @returns "SSAORenderingPipeline"
  60651. */
  60652. getClassName(): string;
  60653. /**
  60654. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60655. */
  60656. dispose(disableDepthRender?: boolean): void;
  60657. private _createBlurPostProcess;
  60658. /** @hidden */
  60659. _rebuild(): void;
  60660. private _createSSAOPostProcess;
  60661. private _createSSAOCombinePostProcess;
  60662. private _createRandomTexture;
  60663. }
  60664. }
  60665. declare module BABYLON {
  60666. /** @hidden */
  60667. export var standardPixelShader: {
  60668. name: string;
  60669. shader: string;
  60670. };
  60671. }
  60672. declare module BABYLON {
  60673. /**
  60674. * Standard rendering pipeline
  60675. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60676. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60677. */
  60678. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60679. /**
  60680. * Public members
  60681. */
  60682. /**
  60683. * Post-process which contains the original scene color before the pipeline applies all the effects
  60684. */
  60685. originalPostProcess: Nullable<PostProcess>;
  60686. /**
  60687. * Post-process used to down scale an image x4
  60688. */
  60689. downSampleX4PostProcess: Nullable<PostProcess>;
  60690. /**
  60691. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60692. */
  60693. brightPassPostProcess: Nullable<PostProcess>;
  60694. /**
  60695. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60696. */
  60697. blurHPostProcesses: PostProcess[];
  60698. /**
  60699. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60700. */
  60701. blurVPostProcesses: PostProcess[];
  60702. /**
  60703. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60704. */
  60705. textureAdderPostProcess: Nullable<PostProcess>;
  60706. /**
  60707. * Post-process used to create volumetric lighting effect
  60708. */
  60709. volumetricLightPostProcess: Nullable<PostProcess>;
  60710. /**
  60711. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60712. */
  60713. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60714. /**
  60715. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60716. */
  60717. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60718. /**
  60719. * Post-process used to merge the volumetric light effect and the real scene color
  60720. */
  60721. volumetricLightMergePostProces: Nullable<PostProcess>;
  60722. /**
  60723. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60724. */
  60725. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60726. /**
  60727. * Base post-process used to calculate the average luminance of the final image for HDR
  60728. */
  60729. luminancePostProcess: Nullable<PostProcess>;
  60730. /**
  60731. * Post-processes used to create down sample post-processes in order to get
  60732. * the average luminance of the final image for HDR
  60733. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60734. */
  60735. luminanceDownSamplePostProcesses: PostProcess[];
  60736. /**
  60737. * Post-process used to create a HDR effect (light adaptation)
  60738. */
  60739. hdrPostProcess: Nullable<PostProcess>;
  60740. /**
  60741. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60742. */
  60743. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60744. /**
  60745. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60746. */
  60747. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60748. /**
  60749. * Post-process used to merge the final HDR post-process and the real scene color
  60750. */
  60751. hdrFinalPostProcess: Nullable<PostProcess>;
  60752. /**
  60753. * Post-process used to create a lens flare effect
  60754. */
  60755. lensFlarePostProcess: Nullable<PostProcess>;
  60756. /**
  60757. * Post-process that merges the result of the lens flare post-process and the real scene color
  60758. */
  60759. lensFlareComposePostProcess: Nullable<PostProcess>;
  60760. /**
  60761. * Post-process used to create a motion blur effect
  60762. */
  60763. motionBlurPostProcess: Nullable<PostProcess>;
  60764. /**
  60765. * Post-process used to create a depth of field effect
  60766. */
  60767. depthOfFieldPostProcess: Nullable<PostProcess>;
  60768. /**
  60769. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60770. */
  60771. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60772. /**
  60773. * Represents the brightness threshold in order to configure the illuminated surfaces
  60774. */
  60775. brightThreshold: number;
  60776. /**
  60777. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60778. */
  60779. blurWidth: number;
  60780. /**
  60781. * Sets if the blur for highlighted surfaces must be only horizontal
  60782. */
  60783. horizontalBlur: boolean;
  60784. /**
  60785. * Gets the overall exposure used by the pipeline
  60786. */
  60787. /**
  60788. * Sets the overall exposure used by the pipeline
  60789. */
  60790. exposure: number;
  60791. /**
  60792. * Texture used typically to simulate "dirty" on camera lens
  60793. */
  60794. lensTexture: Nullable<Texture>;
  60795. /**
  60796. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60797. */
  60798. volumetricLightCoefficient: number;
  60799. /**
  60800. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60801. */
  60802. volumetricLightPower: number;
  60803. /**
  60804. * Used the set the blur intensity to smooth the volumetric lights
  60805. */
  60806. volumetricLightBlurScale: number;
  60807. /**
  60808. * Light (spot or directional) used to generate the volumetric lights rays
  60809. * The source light must have a shadow generate so the pipeline can get its
  60810. * depth map
  60811. */
  60812. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60813. /**
  60814. * For eye adaptation, represents the minimum luminance the eye can see
  60815. */
  60816. hdrMinimumLuminance: number;
  60817. /**
  60818. * For eye adaptation, represents the decrease luminance speed
  60819. */
  60820. hdrDecreaseRate: number;
  60821. /**
  60822. * For eye adaptation, represents the increase luminance speed
  60823. */
  60824. hdrIncreaseRate: number;
  60825. /**
  60826. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60827. */
  60828. /**
  60829. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60830. */
  60831. hdrAutoExposure: boolean;
  60832. /**
  60833. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60834. */
  60835. lensColorTexture: Nullable<Texture>;
  60836. /**
  60837. * The overall strengh for the lens flare effect
  60838. */
  60839. lensFlareStrength: number;
  60840. /**
  60841. * Dispersion coefficient for lens flare ghosts
  60842. */
  60843. lensFlareGhostDispersal: number;
  60844. /**
  60845. * Main lens flare halo width
  60846. */
  60847. lensFlareHaloWidth: number;
  60848. /**
  60849. * Based on the lens distortion effect, defines how much the lens flare result
  60850. * is distorted
  60851. */
  60852. lensFlareDistortionStrength: number;
  60853. /**
  60854. * Configures the blur intensity used for for lens flare (halo)
  60855. */
  60856. lensFlareBlurWidth: number;
  60857. /**
  60858. * Lens star texture must be used to simulate rays on the flares and is available
  60859. * in the documentation
  60860. */
  60861. lensStarTexture: Nullable<Texture>;
  60862. /**
  60863. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60864. * flare effect by taking account of the dirt texture
  60865. */
  60866. lensFlareDirtTexture: Nullable<Texture>;
  60867. /**
  60868. * Represents the focal length for the depth of field effect
  60869. */
  60870. depthOfFieldDistance: number;
  60871. /**
  60872. * Represents the blur intensity for the blurred part of the depth of field effect
  60873. */
  60874. depthOfFieldBlurWidth: number;
  60875. /**
  60876. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60877. */
  60878. /**
  60879. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60880. */
  60881. motionStrength: number;
  60882. /**
  60883. * Gets wether or not the motion blur post-process is object based or screen based.
  60884. */
  60885. /**
  60886. * Sets wether or not the motion blur post-process should be object based or screen based
  60887. */
  60888. objectBasedMotionBlur: boolean;
  60889. /**
  60890. * List of animations for the pipeline (IAnimatable implementation)
  60891. */
  60892. animations: Animation[];
  60893. /**
  60894. * Private members
  60895. */
  60896. private _scene;
  60897. private _currentDepthOfFieldSource;
  60898. private _basePostProcess;
  60899. private _fixedExposure;
  60900. private _currentExposure;
  60901. private _hdrAutoExposure;
  60902. private _hdrCurrentLuminance;
  60903. private _motionStrength;
  60904. private _isObjectBasedMotionBlur;
  60905. private _floatTextureType;
  60906. private _camerasToBeAttached;
  60907. private _ratio;
  60908. private _bloomEnabled;
  60909. private _depthOfFieldEnabled;
  60910. private _vlsEnabled;
  60911. private _lensFlareEnabled;
  60912. private _hdrEnabled;
  60913. private _motionBlurEnabled;
  60914. private _fxaaEnabled;
  60915. private _motionBlurSamples;
  60916. private _volumetricLightStepsCount;
  60917. private _samples;
  60918. /**
  60919. * @ignore
  60920. * Specifies if the bloom pipeline is enabled
  60921. */
  60922. BloomEnabled: boolean;
  60923. /**
  60924. * @ignore
  60925. * Specifies if the depth of field pipeline is enabed
  60926. */
  60927. DepthOfFieldEnabled: boolean;
  60928. /**
  60929. * @ignore
  60930. * Specifies if the lens flare pipeline is enabed
  60931. */
  60932. LensFlareEnabled: boolean;
  60933. /**
  60934. * @ignore
  60935. * Specifies if the HDR pipeline is enabled
  60936. */
  60937. HDREnabled: boolean;
  60938. /**
  60939. * @ignore
  60940. * Specifies if the volumetric lights scattering effect is enabled
  60941. */
  60942. VLSEnabled: boolean;
  60943. /**
  60944. * @ignore
  60945. * Specifies if the motion blur effect is enabled
  60946. */
  60947. MotionBlurEnabled: boolean;
  60948. /**
  60949. * Specifies if anti-aliasing is enabled
  60950. */
  60951. fxaaEnabled: boolean;
  60952. /**
  60953. * Specifies the number of steps used to calculate the volumetric lights
  60954. * Typically in interval [50, 200]
  60955. */
  60956. volumetricLightStepsCount: number;
  60957. /**
  60958. * Specifies the number of samples used for the motion blur effect
  60959. * Typically in interval [16, 64]
  60960. */
  60961. motionBlurSamples: number;
  60962. /**
  60963. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60964. */
  60965. samples: number;
  60966. /**
  60967. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60968. * @constructor
  60969. * @param name The rendering pipeline name
  60970. * @param scene The scene linked to this pipeline
  60971. * @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)
  60972. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60973. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60974. */
  60975. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60976. private _buildPipeline;
  60977. private _createDownSampleX4PostProcess;
  60978. private _createBrightPassPostProcess;
  60979. private _createBlurPostProcesses;
  60980. private _createTextureAdderPostProcess;
  60981. private _createVolumetricLightPostProcess;
  60982. private _createLuminancePostProcesses;
  60983. private _createHdrPostProcess;
  60984. private _createLensFlarePostProcess;
  60985. private _createDepthOfFieldPostProcess;
  60986. private _createMotionBlurPostProcess;
  60987. private _getDepthTexture;
  60988. private _disposePostProcesses;
  60989. /**
  60990. * Dispose of the pipeline and stop all post processes
  60991. */
  60992. dispose(): void;
  60993. /**
  60994. * Serialize the rendering pipeline (Used when exporting)
  60995. * @returns the serialized object
  60996. */
  60997. serialize(): any;
  60998. /**
  60999. * Parse the serialized pipeline
  61000. * @param source Source pipeline.
  61001. * @param scene The scene to load the pipeline to.
  61002. * @param rootUrl The URL of the serialized pipeline.
  61003. * @returns An instantiated pipeline from the serialized object.
  61004. */
  61005. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61006. /**
  61007. * Luminance steps
  61008. */
  61009. static LuminanceSteps: number;
  61010. }
  61011. }
  61012. declare module BABYLON {
  61013. /** @hidden */
  61014. export var tonemapPixelShader: {
  61015. name: string;
  61016. shader: string;
  61017. };
  61018. }
  61019. declare module BABYLON {
  61020. /** Defines operator used for tonemapping */
  61021. export enum TonemappingOperator {
  61022. /** Hable */
  61023. Hable = 0,
  61024. /** Reinhard */
  61025. Reinhard = 1,
  61026. /** HejiDawson */
  61027. HejiDawson = 2,
  61028. /** Photographic */
  61029. Photographic = 3
  61030. }
  61031. /**
  61032. * Defines a post process to apply tone mapping
  61033. */
  61034. export class TonemapPostProcess extends PostProcess {
  61035. private _operator;
  61036. /** Defines the required exposure adjustement */
  61037. exposureAdjustment: number;
  61038. /**
  61039. * Creates a new TonemapPostProcess
  61040. * @param name defines the name of the postprocess
  61041. * @param _operator defines the operator to use
  61042. * @param exposureAdjustment defines the required exposure adjustement
  61043. * @param camera defines the camera to use (can be null)
  61044. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61045. * @param engine defines the hosting engine (can be ignore if camera is set)
  61046. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61047. */
  61048. constructor(name: string, _operator: TonemappingOperator,
  61049. /** Defines the required exposure adjustement */
  61050. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61051. }
  61052. }
  61053. declare module BABYLON {
  61054. /** @hidden */
  61055. export var depthVertexShader: {
  61056. name: string;
  61057. shader: string;
  61058. };
  61059. }
  61060. declare module BABYLON {
  61061. /** @hidden */
  61062. export var volumetricLightScatteringPixelShader: {
  61063. name: string;
  61064. shader: string;
  61065. };
  61066. }
  61067. declare module BABYLON {
  61068. /** @hidden */
  61069. export var volumetricLightScatteringPassVertexShader: {
  61070. name: string;
  61071. shader: string;
  61072. };
  61073. }
  61074. declare module BABYLON {
  61075. /** @hidden */
  61076. export var volumetricLightScatteringPassPixelShader: {
  61077. name: string;
  61078. shader: string;
  61079. };
  61080. }
  61081. declare module BABYLON {
  61082. /**
  61083. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61084. */
  61085. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61086. private _volumetricLightScatteringPass;
  61087. private _volumetricLightScatteringRTT;
  61088. private _viewPort;
  61089. private _screenCoordinates;
  61090. private _cachedDefines;
  61091. /**
  61092. * If not undefined, the mesh position is computed from the attached node position
  61093. */
  61094. attachedNode: {
  61095. position: Vector3;
  61096. };
  61097. /**
  61098. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61099. */
  61100. customMeshPosition: Vector3;
  61101. /**
  61102. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61103. */
  61104. useCustomMeshPosition: boolean;
  61105. /**
  61106. * If the post-process should inverse the light scattering direction
  61107. */
  61108. invert: boolean;
  61109. /**
  61110. * The internal mesh used by the post-process
  61111. */
  61112. mesh: Mesh;
  61113. /**
  61114. * @hidden
  61115. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61116. */
  61117. useDiffuseColor: boolean;
  61118. /**
  61119. * Array containing the excluded meshes not rendered in the internal pass
  61120. */
  61121. excludedMeshes: AbstractMesh[];
  61122. /**
  61123. * Controls the overall intensity of the post-process
  61124. */
  61125. exposure: number;
  61126. /**
  61127. * Dissipates each sample's contribution in range [0, 1]
  61128. */
  61129. decay: number;
  61130. /**
  61131. * Controls the overall intensity of each sample
  61132. */
  61133. weight: number;
  61134. /**
  61135. * Controls the density of each sample
  61136. */
  61137. density: number;
  61138. /**
  61139. * @constructor
  61140. * @param name The post-process name
  61141. * @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)
  61142. * @param camera The camera that the post-process will be attached to
  61143. * @param mesh The mesh used to create the light scattering
  61144. * @param samples The post-process quality, default 100
  61145. * @param samplingModeThe post-process filtering mode
  61146. * @param engine The babylon engine
  61147. * @param reusable If the post-process is reusable
  61148. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61149. */
  61150. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61151. /**
  61152. * Returns the string "VolumetricLightScatteringPostProcess"
  61153. * @returns "VolumetricLightScatteringPostProcess"
  61154. */
  61155. getClassName(): string;
  61156. private _isReady;
  61157. /**
  61158. * Sets the new light position for light scattering effect
  61159. * @param position The new custom light position
  61160. */
  61161. setCustomMeshPosition(position: Vector3): void;
  61162. /**
  61163. * Returns the light position for light scattering effect
  61164. * @return Vector3 The custom light position
  61165. */
  61166. getCustomMeshPosition(): Vector3;
  61167. /**
  61168. * Disposes the internal assets and detaches the post-process from the camera
  61169. */
  61170. dispose(camera: Camera): void;
  61171. /**
  61172. * Returns the render target texture used by the post-process
  61173. * @return the render target texture used by the post-process
  61174. */
  61175. getPass(): RenderTargetTexture;
  61176. private _meshExcluded;
  61177. private _createPass;
  61178. private _updateMeshScreenCoordinates;
  61179. /**
  61180. * Creates a default mesh for the Volumeric Light Scattering post-process
  61181. * @param name The mesh name
  61182. * @param scene The scene where to create the mesh
  61183. * @return the default mesh
  61184. */
  61185. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61186. }
  61187. }
  61188. declare module BABYLON {
  61189. interface Scene {
  61190. /** @hidden (Backing field) */
  61191. _boundingBoxRenderer: BoundingBoxRenderer;
  61192. /** @hidden (Backing field) */
  61193. _forceShowBoundingBoxes: boolean;
  61194. /**
  61195. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61196. */
  61197. forceShowBoundingBoxes: boolean;
  61198. /**
  61199. * Gets the bounding box renderer associated with the scene
  61200. * @returns a BoundingBoxRenderer
  61201. */
  61202. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61203. }
  61204. interface AbstractMesh {
  61205. /** @hidden (Backing field) */
  61206. _showBoundingBox: boolean;
  61207. /**
  61208. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61209. */
  61210. showBoundingBox: boolean;
  61211. }
  61212. /**
  61213. * Component responsible of rendering the bounding box of the meshes in a scene.
  61214. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61215. */
  61216. export class BoundingBoxRenderer implements ISceneComponent {
  61217. /**
  61218. * The component name helpfull to identify the component in the list of scene components.
  61219. */
  61220. readonly name: string;
  61221. /**
  61222. * The scene the component belongs to.
  61223. */
  61224. scene: Scene;
  61225. /**
  61226. * Color of the bounding box lines placed in front of an object
  61227. */
  61228. frontColor: Color3;
  61229. /**
  61230. * Color of the bounding box lines placed behind an object
  61231. */
  61232. backColor: Color3;
  61233. /**
  61234. * Defines if the renderer should show the back lines or not
  61235. */
  61236. showBackLines: boolean;
  61237. /**
  61238. * @hidden
  61239. */
  61240. renderList: SmartArray<BoundingBox>;
  61241. private _colorShader;
  61242. private _vertexBuffers;
  61243. private _indexBuffer;
  61244. private _fillIndexBuffer;
  61245. private _fillIndexData;
  61246. /**
  61247. * Instantiates a new bounding box renderer in a scene.
  61248. * @param scene the scene the renderer renders in
  61249. */
  61250. constructor(scene: Scene);
  61251. /**
  61252. * Registers the component in a given scene
  61253. */
  61254. register(): void;
  61255. private _evaluateSubMesh;
  61256. private _activeMesh;
  61257. private _prepareRessources;
  61258. private _createIndexBuffer;
  61259. /**
  61260. * Rebuilds the elements related to this component in case of
  61261. * context lost for instance.
  61262. */
  61263. rebuild(): void;
  61264. /**
  61265. * @hidden
  61266. */
  61267. reset(): void;
  61268. /**
  61269. * Render the bounding boxes of a specific rendering group
  61270. * @param renderingGroupId defines the rendering group to render
  61271. */
  61272. render(renderingGroupId: number): void;
  61273. /**
  61274. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61275. * @param mesh Define the mesh to render the occlusion bounding box for
  61276. */
  61277. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61278. /**
  61279. * Dispose and release the resources attached to this renderer.
  61280. */
  61281. dispose(): void;
  61282. }
  61283. }
  61284. declare module BABYLON {
  61285. /** @hidden */
  61286. export var depthPixelShader: {
  61287. name: string;
  61288. shader: string;
  61289. };
  61290. }
  61291. declare module BABYLON {
  61292. /**
  61293. * This represents a depth renderer in Babylon.
  61294. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61295. */
  61296. export class DepthRenderer {
  61297. private _scene;
  61298. private _depthMap;
  61299. private _effect;
  61300. private readonly _storeNonLinearDepth;
  61301. private readonly _clearColor;
  61302. /** Get if the depth renderer is using packed depth or not */
  61303. readonly isPacked: boolean;
  61304. private _cachedDefines;
  61305. private _camera;
  61306. /**
  61307. * Specifiess that the depth renderer will only be used within
  61308. * the camera it is created for.
  61309. * This can help forcing its rendering during the camera processing.
  61310. */
  61311. useOnlyInActiveCamera: boolean;
  61312. /** @hidden */
  61313. static _SceneComponentInitialization: (scene: Scene) => void;
  61314. /**
  61315. * Instantiates a depth renderer
  61316. * @param scene The scene the renderer belongs to
  61317. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61318. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61319. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61320. */
  61321. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61322. /**
  61323. * Creates the depth rendering effect and checks if the effect is ready.
  61324. * @param subMesh The submesh to be used to render the depth map of
  61325. * @param useInstances If multiple world instances should be used
  61326. * @returns if the depth renderer is ready to render the depth map
  61327. */
  61328. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61329. /**
  61330. * Gets the texture which the depth map will be written to.
  61331. * @returns The depth map texture
  61332. */
  61333. getDepthMap(): RenderTargetTexture;
  61334. /**
  61335. * Disposes of the depth renderer.
  61336. */
  61337. dispose(): void;
  61338. }
  61339. }
  61340. declare module BABYLON {
  61341. interface Scene {
  61342. /** @hidden (Backing field) */
  61343. _depthRenderer: {
  61344. [id: string]: DepthRenderer;
  61345. };
  61346. /**
  61347. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61348. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61349. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61350. * @returns the created depth renderer
  61351. */
  61352. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61353. /**
  61354. * Disables a depth renderer for a given camera
  61355. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61356. */
  61357. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61358. }
  61359. /**
  61360. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61361. * in several rendering techniques.
  61362. */
  61363. export class DepthRendererSceneComponent implements ISceneComponent {
  61364. /**
  61365. * The component name helpfull to identify the component in the list of scene components.
  61366. */
  61367. readonly name: string;
  61368. /**
  61369. * The scene the component belongs to.
  61370. */
  61371. scene: Scene;
  61372. /**
  61373. * Creates a new instance of the component for the given scene
  61374. * @param scene Defines the scene to register the component in
  61375. */
  61376. constructor(scene: Scene);
  61377. /**
  61378. * Registers the component in a given scene
  61379. */
  61380. register(): void;
  61381. /**
  61382. * Rebuilds the elements related to this component in case of
  61383. * context lost for instance.
  61384. */
  61385. rebuild(): void;
  61386. /**
  61387. * Disposes the component and the associated ressources
  61388. */
  61389. dispose(): void;
  61390. private _gatherRenderTargets;
  61391. private _gatherActiveCameraRenderTargets;
  61392. }
  61393. }
  61394. declare module BABYLON {
  61395. /** @hidden */
  61396. export var outlinePixelShader: {
  61397. name: string;
  61398. shader: string;
  61399. };
  61400. }
  61401. declare module BABYLON {
  61402. /** @hidden */
  61403. export var outlineVertexShader: {
  61404. name: string;
  61405. shader: string;
  61406. };
  61407. }
  61408. declare module BABYLON {
  61409. interface Scene {
  61410. /** @hidden */
  61411. _outlineRenderer: OutlineRenderer;
  61412. /**
  61413. * Gets the outline renderer associated with the scene
  61414. * @returns a OutlineRenderer
  61415. */
  61416. getOutlineRenderer(): OutlineRenderer;
  61417. }
  61418. interface AbstractMesh {
  61419. /** @hidden (Backing field) */
  61420. _renderOutline: boolean;
  61421. /**
  61422. * Gets or sets a boolean indicating if the outline must be rendered as well
  61423. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61424. */
  61425. renderOutline: boolean;
  61426. /** @hidden (Backing field) */
  61427. _renderOverlay: boolean;
  61428. /**
  61429. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61430. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61431. */
  61432. renderOverlay: boolean;
  61433. }
  61434. /**
  61435. * This class is responsible to draw bothe outline/overlay of meshes.
  61436. * It should not be used directly but through the available method on mesh.
  61437. */
  61438. export class OutlineRenderer implements ISceneComponent {
  61439. /**
  61440. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61441. */
  61442. private static _StencilReference;
  61443. /**
  61444. * The name of the component. Each component must have a unique name.
  61445. */
  61446. name: string;
  61447. /**
  61448. * The scene the component belongs to.
  61449. */
  61450. scene: Scene;
  61451. /**
  61452. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61453. */
  61454. zOffset: number;
  61455. private _engine;
  61456. private _effect;
  61457. private _cachedDefines;
  61458. private _savedDepthWrite;
  61459. /**
  61460. * Instantiates a new outline renderer. (There could be only one per scene).
  61461. * @param scene Defines the scene it belongs to
  61462. */
  61463. constructor(scene: Scene);
  61464. /**
  61465. * Register the component to one instance of a scene.
  61466. */
  61467. register(): void;
  61468. /**
  61469. * Rebuilds the elements related to this component in case of
  61470. * context lost for instance.
  61471. */
  61472. rebuild(): void;
  61473. /**
  61474. * Disposes the component and the associated ressources.
  61475. */
  61476. dispose(): void;
  61477. /**
  61478. * Renders the outline in the canvas.
  61479. * @param subMesh Defines the sumesh to render
  61480. * @param batch Defines the batch of meshes in case of instances
  61481. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61482. */
  61483. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61484. /**
  61485. * Returns whether or not the outline renderer is ready for a given submesh.
  61486. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61487. * @param subMesh Defines the submesh to check readyness for
  61488. * @param useInstances Defines wheter wee are trying to render instances or not
  61489. * @returns true if ready otherwise false
  61490. */
  61491. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61492. private _beforeRenderingMesh;
  61493. private _afterRenderingMesh;
  61494. }
  61495. }
  61496. declare module BABYLON {
  61497. /**
  61498. * Class used to manage multiple sprites of different sizes on the same spritesheet
  61499. * @see http://doc.babylonjs.com/babylon101/sprites
  61500. */
  61501. export class SpritePackedManager extends SpriteManager {
  61502. /** defines the packed manager's name */
  61503. name: string;
  61504. /**
  61505. * Creates a new sprite manager from a packed sprite sheet
  61506. * @param name defines the manager's name
  61507. * @param imgUrl defines the sprite sheet url
  61508. * @param capacity defines the maximum allowed number of sprites
  61509. * @param scene defines the hosting scene
  61510. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  61511. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  61512. * @param samplingMode defines the smapling mode to use with spritesheet
  61513. * @param fromPacked set to true; do not alter
  61514. */
  61515. constructor(
  61516. /** defines the packed manager's name */
  61517. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  61518. }
  61519. }
  61520. declare module BABYLON {
  61521. /**
  61522. * Defines the list of states available for a task inside a AssetsManager
  61523. */
  61524. export enum AssetTaskState {
  61525. /**
  61526. * Initialization
  61527. */
  61528. INIT = 0,
  61529. /**
  61530. * Running
  61531. */
  61532. RUNNING = 1,
  61533. /**
  61534. * Done
  61535. */
  61536. DONE = 2,
  61537. /**
  61538. * Error
  61539. */
  61540. ERROR = 3
  61541. }
  61542. /**
  61543. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61544. */
  61545. export abstract class AbstractAssetTask {
  61546. /**
  61547. * Task name
  61548. */ name: string;
  61549. /**
  61550. * Callback called when the task is successful
  61551. */
  61552. onSuccess: (task: any) => void;
  61553. /**
  61554. * Callback called when the task is not successful
  61555. */
  61556. onError: (task: any, message?: string, exception?: any) => void;
  61557. /**
  61558. * Creates a new AssetsManager
  61559. * @param name defines the name of the task
  61560. */
  61561. constructor(
  61562. /**
  61563. * Task name
  61564. */ name: string);
  61565. private _isCompleted;
  61566. private _taskState;
  61567. private _errorObject;
  61568. /**
  61569. * Get if the task is completed
  61570. */
  61571. readonly isCompleted: boolean;
  61572. /**
  61573. * Gets the current state of the task
  61574. */
  61575. readonly taskState: AssetTaskState;
  61576. /**
  61577. * Gets the current error object (if task is in error)
  61578. */
  61579. readonly errorObject: {
  61580. message?: string;
  61581. exception?: any;
  61582. };
  61583. /**
  61584. * Internal only
  61585. * @hidden
  61586. */
  61587. _setErrorObject(message?: string, exception?: any): void;
  61588. /**
  61589. * Execute the current task
  61590. * @param scene defines the scene where you want your assets to be loaded
  61591. * @param onSuccess is a callback called when the task is successfully executed
  61592. * @param onError is a callback called if an error occurs
  61593. */
  61594. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61595. /**
  61596. * Execute the current task
  61597. * @param scene defines the scene where you want your assets to be loaded
  61598. * @param onSuccess is a callback called when the task is successfully executed
  61599. * @param onError is a callback called if an error occurs
  61600. */
  61601. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61602. /**
  61603. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61604. * This can be used with failed tasks that have the reason for failure fixed.
  61605. */
  61606. reset(): void;
  61607. private onErrorCallback;
  61608. private onDoneCallback;
  61609. }
  61610. /**
  61611. * Define the interface used by progress events raised during assets loading
  61612. */
  61613. export interface IAssetsProgressEvent {
  61614. /**
  61615. * Defines the number of remaining tasks to process
  61616. */
  61617. remainingCount: number;
  61618. /**
  61619. * Defines the total number of tasks
  61620. */
  61621. totalCount: number;
  61622. /**
  61623. * Defines the task that was just processed
  61624. */
  61625. task: AbstractAssetTask;
  61626. }
  61627. /**
  61628. * Class used to share progress information about assets loading
  61629. */
  61630. export class AssetsProgressEvent implements IAssetsProgressEvent {
  61631. /**
  61632. * Defines the number of remaining tasks to process
  61633. */
  61634. remainingCount: number;
  61635. /**
  61636. * Defines the total number of tasks
  61637. */
  61638. totalCount: number;
  61639. /**
  61640. * Defines the task that was just processed
  61641. */
  61642. task: AbstractAssetTask;
  61643. /**
  61644. * Creates a AssetsProgressEvent
  61645. * @param remainingCount defines the number of remaining tasks to process
  61646. * @param totalCount defines the total number of tasks
  61647. * @param task defines the task that was just processed
  61648. */
  61649. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  61650. }
  61651. /**
  61652. * Define a task used by AssetsManager to load meshes
  61653. */
  61654. export class MeshAssetTask extends AbstractAssetTask {
  61655. /**
  61656. * Defines the name of the task
  61657. */
  61658. name: string;
  61659. /**
  61660. * Defines the list of mesh's names you want to load
  61661. */
  61662. meshesNames: any;
  61663. /**
  61664. * Defines the root url to use as a base to load your meshes and associated resources
  61665. */
  61666. rootUrl: string;
  61667. /**
  61668. * Defines the filename of the scene to load from
  61669. */
  61670. sceneFilename: string;
  61671. /**
  61672. * Gets the list of loaded meshes
  61673. */
  61674. loadedMeshes: Array<AbstractMesh>;
  61675. /**
  61676. * Gets the list of loaded particle systems
  61677. */
  61678. loadedParticleSystems: Array<IParticleSystem>;
  61679. /**
  61680. * Gets the list of loaded skeletons
  61681. */
  61682. loadedSkeletons: Array<Skeleton>;
  61683. /**
  61684. * Gets the list of loaded animation groups
  61685. */
  61686. loadedAnimationGroups: Array<AnimationGroup>;
  61687. /**
  61688. * Callback called when the task is successful
  61689. */
  61690. onSuccess: (task: MeshAssetTask) => void;
  61691. /**
  61692. * Callback called when the task is successful
  61693. */
  61694. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61695. /**
  61696. * Creates a new MeshAssetTask
  61697. * @param name defines the name of the task
  61698. * @param meshesNames defines the list of mesh's names you want to load
  61699. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61700. * @param sceneFilename defines the filename of the scene to load from
  61701. */
  61702. constructor(
  61703. /**
  61704. * Defines the name of the task
  61705. */
  61706. name: string,
  61707. /**
  61708. * Defines the list of mesh's names you want to load
  61709. */
  61710. meshesNames: any,
  61711. /**
  61712. * Defines the root url to use as a base to load your meshes and associated resources
  61713. */
  61714. rootUrl: string,
  61715. /**
  61716. * Defines the filename of the scene to load from
  61717. */
  61718. sceneFilename: string);
  61719. /**
  61720. * Execute the current task
  61721. * @param scene defines the scene where you want your assets to be loaded
  61722. * @param onSuccess is a callback called when the task is successfully executed
  61723. * @param onError is a callback called if an error occurs
  61724. */
  61725. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61726. }
  61727. /**
  61728. * Define a task used by AssetsManager to load text content
  61729. */
  61730. export class TextFileAssetTask extends AbstractAssetTask {
  61731. /**
  61732. * Defines the name of the task
  61733. */
  61734. name: string;
  61735. /**
  61736. * Defines the location of the file to load
  61737. */
  61738. url: string;
  61739. /**
  61740. * Gets the loaded text string
  61741. */
  61742. text: string;
  61743. /**
  61744. * Callback called when the task is successful
  61745. */
  61746. onSuccess: (task: TextFileAssetTask) => void;
  61747. /**
  61748. * Callback called when the task is successful
  61749. */
  61750. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61751. /**
  61752. * Creates a new TextFileAssetTask object
  61753. * @param name defines the name of the task
  61754. * @param url defines the location of the file to load
  61755. */
  61756. constructor(
  61757. /**
  61758. * Defines the name of the task
  61759. */
  61760. name: string,
  61761. /**
  61762. * Defines the location of the file to load
  61763. */
  61764. url: string);
  61765. /**
  61766. * Execute the current task
  61767. * @param scene defines the scene where you want your assets to be loaded
  61768. * @param onSuccess is a callback called when the task is successfully executed
  61769. * @param onError is a callback called if an error occurs
  61770. */
  61771. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61772. }
  61773. /**
  61774. * Define a task used by AssetsManager to load binary data
  61775. */
  61776. export class BinaryFileAssetTask extends AbstractAssetTask {
  61777. /**
  61778. * Defines the name of the task
  61779. */
  61780. name: string;
  61781. /**
  61782. * Defines the location of the file to load
  61783. */
  61784. url: string;
  61785. /**
  61786. * Gets the lodaded data (as an array buffer)
  61787. */
  61788. data: ArrayBuffer;
  61789. /**
  61790. * Callback called when the task is successful
  61791. */
  61792. onSuccess: (task: BinaryFileAssetTask) => void;
  61793. /**
  61794. * Callback called when the task is successful
  61795. */
  61796. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61797. /**
  61798. * Creates a new BinaryFileAssetTask object
  61799. * @param name defines the name of the new task
  61800. * @param url defines the location of the file to load
  61801. */
  61802. constructor(
  61803. /**
  61804. * Defines the name of the task
  61805. */
  61806. name: string,
  61807. /**
  61808. * Defines the location of the file to load
  61809. */
  61810. url: string);
  61811. /**
  61812. * Execute the current task
  61813. * @param scene defines the scene where you want your assets to be loaded
  61814. * @param onSuccess is a callback called when the task is successfully executed
  61815. * @param onError is a callback called if an error occurs
  61816. */
  61817. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61818. }
  61819. /**
  61820. * Define a task used by AssetsManager to load images
  61821. */
  61822. export class ImageAssetTask extends AbstractAssetTask {
  61823. /**
  61824. * Defines the name of the task
  61825. */
  61826. name: string;
  61827. /**
  61828. * Defines the location of the image to load
  61829. */
  61830. url: string;
  61831. /**
  61832. * Gets the loaded images
  61833. */
  61834. image: HTMLImageElement;
  61835. /**
  61836. * Callback called when the task is successful
  61837. */
  61838. onSuccess: (task: ImageAssetTask) => void;
  61839. /**
  61840. * Callback called when the task is successful
  61841. */
  61842. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61843. /**
  61844. * Creates a new ImageAssetTask
  61845. * @param name defines the name of the task
  61846. * @param url defines the location of the image to load
  61847. */
  61848. constructor(
  61849. /**
  61850. * Defines the name of the task
  61851. */
  61852. name: string,
  61853. /**
  61854. * Defines the location of the image to load
  61855. */
  61856. url: string);
  61857. /**
  61858. * Execute the current task
  61859. * @param scene defines the scene where you want your assets to be loaded
  61860. * @param onSuccess is a callback called when the task is successfully executed
  61861. * @param onError is a callback called if an error occurs
  61862. */
  61863. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61864. }
  61865. /**
  61866. * Defines the interface used by texture loading tasks
  61867. */
  61868. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61869. /**
  61870. * Gets the loaded texture
  61871. */
  61872. texture: TEX;
  61873. }
  61874. /**
  61875. * Define a task used by AssetsManager to load 2D textures
  61876. */
  61877. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61878. /**
  61879. * Defines the name of the task
  61880. */
  61881. name: string;
  61882. /**
  61883. * Defines the location of the file to load
  61884. */
  61885. url: string;
  61886. /**
  61887. * Defines if mipmap should not be generated (default is false)
  61888. */
  61889. noMipmap?: boolean | undefined;
  61890. /**
  61891. * Defines if texture must be inverted on Y axis (default is false)
  61892. */
  61893. invertY?: boolean | undefined;
  61894. /**
  61895. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61896. */
  61897. samplingMode: number;
  61898. /**
  61899. * Gets the loaded texture
  61900. */
  61901. texture: Texture;
  61902. /**
  61903. * Callback called when the task is successful
  61904. */
  61905. onSuccess: (task: TextureAssetTask) => void;
  61906. /**
  61907. * Callback called when the task is successful
  61908. */
  61909. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61910. /**
  61911. * Creates a new TextureAssetTask object
  61912. * @param name defines the name of the task
  61913. * @param url defines the location of the file to load
  61914. * @param noMipmap defines if mipmap should not be generated (default is false)
  61915. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61916. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61917. */
  61918. constructor(
  61919. /**
  61920. * Defines the name of the task
  61921. */
  61922. name: string,
  61923. /**
  61924. * Defines the location of the file to load
  61925. */
  61926. url: string,
  61927. /**
  61928. * Defines if mipmap should not be generated (default is false)
  61929. */
  61930. noMipmap?: boolean | undefined,
  61931. /**
  61932. * Defines if texture must be inverted on Y axis (default is false)
  61933. */
  61934. invertY?: boolean | undefined,
  61935. /**
  61936. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61937. */
  61938. samplingMode?: number);
  61939. /**
  61940. * Execute the current task
  61941. * @param scene defines the scene where you want your assets to be loaded
  61942. * @param onSuccess is a callback called when the task is successfully executed
  61943. * @param onError is a callback called if an error occurs
  61944. */
  61945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61946. }
  61947. /**
  61948. * Define a task used by AssetsManager to load cube textures
  61949. */
  61950. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61951. /**
  61952. * Defines the name of the task
  61953. */
  61954. name: string;
  61955. /**
  61956. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61957. */
  61958. url: string;
  61959. /**
  61960. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61961. */
  61962. extensions?: string[] | undefined;
  61963. /**
  61964. * Defines if mipmaps should not be generated (default is false)
  61965. */
  61966. noMipmap?: boolean | undefined;
  61967. /**
  61968. * Defines the explicit list of files (undefined by default)
  61969. */
  61970. files?: string[] | undefined;
  61971. /**
  61972. * Gets the loaded texture
  61973. */
  61974. texture: CubeTexture;
  61975. /**
  61976. * Callback called when the task is successful
  61977. */
  61978. onSuccess: (task: CubeTextureAssetTask) => void;
  61979. /**
  61980. * Callback called when the task is successful
  61981. */
  61982. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61983. /**
  61984. * Creates a new CubeTextureAssetTask
  61985. * @param name defines the name of the task
  61986. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61987. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61988. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61989. * @param files defines the explicit list of files (undefined by default)
  61990. */
  61991. constructor(
  61992. /**
  61993. * Defines the name of the task
  61994. */
  61995. name: string,
  61996. /**
  61997. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61998. */
  61999. url: string,
  62000. /**
  62001. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62002. */
  62003. extensions?: string[] | undefined,
  62004. /**
  62005. * Defines if mipmaps should not be generated (default is false)
  62006. */
  62007. noMipmap?: boolean | undefined,
  62008. /**
  62009. * Defines the explicit list of files (undefined by default)
  62010. */
  62011. files?: string[] | undefined);
  62012. /**
  62013. * Execute the current task
  62014. * @param scene defines the scene where you want your assets to be loaded
  62015. * @param onSuccess is a callback called when the task is successfully executed
  62016. * @param onError is a callback called if an error occurs
  62017. */
  62018. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62019. }
  62020. /**
  62021. * Define a task used by AssetsManager to load HDR cube textures
  62022. */
  62023. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62024. /**
  62025. * Defines the name of the task
  62026. */
  62027. name: string;
  62028. /**
  62029. * Defines the location of the file to load
  62030. */
  62031. url: string;
  62032. /**
  62033. * Defines the desired size (the more it increases the longer the generation will be)
  62034. */
  62035. size: number;
  62036. /**
  62037. * Defines if mipmaps should not be generated (default is false)
  62038. */
  62039. noMipmap: boolean;
  62040. /**
  62041. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62042. */
  62043. generateHarmonics: boolean;
  62044. /**
  62045. * 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)
  62046. */
  62047. gammaSpace: boolean;
  62048. /**
  62049. * Internal Use Only
  62050. */
  62051. reserved: boolean;
  62052. /**
  62053. * Gets the loaded texture
  62054. */
  62055. texture: HDRCubeTexture;
  62056. /**
  62057. * Callback called when the task is successful
  62058. */
  62059. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62060. /**
  62061. * Callback called when the task is successful
  62062. */
  62063. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62064. /**
  62065. * Creates a new HDRCubeTextureAssetTask object
  62066. * @param name defines the name of the task
  62067. * @param url defines the location of the file to load
  62068. * @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.
  62069. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62070. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62071. * @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)
  62072. * @param reserved Internal use only
  62073. */
  62074. constructor(
  62075. /**
  62076. * Defines the name of the task
  62077. */
  62078. name: string,
  62079. /**
  62080. * Defines the location of the file to load
  62081. */
  62082. url: string,
  62083. /**
  62084. * Defines the desired size (the more it increases the longer the generation will be)
  62085. */
  62086. size: number,
  62087. /**
  62088. * Defines if mipmaps should not be generated (default is false)
  62089. */
  62090. noMipmap?: boolean,
  62091. /**
  62092. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62093. */
  62094. generateHarmonics?: boolean,
  62095. /**
  62096. * 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)
  62097. */
  62098. gammaSpace?: boolean,
  62099. /**
  62100. * Internal Use Only
  62101. */
  62102. reserved?: boolean);
  62103. /**
  62104. * Execute the current task
  62105. * @param scene defines the scene where you want your assets to be loaded
  62106. * @param onSuccess is a callback called when the task is successfully executed
  62107. * @param onError is a callback called if an error occurs
  62108. */
  62109. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62110. }
  62111. /**
  62112. * Define a task used by AssetsManager to load Equirectangular cube textures
  62113. */
  62114. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62115. /**
  62116. * Defines the name of the task
  62117. */
  62118. name: string;
  62119. /**
  62120. * Defines the location of the file to load
  62121. */
  62122. url: string;
  62123. /**
  62124. * Defines the desired size (the more it increases the longer the generation will be)
  62125. */
  62126. size: number;
  62127. /**
  62128. * Defines if mipmaps should not be generated (default is false)
  62129. */
  62130. noMipmap: boolean;
  62131. /**
  62132. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62133. * but the standard material would require them in Gamma space) (default is true)
  62134. */
  62135. gammaSpace: boolean;
  62136. /**
  62137. * Gets the loaded texture
  62138. */
  62139. texture: EquiRectangularCubeTexture;
  62140. /**
  62141. * Callback called when the task is successful
  62142. */
  62143. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62144. /**
  62145. * Callback called when the task is successful
  62146. */
  62147. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62148. /**
  62149. * Creates a new EquiRectangularCubeTextureAssetTask object
  62150. * @param name defines the name of the task
  62151. * @param url defines the location of the file to load
  62152. * @param size defines the desired size (the more it increases the longer the generation will be)
  62153. * If the size is omitted this implies you are using a preprocessed cubemap.
  62154. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62155. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62156. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62157. * (default is true)
  62158. */
  62159. constructor(
  62160. /**
  62161. * Defines the name of the task
  62162. */
  62163. name: string,
  62164. /**
  62165. * Defines the location of the file to load
  62166. */
  62167. url: string,
  62168. /**
  62169. * Defines the desired size (the more it increases the longer the generation will be)
  62170. */
  62171. size: number,
  62172. /**
  62173. * Defines if mipmaps should not be generated (default is false)
  62174. */
  62175. noMipmap?: boolean,
  62176. /**
  62177. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62178. * but the standard material would require them in Gamma space) (default is true)
  62179. */
  62180. gammaSpace?: boolean);
  62181. /**
  62182. * Execute the current task
  62183. * @param scene defines the scene where you want your assets to be loaded
  62184. * @param onSuccess is a callback called when the task is successfully executed
  62185. * @param onError is a callback called if an error occurs
  62186. */
  62187. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62188. }
  62189. /**
  62190. * This class can be used to easily import assets into a scene
  62191. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62192. */
  62193. export class AssetsManager {
  62194. private _scene;
  62195. private _isLoading;
  62196. protected _tasks: AbstractAssetTask[];
  62197. protected _waitingTasksCount: number;
  62198. protected _totalTasksCount: number;
  62199. /**
  62200. * Callback called when all tasks are processed
  62201. */
  62202. onFinish: (tasks: AbstractAssetTask[]) => void;
  62203. /**
  62204. * Callback called when a task is successful
  62205. */
  62206. onTaskSuccess: (task: AbstractAssetTask) => void;
  62207. /**
  62208. * Callback called when a task had an error
  62209. */
  62210. onTaskError: (task: AbstractAssetTask) => void;
  62211. /**
  62212. * Callback called when a task is done (whatever the result is)
  62213. */
  62214. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62215. /**
  62216. * Observable called when all tasks are processed
  62217. */
  62218. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62219. /**
  62220. * Observable called when a task had an error
  62221. */
  62222. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62223. /**
  62224. * Observable called when all tasks were executed
  62225. */
  62226. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62227. /**
  62228. * Observable called when a task is done (whatever the result is)
  62229. */
  62230. onProgressObservable: Observable<IAssetsProgressEvent>;
  62231. /**
  62232. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62233. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62234. */
  62235. useDefaultLoadingScreen: boolean;
  62236. /**
  62237. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62238. * when all assets have been downloaded.
  62239. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62240. */
  62241. autoHideLoadingUI: boolean;
  62242. /**
  62243. * Creates a new AssetsManager
  62244. * @param scene defines the scene to work on
  62245. */
  62246. constructor(scene: Scene);
  62247. /**
  62248. * Add a MeshAssetTask to the list of active tasks
  62249. * @param taskName defines the name of the new task
  62250. * @param meshesNames defines the name of meshes to load
  62251. * @param rootUrl defines the root url to use to locate files
  62252. * @param sceneFilename defines the filename of the scene file
  62253. * @returns a new MeshAssetTask object
  62254. */
  62255. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62256. /**
  62257. * Add a TextFileAssetTask to the list of active tasks
  62258. * @param taskName defines the name of the new task
  62259. * @param url defines the url of the file to load
  62260. * @returns a new TextFileAssetTask object
  62261. */
  62262. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62263. /**
  62264. * Add a BinaryFileAssetTask to the list of active tasks
  62265. * @param taskName defines the name of the new task
  62266. * @param url defines the url of the file to load
  62267. * @returns a new BinaryFileAssetTask object
  62268. */
  62269. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62270. /**
  62271. * Add a ImageAssetTask to the list of active tasks
  62272. * @param taskName defines the name of the new task
  62273. * @param url defines the url of the file to load
  62274. * @returns a new ImageAssetTask object
  62275. */
  62276. addImageTask(taskName: string, url: string): ImageAssetTask;
  62277. /**
  62278. * Add a TextureAssetTask to the list of active tasks
  62279. * @param taskName defines the name of the new task
  62280. * @param url defines the url of the file to load
  62281. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62282. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62283. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62284. * @returns a new TextureAssetTask object
  62285. */
  62286. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62287. /**
  62288. * Add a CubeTextureAssetTask to the list of active tasks
  62289. * @param taskName defines the name of the new task
  62290. * @param url defines the url of the file to load
  62291. * @param extensions defines the extension to use to load the cube map (can be null)
  62292. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62293. * @param files defines the list of files to load (can be null)
  62294. * @returns a new CubeTextureAssetTask object
  62295. */
  62296. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62297. /**
  62298. *
  62299. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62300. * @param taskName defines the name of the new task
  62301. * @param url defines the url of the file to load
  62302. * @param size defines the size you want for the cubemap (can be null)
  62303. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62304. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62305. * @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)
  62306. * @param reserved Internal use only
  62307. * @returns a new HDRCubeTextureAssetTask object
  62308. */
  62309. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62310. /**
  62311. *
  62312. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62313. * @param taskName defines the name of the new task
  62314. * @param url defines the url of the file to load
  62315. * @param size defines the size you want for the cubemap (can be null)
  62316. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62317. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62318. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62319. * @returns a new EquiRectangularCubeTextureAssetTask object
  62320. */
  62321. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62322. /**
  62323. * Remove a task from the assets manager.
  62324. * @param task the task to remove
  62325. */
  62326. removeTask(task: AbstractAssetTask): void;
  62327. private _decreaseWaitingTasksCount;
  62328. private _runTask;
  62329. /**
  62330. * Reset the AssetsManager and remove all tasks
  62331. * @return the current instance of the AssetsManager
  62332. */
  62333. reset(): AssetsManager;
  62334. /**
  62335. * Start the loading process
  62336. * @return the current instance of the AssetsManager
  62337. */
  62338. load(): AssetsManager;
  62339. /**
  62340. * Start the loading process as an async operation
  62341. * @return a promise returning the list of failed tasks
  62342. */
  62343. loadAsync(): Promise<void>;
  62344. }
  62345. }
  62346. declare module BABYLON {
  62347. /**
  62348. * Wrapper class for promise with external resolve and reject.
  62349. */
  62350. export class Deferred<T> {
  62351. /**
  62352. * The promise associated with this deferred object.
  62353. */
  62354. readonly promise: Promise<T>;
  62355. private _resolve;
  62356. private _reject;
  62357. /**
  62358. * The resolve method of the promise associated with this deferred object.
  62359. */
  62360. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62361. /**
  62362. * The reject method of the promise associated with this deferred object.
  62363. */
  62364. readonly reject: (reason?: any) => void;
  62365. /**
  62366. * Constructor for this deferred object.
  62367. */
  62368. constructor();
  62369. }
  62370. }
  62371. declare module BABYLON {
  62372. /**
  62373. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62374. */
  62375. export class MeshExploder {
  62376. private _centerMesh;
  62377. private _meshes;
  62378. private _meshesOrigins;
  62379. private _toCenterVectors;
  62380. private _scaledDirection;
  62381. private _newPosition;
  62382. private _centerPosition;
  62383. /**
  62384. * Explodes meshes from a center mesh.
  62385. * @param meshes The meshes to explode.
  62386. * @param centerMesh The mesh to be center of explosion.
  62387. */
  62388. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62389. private _setCenterMesh;
  62390. /**
  62391. * Get class name
  62392. * @returns "MeshExploder"
  62393. */
  62394. getClassName(): string;
  62395. /**
  62396. * "Exploded meshes"
  62397. * @returns Array of meshes with the centerMesh at index 0.
  62398. */
  62399. getMeshes(): Array<Mesh>;
  62400. /**
  62401. * Explodes meshes giving a specific direction
  62402. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62403. */
  62404. explode(direction?: number): void;
  62405. }
  62406. }
  62407. declare module BABYLON {
  62408. /**
  62409. * Class used to help managing file picking and drag'n'drop
  62410. */
  62411. export class FilesInput {
  62412. /**
  62413. * List of files ready to be loaded
  62414. */
  62415. static readonly FilesToLoad: {
  62416. [key: string]: File;
  62417. };
  62418. /**
  62419. * Callback called when a file is processed
  62420. */
  62421. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62422. private _engine;
  62423. private _currentScene;
  62424. private _sceneLoadedCallback;
  62425. private _progressCallback;
  62426. private _additionalRenderLoopLogicCallback;
  62427. private _textureLoadingCallback;
  62428. private _startingProcessingFilesCallback;
  62429. private _onReloadCallback;
  62430. private _errorCallback;
  62431. private _elementToMonitor;
  62432. private _sceneFileToLoad;
  62433. private _filesToLoad;
  62434. /**
  62435. * Creates a new FilesInput
  62436. * @param engine defines the rendering engine
  62437. * @param scene defines the hosting scene
  62438. * @param sceneLoadedCallback callback called when scene is loaded
  62439. * @param progressCallback callback called to track progress
  62440. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62441. * @param textureLoadingCallback callback called when a texture is loading
  62442. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62443. * @param onReloadCallback callback called when a reload is requested
  62444. * @param errorCallback callback call if an error occurs
  62445. */
  62446. 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);
  62447. private _dragEnterHandler;
  62448. private _dragOverHandler;
  62449. private _dropHandler;
  62450. /**
  62451. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62452. * @param elementToMonitor defines the DOM element to track
  62453. */
  62454. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62455. /**
  62456. * Release all associated resources
  62457. */
  62458. dispose(): void;
  62459. private renderFunction;
  62460. private drag;
  62461. private drop;
  62462. private _traverseFolder;
  62463. private _processFiles;
  62464. /**
  62465. * Load files from a drop event
  62466. * @param event defines the drop event to use as source
  62467. */
  62468. loadFiles(event: any): void;
  62469. private _processReload;
  62470. /**
  62471. * Reload the current scene from the loaded files
  62472. */
  62473. reload(): void;
  62474. }
  62475. }
  62476. declare module BABYLON {
  62477. /**
  62478. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62479. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62480. */
  62481. export class SceneOptimization {
  62482. /**
  62483. * Defines the priority of this optimization (0 by default which means first in the list)
  62484. */
  62485. priority: number;
  62486. /**
  62487. * Gets a string describing the action executed by the current optimization
  62488. * @returns description string
  62489. */
  62490. getDescription(): string;
  62491. /**
  62492. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62493. * @param scene defines the current scene where to apply this optimization
  62494. * @param optimizer defines the current optimizer
  62495. * @returns true if everything that can be done was applied
  62496. */
  62497. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62498. /**
  62499. * Creates the SceneOptimization object
  62500. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62501. * @param desc defines the description associated with the optimization
  62502. */
  62503. constructor(
  62504. /**
  62505. * Defines the priority of this optimization (0 by default which means first in the list)
  62506. */
  62507. priority?: number);
  62508. }
  62509. /**
  62510. * Defines an optimization used to reduce the size of render target textures
  62511. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62512. */
  62513. export class TextureOptimization extends SceneOptimization {
  62514. /**
  62515. * Defines the priority of this optimization (0 by default which means first in the list)
  62516. */
  62517. priority: number;
  62518. /**
  62519. * 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
  62520. */
  62521. maximumSize: number;
  62522. /**
  62523. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62524. */
  62525. step: number;
  62526. /**
  62527. * Gets a string describing the action executed by the current optimization
  62528. * @returns description string
  62529. */
  62530. getDescription(): string;
  62531. /**
  62532. * Creates the TextureOptimization object
  62533. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62534. * @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
  62535. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62536. */
  62537. constructor(
  62538. /**
  62539. * Defines the priority of this optimization (0 by default which means first in the list)
  62540. */
  62541. priority?: number,
  62542. /**
  62543. * 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
  62544. */
  62545. maximumSize?: number,
  62546. /**
  62547. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62548. */
  62549. step?: number);
  62550. /**
  62551. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62552. * @param scene defines the current scene where to apply this optimization
  62553. * @param optimizer defines the current optimizer
  62554. * @returns true if everything that can be done was applied
  62555. */
  62556. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62557. }
  62558. /**
  62559. * Defines an optimization used to increase or decrease the rendering resolution
  62560. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62561. */
  62562. export class HardwareScalingOptimization extends SceneOptimization {
  62563. /**
  62564. * Defines the priority of this optimization (0 by default which means first in the list)
  62565. */
  62566. priority: number;
  62567. /**
  62568. * Defines the maximum scale to use (2 by default)
  62569. */
  62570. maximumScale: number;
  62571. /**
  62572. * Defines the step to use between two passes (0.5 by default)
  62573. */
  62574. step: number;
  62575. private _currentScale;
  62576. private _directionOffset;
  62577. /**
  62578. * Gets a string describing the action executed by the current optimization
  62579. * @return description string
  62580. */
  62581. getDescription(): string;
  62582. /**
  62583. * Creates the HardwareScalingOptimization object
  62584. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62585. * @param maximumScale defines the maximum scale to use (2 by default)
  62586. * @param step defines the step to use between two passes (0.5 by default)
  62587. */
  62588. constructor(
  62589. /**
  62590. * Defines the priority of this optimization (0 by default which means first in the list)
  62591. */
  62592. priority?: number,
  62593. /**
  62594. * Defines the maximum scale to use (2 by default)
  62595. */
  62596. maximumScale?: number,
  62597. /**
  62598. * Defines the step to use between two passes (0.5 by default)
  62599. */
  62600. step?: number);
  62601. /**
  62602. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62603. * @param scene defines the current scene where to apply this optimization
  62604. * @param optimizer defines the current optimizer
  62605. * @returns true if everything that can be done was applied
  62606. */
  62607. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62608. }
  62609. /**
  62610. * Defines an optimization used to remove shadows
  62611. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62612. */
  62613. export class ShadowsOptimization extends SceneOptimization {
  62614. /**
  62615. * Gets a string describing the action executed by the current optimization
  62616. * @return description string
  62617. */
  62618. getDescription(): string;
  62619. /**
  62620. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62621. * @param scene defines the current scene where to apply this optimization
  62622. * @param optimizer defines the current optimizer
  62623. * @returns true if everything that can be done was applied
  62624. */
  62625. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62626. }
  62627. /**
  62628. * Defines an optimization used to turn post-processes off
  62629. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62630. */
  62631. export class PostProcessesOptimization extends SceneOptimization {
  62632. /**
  62633. * Gets a string describing the action executed by the current optimization
  62634. * @return description string
  62635. */
  62636. getDescription(): string;
  62637. /**
  62638. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62639. * @param scene defines the current scene where to apply this optimization
  62640. * @param optimizer defines the current optimizer
  62641. * @returns true if everything that can be done was applied
  62642. */
  62643. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62644. }
  62645. /**
  62646. * Defines an optimization used to turn lens flares off
  62647. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62648. */
  62649. export class LensFlaresOptimization extends SceneOptimization {
  62650. /**
  62651. * Gets a string describing the action executed by the current optimization
  62652. * @return description string
  62653. */
  62654. getDescription(): string;
  62655. /**
  62656. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62657. * @param scene defines the current scene where to apply this optimization
  62658. * @param optimizer defines the current optimizer
  62659. * @returns true if everything that can be done was applied
  62660. */
  62661. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62662. }
  62663. /**
  62664. * Defines an optimization based on user defined callback.
  62665. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62666. */
  62667. export class CustomOptimization extends SceneOptimization {
  62668. /**
  62669. * Callback called to apply the custom optimization.
  62670. */
  62671. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62672. /**
  62673. * Callback called to get custom description
  62674. */
  62675. onGetDescription: () => string;
  62676. /**
  62677. * Gets a string describing the action executed by the current optimization
  62678. * @returns description string
  62679. */
  62680. getDescription(): string;
  62681. /**
  62682. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62683. * @param scene defines the current scene where to apply this optimization
  62684. * @param optimizer defines the current optimizer
  62685. * @returns true if everything that can be done was applied
  62686. */
  62687. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62688. }
  62689. /**
  62690. * Defines an optimization used to turn particles off
  62691. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62692. */
  62693. export class ParticlesOptimization extends SceneOptimization {
  62694. /**
  62695. * Gets a string describing the action executed by the current optimization
  62696. * @return description string
  62697. */
  62698. getDescription(): string;
  62699. /**
  62700. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62701. * @param scene defines the current scene where to apply this optimization
  62702. * @param optimizer defines the current optimizer
  62703. * @returns true if everything that can be done was applied
  62704. */
  62705. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62706. }
  62707. /**
  62708. * Defines an optimization used to turn render targets off
  62709. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62710. */
  62711. export class RenderTargetsOptimization extends SceneOptimization {
  62712. /**
  62713. * Gets a string describing the action executed by the current optimization
  62714. * @return description string
  62715. */
  62716. getDescription(): string;
  62717. /**
  62718. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62719. * @param scene defines the current scene where to apply this optimization
  62720. * @param optimizer defines the current optimizer
  62721. * @returns true if everything that can be done was applied
  62722. */
  62723. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62724. }
  62725. /**
  62726. * Defines an optimization used to merge meshes with compatible materials
  62727. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62728. */
  62729. export class MergeMeshesOptimization extends SceneOptimization {
  62730. private static _UpdateSelectionTree;
  62731. /**
  62732. * Gets or sets a boolean which defines if optimization octree has to be updated
  62733. */
  62734. /**
  62735. * Gets or sets a boolean which defines if optimization octree has to be updated
  62736. */
  62737. static UpdateSelectionTree: boolean;
  62738. /**
  62739. * Gets a string describing the action executed by the current optimization
  62740. * @return description string
  62741. */
  62742. getDescription(): string;
  62743. private _canBeMerged;
  62744. /**
  62745. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62746. * @param scene defines the current scene where to apply this optimization
  62747. * @param optimizer defines the current optimizer
  62748. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62749. * @returns true if everything that can be done was applied
  62750. */
  62751. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62752. }
  62753. /**
  62754. * Defines a list of options used by SceneOptimizer
  62755. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62756. */
  62757. export class SceneOptimizerOptions {
  62758. /**
  62759. * Defines the target frame rate to reach (60 by default)
  62760. */
  62761. targetFrameRate: number;
  62762. /**
  62763. * Defines the interval between two checkes (2000ms by default)
  62764. */
  62765. trackerDuration: number;
  62766. /**
  62767. * Gets the list of optimizations to apply
  62768. */
  62769. optimizations: SceneOptimization[];
  62770. /**
  62771. * Creates a new list of options used by SceneOptimizer
  62772. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62773. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62774. */
  62775. constructor(
  62776. /**
  62777. * Defines the target frame rate to reach (60 by default)
  62778. */
  62779. targetFrameRate?: number,
  62780. /**
  62781. * Defines the interval between two checkes (2000ms by default)
  62782. */
  62783. trackerDuration?: number);
  62784. /**
  62785. * Add a new optimization
  62786. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62787. * @returns the current SceneOptimizerOptions
  62788. */
  62789. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62790. /**
  62791. * Add a new custom optimization
  62792. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62793. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62794. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62795. * @returns the current SceneOptimizerOptions
  62796. */
  62797. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62798. /**
  62799. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62800. * @param targetFrameRate defines the target frame rate (60 by default)
  62801. * @returns a SceneOptimizerOptions object
  62802. */
  62803. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62804. /**
  62805. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62806. * @param targetFrameRate defines the target frame rate (60 by default)
  62807. * @returns a SceneOptimizerOptions object
  62808. */
  62809. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62810. /**
  62811. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62812. * @param targetFrameRate defines the target frame rate (60 by default)
  62813. * @returns a SceneOptimizerOptions object
  62814. */
  62815. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62816. }
  62817. /**
  62818. * Class used to run optimizations in order to reach a target frame rate
  62819. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62820. */
  62821. export class SceneOptimizer implements IDisposable {
  62822. private _isRunning;
  62823. private _options;
  62824. private _scene;
  62825. private _currentPriorityLevel;
  62826. private _targetFrameRate;
  62827. private _trackerDuration;
  62828. private _currentFrameRate;
  62829. private _sceneDisposeObserver;
  62830. private _improvementMode;
  62831. /**
  62832. * Defines an observable called when the optimizer reaches the target frame rate
  62833. */
  62834. onSuccessObservable: Observable<SceneOptimizer>;
  62835. /**
  62836. * Defines an observable called when the optimizer enables an optimization
  62837. */
  62838. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62839. /**
  62840. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62841. */
  62842. onFailureObservable: Observable<SceneOptimizer>;
  62843. /**
  62844. * Gets a boolean indicating if the optimizer is in improvement mode
  62845. */
  62846. readonly isInImprovementMode: boolean;
  62847. /**
  62848. * Gets the current priority level (0 at start)
  62849. */
  62850. readonly currentPriorityLevel: number;
  62851. /**
  62852. * Gets the current frame rate checked by the SceneOptimizer
  62853. */
  62854. readonly currentFrameRate: number;
  62855. /**
  62856. * Gets or sets the current target frame rate (60 by default)
  62857. */
  62858. /**
  62859. * Gets or sets the current target frame rate (60 by default)
  62860. */
  62861. targetFrameRate: number;
  62862. /**
  62863. * Gets or sets the current interval between two checks (every 2000ms by default)
  62864. */
  62865. /**
  62866. * Gets or sets the current interval between two checks (every 2000ms by default)
  62867. */
  62868. trackerDuration: number;
  62869. /**
  62870. * Gets the list of active optimizations
  62871. */
  62872. readonly optimizations: SceneOptimization[];
  62873. /**
  62874. * Creates a new SceneOptimizer
  62875. * @param scene defines the scene to work on
  62876. * @param options defines the options to use with the SceneOptimizer
  62877. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62878. * @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)
  62879. */
  62880. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62881. /**
  62882. * Stops the current optimizer
  62883. */
  62884. stop(): void;
  62885. /**
  62886. * Reset the optimizer to initial step (current priority level = 0)
  62887. */
  62888. reset(): void;
  62889. /**
  62890. * Start the optimizer. By default it will try to reach a specific framerate
  62891. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62892. */
  62893. start(): void;
  62894. private _checkCurrentState;
  62895. /**
  62896. * Release all resources
  62897. */
  62898. dispose(): void;
  62899. /**
  62900. * Helper function to create a SceneOptimizer with one single line of code
  62901. * @param scene defines the scene to work on
  62902. * @param options defines the options to use with the SceneOptimizer
  62903. * @param onSuccess defines a callback to call on success
  62904. * @param onFailure defines a callback to call on failure
  62905. * @returns the new SceneOptimizer object
  62906. */
  62907. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62908. }
  62909. }
  62910. declare module BABYLON {
  62911. /**
  62912. * Class used to serialize a scene into a string
  62913. */
  62914. export class SceneSerializer {
  62915. /**
  62916. * Clear cache used by a previous serialization
  62917. */
  62918. static ClearCache(): void;
  62919. /**
  62920. * Serialize a scene into a JSON compatible object
  62921. * @param scene defines the scene to serialize
  62922. * @returns a JSON compatible object
  62923. */
  62924. static Serialize(scene: Scene): any;
  62925. /**
  62926. * Serialize a mesh into a JSON compatible object
  62927. * @param toSerialize defines the mesh to serialize
  62928. * @param withParents defines if parents must be serialized as well
  62929. * @param withChildren defines if children must be serialized as well
  62930. * @returns a JSON compatible object
  62931. */
  62932. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62933. }
  62934. }
  62935. declare module BABYLON {
  62936. /**
  62937. * Class used to host texture specific utilities
  62938. */
  62939. export class TextureTools {
  62940. /**
  62941. * Uses the GPU to create a copy texture rescaled at a given size
  62942. * @param texture Texture to copy from
  62943. * @param width defines the desired width
  62944. * @param height defines the desired height
  62945. * @param useBilinearMode defines if bilinear mode has to be used
  62946. * @return the generated texture
  62947. */
  62948. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62949. }
  62950. }
  62951. declare module BABYLON {
  62952. /**
  62953. * This represents the different options available for the video capture.
  62954. */
  62955. export interface VideoRecorderOptions {
  62956. /** Defines the mime type of the video. */
  62957. mimeType: string;
  62958. /** Defines the FPS the video should be recorded at. */
  62959. fps: number;
  62960. /** Defines the chunk size for the recording data. */
  62961. recordChunckSize: number;
  62962. /** The audio tracks to attach to the recording. */
  62963. audioTracks?: MediaStreamTrack[];
  62964. }
  62965. /**
  62966. * This can help with recording videos from BabylonJS.
  62967. * This is based on the available WebRTC functionalities of the browser.
  62968. *
  62969. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62970. */
  62971. export class VideoRecorder {
  62972. private static readonly _defaultOptions;
  62973. /**
  62974. * Returns whether or not the VideoRecorder is available in your browser.
  62975. * @param engine Defines the Babylon Engine.
  62976. * @returns true if supported otherwise false.
  62977. */
  62978. static IsSupported(engine: Engine): boolean;
  62979. private readonly _options;
  62980. private _canvas;
  62981. private _mediaRecorder;
  62982. private _recordedChunks;
  62983. private _fileName;
  62984. private _resolve;
  62985. private _reject;
  62986. /**
  62987. * True when a recording is already in progress.
  62988. */
  62989. readonly isRecording: boolean;
  62990. /**
  62991. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62992. * @param engine Defines the BabylonJS Engine you wish to record.
  62993. * @param options Defines options that can be used to customize the capture.
  62994. */
  62995. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62996. /**
  62997. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62998. */
  62999. stopRecording(): void;
  63000. /**
  63001. * Starts recording the canvas for a max duration specified in parameters.
  63002. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63003. * If null no automatic download will start and you can rely on the promise to get the data back.
  63004. * @param maxDuration Defines the maximum recording time in seconds.
  63005. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63006. * @return A promise callback at the end of the recording with the video data in Blob.
  63007. */
  63008. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63009. /**
  63010. * Releases internal resources used during the recording.
  63011. */
  63012. dispose(): void;
  63013. private _handleDataAvailable;
  63014. private _handleError;
  63015. private _handleStop;
  63016. }
  63017. }
  63018. declare module BABYLON {
  63019. /**
  63020. * Class containing a set of static utilities functions for screenshots
  63021. */
  63022. export class ScreenshotTools {
  63023. /**
  63024. * Captures a screenshot of the current rendering
  63025. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63026. * @param engine defines the rendering engine
  63027. * @param camera defines the source camera
  63028. * @param size This parameter can be set to a single number or to an object with the
  63029. * following (optional) properties: precision, width, height. If a single number is passed,
  63030. * it will be used for both width and height. If an object is passed, the screenshot size
  63031. * will be derived from the parameters. The precision property is a multiplier allowing
  63032. * rendering at a higher or lower resolution
  63033. * @param successCallback defines the callback receives a single parameter which contains the
  63034. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63035. * src parameter of an <img> to display it
  63036. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63037. * Check your browser for supported MIME types
  63038. */
  63039. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63040. /**
  63041. * Captures a screenshot of the current rendering
  63042. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63043. * @param engine defines the rendering engine
  63044. * @param camera defines the source camera
  63045. * @param size This parameter can be set to a single number or to an object with the
  63046. * following (optional) properties: precision, width, height. If a single number is passed,
  63047. * it will be used for both width and height. If an object is passed, the screenshot size
  63048. * will be derived from the parameters. The precision property is a multiplier allowing
  63049. * rendering at a higher or lower resolution
  63050. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63051. * Check your browser for supported MIME types
  63052. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63053. * to the src parameter of an <img> to display it
  63054. */
  63055. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63056. /**
  63057. * Generates an image screenshot from the specified camera.
  63058. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63059. * @param engine The engine to use for rendering
  63060. * @param camera The camera to use for rendering
  63061. * @param size This parameter can be set to a single number or to an object with the
  63062. * following (optional) properties: precision, width, height. If a single number is passed,
  63063. * it will be used for both width and height. If an object is passed, the screenshot size
  63064. * will be derived from the parameters. The precision property is a multiplier allowing
  63065. * rendering at a higher or lower resolution
  63066. * @param successCallback The callback receives a single parameter which contains the
  63067. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63068. * src parameter of an <img> to display it
  63069. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63070. * Check your browser for supported MIME types
  63071. * @param samples Texture samples (default: 1)
  63072. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63073. * @param fileName A name for for the downloaded file.
  63074. */
  63075. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63076. /**
  63077. * Generates an image screenshot from the specified camera.
  63078. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63079. * @param engine The engine to use for rendering
  63080. * @param camera The camera to use for rendering
  63081. * @param size This parameter can be set to a single number or to an object with the
  63082. * following (optional) properties: precision, width, height. If a single number is passed,
  63083. * it will be used for both width and height. If an object is passed, the screenshot size
  63084. * will be derived from the parameters. The precision property is a multiplier allowing
  63085. * rendering at a higher or lower resolution
  63086. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63087. * Check your browser for supported MIME types
  63088. * @param samples Texture samples (default: 1)
  63089. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63090. * @param fileName A name for for the downloaded file.
  63091. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63092. * to the src parameter of an <img> to display it
  63093. */
  63094. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63095. /**
  63096. * Gets height and width for screenshot size
  63097. * @private
  63098. */
  63099. private static _getScreenshotSize;
  63100. }
  63101. }
  63102. declare module BABYLON {
  63103. /**
  63104. * A cursor which tracks a point on a path
  63105. */
  63106. export class PathCursor {
  63107. private path;
  63108. /**
  63109. * Stores path cursor callbacks for when an onchange event is triggered
  63110. */
  63111. private _onchange;
  63112. /**
  63113. * The value of the path cursor
  63114. */
  63115. value: number;
  63116. /**
  63117. * The animation array of the path cursor
  63118. */
  63119. animations: Animation[];
  63120. /**
  63121. * Initializes the path cursor
  63122. * @param path The path to track
  63123. */
  63124. constructor(path: Path2);
  63125. /**
  63126. * Gets the cursor point on the path
  63127. * @returns A point on the path cursor at the cursor location
  63128. */
  63129. getPoint(): Vector3;
  63130. /**
  63131. * Moves the cursor ahead by the step amount
  63132. * @param step The amount to move the cursor forward
  63133. * @returns This path cursor
  63134. */
  63135. moveAhead(step?: number): PathCursor;
  63136. /**
  63137. * Moves the cursor behind by the step amount
  63138. * @param step The amount to move the cursor back
  63139. * @returns This path cursor
  63140. */
  63141. moveBack(step?: number): PathCursor;
  63142. /**
  63143. * Moves the cursor by the step amount
  63144. * If the step amount is greater than one, an exception is thrown
  63145. * @param step The amount to move the cursor
  63146. * @returns This path cursor
  63147. */
  63148. move(step: number): PathCursor;
  63149. /**
  63150. * Ensures that the value is limited between zero and one
  63151. * @returns This path cursor
  63152. */
  63153. private ensureLimits;
  63154. /**
  63155. * Runs onchange callbacks on change (used by the animation engine)
  63156. * @returns This path cursor
  63157. */
  63158. private raiseOnChange;
  63159. /**
  63160. * Executes a function on change
  63161. * @param f A path cursor onchange callback
  63162. * @returns This path cursor
  63163. */
  63164. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63165. }
  63166. }
  63167. declare module BABYLON {
  63168. /** @hidden */
  63169. export var blurPixelShader: {
  63170. name: string;
  63171. shader: string;
  63172. };
  63173. }
  63174. declare module BABYLON {
  63175. /** @hidden */
  63176. export var pointCloudVertexDeclaration: {
  63177. name: string;
  63178. shader: string;
  63179. };
  63180. }
  63181. // Mixins
  63182. interface Window {
  63183. mozIndexedDB: IDBFactory;
  63184. webkitIndexedDB: IDBFactory;
  63185. msIndexedDB: IDBFactory;
  63186. webkitURL: typeof URL;
  63187. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  63188. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  63189. WebGLRenderingContext: WebGLRenderingContext;
  63190. MSGesture: MSGesture;
  63191. CANNON: any;
  63192. AudioContext: AudioContext;
  63193. webkitAudioContext: AudioContext;
  63194. PointerEvent: any;
  63195. Math: Math;
  63196. Uint8Array: Uint8ArrayConstructor;
  63197. Float32Array: Float32ArrayConstructor;
  63198. mozURL: typeof URL;
  63199. msURL: typeof URL;
  63200. VRFrameData: any; // WebVR, from specs 1.1
  63201. DracoDecoderModule: any;
  63202. setImmediate(handler: (...args: any[]) => void): number;
  63203. }
  63204. interface HTMLCanvasElement {
  63205. requestPointerLock(): void;
  63206. msRequestPointerLock?(): void;
  63207. mozRequestPointerLock?(): void;
  63208. webkitRequestPointerLock?(): void;
  63209. /** Track wether a record is in progress */
  63210. isRecording: boolean;
  63211. /** Capture Stream method defined by some browsers */
  63212. captureStream(fps?: number): MediaStream;
  63213. }
  63214. interface CanvasRenderingContext2D {
  63215. msImageSmoothingEnabled: boolean;
  63216. }
  63217. interface MouseEvent {
  63218. mozMovementX: number;
  63219. mozMovementY: number;
  63220. webkitMovementX: number;
  63221. webkitMovementY: number;
  63222. msMovementX: number;
  63223. msMovementY: number;
  63224. }
  63225. interface Navigator {
  63226. mozGetVRDevices: (any: any) => any;
  63227. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63228. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63229. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63230. webkitGetGamepads(): Gamepad[];
  63231. msGetGamepads(): Gamepad[];
  63232. webkitGamepads(): Gamepad[];
  63233. }
  63234. interface HTMLVideoElement {
  63235. mozSrcObject: any;
  63236. }
  63237. interface Math {
  63238. fround(x: number): number;
  63239. imul(a: number, b: number): number;
  63240. }
  63241. interface WebGLRenderingContext {
  63242. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  63243. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  63244. vertexAttribDivisor(index: number, divisor: number): void;
  63245. createVertexArray(): any;
  63246. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  63247. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  63248. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  63249. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  63250. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  63251. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  63252. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  63253. // Queries
  63254. createQuery(): WebGLQuery;
  63255. deleteQuery(query: WebGLQuery): void;
  63256. beginQuery(target: number, query: WebGLQuery): void;
  63257. endQuery(target: number): void;
  63258. getQueryParameter(query: WebGLQuery, pname: number): any;
  63259. getQuery(target: number, pname: number): any;
  63260. MAX_SAMPLES: number;
  63261. RGBA8: number;
  63262. READ_FRAMEBUFFER: number;
  63263. DRAW_FRAMEBUFFER: number;
  63264. UNIFORM_BUFFER: number;
  63265. HALF_FLOAT_OES: number;
  63266. RGBA16F: number;
  63267. RGBA32F: number;
  63268. R32F: number;
  63269. RG32F: number;
  63270. RGB32F: number;
  63271. R16F: number;
  63272. RG16F: number;
  63273. RGB16F: number;
  63274. RED: number;
  63275. RG: number;
  63276. R8: number;
  63277. RG8: number;
  63278. UNSIGNED_INT_24_8: number;
  63279. DEPTH24_STENCIL8: number;
  63280. MIN: number;
  63281. MAX: number;
  63282. /* Multiple Render Targets */
  63283. drawBuffers(buffers: number[]): void;
  63284. readBuffer(src: number): void;
  63285. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  63286. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  63287. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  63288. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  63289. // Occlusion Query
  63290. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  63291. ANY_SAMPLES_PASSED: number;
  63292. QUERY_RESULT_AVAILABLE: number;
  63293. QUERY_RESULT: number;
  63294. }
  63295. interface WebGLProgram {
  63296. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  63297. }
  63298. interface EXT_disjoint_timer_query {
  63299. QUERY_COUNTER_BITS_EXT: number;
  63300. TIME_ELAPSED_EXT: number;
  63301. TIMESTAMP_EXT: number;
  63302. GPU_DISJOINT_EXT: number;
  63303. QUERY_RESULT_EXT: number;
  63304. QUERY_RESULT_AVAILABLE_EXT: number;
  63305. queryCounterEXT(query: WebGLQuery, target: number): void;
  63306. createQueryEXT(): WebGLQuery;
  63307. beginQueryEXT(target: number, query: WebGLQuery): void;
  63308. endQueryEXT(target: number): void;
  63309. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  63310. deleteQueryEXT(query: WebGLQuery): void;
  63311. }
  63312. interface WebGLUniformLocation {
  63313. _currentState: any;
  63314. }
  63315. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  63316. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  63317. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  63318. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63319. interface WebGLRenderingContext {
  63320. readonly RASTERIZER_DISCARD: number;
  63321. readonly DEPTH_COMPONENT24: number;
  63322. readonly TEXTURE_3D: number;
  63323. readonly TEXTURE_2D_ARRAY: number;
  63324. readonly TEXTURE_COMPARE_FUNC: number;
  63325. readonly TEXTURE_COMPARE_MODE: number;
  63326. readonly COMPARE_REF_TO_TEXTURE: number;
  63327. readonly TEXTURE_WRAP_R: number;
  63328. readonly HALF_FLOAT: number;
  63329. readonly RGB8: number;
  63330. readonly RED_INTEGER: number;
  63331. readonly RG_INTEGER: number;
  63332. readonly RGB_INTEGER: number;
  63333. readonly RGBA_INTEGER: number;
  63334. readonly R8_SNORM: number;
  63335. readonly RG8_SNORM: number;
  63336. readonly RGB8_SNORM: number;
  63337. readonly RGBA8_SNORM: number;
  63338. readonly R8I: number;
  63339. readonly RG8I: number;
  63340. readonly RGB8I: number;
  63341. readonly RGBA8I: number;
  63342. readonly R8UI: number;
  63343. readonly RG8UI: number;
  63344. readonly RGB8UI: number;
  63345. readonly RGBA8UI: number;
  63346. readonly R16I: number;
  63347. readonly RG16I: number;
  63348. readonly RGB16I: number;
  63349. readonly RGBA16I: number;
  63350. readonly R16UI: number;
  63351. readonly RG16UI: number;
  63352. readonly RGB16UI: number;
  63353. readonly RGBA16UI: number;
  63354. readonly R32I: number;
  63355. readonly RG32I: number;
  63356. readonly RGB32I: number;
  63357. readonly RGBA32I: number;
  63358. readonly R32UI: number;
  63359. readonly RG32UI: number;
  63360. readonly RGB32UI: number;
  63361. readonly RGBA32UI: number;
  63362. readonly RGB10_A2UI: number;
  63363. readonly R11F_G11F_B10F: number;
  63364. readonly RGB9_E5: number;
  63365. readonly RGB10_A2: number;
  63366. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  63367. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  63368. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  63369. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63370. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  63371. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  63372. 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;
  63373. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  63374. readonly TRANSFORM_FEEDBACK: number;
  63375. readonly INTERLEAVED_ATTRIBS: number;
  63376. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  63377. createTransformFeedback(): WebGLTransformFeedback;
  63378. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  63379. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  63380. beginTransformFeedback(primitiveMode: number): void;
  63381. endTransformFeedback(): void;
  63382. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  63383. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63384. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63385. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63386. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  63387. }
  63388. interface ImageBitmap {
  63389. readonly width: number;
  63390. readonly height: number;
  63391. close(): void;
  63392. }
  63393. interface WebGLQuery extends WebGLObject {
  63394. }
  63395. declare var WebGLQuery: {
  63396. prototype: WebGLQuery;
  63397. new(): WebGLQuery;
  63398. };
  63399. interface WebGLSampler extends WebGLObject {
  63400. }
  63401. declare var WebGLSampler: {
  63402. prototype: WebGLSampler;
  63403. new(): WebGLSampler;
  63404. };
  63405. interface WebGLSync extends WebGLObject {
  63406. }
  63407. declare var WebGLSync: {
  63408. prototype: WebGLSync;
  63409. new(): WebGLSync;
  63410. };
  63411. interface WebGLTransformFeedback extends WebGLObject {
  63412. }
  63413. declare var WebGLTransformFeedback: {
  63414. prototype: WebGLTransformFeedback;
  63415. new(): WebGLTransformFeedback;
  63416. };
  63417. interface WebGLVertexArrayObject extends WebGLObject {
  63418. }
  63419. declare var WebGLVertexArrayObject: {
  63420. prototype: WebGLVertexArrayObject;
  63421. new(): WebGLVertexArrayObject;
  63422. };
  63423. // Type definitions for WebVR API
  63424. // Project: https://w3c.github.io/webvr/
  63425. // Definitions by: six a <https://github.com/lostfictions>
  63426. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63427. interface VRDisplay extends EventTarget {
  63428. /**
  63429. * Dictionary of capabilities describing the VRDisplay.
  63430. */
  63431. readonly capabilities: VRDisplayCapabilities;
  63432. /**
  63433. * z-depth defining the far plane of the eye view frustum
  63434. * enables mapping of values in the render target depth
  63435. * attachment to scene coordinates. Initially set to 10000.0.
  63436. */
  63437. depthFar: number;
  63438. /**
  63439. * z-depth defining the near plane of the eye view frustum
  63440. * enables mapping of values in the render target depth
  63441. * attachment to scene coordinates. Initially set to 0.01.
  63442. */
  63443. depthNear: number;
  63444. /**
  63445. * An identifier for this distinct VRDisplay. Used as an
  63446. * association point in the Gamepad API.
  63447. */
  63448. readonly displayId: number;
  63449. /**
  63450. * A display name, a user-readable name identifying it.
  63451. */
  63452. readonly displayName: string;
  63453. readonly isConnected: boolean;
  63454. readonly isPresenting: boolean;
  63455. /**
  63456. * If this VRDisplay supports room-scale experiences, the optional
  63457. * stage attribute contains details on the room-scale parameters.
  63458. */
  63459. readonly stageParameters: VRStageParameters | null;
  63460. /**
  63461. * Passing the value returned by `requestAnimationFrame` to
  63462. * `cancelAnimationFrame` will unregister the callback.
  63463. * @param handle Define the hanle of the request to cancel
  63464. */
  63465. cancelAnimationFrame(handle: number): void;
  63466. /**
  63467. * Stops presenting to the VRDisplay.
  63468. * @returns a promise to know when it stopped
  63469. */
  63470. exitPresent(): Promise<void>;
  63471. /**
  63472. * Return the current VREyeParameters for the given eye.
  63473. * @param whichEye Define the eye we want the parameter for
  63474. * @returns the eye parameters
  63475. */
  63476. getEyeParameters(whichEye: string): VREyeParameters;
  63477. /**
  63478. * Populates the passed VRFrameData with the information required to render
  63479. * the current frame.
  63480. * @param frameData Define the data structure to populate
  63481. * @returns true if ok otherwise false
  63482. */
  63483. getFrameData(frameData: VRFrameData): boolean;
  63484. /**
  63485. * Get the layers currently being presented.
  63486. * @returns the list of VR layers
  63487. */
  63488. getLayers(): VRLayer[];
  63489. /**
  63490. * Return a VRPose containing the future predicted pose of the VRDisplay
  63491. * when the current frame will be presented. The value returned will not
  63492. * change until JavaScript has returned control to the browser.
  63493. *
  63494. * The VRPose will contain the position, orientation, velocity,
  63495. * and acceleration of each of these properties.
  63496. * @returns the pose object
  63497. */
  63498. getPose(): VRPose;
  63499. /**
  63500. * Return the current instantaneous pose of the VRDisplay, with no
  63501. * prediction applied.
  63502. * @returns the current instantaneous pose
  63503. */
  63504. getImmediatePose(): VRPose;
  63505. /**
  63506. * The callback passed to `requestAnimationFrame` will be called
  63507. * any time a new frame should be rendered. When the VRDisplay is
  63508. * presenting the callback will be called at the native refresh
  63509. * rate of the HMD. When not presenting this function acts
  63510. * identically to how window.requestAnimationFrame acts. Content should
  63511. * make no assumptions of frame rate or vsync behavior as the HMD runs
  63512. * asynchronously from other displays and at differing refresh rates.
  63513. * @param callback Define the eaction to run next frame
  63514. * @returns the request handle it
  63515. */
  63516. requestAnimationFrame(callback: FrameRequestCallback): number;
  63517. /**
  63518. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  63519. * Repeat calls while already presenting will update the VRLayers being displayed.
  63520. * @param layers Define the list of layer to present
  63521. * @returns a promise to know when the request has been fulfilled
  63522. */
  63523. requestPresent(layers: VRLayer[]): Promise<void>;
  63524. /**
  63525. * Reset the pose for this display, treating its current position and
  63526. * orientation as the "origin/zero" values. VRPose.position,
  63527. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  63528. * updated when calling resetPose(). This should be called in only
  63529. * sitting-space experiences.
  63530. */
  63531. resetPose(): void;
  63532. /**
  63533. * The VRLayer provided to the VRDisplay will be captured and presented
  63534. * in the HMD. Calling this function has the same effect on the source
  63535. * canvas as any other operation that uses its source image, and canvases
  63536. * created without preserveDrawingBuffer set to true will be cleared.
  63537. * @param pose Define the pose to submit
  63538. */
  63539. submitFrame(pose?: VRPose): void;
  63540. }
  63541. declare var VRDisplay: {
  63542. prototype: VRDisplay;
  63543. new(): VRDisplay;
  63544. };
  63545. interface VRLayer {
  63546. leftBounds?: number[] | Float32Array | null;
  63547. rightBounds?: number[] | Float32Array | null;
  63548. source?: HTMLCanvasElement | null;
  63549. }
  63550. interface VRDisplayCapabilities {
  63551. readonly canPresent: boolean;
  63552. readonly hasExternalDisplay: boolean;
  63553. readonly hasOrientation: boolean;
  63554. readonly hasPosition: boolean;
  63555. readonly maxLayers: number;
  63556. }
  63557. interface VREyeParameters {
  63558. /** @deprecated */
  63559. readonly fieldOfView: VRFieldOfView;
  63560. readonly offset: Float32Array;
  63561. readonly renderHeight: number;
  63562. readonly renderWidth: number;
  63563. }
  63564. interface VRFieldOfView {
  63565. readonly downDegrees: number;
  63566. readonly leftDegrees: number;
  63567. readonly rightDegrees: number;
  63568. readonly upDegrees: number;
  63569. }
  63570. interface VRFrameData {
  63571. readonly leftProjectionMatrix: Float32Array;
  63572. readonly leftViewMatrix: Float32Array;
  63573. readonly pose: VRPose;
  63574. readonly rightProjectionMatrix: Float32Array;
  63575. readonly rightViewMatrix: Float32Array;
  63576. readonly timestamp: number;
  63577. }
  63578. interface VRPose {
  63579. readonly angularAcceleration: Float32Array | null;
  63580. readonly angularVelocity: Float32Array | null;
  63581. readonly linearAcceleration: Float32Array | null;
  63582. readonly linearVelocity: Float32Array | null;
  63583. readonly orientation: Float32Array | null;
  63584. readonly position: Float32Array | null;
  63585. readonly timestamp: number;
  63586. }
  63587. interface VRStageParameters {
  63588. sittingToStandingTransform?: Float32Array;
  63589. sizeX?: number;
  63590. sizeY?: number;
  63591. }
  63592. interface Navigator {
  63593. getVRDisplays(): Promise<VRDisplay[]>;
  63594. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  63595. }
  63596. interface Window {
  63597. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  63598. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  63599. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  63600. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63601. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63602. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  63603. }
  63604. interface Gamepad {
  63605. readonly displayId: number;
  63606. }
  63607. type XRSessionMode =
  63608. | "inline"
  63609. | "immersive-vr"
  63610. | "immersive-ar";
  63611. type XRReferenceSpaceType =
  63612. | "viewer"
  63613. | "local"
  63614. | "local-floor"
  63615. | "bounded-floor"
  63616. | "unbounded";
  63617. type XREnvironmentBlendMode =
  63618. | "opaque"
  63619. | "additive"
  63620. | "alpha-blend";
  63621. type XRVisibilityState =
  63622. | "visible"
  63623. | "visible-blurred"
  63624. | "hidden";
  63625. type XRHandedness =
  63626. | "none"
  63627. | "left"
  63628. | "right";
  63629. type XRTargetRayMode =
  63630. | "gaze"
  63631. | "tracked-pointer"
  63632. | "screen";
  63633. type XREye =
  63634. | "none"
  63635. | "left"
  63636. | "right";
  63637. interface XRSpace extends EventTarget {
  63638. }
  63639. interface XRRenderState {
  63640. depthNear?: number;
  63641. depthFar?: number;
  63642. inlineVerticalFieldOfView?: number;
  63643. baseLayer?: XRWebGLLayer;
  63644. }
  63645. interface XRInputSource {
  63646. handedness: XRHandedness;
  63647. targetRayMode: XRTargetRayMode;
  63648. targetRaySpace: XRSpace;
  63649. gripSpace: XRSpace | undefined;
  63650. gamepad: Gamepad | undefined;
  63651. profiles: Array<string>;
  63652. }
  63653. interface XRSession {
  63654. addEventListener: Function;
  63655. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  63656. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  63657. requestAnimationFrame: Function;
  63658. end(): Promise<void>;
  63659. renderState: XRRenderState;
  63660. inputSources: Array<XRInputSource>;
  63661. }
  63662. interface XRReferenceSpace extends XRSpace {
  63663. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  63664. onreset: any;
  63665. }
  63666. interface XRFrame {
  63667. session: XRSession;
  63668. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  63669. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  63670. }
  63671. interface XRViewerPose extends XRPose {
  63672. views: Array<XRView>;
  63673. }
  63674. interface XRPose {
  63675. transform: XRRigidTransform;
  63676. emulatedPosition: boolean;
  63677. }
  63678. declare var XRWebGLLayer: {
  63679. prototype: XRWebGLLayer;
  63680. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  63681. };
  63682. interface XRWebGLLayer {
  63683. framebuffer: WebGLFramebuffer;
  63684. framebufferWidth: number;
  63685. framebufferHeight: number;
  63686. getViewport: Function;
  63687. }
  63688. interface XRRigidTransform {
  63689. position: DOMPointReadOnly;
  63690. orientation: DOMPointReadOnly;
  63691. matrix: Float32Array;
  63692. inverse: XRRigidTransform;
  63693. }
  63694. interface XRView {
  63695. eye: XREye;
  63696. projectionMatrix: Float32Array;
  63697. transform: XRRigidTransform;
  63698. }
  63699. interface XRInputSourceChangeEvent {
  63700. session: XRSession;
  63701. removed: Array<XRInputSource>;
  63702. added: Array<XRInputSource>;
  63703. }
  63704. /**
  63705. * @ignore
  63706. */
  63707. declare module BABYLON.GLTF2.Exporter {
  63708. }
  63709. /**
  63710. * @ignore
  63711. */
  63712. declare module BABYLON.GLTF1 {
  63713. }
  63714. declare module BABYLON.GUI {
  63715. /**
  63716. * Class used to specific a value and its associated unit
  63717. */
  63718. export class ValueAndUnit {
  63719. /** defines the unit to store */
  63720. unit: number;
  63721. /** defines a boolean indicating if the value can be negative */
  63722. negativeValueAllowed: boolean;
  63723. private _value;
  63724. private _originalUnit;
  63725. /**
  63726. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  63727. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63728. */
  63729. ignoreAdaptiveScaling: boolean;
  63730. /**
  63731. * Creates a new ValueAndUnit
  63732. * @param value defines the value to store
  63733. * @param unit defines the unit to store
  63734. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  63735. */
  63736. constructor(value: number,
  63737. /** defines the unit to store */
  63738. unit?: number,
  63739. /** defines a boolean indicating if the value can be negative */
  63740. negativeValueAllowed?: boolean);
  63741. /** Gets a boolean indicating if the value is a percentage */
  63742. readonly isPercentage: boolean;
  63743. /** Gets a boolean indicating if the value is store as pixel */
  63744. readonly isPixel: boolean;
  63745. /** Gets direct internal value */
  63746. readonly internalValue: number;
  63747. /**
  63748. * Gets value as pixel
  63749. * @param host defines the root host
  63750. * @param refValue defines the reference value for percentages
  63751. * @returns the value as pixel
  63752. */
  63753. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  63754. /**
  63755. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  63756. * @param value defines the value to store
  63757. * @param unit defines the unit to store
  63758. * @returns the current ValueAndUnit
  63759. */
  63760. updateInPlace(value: number, unit?: number): ValueAndUnit;
  63761. /**
  63762. * Gets the value accordingly to its unit
  63763. * @param host defines the root host
  63764. * @returns the value
  63765. */
  63766. getValue(host: AdvancedDynamicTexture): number;
  63767. /**
  63768. * Gets a string representation of the value
  63769. * @param host defines the root host
  63770. * @param decimals defines an optional number of decimals to display
  63771. * @returns a string
  63772. */
  63773. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  63774. /**
  63775. * Store a value parsed from a string
  63776. * @param source defines the source string
  63777. * @returns true if the value was successfully parsed
  63778. */
  63779. fromString(source: string | number): boolean;
  63780. private static _Regex;
  63781. private static _UNITMODE_PERCENTAGE;
  63782. private static _UNITMODE_PIXEL;
  63783. /** UNITMODE_PERCENTAGE */
  63784. static readonly UNITMODE_PERCENTAGE: number;
  63785. /** UNITMODE_PIXEL */
  63786. static readonly UNITMODE_PIXEL: number;
  63787. }
  63788. }
  63789. declare module BABYLON.GUI {
  63790. /**
  63791. * Define a style used by control to automatically setup properties based on a template.
  63792. * Only support font related properties so far
  63793. */
  63794. export class Style implements BABYLON.IDisposable {
  63795. private _fontFamily;
  63796. private _fontStyle;
  63797. private _fontWeight;
  63798. /** @hidden */
  63799. _host: AdvancedDynamicTexture;
  63800. /** @hidden */
  63801. _fontSize: ValueAndUnit;
  63802. /**
  63803. * BABYLON.Observable raised when the style values are changed
  63804. */
  63805. onChangedObservable: BABYLON.Observable<Style>;
  63806. /**
  63807. * Creates a new style object
  63808. * @param host defines the AdvancedDynamicTexture which hosts this style
  63809. */
  63810. constructor(host: AdvancedDynamicTexture);
  63811. /**
  63812. * Gets or sets the font size
  63813. */
  63814. fontSize: string | number;
  63815. /**
  63816. * Gets or sets the font family
  63817. */
  63818. fontFamily: string;
  63819. /**
  63820. * Gets or sets the font style
  63821. */
  63822. fontStyle: string;
  63823. /** Gets or sets font weight */
  63824. fontWeight: string;
  63825. /** Dispose all associated resources */
  63826. dispose(): void;
  63827. }
  63828. }
  63829. declare module BABYLON.GUI {
  63830. /**
  63831. * Class used to transport BABYLON.Vector2 information for pointer events
  63832. */
  63833. export class Vector2WithInfo extends BABYLON.Vector2 {
  63834. /** defines the current mouse button index */
  63835. buttonIndex: number;
  63836. /**
  63837. * Creates a new Vector2WithInfo
  63838. * @param source defines the vector2 data to transport
  63839. * @param buttonIndex defines the current mouse button index
  63840. */
  63841. constructor(source: BABYLON.Vector2,
  63842. /** defines the current mouse button index */
  63843. buttonIndex?: number);
  63844. }
  63845. /** Class used to provide 2D matrix features */
  63846. export class Matrix2D {
  63847. /** Gets the internal array of 6 floats used to store matrix data */
  63848. m: Float32Array;
  63849. /**
  63850. * Creates a new matrix
  63851. * @param m00 defines value for (0, 0)
  63852. * @param m01 defines value for (0, 1)
  63853. * @param m10 defines value for (1, 0)
  63854. * @param m11 defines value for (1, 1)
  63855. * @param m20 defines value for (2, 0)
  63856. * @param m21 defines value for (2, 1)
  63857. */
  63858. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63859. /**
  63860. * Fills the matrix from direct values
  63861. * @param m00 defines value for (0, 0)
  63862. * @param m01 defines value for (0, 1)
  63863. * @param m10 defines value for (1, 0)
  63864. * @param m11 defines value for (1, 1)
  63865. * @param m20 defines value for (2, 0)
  63866. * @param m21 defines value for (2, 1)
  63867. * @returns the current modified matrix
  63868. */
  63869. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63870. /**
  63871. * Gets matrix determinant
  63872. * @returns the determinant
  63873. */
  63874. determinant(): number;
  63875. /**
  63876. * Inverses the matrix and stores it in a target matrix
  63877. * @param result defines the target matrix
  63878. * @returns the current matrix
  63879. */
  63880. invertToRef(result: Matrix2D): Matrix2D;
  63881. /**
  63882. * Multiplies the current matrix with another one
  63883. * @param other defines the second operand
  63884. * @param result defines the target matrix
  63885. * @returns the current matrix
  63886. */
  63887. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63888. /**
  63889. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63890. * @param x defines the x coordinate to transform
  63891. * @param y defines the x coordinate to transform
  63892. * @param result defines the target vector2
  63893. * @returns the current matrix
  63894. */
  63895. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63896. /**
  63897. * Creates an identity matrix
  63898. * @returns a new matrix
  63899. */
  63900. static Identity(): Matrix2D;
  63901. /**
  63902. * Creates a translation matrix and stores it in a target matrix
  63903. * @param x defines the x coordinate of the translation
  63904. * @param y defines the y coordinate of the translation
  63905. * @param result defines the target matrix
  63906. */
  63907. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63908. /**
  63909. * Creates a scaling matrix and stores it in a target matrix
  63910. * @param x defines the x coordinate of the scaling
  63911. * @param y defines the y coordinate of the scaling
  63912. * @param result defines the target matrix
  63913. */
  63914. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63915. /**
  63916. * Creates a rotation matrix and stores it in a target matrix
  63917. * @param angle defines the rotation angle
  63918. * @param result defines the target matrix
  63919. */
  63920. static RotationToRef(angle: number, result: Matrix2D): void;
  63921. private static _TempPreTranslationMatrix;
  63922. private static _TempPostTranslationMatrix;
  63923. private static _TempRotationMatrix;
  63924. private static _TempScalingMatrix;
  63925. private static _TempCompose0;
  63926. private static _TempCompose1;
  63927. private static _TempCompose2;
  63928. /**
  63929. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63930. * @param tx defines the x coordinate of the translation
  63931. * @param ty defines the y coordinate of the translation
  63932. * @param angle defines the rotation angle
  63933. * @param scaleX defines the x coordinate of the scaling
  63934. * @param scaleY defines the y coordinate of the scaling
  63935. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63936. * @param result defines the target matrix
  63937. */
  63938. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63939. }
  63940. }
  63941. declare module BABYLON.GUI {
  63942. /**
  63943. * Class used to store 2D control sizes
  63944. */
  63945. export class Measure {
  63946. /** defines left coordinate */
  63947. left: number;
  63948. /** defines top coordinate */
  63949. top: number;
  63950. /** defines width dimension */
  63951. width: number;
  63952. /** defines height dimension */
  63953. height: number;
  63954. /**
  63955. * Creates a new measure
  63956. * @param left defines left coordinate
  63957. * @param top defines top coordinate
  63958. * @param width defines width dimension
  63959. * @param height defines height dimension
  63960. */
  63961. constructor(
  63962. /** defines left coordinate */
  63963. left: number,
  63964. /** defines top coordinate */
  63965. top: number,
  63966. /** defines width dimension */
  63967. width: number,
  63968. /** defines height dimension */
  63969. height: number);
  63970. /**
  63971. * Copy from another measure
  63972. * @param other defines the other measure to copy from
  63973. */
  63974. copyFrom(other: Measure): void;
  63975. /**
  63976. * Copy from a group of 4 floats
  63977. * @param left defines left coordinate
  63978. * @param top defines top coordinate
  63979. * @param width defines width dimension
  63980. * @param height defines height dimension
  63981. */
  63982. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63983. /**
  63984. * Computes the axis aligned bounding box measure for two given measures
  63985. * @param a Input measure
  63986. * @param b Input measure
  63987. * @param result the resulting bounding measure
  63988. */
  63989. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63990. /**
  63991. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63992. * @param transform the matrix to transform the measure before computing the AABB
  63993. * @param result the resulting AABB
  63994. */
  63995. transformToRef(transform: Matrix2D, result: Measure): void;
  63996. /**
  63997. * Check equality between this measure and another one
  63998. * @param other defines the other measures
  63999. * @returns true if both measures are equals
  64000. */
  64001. isEqualsTo(other: Measure): boolean;
  64002. /**
  64003. * Creates an empty measure
  64004. * @returns a new measure
  64005. */
  64006. static Empty(): Measure;
  64007. }
  64008. }
  64009. declare module BABYLON.GUI {
  64010. /**
  64011. * Interface used to define a control that can receive focus
  64012. */
  64013. export interface IFocusableControl {
  64014. /**
  64015. * Function called when the control receives the focus
  64016. */
  64017. onFocus(): void;
  64018. /**
  64019. * Function called when the control loses the focus
  64020. */
  64021. onBlur(): void;
  64022. /**
  64023. * Function called to let the control handle keyboard events
  64024. * @param evt defines the current keyboard event
  64025. */
  64026. processKeyboard(evt: KeyboardEvent): void;
  64027. /**
  64028. * Function called to get the list of controls that should not steal the focus from this control
  64029. * @returns an array of controls
  64030. */
  64031. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64032. }
  64033. /**
  64034. * Class used to create texture to support 2D GUI elements
  64035. * @see http://doc.babylonjs.com/how_to/gui
  64036. */
  64037. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  64038. private _isDirty;
  64039. private _renderObserver;
  64040. private _resizeObserver;
  64041. private _preKeyboardObserver;
  64042. private _pointerMoveObserver;
  64043. private _pointerObserver;
  64044. private _canvasPointerOutObserver;
  64045. private _background;
  64046. /** @hidden */
  64047. _rootContainer: Container;
  64048. /** @hidden */
  64049. _lastPickedControl: Control;
  64050. /** @hidden */
  64051. _lastControlOver: {
  64052. [pointerId: number]: Control;
  64053. };
  64054. /** @hidden */
  64055. _lastControlDown: {
  64056. [pointerId: number]: Control;
  64057. };
  64058. /** @hidden */
  64059. _capturingControl: {
  64060. [pointerId: number]: Control;
  64061. };
  64062. /** @hidden */
  64063. _shouldBlockPointer: boolean;
  64064. /** @hidden */
  64065. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  64066. /** @hidden */
  64067. _linkedControls: Control[];
  64068. private _isFullscreen;
  64069. private _fullscreenViewport;
  64070. private _idealWidth;
  64071. private _idealHeight;
  64072. private _useSmallestIdeal;
  64073. private _renderAtIdealSize;
  64074. private _focusedControl;
  64075. private _blockNextFocusCheck;
  64076. private _renderScale;
  64077. private _rootCanvas;
  64078. private _cursorChanged;
  64079. /**
  64080. * Define type to string to ensure compatibility across browsers
  64081. * Safari doesn't support DataTransfer constructor
  64082. */
  64083. private _clipboardData;
  64084. /**
  64085. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  64086. */
  64087. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  64088. /**
  64089. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  64090. */
  64091. onControlPickedObservable: BABYLON.Observable<Control>;
  64092. /**
  64093. * BABYLON.Observable event triggered before layout is evaluated
  64094. */
  64095. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64096. /**
  64097. * BABYLON.Observable event triggered after the layout was evaluated
  64098. */
  64099. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64100. /**
  64101. * BABYLON.Observable event triggered before the texture is rendered
  64102. */
  64103. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64104. /**
  64105. * BABYLON.Observable event triggered after the texture was rendered
  64106. */
  64107. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64108. /**
  64109. * Gets or sets a boolean defining if alpha is stored as premultiplied
  64110. */
  64111. premulAlpha: boolean;
  64112. /**
  64113. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  64114. * Useful when you want more antialiasing
  64115. */
  64116. renderScale: number;
  64117. /** Gets or sets the background color */
  64118. background: string;
  64119. /**
  64120. * Gets or sets the ideal width used to design controls.
  64121. * The GUI will then rescale everything accordingly
  64122. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64123. */
  64124. idealWidth: number;
  64125. /**
  64126. * Gets or sets the ideal height used to design controls.
  64127. * The GUI will then rescale everything accordingly
  64128. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64129. */
  64130. idealHeight: number;
  64131. /**
  64132. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  64133. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64134. */
  64135. useSmallestIdeal: boolean;
  64136. /**
  64137. * Gets or sets a boolean indicating if adaptive scaling must be used
  64138. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64139. */
  64140. renderAtIdealSize: boolean;
  64141. /**
  64142. * Gets the underlying layer used to render the texture when in fullscreen mode
  64143. */
  64144. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  64145. /**
  64146. * Gets the root container control
  64147. */
  64148. readonly rootContainer: Container;
  64149. /**
  64150. * Returns an array containing the root container.
  64151. * This is mostly used to let the Inspector introspects the ADT
  64152. * @returns an array containing the rootContainer
  64153. */
  64154. getChildren(): Array<Container>;
  64155. /**
  64156. * Will return all controls that are inside this texture
  64157. * @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
  64158. * @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
  64159. * @return all child controls
  64160. */
  64161. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64162. /**
  64163. * Gets or sets the current focused control
  64164. */
  64165. focusedControl: BABYLON.Nullable<IFocusableControl>;
  64166. /**
  64167. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  64168. */
  64169. isForeground: boolean;
  64170. /**
  64171. * Gets or set information about clipboardData
  64172. */
  64173. clipboardData: string;
  64174. /**
  64175. * Creates a new AdvancedDynamicTexture
  64176. * @param name defines the name of the texture
  64177. * @param width defines the width of the texture
  64178. * @param height defines the height of the texture
  64179. * @param scene defines the hosting scene
  64180. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  64181. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  64182. */
  64183. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  64184. /**
  64185. * Get the current class name of the texture useful for serialization or dynamic coding.
  64186. * @returns "AdvancedDynamicTexture"
  64187. */
  64188. getClassName(): string;
  64189. /**
  64190. * Function used to execute a function on all controls
  64191. * @param func defines the function to execute
  64192. * @param container defines the container where controls belong. If null the root container will be used
  64193. */
  64194. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  64195. private _useInvalidateRectOptimization;
  64196. /**
  64197. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  64198. */
  64199. useInvalidateRectOptimization: boolean;
  64200. private _invalidatedRectangle;
  64201. /**
  64202. * Invalidates a rectangle area on the gui texture
  64203. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  64204. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  64205. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  64206. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  64207. */
  64208. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  64209. /**
  64210. * Marks the texture as dirty forcing a complete update
  64211. */
  64212. markAsDirty(): void;
  64213. /**
  64214. * Helper function used to create a new style
  64215. * @returns a new style
  64216. * @see http://doc.babylonjs.com/how_to/gui#styles
  64217. */
  64218. createStyle(): Style;
  64219. /**
  64220. * Adds a new control to the root container
  64221. * @param control defines the control to add
  64222. * @returns the current texture
  64223. */
  64224. addControl(control: Control): AdvancedDynamicTexture;
  64225. /**
  64226. * Removes a control from the root container
  64227. * @param control defines the control to remove
  64228. * @returns the current texture
  64229. */
  64230. removeControl(control: Control): AdvancedDynamicTexture;
  64231. /**
  64232. * Release all resources
  64233. */
  64234. dispose(): void;
  64235. private _onResize;
  64236. /** @hidden */
  64237. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  64238. /**
  64239. * Get screen coordinates for a vector3
  64240. * @param position defines the position to project
  64241. * @param worldMatrix defines the world matrix to use
  64242. * @returns the projected position
  64243. */
  64244. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  64245. private _checkUpdate;
  64246. private _clearMeasure;
  64247. private _render;
  64248. /** @hidden */
  64249. _changeCursor(cursor: string): void;
  64250. /** @hidden */
  64251. _registerLastControlDown(control: Control, pointerId: number): void;
  64252. private _doPicking;
  64253. /** @hidden */
  64254. _cleanControlAfterRemovalFromList(list: {
  64255. [pointerId: number]: Control;
  64256. }, control: Control): void;
  64257. /** @hidden */
  64258. _cleanControlAfterRemoval(control: Control): void;
  64259. /** Attach to all scene events required to support pointer events */
  64260. attach(): void;
  64261. /** @hidden */
  64262. private onClipboardCopy;
  64263. /** @hidden */
  64264. private onClipboardCut;
  64265. /** @hidden */
  64266. private onClipboardPaste;
  64267. /**
  64268. * Register the clipboard Events onto the canvas
  64269. */
  64270. registerClipboardEvents(): void;
  64271. /**
  64272. * Unregister the clipboard Events from the canvas
  64273. */
  64274. unRegisterClipboardEvents(): void;
  64275. /**
  64276. * Connect the texture to a hosting mesh to enable interactions
  64277. * @param mesh defines the mesh to attach to
  64278. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  64279. */
  64280. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  64281. /**
  64282. * Move the focus to a specific control
  64283. * @param control defines the control which will receive the focus
  64284. */
  64285. moveFocusToControl(control: IFocusableControl): void;
  64286. private _manageFocus;
  64287. private _attachToOnPointerOut;
  64288. /**
  64289. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  64290. * @param mesh defines the mesh which will receive the texture
  64291. * @param width defines the texture width (1024 by default)
  64292. * @param height defines the texture height (1024 by default)
  64293. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  64294. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  64295. * @returns a new AdvancedDynamicTexture
  64296. */
  64297. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  64298. /**
  64299. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  64300. * In this mode the texture will rely on a layer for its rendering.
  64301. * This allows it to be treated like any other layer.
  64302. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  64303. * LayerMask is set through advancedTexture.layer.layerMask
  64304. * @param name defines name for the texture
  64305. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  64306. * @param scene defines the hsoting scene
  64307. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  64308. * @returns a new AdvancedDynamicTexture
  64309. */
  64310. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  64311. }
  64312. }
  64313. declare module BABYLON.GUI {
  64314. /**
  64315. * Root class used for all 2D controls
  64316. * @see http://doc.babylonjs.com/how_to/gui#controls
  64317. */
  64318. export class Control {
  64319. /** defines the name of the control */
  64320. name?: string | undefined;
  64321. /**
  64322. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  64323. */
  64324. static AllowAlphaInheritance: boolean;
  64325. private _alpha;
  64326. private _alphaSet;
  64327. private _zIndex;
  64328. /** @hidden */
  64329. _host: AdvancedDynamicTexture;
  64330. /** Gets or sets the control parent */
  64331. parent: BABYLON.Nullable<Container>;
  64332. /** @hidden */
  64333. _currentMeasure: Measure;
  64334. private _fontFamily;
  64335. private _fontStyle;
  64336. private _fontWeight;
  64337. private _fontSize;
  64338. private _font;
  64339. /** @hidden */
  64340. _width: ValueAndUnit;
  64341. /** @hidden */
  64342. _height: ValueAndUnit;
  64343. /** @hidden */
  64344. protected _fontOffset: {
  64345. ascent: number;
  64346. height: number;
  64347. descent: number;
  64348. };
  64349. private _color;
  64350. private _style;
  64351. private _styleObserver;
  64352. /** @hidden */
  64353. protected _horizontalAlignment: number;
  64354. /** @hidden */
  64355. protected _verticalAlignment: number;
  64356. /** @hidden */
  64357. protected _isDirty: boolean;
  64358. /** @hidden */
  64359. protected _wasDirty: boolean;
  64360. /** @hidden */
  64361. _tempParentMeasure: Measure;
  64362. /** @hidden */
  64363. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  64364. /** @hidden */
  64365. protected _cachedParentMeasure: Measure;
  64366. private _paddingLeft;
  64367. private _paddingRight;
  64368. private _paddingTop;
  64369. private _paddingBottom;
  64370. /** @hidden */
  64371. _left: ValueAndUnit;
  64372. /** @hidden */
  64373. _top: ValueAndUnit;
  64374. private _scaleX;
  64375. private _scaleY;
  64376. private _rotation;
  64377. private _transformCenterX;
  64378. private _transformCenterY;
  64379. /** @hidden */
  64380. _transformMatrix: Matrix2D;
  64381. /** @hidden */
  64382. protected _invertTransformMatrix: Matrix2D;
  64383. /** @hidden */
  64384. protected _transformedPosition: BABYLON.Vector2;
  64385. private _isMatrixDirty;
  64386. private _cachedOffsetX;
  64387. private _cachedOffsetY;
  64388. private _isVisible;
  64389. private _isHighlighted;
  64390. /** @hidden */
  64391. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64392. private _fontSet;
  64393. private _dummyVector2;
  64394. private _downCount;
  64395. private _enterCount;
  64396. private _doNotRender;
  64397. private _downPointerIds;
  64398. protected _isEnabled: boolean;
  64399. protected _disabledColor: string;
  64400. /** @hidden */
  64401. protected _rebuildLayout: boolean;
  64402. /** @hidden */
  64403. _isClipped: boolean;
  64404. /** @hidden */
  64405. _tag: any;
  64406. /**
  64407. * 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
  64408. */
  64409. uniqueId: number;
  64410. /**
  64411. * Gets or sets an object used to store user defined information for the node
  64412. */
  64413. metadata: any;
  64414. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64415. isHitTestVisible: boolean;
  64416. /** Gets or sets a boolean indicating if the control can block pointer events */
  64417. isPointerBlocker: boolean;
  64418. /** Gets or sets a boolean indicating if the control can be focusable */
  64419. isFocusInvisible: boolean;
  64420. /**
  64421. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64422. * 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
  64423. */
  64424. clipChildren: boolean;
  64425. /**
  64426. * Gets or sets a boolean indicating that control content must be clipped
  64427. * 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
  64428. */
  64429. clipContent: boolean;
  64430. /**
  64431. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  64432. */
  64433. useBitmapCache: boolean;
  64434. private _cacheData;
  64435. private _shadowOffsetX;
  64436. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  64437. shadowOffsetX: number;
  64438. private _shadowOffsetY;
  64439. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  64440. shadowOffsetY: number;
  64441. private _shadowBlur;
  64442. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  64443. shadowBlur: number;
  64444. private _shadowColor;
  64445. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  64446. shadowColor: string;
  64447. /** Gets or sets the cursor to use when the control is hovered */
  64448. hoverCursor: string;
  64449. /** @hidden */
  64450. protected _linkOffsetX: ValueAndUnit;
  64451. /** @hidden */
  64452. protected _linkOffsetY: ValueAndUnit;
  64453. /** Gets the control type name */
  64454. readonly typeName: string;
  64455. /**
  64456. * Get the current class name of the control.
  64457. * @returns current class name
  64458. */
  64459. getClassName(): string;
  64460. /**
  64461. * An event triggered when the pointer move over the control.
  64462. */
  64463. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  64464. /**
  64465. * An event triggered when the pointer move out of the control.
  64466. */
  64467. onPointerOutObservable: BABYLON.Observable<Control>;
  64468. /**
  64469. * An event triggered when the pointer taps the control
  64470. */
  64471. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  64472. /**
  64473. * An event triggered when pointer up
  64474. */
  64475. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  64476. /**
  64477. * An event triggered when a control is clicked on
  64478. */
  64479. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  64480. /**
  64481. * An event triggered when pointer enters the control
  64482. */
  64483. onPointerEnterObservable: BABYLON.Observable<Control>;
  64484. /**
  64485. * An event triggered when the control is marked as dirty
  64486. */
  64487. onDirtyObservable: BABYLON.Observable<Control>;
  64488. /**
  64489. * An event triggered before drawing the control
  64490. */
  64491. onBeforeDrawObservable: BABYLON.Observable<Control>;
  64492. /**
  64493. * An event triggered after the control was drawn
  64494. */
  64495. onAfterDrawObservable: BABYLON.Observable<Control>;
  64496. /**
  64497. * Get the hosting AdvancedDynamicTexture
  64498. */
  64499. readonly host: AdvancedDynamicTexture;
  64500. /** Gets or set information about font offsets (used to render and align text) */
  64501. fontOffset: {
  64502. ascent: number;
  64503. height: number;
  64504. descent: number;
  64505. };
  64506. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  64507. alpha: number;
  64508. /**
  64509. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  64510. */
  64511. isHighlighted: boolean;
  64512. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  64513. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64514. */
  64515. scaleX: number;
  64516. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  64517. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64518. */
  64519. scaleY: number;
  64520. /** Gets or sets the rotation angle (0 by default)
  64521. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64522. */
  64523. rotation: number;
  64524. /** Gets or sets the transformation center on Y axis (0 by default)
  64525. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64526. */
  64527. transformCenterY: number;
  64528. /** Gets or sets the transformation center on X axis (0 by default)
  64529. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64530. */
  64531. transformCenterX: number;
  64532. /**
  64533. * Gets or sets the horizontal alignment
  64534. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64535. */
  64536. horizontalAlignment: number;
  64537. /**
  64538. * Gets or sets the vertical alignment
  64539. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64540. */
  64541. verticalAlignment: number;
  64542. /**
  64543. * Gets or sets control width
  64544. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64545. */
  64546. width: string | number;
  64547. /**
  64548. * Gets or sets the control width in pixel
  64549. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64550. */
  64551. widthInPixels: number;
  64552. /**
  64553. * Gets or sets control height
  64554. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64555. */
  64556. height: string | number;
  64557. /**
  64558. * Gets or sets control height in pixel
  64559. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64560. */
  64561. heightInPixels: number;
  64562. /** Gets or set font family */
  64563. fontFamily: string;
  64564. /** Gets or sets font style */
  64565. fontStyle: string;
  64566. /** Gets or sets font weight */
  64567. fontWeight: string;
  64568. /**
  64569. * Gets or sets style
  64570. * @see http://doc.babylonjs.com/how_to/gui#styles
  64571. */
  64572. style: BABYLON.Nullable<Style>;
  64573. /** @hidden */
  64574. readonly _isFontSizeInPercentage: boolean;
  64575. /** Gets or sets font size in pixels */
  64576. fontSizeInPixels: number;
  64577. /** Gets or sets font size */
  64578. fontSize: string | number;
  64579. /** Gets or sets foreground color */
  64580. color: string;
  64581. /** Gets or sets z index which is used to reorder controls on the z axis */
  64582. zIndex: number;
  64583. /** Gets or sets a boolean indicating if the control can be rendered */
  64584. notRenderable: boolean;
  64585. /** Gets or sets a boolean indicating if the control is visible */
  64586. isVisible: boolean;
  64587. /** Gets a boolean indicating that the control needs to update its rendering */
  64588. readonly isDirty: boolean;
  64589. /**
  64590. * Gets the current linked mesh (or null if none)
  64591. */
  64592. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64593. /**
  64594. * Gets or sets a value indicating the padding to use on the left of the control
  64595. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64596. */
  64597. paddingLeft: string | number;
  64598. /**
  64599. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  64600. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64601. */
  64602. paddingLeftInPixels: number;
  64603. /**
  64604. * Gets or sets a value indicating the padding to use on the right of the control
  64605. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64606. */
  64607. paddingRight: string | number;
  64608. /**
  64609. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  64610. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64611. */
  64612. paddingRightInPixels: number;
  64613. /**
  64614. * Gets or sets a value indicating the padding to use on the top of the control
  64615. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64616. */
  64617. paddingTop: string | number;
  64618. /**
  64619. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  64620. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64621. */
  64622. paddingTopInPixels: number;
  64623. /**
  64624. * Gets or sets a value indicating the padding to use on the bottom of the control
  64625. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64626. */
  64627. paddingBottom: string | number;
  64628. /**
  64629. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  64630. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64631. */
  64632. paddingBottomInPixels: number;
  64633. /**
  64634. * Gets or sets a value indicating the left coordinate of the control
  64635. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64636. */
  64637. left: string | number;
  64638. /**
  64639. * Gets or sets a value indicating the left coordinate in pixels of the control
  64640. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64641. */
  64642. leftInPixels: number;
  64643. /**
  64644. * Gets or sets a value indicating the top coordinate of the control
  64645. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64646. */
  64647. top: string | number;
  64648. /**
  64649. * Gets or sets a value indicating the top coordinate in pixels of the control
  64650. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64651. */
  64652. topInPixels: number;
  64653. /**
  64654. * Gets or sets a value indicating the offset on X axis to the linked mesh
  64655. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64656. */
  64657. linkOffsetX: string | number;
  64658. /**
  64659. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  64660. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64661. */
  64662. linkOffsetXInPixels: number;
  64663. /**
  64664. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  64665. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64666. */
  64667. linkOffsetY: string | number;
  64668. /**
  64669. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  64670. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64671. */
  64672. linkOffsetYInPixels: number;
  64673. /** Gets the center coordinate on X axis */
  64674. readonly centerX: number;
  64675. /** Gets the center coordinate on Y axis */
  64676. readonly centerY: number;
  64677. /** Gets or sets if control is Enabled*/
  64678. isEnabled: boolean;
  64679. /** Gets or sets background color of control if it's disabled*/
  64680. disabledColor: string;
  64681. /**
  64682. * Creates a new control
  64683. * @param name defines the name of the control
  64684. */
  64685. constructor(
  64686. /** defines the name of the control */
  64687. name?: string | undefined);
  64688. /** @hidden */
  64689. protected _getTypeName(): string;
  64690. /**
  64691. * Gets the first ascendant in the hierarchy of the given type
  64692. * @param className defines the required type
  64693. * @returns the ascendant or null if not found
  64694. */
  64695. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  64696. /** @hidden */
  64697. _resetFontCache(): void;
  64698. /**
  64699. * Determines if a container is an ascendant of the current control
  64700. * @param container defines the container to look for
  64701. * @returns true if the container is one of the ascendant of the control
  64702. */
  64703. isAscendant(container: Control): boolean;
  64704. /**
  64705. * Gets coordinates in local control space
  64706. * @param globalCoordinates defines the coordinates to transform
  64707. * @returns the new coordinates in local space
  64708. */
  64709. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64710. /**
  64711. * Gets coordinates in local control space
  64712. * @param globalCoordinates defines the coordinates to transform
  64713. * @param result defines the target vector2 where to store the result
  64714. * @returns the current control
  64715. */
  64716. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  64717. /**
  64718. * Gets coordinates in parent local control space
  64719. * @param globalCoordinates defines the coordinates to transform
  64720. * @returns the new coordinates in parent local space
  64721. */
  64722. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64723. /**
  64724. * Move the current control to a vector3 position projected onto the screen.
  64725. * @param position defines the target position
  64726. * @param scene defines the hosting scene
  64727. */
  64728. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  64729. /** @hidden */
  64730. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64731. /**
  64732. * Will return all controls that have this control as ascendant
  64733. * @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
  64734. * @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
  64735. * @return all child controls
  64736. */
  64737. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64738. /**
  64739. * Link current control with a target mesh
  64740. * @param mesh defines the mesh to link with
  64741. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64742. */
  64743. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  64744. /** @hidden */
  64745. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  64746. /** @hidden */
  64747. _offsetLeft(offset: number): void;
  64748. /** @hidden */
  64749. _offsetTop(offset: number): void;
  64750. /** @hidden */
  64751. _markMatrixAsDirty(): void;
  64752. /** @hidden */
  64753. _flagDescendantsAsMatrixDirty(): void;
  64754. /** @hidden */
  64755. _intersectsRect(rect: Measure): boolean;
  64756. /** @hidden */
  64757. protected invalidateRect(): void;
  64758. /** @hidden */
  64759. _markAsDirty(force?: boolean): void;
  64760. /** @hidden */
  64761. _markAllAsDirty(): void;
  64762. /** @hidden */
  64763. _link(host: AdvancedDynamicTexture): void;
  64764. /** @hidden */
  64765. protected _transform(context?: CanvasRenderingContext2D): void;
  64766. /** @hidden */
  64767. _renderHighlight(context: CanvasRenderingContext2D): void;
  64768. /** @hidden */
  64769. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64770. /** @hidden */
  64771. protected _applyStates(context: CanvasRenderingContext2D): void;
  64772. /** @hidden */
  64773. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64774. /** @hidden */
  64775. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64776. protected _evaluateClippingState(parentMeasure: Measure): void;
  64777. /** @hidden */
  64778. _measure(): void;
  64779. /** @hidden */
  64780. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64781. /** @hidden */
  64782. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64783. /** @hidden */
  64784. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64785. /** @hidden */
  64786. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64787. private static _ClipMeasure;
  64788. private _tmpMeasureA;
  64789. private _clip;
  64790. /** @hidden */
  64791. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  64792. /** @hidden */
  64793. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  64794. /**
  64795. * Tests if a given coordinates belong to the current control
  64796. * @param x defines x coordinate to test
  64797. * @param y defines y coordinate to test
  64798. * @returns true if the coordinates are inside the control
  64799. */
  64800. contains(x: number, y: number): boolean;
  64801. /** @hidden */
  64802. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64803. /** @hidden */
  64804. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64805. /** @hidden */
  64806. _onPointerEnter(target: Control): boolean;
  64807. /** @hidden */
  64808. _onPointerOut(target: Control, force?: boolean): void;
  64809. /** @hidden */
  64810. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64811. /** @hidden */
  64812. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64813. /** @hidden */
  64814. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64815. /** @hidden */
  64816. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  64817. private _prepareFont;
  64818. /** Releases associated resources */
  64819. dispose(): void;
  64820. private static _HORIZONTAL_ALIGNMENT_LEFT;
  64821. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  64822. private static _HORIZONTAL_ALIGNMENT_CENTER;
  64823. private static _VERTICAL_ALIGNMENT_TOP;
  64824. private static _VERTICAL_ALIGNMENT_BOTTOM;
  64825. private static _VERTICAL_ALIGNMENT_CENTER;
  64826. /** HORIZONTAL_ALIGNMENT_LEFT */
  64827. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  64828. /** HORIZONTAL_ALIGNMENT_RIGHT */
  64829. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  64830. /** HORIZONTAL_ALIGNMENT_CENTER */
  64831. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  64832. /** VERTICAL_ALIGNMENT_TOP */
  64833. static readonly VERTICAL_ALIGNMENT_TOP: number;
  64834. /** VERTICAL_ALIGNMENT_BOTTOM */
  64835. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  64836. /** VERTICAL_ALIGNMENT_CENTER */
  64837. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  64838. private static _FontHeightSizes;
  64839. /** @hidden */
  64840. static _GetFontOffset(font: string): {
  64841. ascent: number;
  64842. height: number;
  64843. descent: number;
  64844. };
  64845. /**
  64846. * Creates a stack panel that can be used to render headers
  64847. * @param control defines the control to associate with the header
  64848. * @param text defines the text of the header
  64849. * @param size defines the size of the header
  64850. * @param options defines options used to configure the header
  64851. * @returns a new StackPanel
  64852. * @ignore
  64853. * @hidden
  64854. */
  64855. static AddHeader: (control: Control, text: string, size: string | number, options: {
  64856. isHorizontal: boolean;
  64857. controlFirst: boolean;
  64858. }) => any;
  64859. /** @hidden */
  64860. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  64861. }
  64862. }
  64863. declare module BABYLON.GUI {
  64864. /**
  64865. * Root class for 2D containers
  64866. * @see http://doc.babylonjs.com/how_to/gui#containers
  64867. */
  64868. export class Container extends Control {
  64869. name?: string | undefined;
  64870. /** @hidden */
  64871. protected _children: Control[];
  64872. /** @hidden */
  64873. protected _measureForChildren: Measure;
  64874. /** @hidden */
  64875. protected _background: string;
  64876. /** @hidden */
  64877. protected _adaptWidthToChildren: boolean;
  64878. /** @hidden */
  64879. protected _adaptHeightToChildren: boolean;
  64880. /**
  64881. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  64882. */
  64883. logLayoutCycleErrors: boolean;
  64884. /**
  64885. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  64886. */
  64887. maxLayoutCycle: number;
  64888. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  64889. adaptHeightToChildren: boolean;
  64890. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  64891. adaptWidthToChildren: boolean;
  64892. /** Gets or sets background color */
  64893. background: string;
  64894. /** Gets the list of children */
  64895. readonly children: Control[];
  64896. /**
  64897. * Creates a new Container
  64898. * @param name defines the name of the container
  64899. */
  64900. constructor(name?: string | undefined);
  64901. protected _getTypeName(): string;
  64902. _flagDescendantsAsMatrixDirty(): void;
  64903. /**
  64904. * Gets a child using its name
  64905. * @param name defines the child name to look for
  64906. * @returns the child control if found
  64907. */
  64908. getChildByName(name: string): BABYLON.Nullable<Control>;
  64909. /**
  64910. * Gets a child using its type and its name
  64911. * @param name defines the child name to look for
  64912. * @param type defines the child type to look for
  64913. * @returns the child control if found
  64914. */
  64915. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64916. /**
  64917. * Search for a specific control in children
  64918. * @param control defines the control to look for
  64919. * @returns true if the control is in child list
  64920. */
  64921. containsControl(control: Control): boolean;
  64922. /**
  64923. * Adds a new control to the current container
  64924. * @param control defines the control to add
  64925. * @returns the current container
  64926. */
  64927. addControl(control: BABYLON.Nullable<Control>): Container;
  64928. /**
  64929. * Removes all controls from the current container
  64930. * @returns the current container
  64931. */
  64932. clearControls(): Container;
  64933. /**
  64934. * Removes a control from the current container
  64935. * @param control defines the control to remove
  64936. * @returns the current container
  64937. */
  64938. removeControl(control: Control): Container;
  64939. /** @hidden */
  64940. _reOrderControl(control: Control): void;
  64941. /** @hidden */
  64942. _offsetLeft(offset: number): void;
  64943. /** @hidden */
  64944. _offsetTop(offset: number): void;
  64945. /** @hidden */
  64946. _markAllAsDirty(): void;
  64947. /** @hidden */
  64948. protected _localDraw(context: CanvasRenderingContext2D): void;
  64949. /** @hidden */
  64950. _link(host: AdvancedDynamicTexture): void;
  64951. /** @hidden */
  64952. protected _beforeLayout(): void;
  64953. /** @hidden */
  64954. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64955. /** @hidden */
  64956. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64957. protected _postMeasure(): void;
  64958. /** @hidden */
  64959. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64960. /** @hidden */
  64961. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64962. /** @hidden */
  64963. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64964. /** @hidden */
  64965. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64966. /** Releases associated resources */
  64967. dispose(): void;
  64968. }
  64969. }
  64970. declare module BABYLON.GUI {
  64971. /** Class used to create rectangle container */
  64972. export class Rectangle extends Container {
  64973. name?: string | undefined;
  64974. private _thickness;
  64975. private _cornerRadius;
  64976. /** Gets or sets border thickness */
  64977. thickness: number;
  64978. /** Gets or sets the corner radius angle */
  64979. cornerRadius: number;
  64980. /**
  64981. * Creates a new Rectangle
  64982. * @param name defines the control name
  64983. */
  64984. constructor(name?: string | undefined);
  64985. protected _getTypeName(): string;
  64986. protected _localDraw(context: CanvasRenderingContext2D): void;
  64987. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64988. private _drawRoundedRect;
  64989. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64990. }
  64991. }
  64992. declare module BABYLON.GUI {
  64993. /**
  64994. * Enum that determines the text-wrapping mode to use.
  64995. */
  64996. export enum TextWrapping {
  64997. /**
  64998. * Clip the text when it's larger than Control.width; this is the default mode.
  64999. */
  65000. Clip = 0,
  65001. /**
  65002. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  65003. */
  65004. WordWrap = 1,
  65005. /**
  65006. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  65007. */
  65008. Ellipsis = 2
  65009. }
  65010. /**
  65011. * Class used to create text block control
  65012. */
  65013. export class TextBlock extends Control {
  65014. /**
  65015. * Defines the name of the control
  65016. */
  65017. name?: string | undefined;
  65018. private _text;
  65019. private _textWrapping;
  65020. private _textHorizontalAlignment;
  65021. private _textVerticalAlignment;
  65022. private _lines;
  65023. private _resizeToFit;
  65024. private _lineSpacing;
  65025. private _outlineWidth;
  65026. private _outlineColor;
  65027. /**
  65028. * An event triggered after the text is changed
  65029. */
  65030. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  65031. /**
  65032. * An event triggered after the text was broken up into lines
  65033. */
  65034. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  65035. /**
  65036. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  65037. */
  65038. readonly lines: any[];
  65039. /**
  65040. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65041. */
  65042. /**
  65043. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65044. */
  65045. resizeToFit: boolean;
  65046. /**
  65047. * Gets or sets a boolean indicating if text must be wrapped
  65048. */
  65049. /**
  65050. * Gets or sets a boolean indicating if text must be wrapped
  65051. */
  65052. textWrapping: TextWrapping | boolean;
  65053. /**
  65054. * Gets or sets text to display
  65055. */
  65056. /**
  65057. * Gets or sets text to display
  65058. */
  65059. text: string;
  65060. /**
  65061. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65062. */
  65063. /**
  65064. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65065. */
  65066. textHorizontalAlignment: number;
  65067. /**
  65068. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65069. */
  65070. /**
  65071. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65072. */
  65073. textVerticalAlignment: number;
  65074. /**
  65075. * Gets or sets line spacing value
  65076. */
  65077. /**
  65078. * Gets or sets line spacing value
  65079. */
  65080. lineSpacing: string | number;
  65081. /**
  65082. * Gets or sets outlineWidth of the text to display
  65083. */
  65084. /**
  65085. * Gets or sets outlineWidth of the text to display
  65086. */
  65087. outlineWidth: number;
  65088. /**
  65089. * Gets or sets outlineColor of the text to display
  65090. */
  65091. /**
  65092. * Gets or sets outlineColor of the text to display
  65093. */
  65094. outlineColor: string;
  65095. /**
  65096. * Creates a new TextBlock object
  65097. * @param name defines the name of the control
  65098. * @param text defines the text to display (emptry string by default)
  65099. */
  65100. constructor(
  65101. /**
  65102. * Defines the name of the control
  65103. */
  65104. name?: string | undefined, text?: string);
  65105. protected _getTypeName(): string;
  65106. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65107. private _drawText;
  65108. /** @hidden */
  65109. _draw(context: CanvasRenderingContext2D): void;
  65110. protected _applyStates(context: CanvasRenderingContext2D): void;
  65111. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  65112. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  65113. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  65114. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  65115. protected _renderLines(context: CanvasRenderingContext2D): void;
  65116. /**
  65117. * Given a width constraint applied on the text block, find the expected height
  65118. * @returns expected height
  65119. */
  65120. computeExpectedHeight(): number;
  65121. dispose(): void;
  65122. }
  65123. }
  65124. declare module BABYLON.GUI {
  65125. /**
  65126. * Class used to create 2D images
  65127. */
  65128. export class Image extends Control {
  65129. name?: string | undefined;
  65130. private static _WorkingCanvas;
  65131. private _domImage;
  65132. private _imageWidth;
  65133. private _imageHeight;
  65134. private _loaded;
  65135. private _stretch;
  65136. private _source;
  65137. private _autoScale;
  65138. private _sourceLeft;
  65139. private _sourceTop;
  65140. private _sourceWidth;
  65141. private _sourceHeight;
  65142. private _cellWidth;
  65143. private _cellHeight;
  65144. private _cellId;
  65145. private _populateNinePatchSlicesFromImage;
  65146. private _sliceLeft;
  65147. private _sliceRight;
  65148. private _sliceTop;
  65149. private _sliceBottom;
  65150. private _detectPointerOnOpaqueOnly;
  65151. /**
  65152. * BABYLON.Observable notified when the content is loaded
  65153. */
  65154. onImageLoadedObservable: BABYLON.Observable<Image>;
  65155. /**
  65156. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  65157. */
  65158. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  65159. /**
  65160. * Gets a boolean indicating that the content is loaded
  65161. */
  65162. readonly isLoaded: boolean;
  65163. /**
  65164. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  65165. */
  65166. populateNinePatchSlicesFromImage: boolean;
  65167. /**
  65168. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  65169. * Beware using this as this will comsume more memory as the image has to be stored twice
  65170. */
  65171. detectPointerOnOpaqueOnly: boolean;
  65172. /**
  65173. * Gets or sets the left value for slicing (9-patch)
  65174. */
  65175. sliceLeft: number;
  65176. /**
  65177. * Gets or sets the right value for slicing (9-patch)
  65178. */
  65179. sliceRight: number;
  65180. /**
  65181. * Gets or sets the top value for slicing (9-patch)
  65182. */
  65183. sliceTop: number;
  65184. /**
  65185. * Gets or sets the bottom value for slicing (9-patch)
  65186. */
  65187. sliceBottom: number;
  65188. /**
  65189. * Gets or sets the left coordinate in the source image
  65190. */
  65191. sourceLeft: number;
  65192. /**
  65193. * Gets or sets the top coordinate in the source image
  65194. */
  65195. sourceTop: number;
  65196. /**
  65197. * Gets or sets the width to capture in the source image
  65198. */
  65199. sourceWidth: number;
  65200. /**
  65201. * Gets or sets the height to capture in the source image
  65202. */
  65203. sourceHeight: number;
  65204. /**
  65205. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  65206. * @see http://doc.babylonjs.com/how_to/gui#image
  65207. */
  65208. autoScale: boolean;
  65209. /** Gets or sets the streching mode used by the image */
  65210. stretch: number;
  65211. /**
  65212. * Gets or sets the internal DOM image used to render the control
  65213. */
  65214. domImage: HTMLImageElement;
  65215. private _onImageLoaded;
  65216. private _extractNinePatchSliceDataFromImage;
  65217. /**
  65218. * Gets or sets image source url
  65219. */
  65220. source: BABYLON.Nullable<string>;
  65221. /**
  65222. * Checks for svg document with icon id present
  65223. */
  65224. private _svgCheck;
  65225. /**
  65226. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  65227. * given external svg file and icon id
  65228. */
  65229. private _getSVGAttribs;
  65230. /**
  65231. * Gets or sets the cell width to use when animation sheet is enabled
  65232. * @see http://doc.babylonjs.com/how_to/gui#image
  65233. */
  65234. cellWidth: number;
  65235. /**
  65236. * Gets or sets the cell height to use when animation sheet is enabled
  65237. * @see http://doc.babylonjs.com/how_to/gui#image
  65238. */
  65239. cellHeight: number;
  65240. /**
  65241. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  65242. * @see http://doc.babylonjs.com/how_to/gui#image
  65243. */
  65244. cellId: number;
  65245. /**
  65246. * Creates a new Image
  65247. * @param name defines the control name
  65248. * @param url defines the image url
  65249. */
  65250. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  65251. /**
  65252. * Tests if a given coordinates belong to the current control
  65253. * @param x defines x coordinate to test
  65254. * @param y defines y coordinate to test
  65255. * @returns true if the coordinates are inside the control
  65256. */
  65257. contains(x: number, y: number): boolean;
  65258. protected _getTypeName(): string;
  65259. /** Force the control to synchronize with its content */
  65260. synchronizeSizeWithContent(): void;
  65261. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65262. private _prepareWorkingCanvasForOpaqueDetection;
  65263. private _drawImage;
  65264. _draw(context: CanvasRenderingContext2D): void;
  65265. private _renderCornerPatch;
  65266. private _renderNinePatch;
  65267. dispose(): void;
  65268. /** STRETCH_NONE */
  65269. static readonly STRETCH_NONE: number;
  65270. /** STRETCH_FILL */
  65271. static readonly STRETCH_FILL: number;
  65272. /** STRETCH_UNIFORM */
  65273. static readonly STRETCH_UNIFORM: number;
  65274. /** STRETCH_EXTEND */
  65275. static readonly STRETCH_EXTEND: number;
  65276. /** NINE_PATCH */
  65277. static readonly STRETCH_NINE_PATCH: number;
  65278. }
  65279. }
  65280. declare module BABYLON.GUI {
  65281. /**
  65282. * Class used to create 2D buttons
  65283. */
  65284. export class Button extends Rectangle {
  65285. name?: string | undefined;
  65286. /**
  65287. * Function called to generate a pointer enter animation
  65288. */
  65289. pointerEnterAnimation: () => void;
  65290. /**
  65291. * Function called to generate a pointer out animation
  65292. */
  65293. pointerOutAnimation: () => void;
  65294. /**
  65295. * Function called to generate a pointer down animation
  65296. */
  65297. pointerDownAnimation: () => void;
  65298. /**
  65299. * Function called to generate a pointer up animation
  65300. */
  65301. pointerUpAnimation: () => void;
  65302. /**
  65303. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  65304. */
  65305. delegatePickingToChildren: boolean;
  65306. private _image;
  65307. /**
  65308. * Returns the image part of the button (if any)
  65309. */
  65310. readonly image: BABYLON.Nullable<Image>;
  65311. private _textBlock;
  65312. /**
  65313. * Returns the image part of the button (if any)
  65314. */
  65315. readonly textBlock: BABYLON.Nullable<TextBlock>;
  65316. /**
  65317. * Creates a new Button
  65318. * @param name defines the name of the button
  65319. */
  65320. constructor(name?: string | undefined);
  65321. protected _getTypeName(): string;
  65322. /** @hidden */
  65323. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65324. /** @hidden */
  65325. _onPointerEnter(target: Control): boolean;
  65326. /** @hidden */
  65327. _onPointerOut(target: Control, force?: boolean): void;
  65328. /** @hidden */
  65329. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65330. /** @hidden */
  65331. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65332. /**
  65333. * Creates a new button made with an image and a text
  65334. * @param name defines the name of the button
  65335. * @param text defines the text of the button
  65336. * @param imageUrl defines the url of the image
  65337. * @returns a new Button
  65338. */
  65339. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  65340. /**
  65341. * Creates a new button made with an image
  65342. * @param name defines the name of the button
  65343. * @param imageUrl defines the url of the image
  65344. * @returns a new Button
  65345. */
  65346. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  65347. /**
  65348. * Creates a new button made with a text
  65349. * @param name defines the name of the button
  65350. * @param text defines the text of the button
  65351. * @returns a new Button
  65352. */
  65353. static CreateSimpleButton(name: string, text: string): Button;
  65354. /**
  65355. * Creates a new button made with an image and a centered text
  65356. * @param name defines the name of the button
  65357. * @param text defines the text of the button
  65358. * @param imageUrl defines the url of the image
  65359. * @returns a new Button
  65360. */
  65361. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  65362. }
  65363. }
  65364. declare module BABYLON.GUI {
  65365. /**
  65366. * Class used to create a 2D stack panel container
  65367. */
  65368. export class StackPanel extends Container {
  65369. name?: string | undefined;
  65370. private _isVertical;
  65371. private _manualWidth;
  65372. private _manualHeight;
  65373. private _doNotTrackManualChanges;
  65374. /**
  65375. * Gets or sets a boolean indicating that layou warnings should be ignored
  65376. */
  65377. ignoreLayoutWarnings: boolean;
  65378. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65379. isVertical: boolean;
  65380. /**
  65381. * Gets or sets panel width.
  65382. * This value should not be set when in horizontal mode as it will be computed automatically
  65383. */
  65384. width: string | number;
  65385. /**
  65386. * Gets or sets panel height.
  65387. * This value should not be set when in vertical mode as it will be computed automatically
  65388. */
  65389. height: string | number;
  65390. /**
  65391. * Creates a new StackPanel
  65392. * @param name defines control name
  65393. */
  65394. constructor(name?: string | undefined);
  65395. protected _getTypeName(): string;
  65396. /** @hidden */
  65397. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65398. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65399. protected _postMeasure(): void;
  65400. }
  65401. }
  65402. declare module BABYLON.GUI {
  65403. /**
  65404. * Class used to represent a 2D checkbox
  65405. */
  65406. export class Checkbox extends Control {
  65407. name?: string | undefined;
  65408. private _isChecked;
  65409. private _background;
  65410. private _checkSizeRatio;
  65411. private _thickness;
  65412. /** Gets or sets border thickness */
  65413. thickness: number;
  65414. /**
  65415. * BABYLON.Observable raised when isChecked property changes
  65416. */
  65417. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65418. /** Gets or sets a value indicating the ratio between overall size and check size */
  65419. checkSizeRatio: number;
  65420. /** Gets or sets background color */
  65421. background: string;
  65422. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65423. isChecked: boolean;
  65424. /**
  65425. * Creates a new CheckBox
  65426. * @param name defines the control name
  65427. */
  65428. constructor(name?: string | undefined);
  65429. protected _getTypeName(): string;
  65430. /** @hidden */
  65431. _draw(context: CanvasRenderingContext2D): void;
  65432. /** @hidden */
  65433. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65434. /**
  65435. * Utility function to easily create a checkbox with a header
  65436. * @param title defines the label to use for the header
  65437. * @param onValueChanged defines the callback to call when value changes
  65438. * @returns a StackPanel containing the checkbox and a textBlock
  65439. */
  65440. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  65441. }
  65442. }
  65443. declare module BABYLON.GUI {
  65444. /**
  65445. * Class used to store key control properties
  65446. */
  65447. export class KeyPropertySet {
  65448. /** Width */
  65449. width?: string;
  65450. /** Height */
  65451. height?: string;
  65452. /** Left padding */
  65453. paddingLeft?: string;
  65454. /** Right padding */
  65455. paddingRight?: string;
  65456. /** Top padding */
  65457. paddingTop?: string;
  65458. /** Bottom padding */
  65459. paddingBottom?: string;
  65460. /** Foreground color */
  65461. color?: string;
  65462. /** Background color */
  65463. background?: string;
  65464. }
  65465. /**
  65466. * Class used to create virtual keyboard
  65467. */
  65468. export class VirtualKeyboard extends StackPanel {
  65469. /** BABYLON.Observable raised when a key is pressed */
  65470. onKeyPressObservable: BABYLON.Observable<string>;
  65471. /** Gets or sets default key button width */
  65472. defaultButtonWidth: string;
  65473. /** Gets or sets default key button height */
  65474. defaultButtonHeight: string;
  65475. /** Gets or sets default key button left padding */
  65476. defaultButtonPaddingLeft: string;
  65477. /** Gets or sets default key button right padding */
  65478. defaultButtonPaddingRight: string;
  65479. /** Gets or sets default key button top padding */
  65480. defaultButtonPaddingTop: string;
  65481. /** Gets or sets default key button bottom padding */
  65482. defaultButtonPaddingBottom: string;
  65483. /** Gets or sets default key button foreground color */
  65484. defaultButtonColor: string;
  65485. /** Gets or sets default key button background color */
  65486. defaultButtonBackground: string;
  65487. /** Gets or sets shift button foreground color */
  65488. shiftButtonColor: string;
  65489. /** Gets or sets shift button thickness*/
  65490. selectedShiftThickness: number;
  65491. /** Gets shift key state */
  65492. shiftState: number;
  65493. protected _getTypeName(): string;
  65494. private _createKey;
  65495. /**
  65496. * Adds a new row of keys
  65497. * @param keys defines the list of keys to add
  65498. * @param propertySets defines the associated property sets
  65499. */
  65500. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  65501. /**
  65502. * Set the shift key to a specific state
  65503. * @param shiftState defines the new shift state
  65504. */
  65505. applyShiftState(shiftState: number): void;
  65506. private _currentlyConnectedInputText;
  65507. private _connectedInputTexts;
  65508. private _onKeyPressObserver;
  65509. /** Gets the input text control currently attached to the keyboard */
  65510. readonly connectedInputText: BABYLON.Nullable<InputText>;
  65511. /**
  65512. * Connects the keyboard with an input text control
  65513. *
  65514. * @param input defines the target control
  65515. */
  65516. connect(input: InputText): void;
  65517. /**
  65518. * Disconnects the keyboard from connected InputText controls
  65519. *
  65520. * @param input optionally defines a target control, otherwise all are disconnected
  65521. */
  65522. disconnect(input?: InputText): void;
  65523. private _removeConnectedInputObservables;
  65524. /**
  65525. * Release all resources
  65526. */
  65527. dispose(): void;
  65528. /**
  65529. * Creates a new keyboard using a default layout
  65530. *
  65531. * @param name defines control name
  65532. * @returns a new VirtualKeyboard
  65533. */
  65534. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  65535. }
  65536. }
  65537. declare module BABYLON.GUI {
  65538. /**
  65539. * Class used to create input text control
  65540. */
  65541. export class InputText extends Control implements IFocusableControl {
  65542. name?: string | undefined;
  65543. private _text;
  65544. private _placeholderText;
  65545. private _background;
  65546. private _focusedBackground;
  65547. private _focusedColor;
  65548. private _placeholderColor;
  65549. private _thickness;
  65550. private _margin;
  65551. private _autoStretchWidth;
  65552. private _maxWidth;
  65553. private _isFocused;
  65554. private _blinkTimeout;
  65555. private _blinkIsEven;
  65556. private _cursorOffset;
  65557. private _scrollLeft;
  65558. private _textWidth;
  65559. private _clickedCoordinate;
  65560. private _deadKey;
  65561. private _addKey;
  65562. private _currentKey;
  65563. private _isTextHighlightOn;
  65564. private _textHighlightColor;
  65565. private _highligherOpacity;
  65566. private _highlightedText;
  65567. private _startHighlightIndex;
  65568. private _endHighlightIndex;
  65569. private _cursorIndex;
  65570. private _onFocusSelectAll;
  65571. private _isPointerDown;
  65572. private _onClipboardObserver;
  65573. private _onPointerDblTapObserver;
  65574. /** @hidden */
  65575. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  65576. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  65577. promptMessage: string;
  65578. /** Force disable prompt on mobile device */
  65579. disableMobilePrompt: boolean;
  65580. /** BABYLON.Observable raised when the text changes */
  65581. onTextChangedObservable: BABYLON.Observable<InputText>;
  65582. /** BABYLON.Observable raised just before an entered character is to be added */
  65583. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  65584. /** BABYLON.Observable raised when the control gets the focus */
  65585. onFocusObservable: BABYLON.Observable<InputText>;
  65586. /** BABYLON.Observable raised when the control loses the focus */
  65587. onBlurObservable: BABYLON.Observable<InputText>;
  65588. /**Observable raised when the text is highlighted */
  65589. onTextHighlightObservable: BABYLON.Observable<InputText>;
  65590. /**Observable raised when copy event is triggered */
  65591. onTextCopyObservable: BABYLON.Observable<InputText>;
  65592. /** BABYLON.Observable raised when cut event is triggered */
  65593. onTextCutObservable: BABYLON.Observable<InputText>;
  65594. /** BABYLON.Observable raised when paste event is triggered */
  65595. onTextPasteObservable: BABYLON.Observable<InputText>;
  65596. /** BABYLON.Observable raised when a key event was processed */
  65597. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  65598. /** Gets or sets the maximum width allowed by the control */
  65599. maxWidth: string | number;
  65600. /** Gets the maximum width allowed by the control in pixels */
  65601. readonly maxWidthInPixels: number;
  65602. /** Gets or sets the text highlighter transparency; default: 0.4 */
  65603. highligherOpacity: number;
  65604. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  65605. onFocusSelectAll: boolean;
  65606. /** Gets or sets the text hightlight color */
  65607. textHighlightColor: string;
  65608. /** Gets or sets control margin */
  65609. margin: string;
  65610. /** Gets control margin in pixels */
  65611. readonly marginInPixels: number;
  65612. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  65613. autoStretchWidth: boolean;
  65614. /** Gets or sets border thickness */
  65615. thickness: number;
  65616. /** Gets or sets the background color when focused */
  65617. focusedBackground: string;
  65618. /** Gets or sets the background color when focused */
  65619. focusedColor: string;
  65620. /** Gets or sets the background color */
  65621. background: string;
  65622. /** Gets or sets the placeholder color */
  65623. placeholderColor: string;
  65624. /** Gets or sets the text displayed when the control is empty */
  65625. placeholderText: string;
  65626. /** Gets or sets the dead key flag */
  65627. deadKey: boolean;
  65628. /** Gets or sets the highlight text */
  65629. highlightedText: string;
  65630. /** Gets or sets if the current key should be added */
  65631. addKey: boolean;
  65632. /** Gets or sets the value of the current key being entered */
  65633. currentKey: string;
  65634. /** Gets or sets the text displayed in the control */
  65635. text: string;
  65636. /** Gets or sets control width */
  65637. width: string | number;
  65638. /**
  65639. * Creates a new InputText
  65640. * @param name defines the control name
  65641. * @param text defines the text of the control
  65642. */
  65643. constructor(name?: string | undefined, text?: string);
  65644. /** @hidden */
  65645. onBlur(): void;
  65646. /** @hidden */
  65647. onFocus(): void;
  65648. protected _getTypeName(): string;
  65649. /**
  65650. * Function called to get the list of controls that should not steal the focus from this control
  65651. * @returns an array of controls
  65652. */
  65653. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65654. /** @hidden */
  65655. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  65656. /** @hidden */
  65657. private _updateValueFromCursorIndex;
  65658. /** @hidden */
  65659. private _processDblClick;
  65660. /** @hidden */
  65661. private _selectAllText;
  65662. /**
  65663. * Handles the keyboard event
  65664. * @param evt Defines the KeyboardEvent
  65665. */
  65666. processKeyboard(evt: KeyboardEvent): void;
  65667. /** @hidden */
  65668. private _onCopyText;
  65669. /** @hidden */
  65670. private _onCutText;
  65671. /** @hidden */
  65672. private _onPasteText;
  65673. _draw(context: CanvasRenderingContext2D): void;
  65674. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65675. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65676. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65677. protected _beforeRenderText(text: string): string;
  65678. dispose(): void;
  65679. }
  65680. }
  65681. declare module BABYLON.GUI {
  65682. /**
  65683. * Class used to create a 2D grid container
  65684. */
  65685. export class Grid extends Container {
  65686. name?: string | undefined;
  65687. private _rowDefinitions;
  65688. private _columnDefinitions;
  65689. private _cells;
  65690. private _childControls;
  65691. /**
  65692. * Gets the number of columns
  65693. */
  65694. readonly columnCount: number;
  65695. /**
  65696. * Gets the number of rows
  65697. */
  65698. readonly rowCount: number;
  65699. /** Gets the list of children */
  65700. readonly children: Control[];
  65701. /** Gets the list of cells (e.g. the containers) */
  65702. readonly cells: {
  65703. [key: string]: Container;
  65704. };
  65705. /**
  65706. * Gets the definition of a specific row
  65707. * @param index defines the index of the row
  65708. * @returns the row definition
  65709. */
  65710. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65711. /**
  65712. * Gets the definition of a specific column
  65713. * @param index defines the index of the column
  65714. * @returns the column definition
  65715. */
  65716. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65717. /**
  65718. * Adds a new row to the grid
  65719. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65720. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  65721. * @returns the current grid
  65722. */
  65723. addRowDefinition(height: number, isPixel?: boolean): Grid;
  65724. /**
  65725. * Adds a new column to the grid
  65726. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65727. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65728. * @returns the current grid
  65729. */
  65730. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  65731. /**
  65732. * Update a row definition
  65733. * @param index defines the index of the row to update
  65734. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65735. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  65736. * @returns the current grid
  65737. */
  65738. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  65739. /**
  65740. * Update a column definition
  65741. * @param index defines the index of the column to update
  65742. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65743. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65744. * @returns the current grid
  65745. */
  65746. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  65747. /**
  65748. * Gets the list of children stored in a specific cell
  65749. * @param row defines the row to check
  65750. * @param column defines the column to check
  65751. * @returns the list of controls
  65752. */
  65753. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  65754. /**
  65755. * Gets a string representing the child cell info (row x column)
  65756. * @param child defines the control to get info from
  65757. * @returns a string containing the child cell info (row x column)
  65758. */
  65759. getChildCellInfo(child: Control): string;
  65760. private _removeCell;
  65761. private _offsetCell;
  65762. /**
  65763. * Remove a column definition at specified index
  65764. * @param index defines the index of the column to remove
  65765. * @returns the current grid
  65766. */
  65767. removeColumnDefinition(index: number): Grid;
  65768. /**
  65769. * Remove a row definition at specified index
  65770. * @param index defines the index of the row to remove
  65771. * @returns the current grid
  65772. */
  65773. removeRowDefinition(index: number): Grid;
  65774. /**
  65775. * Adds a new control to the current grid
  65776. * @param control defines the control to add
  65777. * @param row defines the row where to add the control (0 by default)
  65778. * @param column defines the column where to add the control (0 by default)
  65779. * @returns the current grid
  65780. */
  65781. addControl(control: Control, row?: number, column?: number): Grid;
  65782. /**
  65783. * Removes a control from the current container
  65784. * @param control defines the control to remove
  65785. * @returns the current container
  65786. */
  65787. removeControl(control: Control): Container;
  65788. /**
  65789. * Creates a new Grid
  65790. * @param name defines control name
  65791. */
  65792. constructor(name?: string | undefined);
  65793. protected _getTypeName(): string;
  65794. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  65795. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65796. _flagDescendantsAsMatrixDirty(): void;
  65797. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65798. /** Releases associated resources */
  65799. dispose(): void;
  65800. }
  65801. }
  65802. declare module BABYLON.GUI {
  65803. /** Class used to create color pickers */
  65804. export class ColorPicker extends Control {
  65805. name?: string | undefined;
  65806. private static _Epsilon;
  65807. private _colorWheelCanvas;
  65808. private _value;
  65809. private _tmpColor;
  65810. private _pointerStartedOnSquare;
  65811. private _pointerStartedOnWheel;
  65812. private _squareLeft;
  65813. private _squareTop;
  65814. private _squareSize;
  65815. private _h;
  65816. private _s;
  65817. private _v;
  65818. private _lastPointerDownID;
  65819. /**
  65820. * BABYLON.Observable raised when the value changes
  65821. */
  65822. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  65823. /** Gets or sets the color of the color picker */
  65824. value: BABYLON.Color3;
  65825. /**
  65826. * Gets or sets control width
  65827. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65828. */
  65829. width: string | number;
  65830. /**
  65831. * Gets or sets control height
  65832. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65833. */
  65834. /** Gets or sets control height */
  65835. height: string | number;
  65836. /** Gets or sets control size */
  65837. size: string | number;
  65838. /**
  65839. * Creates a new ColorPicker
  65840. * @param name defines the control name
  65841. */
  65842. constructor(name?: string | undefined);
  65843. protected _getTypeName(): string;
  65844. /** @hidden */
  65845. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65846. private _updateSquareProps;
  65847. private _drawGradientSquare;
  65848. private _drawCircle;
  65849. private _createColorWheelCanvas;
  65850. /** @hidden */
  65851. _draw(context: CanvasRenderingContext2D): void;
  65852. private _pointerIsDown;
  65853. private _updateValueFromPointer;
  65854. private _isPointOnSquare;
  65855. private _isPointOnWheel;
  65856. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65857. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65858. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65859. /**
  65860. * This function expands the color picker by creating a color picker dialog with manual
  65861. * color value input and the ability to save colors into an array to be used later in
  65862. * subsequent launches of the dialogue.
  65863. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  65864. * @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.
  65865. * @returns picked color as a hex string and the saved colors array as hex strings.
  65866. */
  65867. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  65868. pickerWidth?: string;
  65869. pickerHeight?: string;
  65870. headerHeight?: string;
  65871. lastColor?: string;
  65872. swatchLimit?: number;
  65873. numSwatchesPerLine?: number;
  65874. savedColors?: Array<string>;
  65875. }): Promise<{
  65876. savedColors?: string[];
  65877. pickedColor: string;
  65878. }>;
  65879. }
  65880. }
  65881. declare module BABYLON.GUI {
  65882. /** Class used to create 2D ellipse containers */
  65883. export class Ellipse extends Container {
  65884. name?: string | undefined;
  65885. private _thickness;
  65886. /** Gets or sets border thickness */
  65887. thickness: number;
  65888. /**
  65889. * Creates a new Ellipse
  65890. * @param name defines the control name
  65891. */
  65892. constructor(name?: string | undefined);
  65893. protected _getTypeName(): string;
  65894. protected _localDraw(context: CanvasRenderingContext2D): void;
  65895. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65896. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65897. }
  65898. }
  65899. declare module BABYLON.GUI {
  65900. /**
  65901. * Class used to create a password control
  65902. */
  65903. export class InputPassword extends InputText {
  65904. protected _beforeRenderText(text: string): string;
  65905. }
  65906. }
  65907. declare module BABYLON.GUI {
  65908. /** Class used to render 2D lines */
  65909. export class Line extends Control {
  65910. name?: string | undefined;
  65911. private _lineWidth;
  65912. private _x1;
  65913. private _y1;
  65914. private _x2;
  65915. private _y2;
  65916. private _dash;
  65917. private _connectedControl;
  65918. private _connectedControlDirtyObserver;
  65919. /** Gets or sets the dash pattern */
  65920. dash: Array<number>;
  65921. /** Gets or sets the control connected with the line end */
  65922. connectedControl: Control;
  65923. /** Gets or sets start coordinates on X axis */
  65924. x1: string | number;
  65925. /** Gets or sets start coordinates on Y axis */
  65926. y1: string | number;
  65927. /** Gets or sets end coordinates on X axis */
  65928. x2: string | number;
  65929. /** Gets or sets end coordinates on Y axis */
  65930. y2: string | number;
  65931. /** Gets or sets line width */
  65932. lineWidth: number;
  65933. /** Gets or sets horizontal alignment */
  65934. horizontalAlignment: number;
  65935. /** Gets or sets vertical alignment */
  65936. verticalAlignment: number;
  65937. private readonly _effectiveX2;
  65938. private readonly _effectiveY2;
  65939. /**
  65940. * Creates a new Line
  65941. * @param name defines the control name
  65942. */
  65943. constructor(name?: string | undefined);
  65944. protected _getTypeName(): string;
  65945. _draw(context: CanvasRenderingContext2D): void;
  65946. _measure(): void;
  65947. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65948. /**
  65949. * Move one end of the line given 3D cartesian coordinates.
  65950. * @param position Targeted world position
  65951. * @param scene BABYLON.Scene
  65952. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65953. */
  65954. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65955. /**
  65956. * Move one end of the line to a position in screen absolute space.
  65957. * @param projectedPosition Position in screen absolute space (X, Y)
  65958. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65959. */
  65960. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65961. }
  65962. }
  65963. declare module BABYLON.GUI {
  65964. /**
  65965. * Class used to store a point for a MultiLine object.
  65966. * The point can be pure 2D coordinates, a mesh or a control
  65967. */
  65968. export class MultiLinePoint {
  65969. private _multiLine;
  65970. private _x;
  65971. private _y;
  65972. private _control;
  65973. private _mesh;
  65974. private _controlObserver;
  65975. private _meshObserver;
  65976. /** @hidden */
  65977. _point: BABYLON.Vector2;
  65978. /**
  65979. * Creates a new MultiLinePoint
  65980. * @param multiLine defines the source MultiLine object
  65981. */
  65982. constructor(multiLine: MultiLine);
  65983. /** Gets or sets x coordinate */
  65984. x: string | number;
  65985. /** Gets or sets y coordinate */
  65986. y: string | number;
  65987. /** Gets or sets the control associated with this point */
  65988. control: BABYLON.Nullable<Control>;
  65989. /** Gets or sets the mesh associated with this point */
  65990. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65991. /** Resets links */
  65992. resetLinks(): void;
  65993. /**
  65994. * Gets a translation vector
  65995. * @returns the translation vector
  65996. */
  65997. translate(): BABYLON.Vector2;
  65998. private _translatePoint;
  65999. /** Release associated resources */
  66000. dispose(): void;
  66001. }
  66002. }
  66003. declare module BABYLON.GUI {
  66004. /**
  66005. * Class used to create multi line control
  66006. */
  66007. export class MultiLine extends Control {
  66008. name?: string | undefined;
  66009. private _lineWidth;
  66010. private _dash;
  66011. private _points;
  66012. private _minX;
  66013. private _minY;
  66014. private _maxX;
  66015. private _maxY;
  66016. /**
  66017. * Creates a new MultiLine
  66018. * @param name defines the control name
  66019. */
  66020. constructor(name?: string | undefined);
  66021. /** Gets or sets dash pattern */
  66022. dash: Array<number>;
  66023. /**
  66024. * Gets point stored at specified index
  66025. * @param index defines the index to look for
  66026. * @returns the requested point if found
  66027. */
  66028. getAt(index: number): MultiLinePoint;
  66029. /** Function called when a point is updated */
  66030. onPointUpdate: () => void;
  66031. /**
  66032. * Adds new points to the point collection
  66033. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  66034. * @returns the list of created MultiLinePoint
  66035. */
  66036. add(...items: (AbstractMesh | Control | {
  66037. x: string | number;
  66038. y: string | number;
  66039. })[]): MultiLinePoint[];
  66040. /**
  66041. * Adds a new point to the point collection
  66042. * @param item defines the item (mesh, control or 2d coordiantes) to add
  66043. * @returns the created MultiLinePoint
  66044. */
  66045. push(item?: (AbstractMesh | Control | {
  66046. x: string | number;
  66047. y: string | number;
  66048. })): MultiLinePoint;
  66049. /**
  66050. * Remove a specific value or point from the active point collection
  66051. * @param value defines the value or point to remove
  66052. */
  66053. remove(value: number | MultiLinePoint): void;
  66054. /**
  66055. * Resets this object to initial state (no point)
  66056. */
  66057. reset(): void;
  66058. /**
  66059. * Resets all links
  66060. */
  66061. resetLinks(): void;
  66062. /** Gets or sets line width */
  66063. lineWidth: number;
  66064. horizontalAlignment: number;
  66065. verticalAlignment: number;
  66066. protected _getTypeName(): string;
  66067. _draw(context: CanvasRenderingContext2D): void;
  66068. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66069. _measure(): void;
  66070. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66071. dispose(): void;
  66072. }
  66073. }
  66074. declare module BABYLON.GUI {
  66075. /**
  66076. * Class used to create radio button controls
  66077. */
  66078. export class RadioButton extends Control {
  66079. name?: string | undefined;
  66080. private _isChecked;
  66081. private _background;
  66082. private _checkSizeRatio;
  66083. private _thickness;
  66084. /** Gets or sets border thickness */
  66085. thickness: number;
  66086. /** Gets or sets group name */
  66087. group: string;
  66088. /** BABYLON.Observable raised when isChecked is changed */
  66089. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66090. /** Gets or sets a value indicating the ratio between overall size and check size */
  66091. checkSizeRatio: number;
  66092. /** Gets or sets background color */
  66093. background: string;
  66094. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66095. isChecked: boolean;
  66096. /**
  66097. * Creates a new RadioButton
  66098. * @param name defines the control name
  66099. */
  66100. constructor(name?: string | undefined);
  66101. protected _getTypeName(): string;
  66102. _draw(context: CanvasRenderingContext2D): void;
  66103. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66104. /**
  66105. * Utility function to easily create a radio button with a header
  66106. * @param title defines the label to use for the header
  66107. * @param group defines the group to use for the radio button
  66108. * @param isChecked defines the initial state of the radio button
  66109. * @param onValueChanged defines the callback to call when value changes
  66110. * @returns a StackPanel containing the radio button and a textBlock
  66111. */
  66112. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  66113. }
  66114. }
  66115. declare module BABYLON.GUI {
  66116. /**
  66117. * Class used to create slider controls
  66118. */
  66119. export class BaseSlider extends Control {
  66120. name?: string | undefined;
  66121. protected _thumbWidth: ValueAndUnit;
  66122. private _minimum;
  66123. private _maximum;
  66124. private _value;
  66125. private _isVertical;
  66126. protected _barOffset: ValueAndUnit;
  66127. private _isThumbClamped;
  66128. protected _displayThumb: boolean;
  66129. private _step;
  66130. private _lastPointerDownID;
  66131. protected _effectiveBarOffset: number;
  66132. protected _renderLeft: number;
  66133. protected _renderTop: number;
  66134. protected _renderWidth: number;
  66135. protected _renderHeight: number;
  66136. protected _backgroundBoxLength: number;
  66137. protected _backgroundBoxThickness: number;
  66138. protected _effectiveThumbThickness: number;
  66139. /** BABYLON.Observable raised when the sldier value changes */
  66140. onValueChangedObservable: BABYLON.Observable<number>;
  66141. /** Gets or sets a boolean indicating if the thumb must be rendered */
  66142. displayThumb: boolean;
  66143. /** Gets or sets a step to apply to values (0 by default) */
  66144. step: number;
  66145. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  66146. barOffset: string | number;
  66147. /** Gets main bar offset in pixels*/
  66148. readonly barOffsetInPixels: number;
  66149. /** Gets or sets thumb width */
  66150. thumbWidth: string | number;
  66151. /** Gets thumb width in pixels */
  66152. readonly thumbWidthInPixels: number;
  66153. /** Gets or sets minimum value */
  66154. minimum: number;
  66155. /** Gets or sets maximum value */
  66156. maximum: number;
  66157. /** Gets or sets current value */
  66158. value: number;
  66159. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  66160. isVertical: boolean;
  66161. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  66162. isThumbClamped: boolean;
  66163. /**
  66164. * Creates a new BaseSlider
  66165. * @param name defines the control name
  66166. */
  66167. constructor(name?: string | undefined);
  66168. protected _getTypeName(): string;
  66169. protected _getThumbPosition(): number;
  66170. protected _getThumbThickness(type: string): number;
  66171. protected _prepareRenderingData(type: string): void;
  66172. private _pointerIsDown;
  66173. /** @hidden */
  66174. protected _updateValueFromPointer(x: number, y: number): void;
  66175. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66176. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66177. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66178. }
  66179. }
  66180. declare module BABYLON.GUI {
  66181. /**
  66182. * Class used to create slider controls
  66183. */
  66184. export class Slider extends BaseSlider {
  66185. name?: string | undefined;
  66186. private _background;
  66187. private _borderColor;
  66188. private _isThumbCircle;
  66189. protected _displayValueBar: boolean;
  66190. /** Gets or sets a boolean indicating if the value bar must be rendered */
  66191. displayValueBar: boolean;
  66192. /** Gets or sets border color */
  66193. borderColor: string;
  66194. /** Gets or sets background color */
  66195. background: string;
  66196. /** Gets or sets a boolean indicating if the thumb should be round or square */
  66197. isThumbCircle: boolean;
  66198. /**
  66199. * Creates a new Slider
  66200. * @param name defines the control name
  66201. */
  66202. constructor(name?: string | undefined);
  66203. protected _getTypeName(): string;
  66204. _draw(context: CanvasRenderingContext2D): void;
  66205. }
  66206. }
  66207. declare module BABYLON.GUI {
  66208. /** Class used to create a RadioGroup
  66209. * which contains groups of radio buttons
  66210. */
  66211. export class SelectorGroup {
  66212. /** name of SelectorGroup */
  66213. name: string;
  66214. private _groupPanel;
  66215. private _selectors;
  66216. private _groupHeader;
  66217. /**
  66218. * Creates a new SelectorGroup
  66219. * @param name of group, used as a group heading
  66220. */
  66221. constructor(
  66222. /** name of SelectorGroup */
  66223. name: string);
  66224. /** Gets the groupPanel of the SelectorGroup */
  66225. readonly groupPanel: StackPanel;
  66226. /** Gets the selectors array */
  66227. readonly selectors: StackPanel[];
  66228. /** Gets and sets the group header */
  66229. header: string;
  66230. /** @hidden */
  66231. private _addGroupHeader;
  66232. /** @hidden*/
  66233. _getSelector(selectorNb: number): StackPanel | undefined;
  66234. /** Removes the selector at the given position
  66235. * @param selectorNb the position of the selector within the group
  66236. */
  66237. removeSelector(selectorNb: number): void;
  66238. }
  66239. /** Class used to create a CheckboxGroup
  66240. * which contains groups of checkbox buttons
  66241. */
  66242. export class CheckboxGroup extends SelectorGroup {
  66243. /** Adds a checkbox as a control
  66244. * @param text is the label for the selector
  66245. * @param func is the function called when the Selector is checked
  66246. * @param checked is true when Selector is checked
  66247. */
  66248. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  66249. /** @hidden */
  66250. _setSelectorLabel(selectorNb: number, label: string): void;
  66251. /** @hidden */
  66252. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66253. /** @hidden */
  66254. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66255. /** @hidden */
  66256. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66257. }
  66258. /** Class used to create a RadioGroup
  66259. * which contains groups of radio buttons
  66260. */
  66261. export class RadioGroup extends SelectorGroup {
  66262. private _selectNb;
  66263. /** Adds a radio button as a control
  66264. * @param label is the label for the selector
  66265. * @param func is the function called when the Selector is checked
  66266. * @param checked is true when Selector is checked
  66267. */
  66268. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  66269. /** @hidden */
  66270. _setSelectorLabel(selectorNb: number, label: string): void;
  66271. /** @hidden */
  66272. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66273. /** @hidden */
  66274. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66275. /** @hidden */
  66276. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66277. }
  66278. /** Class used to create a SliderGroup
  66279. * which contains groups of slider buttons
  66280. */
  66281. export class SliderGroup extends SelectorGroup {
  66282. /**
  66283. * Adds a slider to the SelectorGroup
  66284. * @param label is the label for the SliderBar
  66285. * @param func is the function called when the Slider moves
  66286. * @param unit is a string describing the units used, eg degrees or metres
  66287. * @param min is the minimum value for the Slider
  66288. * @param max is the maximum value for the Slider
  66289. * @param value is the start value for the Slider between min and max
  66290. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  66291. */
  66292. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  66293. /** @hidden */
  66294. _setSelectorLabel(selectorNb: number, label: string): void;
  66295. /** @hidden */
  66296. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66297. /** @hidden */
  66298. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66299. /** @hidden */
  66300. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66301. }
  66302. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  66303. * @see http://doc.babylonjs.com/how_to/selector
  66304. */
  66305. export class SelectionPanel extends Rectangle {
  66306. /** name of SelectionPanel */
  66307. name: string;
  66308. /** an array of SelectionGroups */
  66309. groups: SelectorGroup[];
  66310. private _panel;
  66311. private _buttonColor;
  66312. private _buttonBackground;
  66313. private _headerColor;
  66314. private _barColor;
  66315. private _barHeight;
  66316. private _spacerHeight;
  66317. private _labelColor;
  66318. private _groups;
  66319. private _bars;
  66320. /**
  66321. * Creates a new SelectionPanel
  66322. * @param name of SelectionPanel
  66323. * @param groups is an array of SelectionGroups
  66324. */
  66325. constructor(
  66326. /** name of SelectionPanel */
  66327. name: string,
  66328. /** an array of SelectionGroups */
  66329. groups?: SelectorGroup[]);
  66330. protected _getTypeName(): string;
  66331. /** Gets or sets the headerColor */
  66332. headerColor: string;
  66333. private _setHeaderColor;
  66334. /** Gets or sets the button color */
  66335. buttonColor: string;
  66336. private _setbuttonColor;
  66337. /** Gets or sets the label color */
  66338. labelColor: string;
  66339. private _setLabelColor;
  66340. /** Gets or sets the button background */
  66341. buttonBackground: string;
  66342. private _setButtonBackground;
  66343. /** Gets or sets the color of separator bar */
  66344. barColor: string;
  66345. private _setBarColor;
  66346. /** Gets or sets the height of separator bar */
  66347. barHeight: string;
  66348. private _setBarHeight;
  66349. /** Gets or sets the height of spacers*/
  66350. spacerHeight: string;
  66351. private _setSpacerHeight;
  66352. /** Adds a bar between groups */
  66353. private _addSpacer;
  66354. /** Add a group to the selection panel
  66355. * @param group is the selector group to add
  66356. */
  66357. addGroup(group: SelectorGroup): void;
  66358. /** Remove the group from the given position
  66359. * @param groupNb is the position of the group in the list
  66360. */
  66361. removeGroup(groupNb: number): void;
  66362. /** Change a group header label
  66363. * @param label is the new group header label
  66364. * @param groupNb is the number of the group to relabel
  66365. * */
  66366. setHeaderName(label: string, groupNb: number): void;
  66367. /** Change selector label to the one given
  66368. * @param label is the new selector label
  66369. * @param groupNb is the number of the groupcontaining the selector
  66370. * @param selectorNb is the number of the selector within a group to relabel
  66371. * */
  66372. relabel(label: string, groupNb: number, selectorNb: number): void;
  66373. /** For a given group position remove the selector at the given position
  66374. * @param groupNb is the number of the group to remove the selector from
  66375. * @param selectorNb is the number of the selector within the group
  66376. */
  66377. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  66378. /** For a given group position of correct type add a checkbox button
  66379. * @param groupNb is the number of the group to remove the selector from
  66380. * @param label is the label for the selector
  66381. * @param func is the function called when the Selector is checked
  66382. * @param checked is true when Selector is checked
  66383. */
  66384. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66385. /** For a given group position of correct type add a radio button
  66386. * @param groupNb is the number of the group to remove the selector from
  66387. * @param label is the label for the selector
  66388. * @param func is the function called when the Selector is checked
  66389. * @param checked is true when Selector is checked
  66390. */
  66391. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66392. /**
  66393. * For a given slider group add a slider
  66394. * @param groupNb is the number of the group to add the slider to
  66395. * @param label is the label for the Slider
  66396. * @param func is the function called when the Slider moves
  66397. * @param unit is a string describing the units used, eg degrees or metres
  66398. * @param min is the minimum value for the Slider
  66399. * @param max is the maximum value for the Slider
  66400. * @param value is the start value for the Slider between min and max
  66401. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66402. */
  66403. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66404. }
  66405. }
  66406. declare module BABYLON.GUI {
  66407. /**
  66408. * Class used to hold a the container for ScrollViewer
  66409. * @hidden
  66410. */
  66411. export class _ScrollViewerWindow extends Container {
  66412. parentClientWidth: number;
  66413. parentClientHeight: number;
  66414. /**
  66415. * Creates a new ScrollViewerWindow
  66416. * @param name of ScrollViewerWindow
  66417. */
  66418. constructor(name?: string);
  66419. protected _getTypeName(): string;
  66420. /** @hidden */
  66421. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66422. protected _postMeasure(): void;
  66423. }
  66424. }
  66425. declare module BABYLON.GUI {
  66426. /**
  66427. * Class used to create slider controls
  66428. */
  66429. export class ScrollBar extends BaseSlider {
  66430. name?: string | undefined;
  66431. private _background;
  66432. private _borderColor;
  66433. private _thumbMeasure;
  66434. /** Gets or sets border color */
  66435. borderColor: string;
  66436. /** Gets or sets background color */
  66437. background: string;
  66438. /**
  66439. * Creates a new Slider
  66440. * @param name defines the control name
  66441. */
  66442. constructor(name?: string | undefined);
  66443. protected _getTypeName(): string;
  66444. protected _getThumbThickness(): number;
  66445. _draw(context: CanvasRenderingContext2D): void;
  66446. private _first;
  66447. private _originX;
  66448. private _originY;
  66449. /** @hidden */
  66450. protected _updateValueFromPointer(x: number, y: number): void;
  66451. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66452. }
  66453. }
  66454. declare module BABYLON.GUI {
  66455. /**
  66456. * Class used to hold a viewer window and sliders in a grid
  66457. */
  66458. export class ScrollViewer extends Rectangle {
  66459. private _grid;
  66460. private _horizontalBarSpace;
  66461. private _verticalBarSpace;
  66462. private _dragSpace;
  66463. private _horizontalBar;
  66464. private _verticalBar;
  66465. private _barColor;
  66466. private _barBackground;
  66467. private _barSize;
  66468. private _endLeft;
  66469. private _endTop;
  66470. private _window;
  66471. private _pointerIsOver;
  66472. private _wheelPrecision;
  66473. private _onPointerObserver;
  66474. private _clientWidth;
  66475. private _clientHeight;
  66476. /**
  66477. * Gets the horizontal scrollbar
  66478. */
  66479. readonly horizontalBar: ScrollBar;
  66480. /**
  66481. * Gets the vertical scrollbar
  66482. */
  66483. readonly verticalBar: ScrollBar;
  66484. /**
  66485. * Adds a new control to the current container
  66486. * @param control defines the control to add
  66487. * @returns the current container
  66488. */
  66489. addControl(control: BABYLON.Nullable<Control>): Container;
  66490. /**
  66491. * Removes a control from the current container
  66492. * @param control defines the control to remove
  66493. * @returns the current container
  66494. */
  66495. removeControl(control: Control): Container;
  66496. /** Gets the list of children */
  66497. readonly children: Control[];
  66498. _flagDescendantsAsMatrixDirty(): void;
  66499. /**
  66500. * Creates a new ScrollViewer
  66501. * @param name of ScrollViewer
  66502. */
  66503. constructor(name?: string);
  66504. /** Reset the scroll viewer window to initial size */
  66505. resetWindow(): void;
  66506. protected _getTypeName(): string;
  66507. private _buildClientSizes;
  66508. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66509. protected _postMeasure(): void;
  66510. /**
  66511. * Gets or sets the mouse wheel precision
  66512. * from 0 to 1 with a default value of 0.05
  66513. * */
  66514. wheelPrecision: number;
  66515. /** Gets or sets the bar color */
  66516. barColor: string;
  66517. /** Gets or sets the size of the bar */
  66518. barSize: number;
  66519. /** Gets or sets the bar background */
  66520. barBackground: string;
  66521. /** @hidden */
  66522. private _updateScroller;
  66523. _link(host: AdvancedDynamicTexture): void;
  66524. /** @hidden */
  66525. private _attachWheel;
  66526. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66527. /** Releases associated resources */
  66528. dispose(): void;
  66529. }
  66530. }
  66531. declare module BABYLON.GUI {
  66532. /** Class used to render a grid */
  66533. export class DisplayGrid extends Control {
  66534. name?: string | undefined;
  66535. private _cellWidth;
  66536. private _cellHeight;
  66537. private _minorLineTickness;
  66538. private _minorLineColor;
  66539. private _majorLineTickness;
  66540. private _majorLineColor;
  66541. private _majorLineFrequency;
  66542. private _background;
  66543. private _displayMajorLines;
  66544. private _displayMinorLines;
  66545. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  66546. displayMinorLines: boolean;
  66547. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  66548. displayMajorLines: boolean;
  66549. /** Gets or sets background color (Black by default) */
  66550. background: string;
  66551. /** Gets or sets the width of each cell (20 by default) */
  66552. cellWidth: number;
  66553. /** Gets or sets the height of each cell (20 by default) */
  66554. cellHeight: number;
  66555. /** Gets or sets the tickness of minor lines (1 by default) */
  66556. minorLineTickness: number;
  66557. /** Gets or sets the color of minor lines (DarkGray by default) */
  66558. minorLineColor: string;
  66559. /** Gets or sets the tickness of major lines (2 by default) */
  66560. majorLineTickness: number;
  66561. /** Gets or sets the color of major lines (White by default) */
  66562. majorLineColor: string;
  66563. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  66564. majorLineFrequency: number;
  66565. /**
  66566. * Creates a new GridDisplayRectangle
  66567. * @param name defines the control name
  66568. */
  66569. constructor(name?: string | undefined);
  66570. _draw(context: CanvasRenderingContext2D): void;
  66571. protected _getTypeName(): string;
  66572. }
  66573. }
  66574. declare module BABYLON.GUI {
  66575. /**
  66576. * Class used to create slider controls based on images
  66577. */
  66578. export class ImageBasedSlider extends BaseSlider {
  66579. name?: string | undefined;
  66580. private _backgroundImage;
  66581. private _thumbImage;
  66582. private _valueBarImage;
  66583. private _tempMeasure;
  66584. displayThumb: boolean;
  66585. /**
  66586. * Gets or sets the image used to render the background
  66587. */
  66588. backgroundImage: Image;
  66589. /**
  66590. * Gets or sets the image used to render the value bar
  66591. */
  66592. valueBarImage: Image;
  66593. /**
  66594. * Gets or sets the image used to render the thumb
  66595. */
  66596. thumbImage: Image;
  66597. /**
  66598. * Creates a new ImageBasedSlider
  66599. * @param name defines the control name
  66600. */
  66601. constructor(name?: string | undefined);
  66602. protected _getTypeName(): string;
  66603. _draw(context: CanvasRenderingContext2D): void;
  66604. }
  66605. }
  66606. declare module BABYLON.GUI {
  66607. /**
  66608. * Forcing an export so that this code will execute
  66609. * @hidden
  66610. */
  66611. const name = "Statics";
  66612. }
  66613. declare module BABYLON.GUI {
  66614. /**
  66615. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  66616. */
  66617. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  66618. /**
  66619. * Define the instrumented AdvancedDynamicTexture.
  66620. */
  66621. texture: AdvancedDynamicTexture;
  66622. private _captureRenderTime;
  66623. private _renderTime;
  66624. private _captureLayoutTime;
  66625. private _layoutTime;
  66626. private _onBeginRenderObserver;
  66627. private _onEndRenderObserver;
  66628. private _onBeginLayoutObserver;
  66629. private _onEndLayoutObserver;
  66630. /**
  66631. * Gets the perf counter used to capture render time
  66632. */
  66633. readonly renderTimeCounter: BABYLON.PerfCounter;
  66634. /**
  66635. * Gets the perf counter used to capture layout time
  66636. */
  66637. readonly layoutTimeCounter: BABYLON.PerfCounter;
  66638. /**
  66639. * Enable or disable the render time capture
  66640. */
  66641. captureRenderTime: boolean;
  66642. /**
  66643. * Enable or disable the layout time capture
  66644. */
  66645. captureLayoutTime: boolean;
  66646. /**
  66647. * Instantiates a new advanced dynamic texture instrumentation.
  66648. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  66649. * @param texture Defines the AdvancedDynamicTexture to instrument
  66650. */
  66651. constructor(
  66652. /**
  66653. * Define the instrumented AdvancedDynamicTexture.
  66654. */
  66655. texture: AdvancedDynamicTexture);
  66656. /**
  66657. * Dispose and release associated resources.
  66658. */
  66659. dispose(): void;
  66660. }
  66661. }
  66662. declare module BABYLON.GUI {
  66663. /**
  66664. * Class used to load GUI via XML.
  66665. */
  66666. export class XmlLoader {
  66667. private _nodes;
  66668. private _nodeTypes;
  66669. private _isLoaded;
  66670. private _objectAttributes;
  66671. private _parentClass;
  66672. /**
  66673. * Create a new xml loader
  66674. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  66675. */
  66676. constructor(parentClass?: null);
  66677. private _getChainElement;
  66678. private _getClassAttribute;
  66679. private _createGuiElement;
  66680. private _parseGrid;
  66681. private _parseElement;
  66682. private _prepareSourceElement;
  66683. private _parseElementsFromSource;
  66684. private _parseXml;
  66685. /**
  66686. * Gets if the loading has finished.
  66687. * @returns whether the loading has finished or not
  66688. */
  66689. isLoaded(): boolean;
  66690. /**
  66691. * Gets a loaded node / control by id.
  66692. * @param id the Controls id set in the xml
  66693. * @returns element of type Control
  66694. */
  66695. getNodeById(id: string): any;
  66696. /**
  66697. * Gets all loaded nodes / controls
  66698. * @returns Array of controls
  66699. */
  66700. getNodes(): any;
  66701. /**
  66702. * Initiates the xml layout loading
  66703. * @param xmlFile defines the xml layout to load
  66704. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  66705. * @param callback defines the callback called on layout load.
  66706. */
  66707. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  66708. }
  66709. }
  66710. declare module BABYLON.GUI {
  66711. /**
  66712. * Class used to create containers for controls
  66713. */
  66714. export class Container3D extends Control3D {
  66715. private _blockLayout;
  66716. /**
  66717. * Gets the list of child controls
  66718. */
  66719. protected _children: Control3D[];
  66720. /**
  66721. * Gets the list of child controls
  66722. */
  66723. readonly children: Array<Control3D>;
  66724. /**
  66725. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  66726. * This is helpful to optimize layout operation when adding multiple children in a row
  66727. */
  66728. blockLayout: boolean;
  66729. /**
  66730. * Creates a new container
  66731. * @param name defines the container name
  66732. */
  66733. constructor(name?: string);
  66734. /**
  66735. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  66736. * @returns the current container
  66737. */
  66738. updateLayout(): Container3D;
  66739. /**
  66740. * Gets a boolean indicating if the given control is in the children of this control
  66741. * @param control defines the control to check
  66742. * @returns true if the control is in the child list
  66743. */
  66744. containsControl(control: Control3D): boolean;
  66745. /**
  66746. * Adds a control to the children of this control
  66747. * @param control defines the control to add
  66748. * @returns the current container
  66749. */
  66750. addControl(control: Control3D): Container3D;
  66751. /**
  66752. * This function will be called everytime a new control is added
  66753. */
  66754. protected _arrangeChildren(): void;
  66755. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66756. /**
  66757. * Removes a control from the children of this control
  66758. * @param control defines the control to remove
  66759. * @returns the current container
  66760. */
  66761. removeControl(control: Control3D): Container3D;
  66762. protected _getTypeName(): string;
  66763. /**
  66764. * Releases all associated resources
  66765. */
  66766. dispose(): void;
  66767. /** Control rotation will remain unchanged */
  66768. static readonly UNSET_ORIENTATION: number;
  66769. /** Control will rotate to make it look at sphere central axis */
  66770. static readonly FACEORIGIN_ORIENTATION: number;
  66771. /** Control will rotate to make it look back at sphere central axis */
  66772. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  66773. /** Control will rotate to look at z axis (0, 0, 1) */
  66774. static readonly FACEFORWARD_ORIENTATION: number;
  66775. /** Control will rotate to look at negative z axis (0, 0, -1) */
  66776. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  66777. }
  66778. }
  66779. declare module BABYLON.GUI {
  66780. /**
  66781. * Class used to manage 3D user interface
  66782. * @see http://doc.babylonjs.com/how_to/gui3d
  66783. */
  66784. export class GUI3DManager implements BABYLON.IDisposable {
  66785. private _scene;
  66786. private _sceneDisposeObserver;
  66787. private _utilityLayer;
  66788. private _rootContainer;
  66789. private _pointerObserver;
  66790. private _pointerOutObserver;
  66791. /** @hidden */
  66792. _lastPickedControl: Control3D;
  66793. /** @hidden */
  66794. _lastControlOver: {
  66795. [pointerId: number]: Control3D;
  66796. };
  66797. /** @hidden */
  66798. _lastControlDown: {
  66799. [pointerId: number]: Control3D;
  66800. };
  66801. /**
  66802. * BABYLON.Observable raised when the point picked by the pointer events changed
  66803. */
  66804. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  66805. /** @hidden */
  66806. _sharedMaterials: {
  66807. [key: string]: BABYLON.Material;
  66808. };
  66809. /** Gets the hosting scene */
  66810. readonly scene: BABYLON.Scene;
  66811. /** Gets associated utility layer */
  66812. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  66813. /**
  66814. * Creates a new GUI3DManager
  66815. * @param scene
  66816. */
  66817. constructor(scene?: BABYLON.Scene);
  66818. private _handlePointerOut;
  66819. private _doPicking;
  66820. /**
  66821. * Gets the root container
  66822. */
  66823. readonly rootContainer: Container3D;
  66824. /**
  66825. * Gets a boolean indicating if the given control is in the root child list
  66826. * @param control defines the control to check
  66827. * @returns true if the control is in the root child list
  66828. */
  66829. containsControl(control: Control3D): boolean;
  66830. /**
  66831. * Adds a control to the root child list
  66832. * @param control defines the control to add
  66833. * @returns the current manager
  66834. */
  66835. addControl(control: Control3D): GUI3DManager;
  66836. /**
  66837. * Removes a control from the root child list
  66838. * @param control defines the control to remove
  66839. * @returns the current container
  66840. */
  66841. removeControl(control: Control3D): GUI3DManager;
  66842. /**
  66843. * Releases all associated resources
  66844. */
  66845. dispose(): void;
  66846. }
  66847. }
  66848. declare module BABYLON.GUI {
  66849. /**
  66850. * Class used to transport BABYLON.Vector3 information for pointer events
  66851. */
  66852. export class Vector3WithInfo extends BABYLON.Vector3 {
  66853. /** defines the current mouse button index */
  66854. buttonIndex: number;
  66855. /**
  66856. * Creates a new Vector3WithInfo
  66857. * @param source defines the vector3 data to transport
  66858. * @param buttonIndex defines the current mouse button index
  66859. */
  66860. constructor(source: BABYLON.Vector3,
  66861. /** defines the current mouse button index */
  66862. buttonIndex?: number);
  66863. }
  66864. }
  66865. declare module BABYLON.GUI {
  66866. /**
  66867. * Class used as base class for controls
  66868. */
  66869. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  66870. /** Defines the control name */
  66871. name?: string | undefined;
  66872. /** @hidden */
  66873. _host: GUI3DManager;
  66874. private _node;
  66875. private _downCount;
  66876. private _enterCount;
  66877. private _downPointerIds;
  66878. private _isVisible;
  66879. /** Gets or sets the control position in world space */
  66880. position: BABYLON.Vector3;
  66881. /** Gets or sets the control scaling in world space */
  66882. scaling: BABYLON.Vector3;
  66883. /** Callback used to start pointer enter animation */
  66884. pointerEnterAnimation: () => void;
  66885. /** Callback used to start pointer out animation */
  66886. pointerOutAnimation: () => void;
  66887. /** Callback used to start pointer down animation */
  66888. pointerDownAnimation: () => void;
  66889. /** Callback used to start pointer up animation */
  66890. pointerUpAnimation: () => void;
  66891. /**
  66892. * An event triggered when the pointer move over the control
  66893. */
  66894. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  66895. /**
  66896. * An event triggered when the pointer move out of the control
  66897. */
  66898. onPointerOutObservable: BABYLON.Observable<Control3D>;
  66899. /**
  66900. * An event triggered when the pointer taps the control
  66901. */
  66902. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  66903. /**
  66904. * An event triggered when pointer is up
  66905. */
  66906. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  66907. /**
  66908. * An event triggered when a control is clicked on (with a mouse)
  66909. */
  66910. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  66911. /**
  66912. * An event triggered when pointer enters the control
  66913. */
  66914. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  66915. /**
  66916. * Gets or sets the parent container
  66917. */
  66918. parent: BABYLON.Nullable<Container3D>;
  66919. private _behaviors;
  66920. /**
  66921. * Gets the list of attached behaviors
  66922. * @see http://doc.babylonjs.com/features/behaviour
  66923. */
  66924. readonly behaviors: BABYLON.Behavior<Control3D>[];
  66925. /**
  66926. * Attach a behavior to the control
  66927. * @see http://doc.babylonjs.com/features/behaviour
  66928. * @param behavior defines the behavior to attach
  66929. * @returns the current control
  66930. */
  66931. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66932. /**
  66933. * Remove an attached behavior
  66934. * @see http://doc.babylonjs.com/features/behaviour
  66935. * @param behavior defines the behavior to attach
  66936. * @returns the current control
  66937. */
  66938. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66939. /**
  66940. * Gets an attached behavior by name
  66941. * @param name defines the name of the behavior to look for
  66942. * @see http://doc.babylonjs.com/features/behaviour
  66943. * @returns null if behavior was not found else the requested behavior
  66944. */
  66945. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  66946. /** Gets or sets a boolean indicating if the control is visible */
  66947. isVisible: boolean;
  66948. /**
  66949. * Creates a new control
  66950. * @param name defines the control name
  66951. */
  66952. constructor(
  66953. /** Defines the control name */
  66954. name?: string | undefined);
  66955. /**
  66956. * Gets a string representing the class name
  66957. */
  66958. readonly typeName: string;
  66959. /**
  66960. * Get the current class name of the control.
  66961. * @returns current class name
  66962. */
  66963. getClassName(): string;
  66964. protected _getTypeName(): string;
  66965. /**
  66966. * Gets the transform node used by this control
  66967. */
  66968. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  66969. /**
  66970. * Gets the mesh used to render this control
  66971. */
  66972. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66973. /**
  66974. * Link the control as child of the given node
  66975. * @param node defines the node to link to. Use null to unlink the control
  66976. * @returns the current control
  66977. */
  66978. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  66979. /** @hidden **/
  66980. _prepareNode(scene: BABYLON.Scene): void;
  66981. /**
  66982. * Node creation.
  66983. * Can be overriden by children
  66984. * @param scene defines the scene where the node must be attached
  66985. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66986. */
  66987. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66988. /**
  66989. * Affect a material to the given mesh
  66990. * @param mesh defines the mesh which will represent the control
  66991. */
  66992. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66993. /** @hidden */
  66994. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66995. /** @hidden */
  66996. _onPointerEnter(target: Control3D): boolean;
  66997. /** @hidden */
  66998. _onPointerOut(target: Control3D): void;
  66999. /** @hidden */
  67000. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67001. /** @hidden */
  67002. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67003. /** @hidden */
  67004. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67005. /** @hidden */
  67006. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67007. /** @hidden */
  67008. _disposeNode(): void;
  67009. /**
  67010. * Releases all associated resources
  67011. */
  67012. dispose(): void;
  67013. }
  67014. }
  67015. declare module BABYLON.GUI {
  67016. /**
  67017. * Class used as a root to all buttons
  67018. */
  67019. export class AbstractButton3D extends Control3D {
  67020. /**
  67021. * Creates a new button
  67022. * @param name defines the control name
  67023. */
  67024. constructor(name?: string);
  67025. protected _getTypeName(): string;
  67026. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67027. }
  67028. }
  67029. declare module BABYLON.GUI {
  67030. /**
  67031. * Class used to create a button in 3D
  67032. */
  67033. export class Button3D extends AbstractButton3D {
  67034. /** @hidden */
  67035. protected _currentMaterial: BABYLON.Material;
  67036. private _facadeTexture;
  67037. private _content;
  67038. private _contentResolution;
  67039. private _contentScaleRatio;
  67040. /**
  67041. * Gets or sets the texture resolution used to render content (512 by default)
  67042. */
  67043. contentResolution: BABYLON.int;
  67044. /**
  67045. * Gets or sets the texture scale ratio used to render content (2 by default)
  67046. */
  67047. contentScaleRatio: number;
  67048. protected _disposeFacadeTexture(): void;
  67049. protected _resetContent(): void;
  67050. /**
  67051. * Creates a new button
  67052. * @param name defines the control name
  67053. */
  67054. constructor(name?: string);
  67055. /**
  67056. * Gets or sets the GUI 2D content used to display the button's facade
  67057. */
  67058. content: Control;
  67059. /**
  67060. * Apply the facade texture (created from the content property).
  67061. * This function can be overloaded by child classes
  67062. * @param facadeTexture defines the AdvancedDynamicTexture to use
  67063. */
  67064. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67065. protected _getTypeName(): string;
  67066. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67067. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67068. /**
  67069. * Releases all associated resources
  67070. */
  67071. dispose(): void;
  67072. }
  67073. }
  67074. declare module BABYLON.GUI {
  67075. /**
  67076. * Abstract class used to create a container panel deployed on the surface of a volume
  67077. */
  67078. export abstract class VolumeBasedPanel extends Container3D {
  67079. private _columns;
  67080. private _rows;
  67081. private _rowThenColum;
  67082. private _orientation;
  67083. protected _cellWidth: number;
  67084. protected _cellHeight: number;
  67085. /**
  67086. * Gets or sets the distance between elements
  67087. */
  67088. margin: number;
  67089. /**
  67090. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  67091. * | Value | Type | Description |
  67092. * | ----- | ----------------------------------- | ----------- |
  67093. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  67094. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  67095. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  67096. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  67097. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  67098. */
  67099. orientation: number;
  67100. /**
  67101. * Gets or sets the number of columns requested (10 by default).
  67102. * The panel will automatically compute the number of rows based on number of child controls.
  67103. */
  67104. columns: BABYLON.int;
  67105. /**
  67106. * Gets or sets a the number of rows requested.
  67107. * The panel will automatically compute the number of columns based on number of child controls.
  67108. */
  67109. rows: BABYLON.int;
  67110. /**
  67111. * Creates new VolumeBasedPanel
  67112. */
  67113. constructor();
  67114. protected _arrangeChildren(): void;
  67115. /** Child classes must implement this function to provide correct control positioning */
  67116. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67117. /** Child classes can implement this function to provide additional processing */
  67118. protected _finalProcessing(): void;
  67119. }
  67120. }
  67121. declare module BABYLON.GUI {
  67122. /**
  67123. * Class used to create a container panel deployed on the surface of a cylinder
  67124. */
  67125. export class CylinderPanel extends VolumeBasedPanel {
  67126. private _radius;
  67127. /**
  67128. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  67129. */
  67130. radius: BABYLON.float;
  67131. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67132. private _cylindricalMapping;
  67133. }
  67134. }
  67135. declare module BABYLON.GUI {
  67136. /** @hidden */
  67137. export var fluentVertexShader: {
  67138. name: string;
  67139. shader: string;
  67140. };
  67141. }
  67142. declare module BABYLON.GUI {
  67143. /** @hidden */
  67144. export var fluentPixelShader: {
  67145. name: string;
  67146. shader: string;
  67147. };
  67148. }
  67149. declare module BABYLON.GUI {
  67150. /** @hidden */
  67151. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  67152. INNERGLOW: boolean;
  67153. BORDER: boolean;
  67154. HOVERLIGHT: boolean;
  67155. TEXTURE: boolean;
  67156. constructor();
  67157. }
  67158. /**
  67159. * Class used to render controls with fluent desgin
  67160. */
  67161. export class FluentMaterial extends BABYLON.PushMaterial {
  67162. /**
  67163. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  67164. */
  67165. innerGlowColorIntensity: number;
  67166. /**
  67167. * Gets or sets the inner glow color (white by default)
  67168. */
  67169. innerGlowColor: BABYLON.Color3;
  67170. /**
  67171. * Gets or sets alpha value (default is 1.0)
  67172. */
  67173. alpha: number;
  67174. /**
  67175. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  67176. */
  67177. albedoColor: BABYLON.Color3;
  67178. /**
  67179. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  67180. */
  67181. renderBorders: boolean;
  67182. /**
  67183. * Gets or sets border width (default is 0.5)
  67184. */
  67185. borderWidth: number;
  67186. /**
  67187. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  67188. */
  67189. edgeSmoothingValue: number;
  67190. /**
  67191. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  67192. */
  67193. borderMinValue: number;
  67194. /**
  67195. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  67196. */
  67197. renderHoverLight: boolean;
  67198. /**
  67199. * Gets or sets the radius used to render the hover light (default is 1.0)
  67200. */
  67201. hoverRadius: number;
  67202. /**
  67203. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  67204. */
  67205. hoverColor: BABYLON.Color4;
  67206. /**
  67207. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  67208. */
  67209. hoverPosition: BABYLON.Vector3;
  67210. private _albedoTexture;
  67211. /** Gets or sets the texture to use for albedo color */
  67212. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67213. /**
  67214. * Creates a new Fluent material
  67215. * @param name defines the name of the material
  67216. * @param scene defines the hosting scene
  67217. */
  67218. constructor(name: string, scene: BABYLON.Scene);
  67219. needAlphaBlending(): boolean;
  67220. needAlphaTesting(): boolean;
  67221. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67222. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67223. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67224. getActiveTextures(): BABYLON.BaseTexture[];
  67225. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67226. dispose(forceDisposeEffect?: boolean): void;
  67227. clone(name: string): FluentMaterial;
  67228. serialize(): any;
  67229. getClassName(): string;
  67230. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  67231. }
  67232. }
  67233. declare module BABYLON.GUI {
  67234. /**
  67235. * Class used to create a holographic button in 3D
  67236. */
  67237. export class HolographicButton extends Button3D {
  67238. private _backPlate;
  67239. private _textPlate;
  67240. private _frontPlate;
  67241. private _text;
  67242. private _imageUrl;
  67243. private _shareMaterials;
  67244. private _frontMaterial;
  67245. private _backMaterial;
  67246. private _plateMaterial;
  67247. private _pickedPointObserver;
  67248. private _tooltipFade;
  67249. private _tooltipTextBlock;
  67250. private _tooltipTexture;
  67251. private _tooltipMesh;
  67252. private _tooltipHoverObserver;
  67253. private _tooltipOutObserver;
  67254. private _disposeTooltip;
  67255. /**
  67256. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  67257. */
  67258. tooltipText: BABYLON.Nullable<string>;
  67259. /**
  67260. * Gets or sets text for the button
  67261. */
  67262. text: string;
  67263. /**
  67264. * Gets or sets the image url for the button
  67265. */
  67266. imageUrl: string;
  67267. /**
  67268. * Gets the back material used by this button
  67269. */
  67270. readonly backMaterial: FluentMaterial;
  67271. /**
  67272. * Gets the front material used by this button
  67273. */
  67274. readonly frontMaterial: FluentMaterial;
  67275. /**
  67276. * Gets the plate material used by this button
  67277. */
  67278. readonly plateMaterial: BABYLON.StandardMaterial;
  67279. /**
  67280. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  67281. */
  67282. readonly shareMaterials: boolean;
  67283. /**
  67284. * Creates a new button
  67285. * @param name defines the control name
  67286. */
  67287. constructor(name?: string, shareMaterials?: boolean);
  67288. protected _getTypeName(): string;
  67289. private _rebuildContent;
  67290. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67291. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67292. private _createBackMaterial;
  67293. private _createFrontMaterial;
  67294. private _createPlateMaterial;
  67295. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  67296. /**
  67297. * Releases all associated resources
  67298. */
  67299. dispose(): void;
  67300. }
  67301. }
  67302. declare module BABYLON.GUI {
  67303. /**
  67304. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  67305. */
  67306. export class MeshButton3D extends Button3D {
  67307. /** @hidden */
  67308. protected _currentMesh: BABYLON.Mesh;
  67309. /**
  67310. * Creates a new 3D button based on a mesh
  67311. * @param mesh mesh to become a 3D button
  67312. * @param name defines the control name
  67313. */
  67314. constructor(mesh: BABYLON.Mesh, name?: string);
  67315. protected _getTypeName(): string;
  67316. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67317. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67318. }
  67319. }
  67320. declare module BABYLON.GUI {
  67321. /**
  67322. * Class used to create a container panel deployed on the surface of a plane
  67323. */
  67324. export class PlanePanel extends VolumeBasedPanel {
  67325. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67326. }
  67327. }
  67328. declare module BABYLON.GUI {
  67329. /**
  67330. * Class used to create a container panel where items get randomized planar mapping
  67331. */
  67332. export class ScatterPanel extends VolumeBasedPanel {
  67333. private _iteration;
  67334. /**
  67335. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  67336. */
  67337. iteration: BABYLON.float;
  67338. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67339. private _scatterMapping;
  67340. protected _finalProcessing(): void;
  67341. }
  67342. }
  67343. declare module BABYLON.GUI {
  67344. /**
  67345. * Class used to create a container panel deployed on the surface of a sphere
  67346. */
  67347. export class SpherePanel extends VolumeBasedPanel {
  67348. private _radius;
  67349. /**
  67350. * Gets or sets the radius of the sphere where to project controls (5 by default)
  67351. */
  67352. radius: BABYLON.float;
  67353. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67354. private _sphericalMapping;
  67355. }
  67356. }
  67357. declare module BABYLON.GUI {
  67358. /**
  67359. * Class used to create a stack panel in 3D on XY plane
  67360. */
  67361. export class StackPanel3D extends Container3D {
  67362. private _isVertical;
  67363. /**
  67364. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  67365. */
  67366. isVertical: boolean;
  67367. /**
  67368. * Gets or sets the distance between elements
  67369. */
  67370. margin: number;
  67371. /**
  67372. * Creates new StackPanel
  67373. * @param isVertical
  67374. */
  67375. constructor(isVertical?: boolean);
  67376. protected _arrangeChildren(): void;
  67377. }
  67378. }
  67379. declare module BABYLON {
  67380. /**
  67381. * Mode that determines the coordinate system to use.
  67382. */
  67383. export enum GLTFLoaderCoordinateSystemMode {
  67384. /**
  67385. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67386. */
  67387. AUTO = 0,
  67388. /**
  67389. * Sets the useRightHandedSystem flag on the scene.
  67390. */
  67391. FORCE_RIGHT_HANDED = 1
  67392. }
  67393. /**
  67394. * Mode that determines what animations will start.
  67395. */
  67396. export enum GLTFLoaderAnimationStartMode {
  67397. /**
  67398. * No animation will start.
  67399. */
  67400. NONE = 0,
  67401. /**
  67402. * The first animation will start.
  67403. */
  67404. FIRST = 1,
  67405. /**
  67406. * All animations will start.
  67407. */
  67408. ALL = 2
  67409. }
  67410. /**
  67411. * Interface that contains the data for the glTF asset.
  67412. */
  67413. export interface IGLTFLoaderData {
  67414. /**
  67415. * Object that represents the glTF JSON.
  67416. */
  67417. json: Object;
  67418. /**
  67419. * The BIN chunk of a binary glTF.
  67420. */
  67421. bin: Nullable<ArrayBufferView>;
  67422. }
  67423. /**
  67424. * Interface for extending the loader.
  67425. */
  67426. export interface IGLTFLoaderExtension {
  67427. /**
  67428. * The name of this extension.
  67429. */
  67430. readonly name: string;
  67431. /**
  67432. * Defines whether this extension is enabled.
  67433. */
  67434. enabled: boolean;
  67435. }
  67436. /**
  67437. * Loader state.
  67438. */
  67439. export enum GLTFLoaderState {
  67440. /**
  67441. * The asset is loading.
  67442. */
  67443. LOADING = 0,
  67444. /**
  67445. * The asset is ready for rendering.
  67446. */
  67447. READY = 1,
  67448. /**
  67449. * The asset is completely loaded.
  67450. */
  67451. COMPLETE = 2
  67452. }
  67453. /** @hidden */
  67454. export interface IGLTFLoader extends IDisposable {
  67455. readonly state: Nullable<GLTFLoaderState>;
  67456. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  67457. meshes: AbstractMesh[];
  67458. particleSystems: IParticleSystem[];
  67459. skeletons: Skeleton[];
  67460. animationGroups: AnimationGroup[];
  67461. }>;
  67462. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  67463. }
  67464. /**
  67465. * File loader for loading glTF files into a scene.
  67466. */
  67467. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67468. /** @hidden */
  67469. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67470. /** @hidden */
  67471. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67472. /**
  67473. * Raised when the asset has been parsed
  67474. */
  67475. onParsedObservable: Observable<IGLTFLoaderData>;
  67476. private _onParsedObserver;
  67477. /**
  67478. * Raised when the asset has been parsed
  67479. */
  67480. onParsed: (loaderData: IGLTFLoaderData) => void;
  67481. /**
  67482. * 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.
  67483. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  67484. * Defaults to true.
  67485. * @hidden
  67486. */
  67487. static IncrementalLoading: boolean;
  67488. /**
  67489. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  67490. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  67491. * @hidden
  67492. */
  67493. static HomogeneousCoordinates: boolean;
  67494. /**
  67495. * The coordinate system mode. Defaults to AUTO.
  67496. */
  67497. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  67498. /**
  67499. * The animation start mode. Defaults to FIRST.
  67500. */
  67501. animationStartMode: GLTFLoaderAnimationStartMode;
  67502. /**
  67503. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  67504. */
  67505. compileMaterials: boolean;
  67506. /**
  67507. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  67508. */
  67509. useClipPlane: boolean;
  67510. /**
  67511. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  67512. */
  67513. compileShadowGenerators: boolean;
  67514. /**
  67515. * Defines if the Alpha blended materials are only applied as coverage.
  67516. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  67517. * If true, no extra effects are applied to transparent pixels.
  67518. */
  67519. transparencyAsCoverage: boolean;
  67520. /**
  67521. * Function called before loading a url referenced by the asset.
  67522. */
  67523. preprocessUrlAsync: (url: string) => Promise<string>;
  67524. /**
  67525. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67526. */
  67527. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  67528. private _onMeshLoadedObserver;
  67529. /**
  67530. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67531. */
  67532. onMeshLoaded: (mesh: AbstractMesh) => void;
  67533. /**
  67534. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  67535. */
  67536. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  67537. private _onTextureLoadedObserver;
  67538. /**
  67539. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  67540. */
  67541. onTextureLoaded: (texture: BaseTexture) => void;
  67542. /**
  67543. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  67544. */
  67545. readonly onMaterialLoadedObservable: Observable<Material>;
  67546. private _onMaterialLoadedObserver;
  67547. /**
  67548. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  67549. */
  67550. onMaterialLoaded: (material: Material) => void;
  67551. /**
  67552. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  67553. */
  67554. readonly onCameraLoadedObservable: Observable<Camera>;
  67555. private _onCameraLoadedObserver;
  67556. /**
  67557. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  67558. */
  67559. onCameraLoaded: (camera: Camera) => void;
  67560. /**
  67561. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  67562. * For assets with LODs, raised when all of the LODs are complete.
  67563. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67564. */
  67565. readonly onCompleteObservable: Observable<void>;
  67566. private _onCompleteObserver;
  67567. /**
  67568. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  67569. * For assets with LODs, raised when all of the LODs are complete.
  67570. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67571. */
  67572. onComplete: () => void;
  67573. /**
  67574. * Observable raised when an error occurs.
  67575. */
  67576. readonly onErrorObservable: Observable<any>;
  67577. private _onErrorObserver;
  67578. /**
  67579. * Callback raised when an error occurs.
  67580. */
  67581. onError: (reason: any) => void;
  67582. /**
  67583. * Observable raised after the loader is disposed.
  67584. */
  67585. readonly onDisposeObservable: Observable<void>;
  67586. private _onDisposeObserver;
  67587. /**
  67588. * Callback raised after the loader is disposed.
  67589. */
  67590. onDispose: () => void;
  67591. /**
  67592. * Observable raised after a loader extension is created.
  67593. * Set additional options for a loader extension in this event.
  67594. */
  67595. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  67596. private _onExtensionLoadedObserver;
  67597. /**
  67598. * Callback raised after a loader extension is created.
  67599. */
  67600. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  67601. /**
  67602. * Defines if the loader logging is enabled.
  67603. */
  67604. loggingEnabled: boolean;
  67605. /**
  67606. * Defines if the loader should capture performance counters.
  67607. */
  67608. capturePerformanceCounters: boolean;
  67609. /**
  67610. * Defines if the loader should validate the asset.
  67611. */
  67612. validate: boolean;
  67613. /**
  67614. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  67615. */
  67616. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  67617. private _onValidatedObserver;
  67618. /**
  67619. * Callback raised after a loader extension is created.
  67620. */
  67621. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  67622. private _loader;
  67623. /**
  67624. * Name of the loader ("gltf")
  67625. */
  67626. name: string;
  67627. /**
  67628. * Supported file extensions of the loader (.gltf, .glb)
  67629. */
  67630. extensions: ISceneLoaderPluginExtensions;
  67631. /**
  67632. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  67633. */
  67634. dispose(): void;
  67635. /** @hidden */
  67636. _clear(): void;
  67637. /**
  67638. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  67639. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67640. * @param scene the scene the meshes should be added to
  67641. * @param data the glTF data to load
  67642. * @param rootUrl root url to load from
  67643. * @param onProgress event that fires when loading progress has occured
  67644. * @param fileName Defines the name of the file to load
  67645. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67646. */
  67647. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67648. meshes: AbstractMesh[];
  67649. particleSystems: IParticleSystem[];
  67650. skeletons: Skeleton[];
  67651. animationGroups: AnimationGroup[];
  67652. }>;
  67653. /**
  67654. * Imports all objects from the loaded glTF data and adds them to the scene
  67655. * @param scene the scene the objects should be added to
  67656. * @param data the glTF data to load
  67657. * @param rootUrl root url to load from
  67658. * @param onProgress event that fires when loading progress has occured
  67659. * @param fileName Defines the name of the file to load
  67660. * @returns a promise which completes when objects have been loaded to the scene
  67661. */
  67662. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67663. /**
  67664. * Load into an asset container.
  67665. * @param scene The scene to load into
  67666. * @param data The data to import
  67667. * @param rootUrl The root url for scene and resources
  67668. * @param onProgress The callback when the load progresses
  67669. * @param fileName Defines the name of the file to load
  67670. * @returns The loaded asset container
  67671. */
  67672. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67673. /**
  67674. * If the data string can be loaded directly.
  67675. * @param data string contianing the file data
  67676. * @returns if the data can be loaded directly
  67677. */
  67678. canDirectLoad(data: string): boolean;
  67679. /**
  67680. * Rewrites a url by combining a root url and response url.
  67681. */
  67682. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  67683. /**
  67684. * Instantiates a glTF file loader plugin.
  67685. * @returns the created plugin
  67686. */
  67687. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  67688. /**
  67689. * The loader state or null if the loader is not active.
  67690. */
  67691. readonly loaderState: Nullable<GLTFLoaderState>;
  67692. /**
  67693. * Returns a promise that resolves when the asset is completely loaded.
  67694. * @returns a promise that resolves when the asset is completely loaded.
  67695. */
  67696. whenCompleteAsync(): Promise<void>;
  67697. private _parseAsync;
  67698. private _validateAsync;
  67699. private _getLoader;
  67700. private _unpackBinary;
  67701. private _unpackBinaryV1;
  67702. private _unpackBinaryV2;
  67703. private static _parseVersion;
  67704. private static _compareVersion;
  67705. private static _decodeBufferToText;
  67706. private static readonly _logSpaces;
  67707. private _logIndentLevel;
  67708. private _loggingEnabled;
  67709. /** @hidden */
  67710. _log: (message: string) => void;
  67711. /** @hidden */
  67712. _logOpen(message: string): void;
  67713. /** @hidden */
  67714. _logClose(): void;
  67715. private _logEnabled;
  67716. private _logDisabled;
  67717. private _capturePerformanceCounters;
  67718. /** @hidden */
  67719. _startPerformanceCounter: (counterName: string) => void;
  67720. /** @hidden */
  67721. _endPerformanceCounter: (counterName: string) => void;
  67722. private _startPerformanceCounterEnabled;
  67723. private _startPerformanceCounterDisabled;
  67724. private _endPerformanceCounterEnabled;
  67725. private _endPerformanceCounterDisabled;
  67726. }
  67727. }
  67728. declare module BABYLON.GLTF1 {
  67729. /**
  67730. * Enums
  67731. * @hidden
  67732. */
  67733. export enum EComponentType {
  67734. BYTE = 5120,
  67735. UNSIGNED_BYTE = 5121,
  67736. SHORT = 5122,
  67737. UNSIGNED_SHORT = 5123,
  67738. FLOAT = 5126
  67739. }
  67740. /** @hidden */
  67741. export enum EShaderType {
  67742. FRAGMENT = 35632,
  67743. VERTEX = 35633
  67744. }
  67745. /** @hidden */
  67746. export enum EParameterType {
  67747. BYTE = 5120,
  67748. UNSIGNED_BYTE = 5121,
  67749. SHORT = 5122,
  67750. UNSIGNED_SHORT = 5123,
  67751. INT = 5124,
  67752. UNSIGNED_INT = 5125,
  67753. FLOAT = 5126,
  67754. FLOAT_VEC2 = 35664,
  67755. FLOAT_VEC3 = 35665,
  67756. FLOAT_VEC4 = 35666,
  67757. INT_VEC2 = 35667,
  67758. INT_VEC3 = 35668,
  67759. INT_VEC4 = 35669,
  67760. BOOL = 35670,
  67761. BOOL_VEC2 = 35671,
  67762. BOOL_VEC3 = 35672,
  67763. BOOL_VEC4 = 35673,
  67764. FLOAT_MAT2 = 35674,
  67765. FLOAT_MAT3 = 35675,
  67766. FLOAT_MAT4 = 35676,
  67767. SAMPLER_2D = 35678
  67768. }
  67769. /** @hidden */
  67770. export enum ETextureWrapMode {
  67771. CLAMP_TO_EDGE = 33071,
  67772. MIRRORED_REPEAT = 33648,
  67773. REPEAT = 10497
  67774. }
  67775. /** @hidden */
  67776. export enum ETextureFilterType {
  67777. NEAREST = 9728,
  67778. LINEAR = 9728,
  67779. NEAREST_MIPMAP_NEAREST = 9984,
  67780. LINEAR_MIPMAP_NEAREST = 9985,
  67781. NEAREST_MIPMAP_LINEAR = 9986,
  67782. LINEAR_MIPMAP_LINEAR = 9987
  67783. }
  67784. /** @hidden */
  67785. export enum ETextureFormat {
  67786. ALPHA = 6406,
  67787. RGB = 6407,
  67788. RGBA = 6408,
  67789. LUMINANCE = 6409,
  67790. LUMINANCE_ALPHA = 6410
  67791. }
  67792. /** @hidden */
  67793. export enum ECullingType {
  67794. FRONT = 1028,
  67795. BACK = 1029,
  67796. FRONT_AND_BACK = 1032
  67797. }
  67798. /** @hidden */
  67799. export enum EBlendingFunction {
  67800. ZERO = 0,
  67801. ONE = 1,
  67802. SRC_COLOR = 768,
  67803. ONE_MINUS_SRC_COLOR = 769,
  67804. DST_COLOR = 774,
  67805. ONE_MINUS_DST_COLOR = 775,
  67806. SRC_ALPHA = 770,
  67807. ONE_MINUS_SRC_ALPHA = 771,
  67808. DST_ALPHA = 772,
  67809. ONE_MINUS_DST_ALPHA = 773,
  67810. CONSTANT_COLOR = 32769,
  67811. ONE_MINUS_CONSTANT_COLOR = 32770,
  67812. CONSTANT_ALPHA = 32771,
  67813. ONE_MINUS_CONSTANT_ALPHA = 32772,
  67814. SRC_ALPHA_SATURATE = 776
  67815. }
  67816. /** @hidden */
  67817. export interface IGLTFProperty {
  67818. extensions?: {
  67819. [key: string]: any;
  67820. };
  67821. extras?: Object;
  67822. }
  67823. /** @hidden */
  67824. export interface IGLTFChildRootProperty extends IGLTFProperty {
  67825. name?: string;
  67826. }
  67827. /** @hidden */
  67828. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  67829. bufferView: string;
  67830. byteOffset: number;
  67831. byteStride: number;
  67832. count: number;
  67833. type: string;
  67834. componentType: EComponentType;
  67835. max?: number[];
  67836. min?: number[];
  67837. name?: string;
  67838. }
  67839. /** @hidden */
  67840. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  67841. buffer: string;
  67842. byteOffset: number;
  67843. byteLength: number;
  67844. byteStride: number;
  67845. target?: number;
  67846. }
  67847. /** @hidden */
  67848. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  67849. uri: string;
  67850. byteLength?: number;
  67851. type?: string;
  67852. }
  67853. /** @hidden */
  67854. export interface IGLTFShader extends IGLTFChildRootProperty {
  67855. uri: string;
  67856. type: EShaderType;
  67857. }
  67858. /** @hidden */
  67859. export interface IGLTFProgram extends IGLTFChildRootProperty {
  67860. attributes: string[];
  67861. fragmentShader: string;
  67862. vertexShader: string;
  67863. }
  67864. /** @hidden */
  67865. export interface IGLTFTechniqueParameter {
  67866. type: number;
  67867. count?: number;
  67868. semantic?: string;
  67869. node?: string;
  67870. value?: number | boolean | string | Array<any>;
  67871. source?: string;
  67872. babylonValue?: any;
  67873. }
  67874. /** @hidden */
  67875. export interface IGLTFTechniqueCommonProfile {
  67876. lightingModel: string;
  67877. texcoordBindings: Object;
  67878. parameters?: Array<any>;
  67879. }
  67880. /** @hidden */
  67881. export interface IGLTFTechniqueStatesFunctions {
  67882. blendColor?: number[];
  67883. blendEquationSeparate?: number[];
  67884. blendFuncSeparate?: number[];
  67885. colorMask: boolean[];
  67886. cullFace: number[];
  67887. }
  67888. /** @hidden */
  67889. export interface IGLTFTechniqueStates {
  67890. enable: number[];
  67891. functions: IGLTFTechniqueStatesFunctions;
  67892. }
  67893. /** @hidden */
  67894. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  67895. parameters: {
  67896. [key: string]: IGLTFTechniqueParameter;
  67897. };
  67898. program: string;
  67899. attributes: {
  67900. [key: string]: string;
  67901. };
  67902. uniforms: {
  67903. [key: string]: string;
  67904. };
  67905. states: IGLTFTechniqueStates;
  67906. }
  67907. /** @hidden */
  67908. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  67909. technique?: string;
  67910. values: string[];
  67911. }
  67912. /** @hidden */
  67913. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  67914. attributes: {
  67915. [key: string]: string;
  67916. };
  67917. indices: string;
  67918. material: string;
  67919. mode?: number;
  67920. }
  67921. /** @hidden */
  67922. export interface IGLTFMesh extends IGLTFChildRootProperty {
  67923. primitives: IGLTFMeshPrimitive[];
  67924. }
  67925. /** @hidden */
  67926. export interface IGLTFImage extends IGLTFChildRootProperty {
  67927. uri: string;
  67928. }
  67929. /** @hidden */
  67930. export interface IGLTFSampler extends IGLTFChildRootProperty {
  67931. magFilter?: number;
  67932. minFilter?: number;
  67933. wrapS?: number;
  67934. wrapT?: number;
  67935. }
  67936. /** @hidden */
  67937. export interface IGLTFTexture extends IGLTFChildRootProperty {
  67938. sampler: string;
  67939. source: string;
  67940. format?: ETextureFormat;
  67941. internalFormat?: ETextureFormat;
  67942. target?: number;
  67943. type?: number;
  67944. babylonTexture?: Texture;
  67945. }
  67946. /** @hidden */
  67947. export interface IGLTFAmbienLight {
  67948. color?: number[];
  67949. }
  67950. /** @hidden */
  67951. export interface IGLTFDirectionalLight {
  67952. color?: number[];
  67953. }
  67954. /** @hidden */
  67955. export interface IGLTFPointLight {
  67956. color?: number[];
  67957. constantAttenuation?: number;
  67958. linearAttenuation?: number;
  67959. quadraticAttenuation?: number;
  67960. }
  67961. /** @hidden */
  67962. export interface IGLTFSpotLight {
  67963. color?: number[];
  67964. constantAttenuation?: number;
  67965. fallOfAngle?: number;
  67966. fallOffExponent?: number;
  67967. linearAttenuation?: number;
  67968. quadraticAttenuation?: number;
  67969. }
  67970. /** @hidden */
  67971. export interface IGLTFLight extends IGLTFChildRootProperty {
  67972. type: string;
  67973. }
  67974. /** @hidden */
  67975. export interface IGLTFCameraOrthographic {
  67976. xmag: number;
  67977. ymag: number;
  67978. zfar: number;
  67979. znear: number;
  67980. }
  67981. /** @hidden */
  67982. export interface IGLTFCameraPerspective {
  67983. aspectRatio: number;
  67984. yfov: number;
  67985. zfar: number;
  67986. znear: number;
  67987. }
  67988. /** @hidden */
  67989. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67990. type: string;
  67991. }
  67992. /** @hidden */
  67993. export interface IGLTFAnimationChannelTarget {
  67994. id: string;
  67995. path: string;
  67996. }
  67997. /** @hidden */
  67998. export interface IGLTFAnimationChannel {
  67999. sampler: string;
  68000. target: IGLTFAnimationChannelTarget;
  68001. }
  68002. /** @hidden */
  68003. export interface IGLTFAnimationSampler {
  68004. input: string;
  68005. output: string;
  68006. interpolation?: string;
  68007. }
  68008. /** @hidden */
  68009. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  68010. channels?: IGLTFAnimationChannel[];
  68011. parameters?: {
  68012. [key: string]: string;
  68013. };
  68014. samplers?: {
  68015. [key: string]: IGLTFAnimationSampler;
  68016. };
  68017. }
  68018. /** @hidden */
  68019. export interface IGLTFNodeInstanceSkin {
  68020. skeletons: string[];
  68021. skin: string;
  68022. meshes: string[];
  68023. }
  68024. /** @hidden */
  68025. export interface IGLTFSkins extends IGLTFChildRootProperty {
  68026. bindShapeMatrix: number[];
  68027. inverseBindMatrices: string;
  68028. jointNames: string[];
  68029. babylonSkeleton?: Skeleton;
  68030. }
  68031. /** @hidden */
  68032. export interface IGLTFNode extends IGLTFChildRootProperty {
  68033. camera?: string;
  68034. children: string[];
  68035. skin?: string;
  68036. jointName?: string;
  68037. light?: string;
  68038. matrix: number[];
  68039. mesh?: string;
  68040. meshes?: string[];
  68041. rotation?: number[];
  68042. scale?: number[];
  68043. translation?: number[];
  68044. babylonNode?: Node;
  68045. }
  68046. /** @hidden */
  68047. export interface IGLTFScene extends IGLTFChildRootProperty {
  68048. nodes: string[];
  68049. }
  68050. /** @hidden */
  68051. export interface IGLTFRuntime {
  68052. extensions: {
  68053. [key: string]: any;
  68054. };
  68055. accessors: {
  68056. [key: string]: IGLTFAccessor;
  68057. };
  68058. buffers: {
  68059. [key: string]: IGLTFBuffer;
  68060. };
  68061. bufferViews: {
  68062. [key: string]: IGLTFBufferView;
  68063. };
  68064. meshes: {
  68065. [key: string]: IGLTFMesh;
  68066. };
  68067. lights: {
  68068. [key: string]: IGLTFLight;
  68069. };
  68070. cameras: {
  68071. [key: string]: IGLTFCamera;
  68072. };
  68073. nodes: {
  68074. [key: string]: IGLTFNode;
  68075. };
  68076. images: {
  68077. [key: string]: IGLTFImage;
  68078. };
  68079. textures: {
  68080. [key: string]: IGLTFTexture;
  68081. };
  68082. shaders: {
  68083. [key: string]: IGLTFShader;
  68084. };
  68085. programs: {
  68086. [key: string]: IGLTFProgram;
  68087. };
  68088. samplers: {
  68089. [key: string]: IGLTFSampler;
  68090. };
  68091. techniques: {
  68092. [key: string]: IGLTFTechnique;
  68093. };
  68094. materials: {
  68095. [key: string]: IGLTFMaterial;
  68096. };
  68097. animations: {
  68098. [key: string]: IGLTFAnimation;
  68099. };
  68100. skins: {
  68101. [key: string]: IGLTFSkins;
  68102. };
  68103. currentScene?: Object;
  68104. scenes: {
  68105. [key: string]: IGLTFScene;
  68106. };
  68107. extensionsUsed: string[];
  68108. extensionsRequired?: string[];
  68109. buffersCount: number;
  68110. shaderscount: number;
  68111. scene: Scene;
  68112. rootUrl: string;
  68113. loadedBufferCount: number;
  68114. loadedBufferViews: {
  68115. [name: string]: ArrayBufferView;
  68116. };
  68117. loadedShaderCount: number;
  68118. importOnlyMeshes: boolean;
  68119. importMeshesNames?: string[];
  68120. dummyNodes: Node[];
  68121. }
  68122. /** @hidden */
  68123. export interface INodeToRoot {
  68124. bone: Bone;
  68125. node: IGLTFNode;
  68126. id: string;
  68127. }
  68128. /** @hidden */
  68129. export interface IJointNode {
  68130. node: IGLTFNode;
  68131. id: string;
  68132. }
  68133. }
  68134. declare module BABYLON.GLTF1 {
  68135. /**
  68136. * Utils functions for GLTF
  68137. * @hidden
  68138. */
  68139. export class GLTFUtils {
  68140. /**
  68141. * Sets the given "parameter" matrix
  68142. * @param scene: the Scene object
  68143. * @param source: the source node where to pick the matrix
  68144. * @param parameter: the GLTF technique parameter
  68145. * @param uniformName: the name of the shader's uniform
  68146. * @param shaderMaterial: the shader material
  68147. */
  68148. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  68149. /**
  68150. * Sets the given "parameter" matrix
  68151. * @param shaderMaterial: the shader material
  68152. * @param uniform: the name of the shader's uniform
  68153. * @param value: the value of the uniform
  68154. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  68155. */
  68156. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  68157. /**
  68158. * Returns the wrap mode of the texture
  68159. * @param mode: the mode value
  68160. */
  68161. static GetWrapMode(mode: number): number;
  68162. /**
  68163. * Returns the byte stride giving an accessor
  68164. * @param accessor: the GLTF accessor objet
  68165. */
  68166. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  68167. /**
  68168. * Returns the texture filter mode giving a mode value
  68169. * @param mode: the filter mode value
  68170. */
  68171. static GetTextureFilterMode(mode: number): ETextureFilterType;
  68172. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  68173. /**
  68174. * Returns a buffer from its accessor
  68175. * @param gltfRuntime: the GLTF runtime
  68176. * @param accessor: the GLTF accessor
  68177. */
  68178. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  68179. /**
  68180. * Decodes a buffer view into a string
  68181. * @param view: the buffer view
  68182. */
  68183. static DecodeBufferToText(view: ArrayBufferView): string;
  68184. /**
  68185. * Returns the default material of gltf. Related to
  68186. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  68187. * @param scene: the Babylon.js scene
  68188. */
  68189. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  68190. private static _DefaultMaterial;
  68191. }
  68192. }
  68193. declare module BABYLON.GLTF1 {
  68194. /**
  68195. * Implementation of the base glTF spec
  68196. * @hidden
  68197. */
  68198. export class GLTFLoaderBase {
  68199. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  68200. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68201. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  68202. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68203. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  68204. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68205. }
  68206. /**
  68207. * glTF V1 Loader
  68208. * @hidden
  68209. */
  68210. export class GLTFLoader implements IGLTFLoader {
  68211. static Extensions: {
  68212. [name: string]: GLTFLoaderExtension;
  68213. };
  68214. static RegisterExtension(extension: GLTFLoaderExtension): void;
  68215. state: Nullable<GLTFLoaderState>;
  68216. dispose(): void;
  68217. private _importMeshAsync;
  68218. /**
  68219. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  68220. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68221. * @param scene the scene the meshes should be added to
  68222. * @param data gltf data containing information of the meshes in a loaded file
  68223. * @param rootUrl root url to load from
  68224. * @param onProgress event that fires when loading progress has occured
  68225. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68226. */
  68227. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  68228. meshes: AbstractMesh[];
  68229. particleSystems: IParticleSystem[];
  68230. skeletons: Skeleton[];
  68231. animationGroups: AnimationGroup[];
  68232. }>;
  68233. private _loadAsync;
  68234. /**
  68235. * Imports all objects from a loaded gltf file and adds them to the scene
  68236. * @param scene the scene the objects should be added to
  68237. * @param data gltf data containing information of the meshes in a loaded file
  68238. * @param rootUrl root url to load from
  68239. * @param onProgress event that fires when loading progress has occured
  68240. * @returns a promise which completes when objects have been loaded to the scene
  68241. */
  68242. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  68243. private _loadShadersAsync;
  68244. private _loadBuffersAsync;
  68245. private _createNodes;
  68246. }
  68247. /** @hidden */
  68248. export abstract class GLTFLoaderExtension {
  68249. private _name;
  68250. constructor(name: string);
  68251. readonly name: string;
  68252. /**
  68253. * Defines an override for loading the runtime
  68254. * Return true to stop further extensions from loading the runtime
  68255. */
  68256. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  68257. /**
  68258. * Defines an onverride for creating gltf runtime
  68259. * Return true to stop further extensions from creating the runtime
  68260. */
  68261. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  68262. /**
  68263. * Defines an override for loading buffers
  68264. * Return true to stop further extensions from loading this buffer
  68265. */
  68266. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  68267. /**
  68268. * Defines an override for loading texture buffers
  68269. * Return true to stop further extensions from loading this texture data
  68270. */
  68271. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68272. /**
  68273. * Defines an override for creating textures
  68274. * Return true to stop further extensions from loading this texture
  68275. */
  68276. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  68277. /**
  68278. * Defines an override for loading shader strings
  68279. * Return true to stop further extensions from loading this shader data
  68280. */
  68281. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68282. /**
  68283. * Defines an override for loading materials
  68284. * Return true to stop further extensions from loading this material
  68285. */
  68286. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68287. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  68288. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  68289. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68290. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68291. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  68292. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68293. private static LoadTextureBufferAsync;
  68294. private static CreateTextureAsync;
  68295. private static ApplyExtensions;
  68296. }
  68297. }
  68298. declare module BABYLON.GLTF1 {
  68299. /** @hidden */
  68300. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  68301. private _bin;
  68302. constructor();
  68303. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  68304. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68305. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68306. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68307. }
  68308. }
  68309. declare module BABYLON.GLTF1 {
  68310. /** @hidden */
  68311. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  68312. constructor();
  68313. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  68314. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68315. private _loadTexture;
  68316. }
  68317. }
  68318. declare module BABYLON.GLTF2.Loader {
  68319. /**
  68320. * Loader interface with an index field.
  68321. */
  68322. export interface IArrayItem {
  68323. /**
  68324. * The index of this item in the array.
  68325. */
  68326. index: number;
  68327. }
  68328. /**
  68329. * Loader interface with additional members.
  68330. */
  68331. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  68332. /** @hidden */
  68333. _data?: Promise<ArrayBufferView>;
  68334. /** @hidden */
  68335. _babylonVertexBuffer?: Promise<VertexBuffer>;
  68336. }
  68337. /**
  68338. * Loader interface with additional members.
  68339. */
  68340. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  68341. }
  68342. /** @hidden */
  68343. export interface _IAnimationSamplerData {
  68344. input: Float32Array;
  68345. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  68346. output: Float32Array;
  68347. }
  68348. /**
  68349. * Loader interface with additional members.
  68350. */
  68351. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  68352. /** @hidden */
  68353. _data?: Promise<_IAnimationSamplerData>;
  68354. }
  68355. /**
  68356. * Loader interface with additional members.
  68357. */
  68358. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  68359. channels: IAnimationChannel[];
  68360. samplers: IAnimationSampler[];
  68361. /** @hidden */
  68362. _babylonAnimationGroup?: AnimationGroup;
  68363. }
  68364. /**
  68365. * Loader interface with additional members.
  68366. */
  68367. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  68368. /** @hidden */
  68369. _data?: Promise<ArrayBufferView>;
  68370. }
  68371. /**
  68372. * Loader interface with additional members.
  68373. */
  68374. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68375. /** @hidden */
  68376. _data?: Promise<ArrayBufferView>;
  68377. /** @hidden */
  68378. _babylonBuffer?: Promise<Buffer>;
  68379. }
  68380. /**
  68381. * Loader interface with additional members.
  68382. */
  68383. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68384. }
  68385. /**
  68386. * Loader interface with additional members.
  68387. */
  68388. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68389. /** @hidden */
  68390. _data?: Promise<ArrayBufferView>;
  68391. }
  68392. /**
  68393. * Loader interface with additional members.
  68394. */
  68395. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68396. }
  68397. /**
  68398. * Loader interface with additional members.
  68399. */
  68400. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68401. }
  68402. /**
  68403. * Loader interface with additional members.
  68404. */
  68405. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68406. baseColorTexture?: ITextureInfo;
  68407. metallicRoughnessTexture?: ITextureInfo;
  68408. }
  68409. /**
  68410. * Loader interface with additional members.
  68411. */
  68412. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68413. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68414. normalTexture?: IMaterialNormalTextureInfo;
  68415. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68416. emissiveTexture?: ITextureInfo;
  68417. /** @hidden */
  68418. _data?: {
  68419. [babylonDrawMode: number]: {
  68420. babylonMaterial: Material;
  68421. babylonMeshes: AbstractMesh[];
  68422. promise: Promise<void>;
  68423. };
  68424. };
  68425. }
  68426. /**
  68427. * Loader interface with additional members.
  68428. */
  68429. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  68430. primitives: IMeshPrimitive[];
  68431. }
  68432. /**
  68433. * Loader interface with additional members.
  68434. */
  68435. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  68436. /** @hidden */
  68437. _instanceData?: {
  68438. babylonSourceMesh: Mesh;
  68439. promise: Promise<any>;
  68440. };
  68441. }
  68442. /**
  68443. * Loader interface with additional members.
  68444. */
  68445. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  68446. /**
  68447. * The parent glTF node.
  68448. */
  68449. parent?: INode;
  68450. /** @hidden */
  68451. _babylonTransformNode?: TransformNode;
  68452. /** @hidden */
  68453. _primitiveBabylonMeshes?: AbstractMesh[];
  68454. /** @hidden */
  68455. _babylonBones?: Bone[];
  68456. /** @hidden */
  68457. _numMorphTargets?: number;
  68458. }
  68459. /** @hidden */
  68460. export interface _ISamplerData {
  68461. noMipMaps: boolean;
  68462. samplingMode: number;
  68463. wrapU: number;
  68464. wrapV: number;
  68465. }
  68466. /**
  68467. * Loader interface with additional members.
  68468. */
  68469. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  68470. /** @hidden */
  68471. _data?: _ISamplerData;
  68472. }
  68473. /**
  68474. * Loader interface with additional members.
  68475. */
  68476. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  68477. }
  68478. /**
  68479. * Loader interface with additional members.
  68480. */
  68481. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  68482. /** @hidden */
  68483. _data?: {
  68484. babylonSkeleton: Skeleton;
  68485. promise: Promise<void>;
  68486. };
  68487. }
  68488. /**
  68489. * Loader interface with additional members.
  68490. */
  68491. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  68492. }
  68493. /**
  68494. * Loader interface with additional members.
  68495. */
  68496. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  68497. }
  68498. /**
  68499. * Loader interface with additional members.
  68500. */
  68501. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  68502. accessors?: IAccessor[];
  68503. animations?: IAnimation[];
  68504. buffers?: IBuffer[];
  68505. bufferViews?: IBufferView[];
  68506. cameras?: ICamera[];
  68507. images?: IImage[];
  68508. materials?: IMaterial[];
  68509. meshes?: IMesh[];
  68510. nodes?: INode[];
  68511. samplers?: ISampler[];
  68512. scenes?: IScene[];
  68513. skins?: ISkin[];
  68514. textures?: ITexture[];
  68515. }
  68516. }
  68517. declare module BABYLON.GLTF2 {
  68518. /**
  68519. * Interface for a glTF loader extension.
  68520. */
  68521. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  68522. /**
  68523. * Called after the loader state changes to LOADING.
  68524. */
  68525. onLoading?(): void;
  68526. /**
  68527. * Called after the loader state changes to READY.
  68528. */
  68529. onReady?(): void;
  68530. /**
  68531. * Define this method to modify the default behavior when loading scenes.
  68532. * @param context The context when loading the asset
  68533. * @param scene The glTF scene property
  68534. * @returns A promise that resolves when the load is complete or null if not handled
  68535. */
  68536. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  68537. /**
  68538. * Define this method to modify the default behavior when loading nodes.
  68539. * @param context The context when loading the asset
  68540. * @param node The glTF node property
  68541. * @param assign A function called synchronously after parsing the glTF properties
  68542. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  68543. */
  68544. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68545. /**
  68546. * Define this method to modify the default behavior when loading cameras.
  68547. * @param context The context when loading the asset
  68548. * @param camera The glTF camera property
  68549. * @param assign A function called synchronously after parsing the glTF properties
  68550. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  68551. */
  68552. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68553. /**
  68554. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  68555. * @param context The context when loading the asset
  68556. * @param primitive The glTF mesh primitive property
  68557. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  68558. */
  68559. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68560. /**
  68561. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68562. * @param context The context when loading the asset
  68563. * @param name The mesh name when loading the asset
  68564. * @param node The glTF node when loading the asset
  68565. * @param mesh The glTF mesh when loading the asset
  68566. * @param primitive The glTF mesh primitive property
  68567. * @param assign A function called synchronously after parsing the glTF properties
  68568. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68569. */
  68570. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68571. /**
  68572. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  68573. * @param context The context when loading the asset
  68574. * @param material The glTF material property
  68575. * @param assign A function called synchronously after parsing the glTF properties
  68576. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  68577. */
  68578. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68579. /**
  68580. * Define this method to modify the default behavior when creating materials.
  68581. * @param context The context when loading the asset
  68582. * @param material The glTF material property
  68583. * @param babylonDrawMode The draw mode for the Babylon material
  68584. * @returns The Babylon material or null if not handled
  68585. */
  68586. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68587. /**
  68588. * Define this method to modify the default behavior when loading material properties.
  68589. * @param context The context when loading the asset
  68590. * @param material The glTF material property
  68591. * @param babylonMaterial The Babylon material
  68592. * @returns A promise that resolves when the load is complete or null if not handled
  68593. */
  68594. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68595. /**
  68596. * Define this method to modify the default behavior when loading texture infos.
  68597. * @param context The context when loading the asset
  68598. * @param textureInfo The glTF texture info property
  68599. * @param assign A function called synchronously after parsing the glTF properties
  68600. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  68601. */
  68602. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68603. /**
  68604. * Define this method to modify the default behavior when loading animations.
  68605. * @param context The context when loading the asset
  68606. * @param animation The glTF animation property
  68607. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  68608. */
  68609. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68610. /**
  68611. * @hidden Define this method to modify the default behavior when loading skins.
  68612. * @param context The context when loading the asset
  68613. * @param node The glTF node property
  68614. * @param skin The glTF skin property
  68615. * @returns A promise that resolves when the load is complete or null if not handled
  68616. */
  68617. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  68618. /**
  68619. * @hidden Define this method to modify the default behavior when loading uris.
  68620. * @param context The context when loading the asset
  68621. * @param property The glTF property associated with the uri
  68622. * @param uri The uri to load
  68623. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68624. */
  68625. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68626. }
  68627. }
  68628. declare module BABYLON.GLTF2 {
  68629. /**
  68630. * Helper class for working with arrays when loading the glTF asset
  68631. */
  68632. export class ArrayItem {
  68633. /**
  68634. * Gets an item from the given array.
  68635. * @param context The context when loading the asset
  68636. * @param array The array to get the item from
  68637. * @param index The index to the array
  68638. * @returns The array item
  68639. */
  68640. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  68641. /**
  68642. * Assign an `index` field to each item of the given array.
  68643. * @param array The array of items
  68644. */
  68645. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  68646. }
  68647. /**
  68648. * The glTF 2.0 loader
  68649. */
  68650. export class GLTFLoader implements IGLTFLoader {
  68651. /** @hidden */
  68652. _completePromises: Promise<any>[];
  68653. private _disposed;
  68654. private _parent;
  68655. private _state;
  68656. private _extensions;
  68657. private _rootUrl;
  68658. private _fileName;
  68659. private _uniqueRootUrl;
  68660. private _gltf;
  68661. private _babylonScene;
  68662. private _rootBabylonMesh;
  68663. private _defaultBabylonMaterialData;
  68664. private _progressCallback?;
  68665. private _requests;
  68666. private static readonly _DefaultSampler;
  68667. private static _ExtensionNames;
  68668. private static _ExtensionFactories;
  68669. /**
  68670. * Registers a loader extension.
  68671. * @param name The name of the loader extension.
  68672. * @param factory The factory function that creates the loader extension.
  68673. */
  68674. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  68675. /**
  68676. * Unregisters a loader extension.
  68677. * @param name The name of the loader extenion.
  68678. * @returns A boolean indicating whether the extension has been unregistered
  68679. */
  68680. static UnregisterExtension(name: string): boolean;
  68681. /**
  68682. * Gets the loader state.
  68683. */
  68684. readonly state: Nullable<GLTFLoaderState>;
  68685. /**
  68686. * The glTF object parsed from the JSON.
  68687. */
  68688. readonly gltf: IGLTF;
  68689. /**
  68690. * The Babylon scene when loading the asset.
  68691. */
  68692. readonly babylonScene: Scene;
  68693. /**
  68694. * The root Babylon mesh when loading the asset.
  68695. */
  68696. readonly rootBabylonMesh: Mesh;
  68697. /** @hidden */
  68698. constructor(parent: GLTFFileLoader);
  68699. /** @hidden */
  68700. dispose(): void;
  68701. /** @hidden */
  68702. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68703. meshes: AbstractMesh[];
  68704. particleSystems: IParticleSystem[];
  68705. skeletons: Skeleton[];
  68706. animationGroups: AnimationGroup[];
  68707. }>;
  68708. /** @hidden */
  68709. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68710. private _loadAsync;
  68711. private _loadData;
  68712. private _setupData;
  68713. private _loadExtensions;
  68714. private _checkExtensions;
  68715. private _setState;
  68716. private _createRootNode;
  68717. /**
  68718. * Loads a glTF scene.
  68719. * @param context The context when loading the asset
  68720. * @param scene The glTF scene property
  68721. * @returns A promise that resolves when the load is complete
  68722. */
  68723. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  68724. private _forEachPrimitive;
  68725. private _getMeshes;
  68726. private _getSkeletons;
  68727. private _getAnimationGroups;
  68728. private _startAnimations;
  68729. /**
  68730. * Loads a glTF node.
  68731. * @param context The context when loading the asset
  68732. * @param node The glTF node property
  68733. * @param assign A function called synchronously after parsing the glTF properties
  68734. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  68735. */
  68736. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  68737. private _loadMeshAsync;
  68738. /**
  68739. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68740. * @param context The context when loading the asset
  68741. * @param name The mesh name when loading the asset
  68742. * @param node The glTF node when loading the asset
  68743. * @param mesh The glTF mesh when loading the asset
  68744. * @param primitive The glTF mesh primitive property
  68745. * @param assign A function called synchronously after parsing the glTF properties
  68746. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68747. */
  68748. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68749. private _loadVertexDataAsync;
  68750. private _createMorphTargets;
  68751. private _loadMorphTargetsAsync;
  68752. private _loadMorphTargetVertexDataAsync;
  68753. private static _LoadTransform;
  68754. private _loadSkinAsync;
  68755. private _loadBones;
  68756. private _loadBone;
  68757. private _loadSkinInverseBindMatricesDataAsync;
  68758. private _updateBoneMatrices;
  68759. private _getNodeMatrix;
  68760. /**
  68761. * Loads a glTF camera.
  68762. * @param context The context when loading the asset
  68763. * @param camera The glTF camera property
  68764. * @param assign A function called synchronously after parsing the glTF properties
  68765. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  68766. */
  68767. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  68768. private _loadAnimationsAsync;
  68769. /**
  68770. * Loads a glTF animation.
  68771. * @param context The context when loading the asset
  68772. * @param animation The glTF animation property
  68773. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  68774. */
  68775. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  68776. /**
  68777. * @hidden Loads a glTF animation channel.
  68778. * @param context The context when loading the asset
  68779. * @param animationContext The context of the animation when loading the asset
  68780. * @param animation The glTF animation property
  68781. * @param channel The glTF animation channel property
  68782. * @param babylonAnimationGroup The babylon animation group property
  68783. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  68784. * @returns A void promise when the channel load is complete
  68785. */
  68786. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  68787. private _loadAnimationSamplerAsync;
  68788. private _loadBufferAsync;
  68789. /**
  68790. * Loads a glTF buffer view.
  68791. * @param context The context when loading the asset
  68792. * @param bufferView The glTF buffer view property
  68793. * @returns A promise that resolves with the loaded data when the load is complete
  68794. */
  68795. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  68796. private _loadAccessorAsync;
  68797. private _loadFloatAccessorAsync;
  68798. private _loadIndicesAccessorAsync;
  68799. private _loadVertexBufferViewAsync;
  68800. private _loadVertexAccessorAsync;
  68801. private _loadMaterialMetallicRoughnessPropertiesAsync;
  68802. /** @hidden */
  68803. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  68804. private _createDefaultMaterial;
  68805. /**
  68806. * Creates a Babylon material from a glTF material.
  68807. * @param context The context when loading the asset
  68808. * @param material The glTF material property
  68809. * @param babylonDrawMode The draw mode for the Babylon material
  68810. * @returns The Babylon material
  68811. */
  68812. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  68813. /**
  68814. * Loads properties from a glTF material into a Babylon material.
  68815. * @param context The context when loading the asset
  68816. * @param material The glTF material property
  68817. * @param babylonMaterial The Babylon material
  68818. * @returns A promise that resolves when the load is complete
  68819. */
  68820. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68821. /**
  68822. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  68823. * @param context The context when loading the asset
  68824. * @param material The glTF material property
  68825. * @param babylonMaterial The Babylon material
  68826. * @returns A promise that resolves when the load is complete
  68827. */
  68828. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68829. /**
  68830. * Loads the alpha properties from a glTF material into a Babylon material.
  68831. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  68832. * @param context The context when loading the asset
  68833. * @param material The glTF material property
  68834. * @param babylonMaterial The Babylon material
  68835. */
  68836. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  68837. /**
  68838. * Loads a glTF texture info.
  68839. * @param context The context when loading the asset
  68840. * @param textureInfo The glTF texture info property
  68841. * @param assign A function called synchronously after parsing the glTF properties
  68842. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  68843. */
  68844. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  68845. private _loadTextureAsync;
  68846. private _loadSampler;
  68847. /**
  68848. * Loads a glTF image.
  68849. * @param context The context when loading the asset
  68850. * @param image The glTF image property
  68851. * @returns A promise that resolves with the loaded data when the load is complete
  68852. */
  68853. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  68854. /**
  68855. * Loads a glTF uri.
  68856. * @param context The context when loading the asset
  68857. * @param property The glTF property associated with the uri
  68858. * @param uri The base64 or relative uri
  68859. * @returns A promise that resolves with the loaded data when the load is complete
  68860. */
  68861. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  68862. private _onProgress;
  68863. /**
  68864. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  68865. * @param babylonObject the Babylon object with metadata
  68866. * @param pointer the JSON pointer
  68867. */
  68868. static AddPointerMetadata(babylonObject: {
  68869. metadata: any;
  68870. }, pointer: string): void;
  68871. private static _GetTextureWrapMode;
  68872. private static _GetTextureSamplingMode;
  68873. private static _GetTypedArrayConstructor;
  68874. private static _GetTypedArray;
  68875. private static _GetNumComponents;
  68876. private static _ValidateUri;
  68877. private static _GetDrawMode;
  68878. private _compileMaterialsAsync;
  68879. private _compileShadowGeneratorsAsync;
  68880. private _forEachExtensions;
  68881. private _applyExtensions;
  68882. private _extensionsOnLoading;
  68883. private _extensionsOnReady;
  68884. private _extensionsLoadSceneAsync;
  68885. private _extensionsLoadNodeAsync;
  68886. private _extensionsLoadCameraAsync;
  68887. private _extensionsLoadVertexDataAsync;
  68888. private _extensionsLoadMeshPrimitiveAsync;
  68889. private _extensionsLoadMaterialAsync;
  68890. private _extensionsCreateMaterial;
  68891. private _extensionsLoadMaterialPropertiesAsync;
  68892. private _extensionsLoadTextureInfoAsync;
  68893. private _extensionsLoadAnimationAsync;
  68894. private _extensionsLoadSkinAsync;
  68895. private _extensionsLoadUriAsync;
  68896. /**
  68897. * Helper method called by a loader extension to load an glTF extension.
  68898. * @param context The context when loading the asset
  68899. * @param property The glTF property to load the extension from
  68900. * @param extensionName The name of the extension to load
  68901. * @param actionAsync The action to run
  68902. * @returns The promise returned by actionAsync or null if the extension does not exist
  68903. */
  68904. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68905. /**
  68906. * Helper method called by a loader extension to load a glTF extra.
  68907. * @param context The context when loading the asset
  68908. * @param property The glTF property to load the extra from
  68909. * @param extensionName The name of the extension to load
  68910. * @param actionAsync The action to run
  68911. * @returns The promise returned by actionAsync or null if the extra does not exist
  68912. */
  68913. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68914. /**
  68915. * Increments the indentation level and logs a message.
  68916. * @param message The message to log
  68917. */
  68918. logOpen(message: string): void;
  68919. /**
  68920. * Decrements the indentation level.
  68921. */
  68922. logClose(): void;
  68923. /**
  68924. * Logs a message
  68925. * @param message The message to log
  68926. */
  68927. log(message: string): void;
  68928. /**
  68929. * Starts a performance counter.
  68930. * @param counterName The name of the performance counter
  68931. */
  68932. startPerformanceCounter(counterName: string): void;
  68933. /**
  68934. * Ends a performance counter.
  68935. * @param counterName The name of the performance counter
  68936. */
  68937. endPerformanceCounter(counterName: string): void;
  68938. }
  68939. }
  68940. declare module BABYLON.GLTF2.Loader.Extensions {
  68941. /**
  68942. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  68943. */
  68944. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  68945. /** The name of this extension. */
  68946. readonly name: string;
  68947. /** Defines whether this extension is enabled. */
  68948. enabled: boolean;
  68949. private _loader;
  68950. private _lights?;
  68951. /** @hidden */
  68952. constructor(loader: GLTFLoader);
  68953. /** @hidden */
  68954. dispose(): void;
  68955. /** @hidden */
  68956. onLoading(): void;
  68957. /** @hidden */
  68958. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68959. private _loadLightAsync;
  68960. }
  68961. }
  68962. declare module BABYLON.GLTF2.Loader.Extensions {
  68963. /**
  68964. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  68965. */
  68966. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  68967. /** The name of this extension. */
  68968. readonly name: string;
  68969. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  68970. dracoCompression?: DracoCompression;
  68971. /** Defines whether this extension is enabled. */
  68972. enabled: boolean;
  68973. private _loader;
  68974. /** @hidden */
  68975. constructor(loader: GLTFLoader);
  68976. /** @hidden */
  68977. dispose(): void;
  68978. /** @hidden */
  68979. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68980. }
  68981. }
  68982. declare module BABYLON.GLTF2.Loader.Extensions {
  68983. /**
  68984. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  68985. */
  68986. export class KHR_lights implements IGLTFLoaderExtension {
  68987. /** The name of this extension. */
  68988. readonly name: string;
  68989. /** Defines whether this extension is enabled. */
  68990. enabled: boolean;
  68991. private _loader;
  68992. private _lights?;
  68993. /** @hidden */
  68994. constructor(loader: GLTFLoader);
  68995. /** @hidden */
  68996. dispose(): void;
  68997. /** @hidden */
  68998. onLoading(): void;
  68999. /** @hidden */
  69000. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69001. }
  69002. }
  69003. declare module BABYLON.GLTF2.Loader.Extensions {
  69004. /**
  69005. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  69006. */
  69007. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  69008. /** The name of this extension. */
  69009. readonly name: string;
  69010. /** Defines whether this extension is enabled. */
  69011. enabled: boolean;
  69012. private _loader;
  69013. /** @hidden */
  69014. constructor(loader: GLTFLoader);
  69015. /** @hidden */
  69016. dispose(): void;
  69017. /** @hidden */
  69018. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69019. private _loadSpecularGlossinessPropertiesAsync;
  69020. }
  69021. }
  69022. declare module BABYLON.GLTF2.Loader.Extensions {
  69023. /**
  69024. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  69025. */
  69026. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  69027. /** The name of this extension. */
  69028. readonly name: string;
  69029. /** Defines whether this extension is enabled. */
  69030. enabled: boolean;
  69031. private _loader;
  69032. /** @hidden */
  69033. constructor(loader: GLTFLoader);
  69034. /** @hidden */
  69035. dispose(): void;
  69036. /** @hidden */
  69037. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69038. private _loadUnlitPropertiesAsync;
  69039. }
  69040. }
  69041. declare module BABYLON.GLTF2.Loader.Extensions {
  69042. /**
  69043. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  69044. */
  69045. export class KHR_texture_transform implements IGLTFLoaderExtension {
  69046. /** The name of this extension. */
  69047. readonly name: string;
  69048. /** Defines whether this extension is enabled. */
  69049. enabled: boolean;
  69050. private _loader;
  69051. /** @hidden */
  69052. constructor(loader: GLTFLoader);
  69053. /** @hidden */
  69054. dispose(): void;
  69055. /** @hidden */
  69056. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69057. }
  69058. }
  69059. declare module BABYLON.GLTF2.Loader.Extensions {
  69060. /**
  69061. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  69062. */
  69063. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  69064. /** The name of this extension. */
  69065. readonly name: string;
  69066. /** Defines whether this extension is enabled. */
  69067. enabled: boolean;
  69068. private _loader;
  69069. private _clips;
  69070. private _emitters;
  69071. /** @hidden */
  69072. constructor(loader: GLTFLoader);
  69073. /** @hidden */
  69074. dispose(): void;
  69075. /** @hidden */
  69076. onLoading(): void;
  69077. /** @hidden */
  69078. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69079. /** @hidden */
  69080. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69081. /** @hidden */
  69082. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69083. private _loadClipAsync;
  69084. private _loadEmitterAsync;
  69085. private _getEventAction;
  69086. private _loadAnimationEventAsync;
  69087. }
  69088. }
  69089. declare module BABYLON.GLTF2.Loader.Extensions {
  69090. /**
  69091. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  69092. */
  69093. export class MSFT_lod implements IGLTFLoaderExtension {
  69094. /** The name of this extension. */
  69095. readonly name: string;
  69096. /** Defines whether this extension is enabled. */
  69097. enabled: boolean;
  69098. /**
  69099. * Maximum number of LODs to load, starting from the lowest LOD.
  69100. */
  69101. maxLODsToLoad: number;
  69102. /**
  69103. * Observable raised when all node LODs of one level are loaded.
  69104. * The event data is the index of the loaded LOD starting from zero.
  69105. * Dispose the loader to cancel the loading of the next level of LODs.
  69106. */
  69107. onNodeLODsLoadedObservable: Observable<number>;
  69108. /**
  69109. * Observable raised when all material LODs of one level are loaded.
  69110. * The event data is the index of the loaded LOD starting from zero.
  69111. * Dispose the loader to cancel the loading of the next level of LODs.
  69112. */
  69113. onMaterialLODsLoadedObservable: Observable<number>;
  69114. private _loader;
  69115. private _nodeIndexLOD;
  69116. private _nodeSignalLODs;
  69117. private _nodePromiseLODs;
  69118. private _materialIndexLOD;
  69119. private _materialSignalLODs;
  69120. private _materialPromiseLODs;
  69121. /** @hidden */
  69122. constructor(loader: GLTFLoader);
  69123. /** @hidden */
  69124. dispose(): void;
  69125. /** @hidden */
  69126. onReady(): void;
  69127. /** @hidden */
  69128. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69129. /** @hidden */
  69130. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69131. /** @hidden */
  69132. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69133. /**
  69134. * Gets an array of LOD properties from lowest to highest.
  69135. */
  69136. private _getLODs;
  69137. private _disposeUnusedMaterials;
  69138. }
  69139. }
  69140. declare module BABYLON.GLTF2.Loader.Extensions {
  69141. /** @hidden */
  69142. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  69143. readonly name: string;
  69144. enabled: boolean;
  69145. private _loader;
  69146. constructor(loader: GLTFLoader);
  69147. dispose(): void;
  69148. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69149. }
  69150. }
  69151. declare module BABYLON.GLTF2.Loader.Extensions {
  69152. /** @hidden */
  69153. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  69154. readonly name: string;
  69155. enabled: boolean;
  69156. private _loader;
  69157. constructor(loader: GLTFLoader);
  69158. dispose(): void;
  69159. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69160. }
  69161. }
  69162. declare module BABYLON.GLTF2.Loader.Extensions {
  69163. /**
  69164. * Store glTF extras (if present) in BJS objects' metadata
  69165. */
  69166. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  69167. /** The name of this extension. */
  69168. readonly name: string;
  69169. /** Defines whether this extension is enabled. */
  69170. enabled: boolean;
  69171. private _loader;
  69172. private _assignExtras;
  69173. /** @hidden */
  69174. constructor(loader: GLTFLoader);
  69175. /** @hidden */
  69176. dispose(): void;
  69177. /** @hidden */
  69178. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69179. /** @hidden */
  69180. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69181. /** @hidden */
  69182. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69183. }
  69184. }
  69185. declare module BABYLON {
  69186. /**
  69187. * Class reading and parsing the MTL file bundled with the obj file.
  69188. */
  69189. export class MTLFileLoader {
  69190. /**
  69191. * All material loaded from the mtl will be set here
  69192. */
  69193. materials: StandardMaterial[];
  69194. /**
  69195. * This function will read the mtl file and create each material described inside
  69196. * This function could be improve by adding :
  69197. * -some component missing (Ni, Tf...)
  69198. * -including the specific options available
  69199. *
  69200. * @param scene defines the scene the material will be created in
  69201. * @param data defines the mtl data to parse
  69202. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  69203. */
  69204. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  69205. /**
  69206. * Gets the texture for the material.
  69207. *
  69208. * If the material is imported from input file,
  69209. * We sanitize the url to ensure it takes the textre from aside the material.
  69210. *
  69211. * @param rootUrl The root url to load from
  69212. * @param value The value stored in the mtl
  69213. * @return The Texture
  69214. */
  69215. private static _getTexture;
  69216. }
  69217. /**
  69218. * Options for loading OBJ/MTL files
  69219. */
  69220. type MeshLoadOptions = {
  69221. /**
  69222. * Defines if UVs are optimized by default during load.
  69223. */
  69224. OptimizeWithUV: boolean;
  69225. /**
  69226. * Defines custom scaling of UV coordinates of loaded meshes.
  69227. */
  69228. UVScaling: Vector2;
  69229. /**
  69230. * Invert model on y-axis (does a model scaling inversion)
  69231. */
  69232. InvertY: boolean;
  69233. /**
  69234. * Invert Y-Axis of referenced textures on load
  69235. */
  69236. InvertTextureY: boolean;
  69237. /**
  69238. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69239. */
  69240. ImportVertexColors: boolean;
  69241. /**
  69242. * Compute the normals for the model, even if normals are present in the file.
  69243. */
  69244. ComputeNormals: boolean;
  69245. /**
  69246. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69247. */
  69248. SkipMaterials: boolean;
  69249. /**
  69250. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69251. */
  69252. MaterialLoadingFailsSilently: boolean;
  69253. };
  69254. /**
  69255. * OBJ file type loader.
  69256. * This is a babylon scene loader plugin.
  69257. */
  69258. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  69259. /**
  69260. * Defines if UVs are optimized by default during load.
  69261. */
  69262. static OPTIMIZE_WITH_UV: boolean;
  69263. /**
  69264. * Invert model on y-axis (does a model scaling inversion)
  69265. */
  69266. static INVERT_Y: boolean;
  69267. /**
  69268. * Invert Y-Axis of referenced textures on load
  69269. */
  69270. static INVERT_TEXTURE_Y: boolean;
  69271. /**
  69272. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69273. */
  69274. static IMPORT_VERTEX_COLORS: boolean;
  69275. /**
  69276. * Compute the normals for the model, even if normals are present in the file.
  69277. */
  69278. static COMPUTE_NORMALS: boolean;
  69279. /**
  69280. * Defines custom scaling of UV coordinates of loaded meshes.
  69281. */
  69282. static UV_SCALING: Vector2;
  69283. /**
  69284. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69285. */
  69286. static SKIP_MATERIALS: boolean;
  69287. /**
  69288. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69289. *
  69290. * Defaults to true for backwards compatibility.
  69291. */
  69292. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  69293. /**
  69294. * Defines the name of the plugin.
  69295. */
  69296. name: string;
  69297. /**
  69298. * Defines the extension the plugin is able to load.
  69299. */
  69300. extensions: string;
  69301. /** @hidden */
  69302. obj: RegExp;
  69303. /** @hidden */
  69304. group: RegExp;
  69305. /** @hidden */
  69306. mtllib: RegExp;
  69307. /** @hidden */
  69308. usemtl: RegExp;
  69309. /** @hidden */
  69310. smooth: RegExp;
  69311. /** @hidden */
  69312. vertexPattern: RegExp;
  69313. /** @hidden */
  69314. normalPattern: RegExp;
  69315. /** @hidden */
  69316. uvPattern: RegExp;
  69317. /** @hidden */
  69318. facePattern1: RegExp;
  69319. /** @hidden */
  69320. facePattern2: RegExp;
  69321. /** @hidden */
  69322. facePattern3: RegExp;
  69323. /** @hidden */
  69324. facePattern4: RegExp;
  69325. /** @hidden */
  69326. facePattern5: RegExp;
  69327. private _meshLoadOptions;
  69328. /**
  69329. * Creates loader for .OBJ files
  69330. *
  69331. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  69332. */
  69333. constructor(meshLoadOptions?: MeshLoadOptions);
  69334. private static readonly currentMeshLoadOptions;
  69335. /**
  69336. * Calls synchronously the MTL file attached to this obj.
  69337. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  69338. * Without this function materials are not displayed in the first frame (but displayed after).
  69339. * In consequence it is impossible to get material information in your HTML file
  69340. *
  69341. * @param url The URL of the MTL file
  69342. * @param rootUrl
  69343. * @param onSuccess Callback function to be called when the MTL file is loaded
  69344. * @private
  69345. */
  69346. private _loadMTL;
  69347. /**
  69348. * Instantiates a OBJ file loader plugin.
  69349. * @returns the created plugin
  69350. */
  69351. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  69352. /**
  69353. * If the data string can be loaded directly.
  69354. *
  69355. * @param data string containing the file data
  69356. * @returns if the data can be loaded directly
  69357. */
  69358. canDirectLoad(data: string): boolean;
  69359. /**
  69360. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  69361. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69362. * @param scene the scene the meshes should be added to
  69363. * @param data the OBJ data to load
  69364. * @param rootUrl root url to load from
  69365. * @param onProgress event that fires when loading progress has occured
  69366. * @param fileName Defines the name of the file to load
  69367. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69368. */
  69369. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69370. meshes: AbstractMesh[];
  69371. particleSystems: IParticleSystem[];
  69372. skeletons: Skeleton[];
  69373. animationGroups: AnimationGroup[];
  69374. }>;
  69375. /**
  69376. * Imports all objects from the loaded OBJ data and adds them to the scene
  69377. * @param scene the scene the objects should be added to
  69378. * @param data the OBJ data to load
  69379. * @param rootUrl root url to load from
  69380. * @param onProgress event that fires when loading progress has occured
  69381. * @param fileName Defines the name of the file to load
  69382. * @returns a promise which completes when objects have been loaded to the scene
  69383. */
  69384. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69385. /**
  69386. * Load into an asset container.
  69387. * @param scene The scene to load into
  69388. * @param data The data to import
  69389. * @param rootUrl The root url for scene and resources
  69390. * @param onProgress The callback when the load progresses
  69391. * @param fileName Defines the name of the file to load
  69392. * @returns The loaded asset container
  69393. */
  69394. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69395. /**
  69396. * Read the OBJ file and create an Array of meshes.
  69397. * Each mesh contains all information given by the OBJ and the MTL file.
  69398. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69399. *
  69400. * @param meshesNames
  69401. * @param scene Scene The scene where are displayed the data
  69402. * @param data String The content of the obj file
  69403. * @param rootUrl String The path to the folder
  69404. * @returns Array<AbstractMesh>
  69405. * @private
  69406. */
  69407. private _parseSolid;
  69408. }
  69409. }
  69410. declare module BABYLON {
  69411. /**
  69412. * STL file type loader.
  69413. * This is a babylon scene loader plugin.
  69414. */
  69415. export class STLFileLoader implements ISceneLoaderPlugin {
  69416. /** @hidden */
  69417. solidPattern: RegExp;
  69418. /** @hidden */
  69419. facetsPattern: RegExp;
  69420. /** @hidden */
  69421. normalPattern: RegExp;
  69422. /** @hidden */
  69423. vertexPattern: RegExp;
  69424. /**
  69425. * Defines the name of the plugin.
  69426. */
  69427. name: string;
  69428. /**
  69429. * Defines the extensions the stl loader is able to load.
  69430. * force data to come in as an ArrayBuffer
  69431. * we'll convert to string if it looks like it's an ASCII .stl
  69432. */
  69433. extensions: ISceneLoaderPluginExtensions;
  69434. /**
  69435. * Import meshes into a scene.
  69436. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  69437. * @param scene The scene to import into
  69438. * @param data The data to import
  69439. * @param rootUrl The root url for scene and resources
  69440. * @param meshes The meshes array to import into
  69441. * @param particleSystems The particle systems array to import into
  69442. * @param skeletons The skeletons array to import into
  69443. * @param onError The callback when import fails
  69444. * @returns True if successful or false otherwise
  69445. */
  69446. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  69447. /**
  69448. * Load into a scene.
  69449. * @param scene The scene to load into
  69450. * @param data The data to import
  69451. * @param rootUrl The root url for scene and resources
  69452. * @param onError The callback when import fails
  69453. * @returns true if successful or false otherwise
  69454. */
  69455. load(scene: Scene, data: any, rootUrl: string): boolean;
  69456. /**
  69457. * Load into an asset container.
  69458. * @param scene The scene to load into
  69459. * @param data The data to import
  69460. * @param rootUrl The root url for scene and resources
  69461. * @param onError The callback when import fails
  69462. * @returns The loaded asset container
  69463. */
  69464. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  69465. private _isBinary;
  69466. private _parseBinary;
  69467. private _parseASCII;
  69468. }
  69469. }
  69470. declare module BABYLON {
  69471. /**
  69472. * Class for generating OBJ data from a Babylon scene.
  69473. */
  69474. export class OBJExport {
  69475. /**
  69476. * Exports the geometry of a Mesh array in .OBJ file format (text)
  69477. * @param mesh defines the list of meshes to serialize
  69478. * @param materials defines if materials should be exported
  69479. * @param matlibname defines the name of the associated mtl file
  69480. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  69481. * @returns the OBJ content
  69482. */
  69483. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  69484. /**
  69485. * Exports the material(s) of a mesh in .MTL file format (text)
  69486. * @param mesh defines the mesh to extract the material from
  69487. * @returns the mtl content
  69488. */
  69489. static MTL(mesh: Mesh): string;
  69490. }
  69491. }
  69492. declare module BABYLON {
  69493. /** @hidden */
  69494. export var __IGLTFExporterExtension: number;
  69495. /**
  69496. * Interface for extending the exporter
  69497. * @hidden
  69498. */
  69499. export interface IGLTFExporterExtension {
  69500. /**
  69501. * The name of this extension
  69502. */
  69503. readonly name: string;
  69504. /**
  69505. * Defines whether this extension is enabled
  69506. */
  69507. enabled: boolean;
  69508. /**
  69509. * Defines whether this extension is required
  69510. */
  69511. required: boolean;
  69512. }
  69513. }
  69514. declare module BABYLON.GLTF2.Exporter {
  69515. /** @hidden */
  69516. export var __IGLTFExporterExtensionV2: number;
  69517. /**
  69518. * Interface for a glTF exporter extension
  69519. * @hidden
  69520. */
  69521. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  69522. /**
  69523. * Define this method to modify the default behavior before exporting a texture
  69524. * @param context The context when loading the asset
  69525. * @param babylonTexture The glTF texture info property
  69526. * @param mimeType The mime-type of the generated image
  69527. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  69528. */
  69529. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69530. /**
  69531. * Define this method to modify the default behavior when exporting texture info
  69532. * @param context The context when loading the asset
  69533. * @param meshPrimitive glTF mesh primitive
  69534. * @param babylonSubMesh Babylon submesh
  69535. * @param binaryWriter glTF serializer binary writer instance
  69536. * @returns nullable IMeshPrimitive promise
  69537. */
  69538. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69539. /**
  69540. * Define this method to modify the default behavior when exporting a node
  69541. * @param context The context when exporting the node
  69542. * @param node glTF node
  69543. * @param babylonNode BabylonJS node
  69544. * @returns nullable INode promise
  69545. */
  69546. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69547. /**
  69548. * Called after the exporter state changes to EXPORTING
  69549. */
  69550. onExporting?(): void;
  69551. }
  69552. }
  69553. declare module BABYLON.GLTF2.Exporter {
  69554. /**
  69555. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  69556. * @hidden
  69557. */
  69558. export class _GLTFMaterialExporter {
  69559. /**
  69560. * Represents the dielectric specular values for R, G and B
  69561. */
  69562. private static readonly _DielectricSpecular;
  69563. /**
  69564. * Allows the maximum specular power to be defined for material calculations
  69565. */
  69566. private static readonly _MaxSpecularPower;
  69567. /**
  69568. * Mapping to store textures
  69569. */
  69570. private _textureMap;
  69571. /**
  69572. * Numeric tolerance value
  69573. */
  69574. private static readonly _Epsilon;
  69575. /**
  69576. * Reference to the glTF Exporter
  69577. */
  69578. private _exporter;
  69579. constructor(exporter: _Exporter);
  69580. /**
  69581. * Specifies if two colors are approximately equal in value
  69582. * @param color1 first color to compare to
  69583. * @param color2 second color to compare to
  69584. * @param epsilon threshold value
  69585. */
  69586. private static FuzzyEquals;
  69587. /**
  69588. * Gets the materials from a Babylon scene and converts them to glTF materials
  69589. * @param scene babylonjs scene
  69590. * @param mimeType texture mime type
  69591. * @param images array of images
  69592. * @param textures array of textures
  69593. * @param materials array of materials
  69594. * @param imageData mapping of texture names to base64 textures
  69595. * @param hasTextureCoords specifies if texture coordinates are present on the material
  69596. */
  69597. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69598. /**
  69599. * Makes a copy of the glTF material without the texture parameters
  69600. * @param originalMaterial original glTF material
  69601. * @returns glTF material without texture parameters
  69602. */
  69603. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  69604. /**
  69605. * Specifies if the material has any texture parameters present
  69606. * @param material glTF Material
  69607. * @returns boolean specifying if texture parameters are present
  69608. */
  69609. _hasTexturesPresent(material: IMaterial): boolean;
  69610. /**
  69611. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  69612. * @param babylonStandardMaterial
  69613. * @returns glTF Metallic Roughness Material representation
  69614. */
  69615. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  69616. /**
  69617. * Computes the metallic factor
  69618. * @param diffuse diffused value
  69619. * @param specular specular value
  69620. * @param oneMinusSpecularStrength one minus the specular strength
  69621. * @returns metallic value
  69622. */
  69623. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  69624. /**
  69625. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  69626. * @param glTFMaterial glTF material
  69627. * @param babylonMaterial Babylon material
  69628. */
  69629. private static _SetAlphaMode;
  69630. /**
  69631. * Converts a Babylon Standard Material to a glTF Material
  69632. * @param babylonStandardMaterial BJS Standard Material
  69633. * @param mimeType mime type to use for the textures
  69634. * @param images array of glTF image interfaces
  69635. * @param textures array of glTF texture interfaces
  69636. * @param materials array of glTF material interfaces
  69637. * @param imageData map of image file name to data
  69638. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69639. */
  69640. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69641. /**
  69642. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69643. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  69644. * @param mimeType mime type to use for the textures
  69645. * @param images array of glTF image interfaces
  69646. * @param textures array of glTF texture interfaces
  69647. * @param materials array of glTF material interfaces
  69648. * @param imageData map of image file name to data
  69649. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69650. */
  69651. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69652. /**
  69653. * Converts an image typed array buffer to a base64 image
  69654. * @param buffer typed array buffer
  69655. * @param width width of the image
  69656. * @param height height of the image
  69657. * @param mimeType mimetype of the image
  69658. * @returns base64 image string
  69659. */
  69660. private _createBase64FromCanvasAsync;
  69661. /**
  69662. * Generates a white texture based on the specified width and height
  69663. * @param width width of the texture in pixels
  69664. * @param height height of the texture in pixels
  69665. * @param scene babylonjs scene
  69666. * @returns white texture
  69667. */
  69668. private _createWhiteTexture;
  69669. /**
  69670. * 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
  69671. * @param texture1 first texture to resize
  69672. * @param texture2 second texture to resize
  69673. * @param scene babylonjs scene
  69674. * @returns resized textures or null
  69675. */
  69676. private _resizeTexturesToSameDimensions;
  69677. /**
  69678. * Converts an array of pixels to a Float32Array
  69679. * Throws an error if the pixel format is not supported
  69680. * @param pixels - array buffer containing pixel values
  69681. * @returns Float32 of pixels
  69682. */
  69683. private _convertPixelArrayToFloat32;
  69684. /**
  69685. * Convert Specular Glossiness Textures to Metallic Roughness
  69686. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  69687. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  69688. * @param diffuseTexture texture used to store diffuse information
  69689. * @param specularGlossinessTexture texture used to store specular and glossiness information
  69690. * @param factors specular glossiness material factors
  69691. * @param mimeType the mime type to use for the texture
  69692. * @returns pbr metallic roughness interface or null
  69693. */
  69694. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  69695. /**
  69696. * Converts specular glossiness material properties to metallic roughness
  69697. * @param specularGlossiness interface with specular glossiness material properties
  69698. * @returns interface with metallic roughness material properties
  69699. */
  69700. private _convertSpecularGlossinessToMetallicRoughness;
  69701. /**
  69702. * Calculates the surface reflectance, independent of lighting conditions
  69703. * @param color Color source to calculate brightness from
  69704. * @returns number representing the perceived brightness, or zero if color is undefined
  69705. */
  69706. private _getPerceivedBrightness;
  69707. /**
  69708. * Returns the maximum color component value
  69709. * @param color
  69710. * @returns maximum color component value, or zero if color is null or undefined
  69711. */
  69712. private _getMaxComponent;
  69713. /**
  69714. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  69715. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69716. * @param mimeType mime type to use for the textures
  69717. * @param images array of glTF image interfaces
  69718. * @param textures array of glTF texture interfaces
  69719. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69720. * @param imageData map of image file name to data
  69721. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69722. * @returns glTF PBR Metallic Roughness factors
  69723. */
  69724. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  69725. private _getGLTFTextureSampler;
  69726. private _getGLTFTextureWrapMode;
  69727. private _getGLTFTextureWrapModesSampler;
  69728. /**
  69729. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  69730. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69731. * @param mimeType mime type to use for the textures
  69732. * @param images array of glTF image interfaces
  69733. * @param textures array of glTF texture interfaces
  69734. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69735. * @param imageData map of image file name to data
  69736. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69737. * @returns glTF PBR Metallic Roughness factors
  69738. */
  69739. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  69740. /**
  69741. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69742. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69743. * @param mimeType mime type to use for the textures
  69744. * @param images array of glTF image interfaces
  69745. * @param textures array of glTF texture interfaces
  69746. * @param materials array of glTF material interfaces
  69747. * @param imageData map of image file name to data
  69748. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69749. */
  69750. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69751. private setMetallicRoughnessPbrMaterial;
  69752. private getPixelsFromTexture;
  69753. /**
  69754. * Extracts a texture from a Babylon texture into file data and glTF data
  69755. * @param babylonTexture Babylon texture to extract
  69756. * @param mimeType Mime Type of the babylonTexture
  69757. * @return glTF texture info, or null if the texture format is not supported
  69758. */
  69759. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69760. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69761. /**
  69762. * Builds a texture from base64 string
  69763. * @param base64Texture base64 texture string
  69764. * @param baseTextureName Name to use for the texture
  69765. * @param mimeType image mime type for the texture
  69766. * @param images array of images
  69767. * @param textures array of textures
  69768. * @param imageData map of image data
  69769. * @returns glTF texture info, or null if the texture format is not supported
  69770. */
  69771. private _getTextureInfoFromBase64;
  69772. }
  69773. }
  69774. declare module BABYLON {
  69775. /**
  69776. * Class for holding and downloading glTF file data
  69777. */
  69778. export class GLTFData {
  69779. /**
  69780. * Object which contains the file name as the key and its data as the value
  69781. */
  69782. glTFFiles: {
  69783. [fileName: string]: string | Blob;
  69784. };
  69785. /**
  69786. * Initializes the glTF file object
  69787. */
  69788. constructor();
  69789. /**
  69790. * Downloads the glTF data as files based on their names and data
  69791. */
  69792. downloadFiles(): void;
  69793. }
  69794. }
  69795. declare module BABYLON {
  69796. /**
  69797. * Holds a collection of exporter options and parameters
  69798. */
  69799. export interface IExportOptions {
  69800. /**
  69801. * Function which indicates whether a babylon node should be exported or not
  69802. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  69803. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  69804. */
  69805. shouldExportNode?(node: Node): boolean;
  69806. /**
  69807. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  69808. * @param metadata source metadata to read from
  69809. * @returns the data to store to glTF node extras
  69810. */
  69811. metadataSelector?(metadata: any): any;
  69812. /**
  69813. * The sample rate to bake animation curves
  69814. */
  69815. animationSampleRate?: number;
  69816. /**
  69817. * Begin serialization without waiting for the scene to be ready
  69818. */
  69819. exportWithoutWaitingForScene?: boolean;
  69820. }
  69821. /**
  69822. * Class for generating glTF data from a Babylon scene.
  69823. */
  69824. export class GLTF2Export {
  69825. /**
  69826. * Exports the geometry of the scene to .gltf file format asynchronously
  69827. * @param scene Babylon scene with scene hierarchy information
  69828. * @param filePrefix File prefix to use when generating the glTF file
  69829. * @param options Exporter options
  69830. * @returns Returns an object with a .gltf file and associates texture names
  69831. * as keys and their data and paths as values
  69832. */
  69833. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69834. private static _PreExportAsync;
  69835. private static _PostExportAsync;
  69836. /**
  69837. * Exports the geometry of the scene to .glb file format asychronously
  69838. * @param scene Babylon scene with scene hierarchy information
  69839. * @param filePrefix File prefix to use when generating glb file
  69840. * @param options Exporter options
  69841. * @returns Returns an object with a .glb filename as key and data as value
  69842. */
  69843. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69844. }
  69845. }
  69846. declare module BABYLON.GLTF2.Exporter {
  69847. /**
  69848. * @hidden
  69849. */
  69850. export class _GLTFUtilities {
  69851. /**
  69852. * Creates a buffer view based on the supplied arguments
  69853. * @param bufferIndex index value of the specified buffer
  69854. * @param byteOffset byte offset value
  69855. * @param byteLength byte length of the bufferView
  69856. * @param byteStride byte distance between conequential elements
  69857. * @param name name of the buffer view
  69858. * @returns bufferView for glTF
  69859. */
  69860. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  69861. /**
  69862. * Creates an accessor based on the supplied arguments
  69863. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  69864. * @param name The name of the accessor
  69865. * @param type The type of the accessor
  69866. * @param componentType The datatype of components in the attribute
  69867. * @param count The number of attributes referenced by this accessor
  69868. * @param byteOffset The offset relative to the start of the bufferView in bytes
  69869. * @param min Minimum value of each component in this attribute
  69870. * @param max Maximum value of each component in this attribute
  69871. * @returns accessor for glTF
  69872. */
  69873. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  69874. /**
  69875. * Calculates the minimum and maximum values of an array of position floats
  69876. * @param positions Positions array of a mesh
  69877. * @param vertexStart Starting vertex offset to calculate min and max values
  69878. * @param vertexCount Number of vertices to check for min and max values
  69879. * @returns min number array and max number array
  69880. */
  69881. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  69882. min: number[];
  69883. max: number[];
  69884. };
  69885. /**
  69886. * Converts a new right-handed Vector3
  69887. * @param vector vector3 array
  69888. * @returns right-handed Vector3
  69889. */
  69890. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  69891. /**
  69892. * Converts a Vector3 to right-handed
  69893. * @param vector Vector3 to convert to right-handed
  69894. */
  69895. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  69896. /**
  69897. * Converts a three element number array to right-handed
  69898. * @param vector number array to convert to right-handed
  69899. */
  69900. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  69901. /**
  69902. * Converts a new right-handed Vector3
  69903. * @param vector vector3 array
  69904. * @returns right-handed Vector3
  69905. */
  69906. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  69907. /**
  69908. * Converts a Vector3 to right-handed
  69909. * @param vector Vector3 to convert to right-handed
  69910. */
  69911. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  69912. /**
  69913. * Converts a three element number array to right-handed
  69914. * @param vector number array to convert to right-handed
  69915. */
  69916. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  69917. /**
  69918. * Converts a Vector4 to right-handed
  69919. * @param vector Vector4 to convert to right-handed
  69920. */
  69921. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  69922. /**
  69923. * Converts a Vector4 to right-handed
  69924. * @param vector Vector4 to convert to right-handed
  69925. */
  69926. static _GetRightHandedArray4FromRef(vector: number[]): void;
  69927. /**
  69928. * Converts a Quaternion to right-handed
  69929. * @param quaternion Source quaternion to convert to right-handed
  69930. */
  69931. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  69932. /**
  69933. * Converts a Quaternion to right-handed
  69934. * @param quaternion Source quaternion to convert to right-handed
  69935. */
  69936. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  69937. static _NormalizeTangentFromRef(tangent: Vector4): void;
  69938. }
  69939. }
  69940. declare module BABYLON.GLTF2.Exporter {
  69941. /**
  69942. * Converts Babylon Scene into glTF 2.0.
  69943. * @hidden
  69944. */
  69945. export class _Exporter {
  69946. /**
  69947. * Stores the glTF to export
  69948. */
  69949. _glTF: IGLTF;
  69950. /**
  69951. * Stores all generated buffer views, which represents views into the main glTF buffer data
  69952. */
  69953. _bufferViews: IBufferView[];
  69954. /**
  69955. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  69956. */
  69957. _accessors: IAccessor[];
  69958. /**
  69959. * Stores all the generated nodes, which contains transform and/or mesh information per node
  69960. */
  69961. private _nodes;
  69962. /**
  69963. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  69964. */
  69965. private _scenes;
  69966. /**
  69967. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  69968. */
  69969. private _meshes;
  69970. /**
  69971. * Stores all the generated material information, which represents the appearance of each primitive
  69972. */
  69973. _materials: IMaterial[];
  69974. _materialMap: {
  69975. [materialID: number]: number;
  69976. };
  69977. /**
  69978. * Stores all the generated texture information, which is referenced by glTF materials
  69979. */
  69980. _textures: ITexture[];
  69981. /**
  69982. * Stores all the generated image information, which is referenced by glTF textures
  69983. */
  69984. _images: IImage[];
  69985. /**
  69986. * Stores all the texture samplers
  69987. */
  69988. _samplers: ISampler[];
  69989. /**
  69990. * Stores all the generated animation samplers, which is referenced by glTF animations
  69991. */
  69992. /**
  69993. * Stores the animations for glTF models
  69994. */
  69995. private _animations;
  69996. /**
  69997. * Stores the total amount of bytes stored in the glTF buffer
  69998. */
  69999. private _totalByteLength;
  70000. /**
  70001. * Stores a reference to the Babylon scene containing the source geometry and material information
  70002. */
  70003. _babylonScene: Scene;
  70004. /**
  70005. * Stores a map of the image data, where the key is the file name and the value
  70006. * is the image data
  70007. */
  70008. _imageData: {
  70009. [fileName: string]: {
  70010. data: Uint8Array;
  70011. mimeType: ImageMimeType;
  70012. };
  70013. };
  70014. /**
  70015. * Stores a map of the unique id of a node to its index in the node array
  70016. */
  70017. private _nodeMap;
  70018. /**
  70019. * Specifies if the Babylon scene should be converted to right-handed on export
  70020. */
  70021. _convertToRightHandedSystem: boolean;
  70022. /**
  70023. * Baked animation sample rate
  70024. */
  70025. private _animationSampleRate;
  70026. private _options;
  70027. private _localEngine;
  70028. _glTFMaterialExporter: _GLTFMaterialExporter;
  70029. private _extensions;
  70030. private static _ExtensionNames;
  70031. private static _ExtensionFactories;
  70032. private _applyExtensions;
  70033. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  70034. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70035. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70036. private _forEachExtensions;
  70037. private _extensionsOnExporting;
  70038. /**
  70039. * Load glTF serializer extensions
  70040. */
  70041. private _loadExtensions;
  70042. /**
  70043. * Creates a glTF Exporter instance, which can accept optional exporter options
  70044. * @param babylonScene Babylon scene object
  70045. * @param options Options to modify the behavior of the exporter
  70046. */
  70047. constructor(babylonScene: Scene, options?: IExportOptions);
  70048. /**
  70049. * Registers a glTF exporter extension
  70050. * @param name Name of the extension to export
  70051. * @param factory The factory function that creates the exporter extension
  70052. */
  70053. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  70054. /**
  70055. * Un-registers an exporter extension
  70056. * @param name The name fo the exporter extension
  70057. * @returns A boolean indicating whether the extension has been un-registered
  70058. */
  70059. static UnregisterExtension(name: string): boolean;
  70060. /**
  70061. * Lazy load a local engine with premultiplied alpha set to false
  70062. */
  70063. _getLocalEngine(): Engine;
  70064. private reorderIndicesBasedOnPrimitiveMode;
  70065. /**
  70066. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  70067. * clock-wise during export to glTF
  70068. * @param submesh BabylonJS submesh
  70069. * @param primitiveMode Primitive mode of the mesh
  70070. * @param sideOrientation the winding order of the submesh
  70071. * @param vertexBufferKind The type of vertex attribute
  70072. * @param meshAttributeArray The vertex attribute data
  70073. * @param byteOffset The offset to the binary data
  70074. * @param binaryWriter The binary data for the glTF file
  70075. */
  70076. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  70077. /**
  70078. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  70079. * clock-wise during export to glTF
  70080. * @param submesh BabylonJS submesh
  70081. * @param primitiveMode Primitive mode of the mesh
  70082. * @param sideOrientation the winding order of the submesh
  70083. * @param vertexBufferKind The type of vertex attribute
  70084. * @param meshAttributeArray The vertex attribute data
  70085. * @param byteOffset The offset to the binary data
  70086. * @param binaryWriter The binary data for the glTF file
  70087. */
  70088. private reorderTriangleFillMode;
  70089. /**
  70090. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  70091. * clock-wise during export to glTF
  70092. * @param submesh BabylonJS submesh
  70093. * @param primitiveMode Primitive mode of the mesh
  70094. * @param sideOrientation the winding order of the submesh
  70095. * @param vertexBufferKind The type of vertex attribute
  70096. * @param meshAttributeArray The vertex attribute data
  70097. * @param byteOffset The offset to the binary data
  70098. * @param binaryWriter The binary data for the glTF file
  70099. */
  70100. private reorderTriangleStripDrawMode;
  70101. /**
  70102. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  70103. * clock-wise during export to glTF
  70104. * @param submesh BabylonJS submesh
  70105. * @param primitiveMode Primitive mode of the mesh
  70106. * @param sideOrientation the winding order of the submesh
  70107. * @param vertexBufferKind The type of vertex attribute
  70108. * @param meshAttributeArray The vertex attribute data
  70109. * @param byteOffset The offset to the binary data
  70110. * @param binaryWriter The binary data for the glTF file
  70111. */
  70112. private reorderTriangleFanMode;
  70113. /**
  70114. * Writes the vertex attribute data to binary
  70115. * @param vertices The vertices to write to the binary writer
  70116. * @param byteOffset The offset into the binary writer to overwrite binary data
  70117. * @param vertexAttributeKind The vertex attribute type
  70118. * @param meshAttributeArray The vertex attribute data
  70119. * @param binaryWriter The writer containing the binary data
  70120. */
  70121. private writeVertexAttributeData;
  70122. /**
  70123. * Writes mesh attribute data to a data buffer
  70124. * Returns the bytelength of the data
  70125. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  70126. * @param meshAttributeArray Array containing the attribute data
  70127. * @param binaryWriter The buffer to write the binary data to
  70128. * @param indices Used to specify the order of the vertex data
  70129. */
  70130. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  70131. /**
  70132. * Generates glTF json data
  70133. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  70134. * @param glTFPrefix Text to use when prefixing a glTF file
  70135. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  70136. * @returns json data as string
  70137. */
  70138. private generateJSON;
  70139. /**
  70140. * Generates data for .gltf and .bin files based on the glTF prefix string
  70141. * @param glTFPrefix Text to use when prefixing a glTF file
  70142. * @returns GLTFData with glTF file data
  70143. */
  70144. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  70145. /**
  70146. * Creates a binary buffer for glTF
  70147. * @returns array buffer for binary data
  70148. */
  70149. private _generateBinaryAsync;
  70150. /**
  70151. * Pads the number to a multiple of 4
  70152. * @param num number to pad
  70153. * @returns padded number
  70154. */
  70155. private _getPadding;
  70156. /**
  70157. * Generates a glb file from the json and binary data
  70158. * Returns an object with the glb file name as the key and data as the value
  70159. * @param glTFPrefix
  70160. * @returns object with glb filename as key and data as value
  70161. */
  70162. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  70163. /**
  70164. * Sets the TRS for each node
  70165. * @param node glTF Node for storing the transformation data
  70166. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  70167. */
  70168. private setNodeTransformation;
  70169. private getVertexBufferFromMesh;
  70170. /**
  70171. * Creates a bufferview based on the vertices type for the Babylon mesh
  70172. * @param kind Indicates the type of vertices data
  70173. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  70174. * @param binaryWriter The buffer to write the bufferview data to
  70175. */
  70176. private createBufferViewKind;
  70177. /**
  70178. * The primitive mode of the Babylon mesh
  70179. * @param babylonMesh The BabylonJS mesh
  70180. */
  70181. private getMeshPrimitiveMode;
  70182. /**
  70183. * Sets the primitive mode of the glTF mesh primitive
  70184. * @param meshPrimitive glTF mesh primitive
  70185. * @param primitiveMode The primitive mode
  70186. */
  70187. private setPrimitiveMode;
  70188. /**
  70189. * Sets the vertex attribute accessor based of the glTF mesh primitive
  70190. * @param meshPrimitive glTF mesh primitive
  70191. * @param attributeKind vertex attribute
  70192. * @returns boolean specifying if uv coordinates are present
  70193. */
  70194. private setAttributeKind;
  70195. /**
  70196. * Sets data for the primitive attributes of each submesh
  70197. * @param mesh glTF Mesh object to store the primitive attribute information
  70198. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  70199. * @param binaryWriter Buffer to write the attribute data to
  70200. */
  70201. private setPrimitiveAttributesAsync;
  70202. /**
  70203. * Creates a glTF scene based on the array of meshes
  70204. * Returns the the total byte offset
  70205. * @param babylonScene Babylon scene to get the mesh data from
  70206. * @param binaryWriter Buffer to write binary data to
  70207. */
  70208. private createSceneAsync;
  70209. /**
  70210. * Creates a mapping of Node unique id to node index and handles animations
  70211. * @param babylonScene Babylon Scene
  70212. * @param nodes Babylon transform nodes
  70213. * @param binaryWriter Buffer to write binary data to
  70214. * @returns Node mapping of unique id to index
  70215. */
  70216. private createNodeMapAndAnimationsAsync;
  70217. /**
  70218. * Creates a glTF node from a Babylon mesh
  70219. * @param babylonMesh Source Babylon mesh
  70220. * @param binaryWriter Buffer for storing geometry data
  70221. * @returns glTF node
  70222. */
  70223. private createNodeAsync;
  70224. }
  70225. /**
  70226. * @hidden
  70227. *
  70228. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  70229. */
  70230. export class _BinaryWriter {
  70231. /**
  70232. * Array buffer which stores all binary data
  70233. */
  70234. private _arrayBuffer;
  70235. /**
  70236. * View of the array buffer
  70237. */
  70238. private _dataView;
  70239. /**
  70240. * byte offset of data in array buffer
  70241. */
  70242. private _byteOffset;
  70243. /**
  70244. * Initialize binary writer with an initial byte length
  70245. * @param byteLength Initial byte length of the array buffer
  70246. */
  70247. constructor(byteLength: number);
  70248. /**
  70249. * Resize the array buffer to the specified byte length
  70250. * @param byteLength
  70251. */
  70252. private resizeBuffer;
  70253. /**
  70254. * Get an array buffer with the length of the byte offset
  70255. * @returns ArrayBuffer resized to the byte offset
  70256. */
  70257. getArrayBuffer(): ArrayBuffer;
  70258. /**
  70259. * Get the byte offset of the array buffer
  70260. * @returns byte offset
  70261. */
  70262. getByteOffset(): number;
  70263. /**
  70264. * Stores an UInt8 in the array buffer
  70265. * @param entry
  70266. * @param byteOffset If defined, specifies where to set the value as an offset.
  70267. */
  70268. setUInt8(entry: number, byteOffset?: number): void;
  70269. /**
  70270. * Gets an UInt32 in the array buffer
  70271. * @param entry
  70272. * @param byteOffset If defined, specifies where to set the value as an offset.
  70273. */
  70274. getUInt32(byteOffset: number): number;
  70275. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70276. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70277. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70278. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70279. /**
  70280. * Stores a Float32 in the array buffer
  70281. * @param entry
  70282. */
  70283. setFloat32(entry: number, byteOffset?: number): void;
  70284. /**
  70285. * Stores an UInt32 in the array buffer
  70286. * @param entry
  70287. * @param byteOffset If defined, specifies where to set the value as an offset.
  70288. */
  70289. setUInt32(entry: number, byteOffset?: number): void;
  70290. }
  70291. }
  70292. declare module BABYLON.GLTF2.Exporter {
  70293. /**
  70294. * @hidden
  70295. * Interface to store animation data.
  70296. */
  70297. export interface _IAnimationData {
  70298. /**
  70299. * Keyframe data.
  70300. */
  70301. inputs: number[];
  70302. /**
  70303. * Value data.
  70304. */
  70305. outputs: number[][];
  70306. /**
  70307. * Animation interpolation data.
  70308. */
  70309. samplerInterpolation: AnimationSamplerInterpolation;
  70310. /**
  70311. * Minimum keyframe value.
  70312. */
  70313. inputsMin: number;
  70314. /**
  70315. * Maximum keyframe value.
  70316. */
  70317. inputsMax: number;
  70318. }
  70319. /**
  70320. * @hidden
  70321. */
  70322. export interface _IAnimationInfo {
  70323. /**
  70324. * The target channel for the animation
  70325. */
  70326. animationChannelTargetPath: AnimationChannelTargetPath;
  70327. /**
  70328. * The glTF accessor type for the data.
  70329. */
  70330. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  70331. /**
  70332. * Specifies if quaternions should be used.
  70333. */
  70334. useQuaternion: boolean;
  70335. }
  70336. /**
  70337. * @hidden
  70338. * Utility class for generating glTF animation data from BabylonJS.
  70339. */
  70340. export class _GLTFAnimation {
  70341. /**
  70342. * @ignore
  70343. *
  70344. * Creates glTF channel animation from BabylonJS animation.
  70345. * @param babylonTransformNode - BabylonJS mesh.
  70346. * @param animation - animation.
  70347. * @param animationChannelTargetPath - The target animation channel.
  70348. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  70349. * @param useQuaternion - Specifies if quaternions are used.
  70350. * @returns nullable IAnimationData
  70351. */
  70352. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  70353. private static _DeduceAnimationInfo;
  70354. /**
  70355. * @ignore
  70356. * Create node animations from the transform node animations
  70357. * @param babylonNode
  70358. * @param runtimeGLTFAnimation
  70359. * @param idleGLTFAnimations
  70360. * @param nodeMap
  70361. * @param nodes
  70362. * @param binaryWriter
  70363. * @param bufferViews
  70364. * @param accessors
  70365. * @param convertToRightHandedSystem
  70366. */
  70367. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  70368. [key: number]: number;
  70369. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70370. /**
  70371. * @ignore
  70372. * Create node animations from the animation groups
  70373. * @param babylonScene
  70374. * @param glTFAnimations
  70375. * @param nodeMap
  70376. * @param nodes
  70377. * @param binaryWriter
  70378. * @param bufferViews
  70379. * @param accessors
  70380. * @param convertToRightHandedSystem
  70381. */
  70382. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70383. [key: number]: number;
  70384. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70385. private static AddAnimation;
  70386. /**
  70387. * Create a baked animation
  70388. * @param babylonTransformNode BabylonJS mesh
  70389. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70390. * @param animationChannelTargetPath animation target channel
  70391. * @param minFrame minimum animation frame
  70392. * @param maxFrame maximum animation frame
  70393. * @param fps frames per second of the animation
  70394. * @param inputs input key frames of the animation
  70395. * @param outputs output key frame data of the animation
  70396. * @param convertToRightHandedSystem converts the values to right-handed
  70397. * @param useQuaternion specifies if quaternions should be used
  70398. */
  70399. private static _CreateBakedAnimation;
  70400. private static _ConvertFactorToVector3OrQuaternion;
  70401. private static _SetInterpolatedValue;
  70402. /**
  70403. * Creates linear animation from the animation key frames
  70404. * @param babylonTransformNode BabylonJS mesh
  70405. * @param animation BabylonJS animation
  70406. * @param animationChannelTargetPath The target animation channel
  70407. * @param frameDelta The difference between the last and first frame of the animation
  70408. * @param inputs Array to store the key frame times
  70409. * @param outputs Array to store the key frame data
  70410. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70411. * @param useQuaternion Specifies if quaternions are used in the animation
  70412. */
  70413. private static _CreateLinearOrStepAnimation;
  70414. /**
  70415. * Creates cubic spline animation from the animation key frames
  70416. * @param babylonTransformNode BabylonJS mesh
  70417. * @param animation BabylonJS animation
  70418. * @param animationChannelTargetPath The target animation channel
  70419. * @param frameDelta The difference between the last and first frame of the animation
  70420. * @param inputs Array to store the key frame times
  70421. * @param outputs Array to store the key frame data
  70422. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70423. * @param useQuaternion Specifies if quaternions are used in the animation
  70424. */
  70425. private static _CreateCubicSplineAnimation;
  70426. private static _GetBasePositionRotationOrScale;
  70427. /**
  70428. * Adds a key frame value
  70429. * @param keyFrame
  70430. * @param animation
  70431. * @param outputs
  70432. * @param animationChannelTargetPath
  70433. * @param basePositionRotationOrScale
  70434. * @param convertToRightHandedSystem
  70435. * @param useQuaternion
  70436. */
  70437. private static _AddKeyframeValue;
  70438. /**
  70439. * Determine the interpolation based on the key frames
  70440. * @param keyFrames
  70441. * @param animationChannelTargetPath
  70442. * @param useQuaternion
  70443. */
  70444. private static _DeduceInterpolation;
  70445. /**
  70446. * Adds an input tangent or output tangent to the output data
  70447. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  70448. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  70449. * @param outputs The animation data by keyframe
  70450. * @param animationChannelTargetPath The target animation channel
  70451. * @param interpolation The interpolation type
  70452. * @param keyFrame The key frame with the animation data
  70453. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  70454. * @param useQuaternion Specifies if quaternions are used
  70455. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  70456. */
  70457. private static AddSplineTangent;
  70458. /**
  70459. * Get the minimum and maximum key frames' frame values
  70460. * @param keyFrames animation key frames
  70461. * @returns the minimum and maximum key frame value
  70462. */
  70463. private static calculateMinMaxKeyFrames;
  70464. }
  70465. }
  70466. declare module BABYLON.GLTF2.Exporter {
  70467. /** @hidden */
  70468. export var textureTransformPixelShader: {
  70469. name: string;
  70470. shader: string;
  70471. };
  70472. }
  70473. declare module BABYLON.GLTF2.Exporter.Extensions {
  70474. /**
  70475. * @hidden
  70476. */
  70477. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  70478. /** Name of this extension */
  70479. readonly name: string;
  70480. /** Defines whether this extension is enabled */
  70481. enabled: boolean;
  70482. /** Defines whether this extension is required */
  70483. required: boolean;
  70484. /** Reference to the glTF exporter */
  70485. private _exporter;
  70486. constructor(exporter: _Exporter);
  70487. dispose(): void;
  70488. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70489. /**
  70490. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  70491. * @param babylonTexture
  70492. * @param offset
  70493. * @param rotation
  70494. * @param scale
  70495. * @param scene
  70496. */
  70497. private _textureTransformTextureAsync;
  70498. }
  70499. }
  70500. declare module BABYLON.GLTF2.Exporter.Extensions {
  70501. /**
  70502. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70503. */
  70504. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  70505. /** The name of this extension. */
  70506. readonly name: string;
  70507. /** Defines whether this extension is enabled. */
  70508. enabled: boolean;
  70509. /** Defines whether this extension is required */
  70510. required: boolean;
  70511. /** Reference to the glTF exporter */
  70512. private _exporter;
  70513. private _lights;
  70514. /** @hidden */
  70515. constructor(exporter: _Exporter);
  70516. /** @hidden */
  70517. dispose(): void;
  70518. /** @hidden */
  70519. onExporting(): void;
  70520. /**
  70521. * Define this method to modify the default behavior when exporting a node
  70522. * @param context The context when exporting the node
  70523. * @param node glTF node
  70524. * @param babylonNode BabylonJS node
  70525. * @returns nullable INode promise
  70526. */
  70527. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70528. }
  70529. }
  70530. declare module BABYLON {
  70531. /**
  70532. * Class for generating STL data from a Babylon scene.
  70533. */
  70534. export class STLExport {
  70535. /**
  70536. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  70537. * @param meshes list defines the mesh to serialize
  70538. * @param download triggers the automatic download of the file.
  70539. * @param fileName changes the downloads fileName.
  70540. * @param binary changes the STL to a binary type.
  70541. * @param isLittleEndian toggle for binary type exporter.
  70542. * @returns the STL as UTF8 string
  70543. */
  70544. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  70545. }
  70546. }
  70547. declare module "babylonjs-gltf2interface" {
  70548. export = BABYLON.GLTF2;
  70549. }
  70550. /**
  70551. * Module for glTF 2.0 Interface
  70552. */
  70553. declare module BABYLON.GLTF2 {
  70554. /**
  70555. * The datatype of the components in the attribute
  70556. */
  70557. const enum AccessorComponentType {
  70558. /**
  70559. * Byte
  70560. */
  70561. BYTE = 5120,
  70562. /**
  70563. * Unsigned Byte
  70564. */
  70565. UNSIGNED_BYTE = 5121,
  70566. /**
  70567. * Short
  70568. */
  70569. SHORT = 5122,
  70570. /**
  70571. * Unsigned Short
  70572. */
  70573. UNSIGNED_SHORT = 5123,
  70574. /**
  70575. * Unsigned Int
  70576. */
  70577. UNSIGNED_INT = 5125,
  70578. /**
  70579. * Float
  70580. */
  70581. FLOAT = 5126,
  70582. }
  70583. /**
  70584. * Specifies if the attirbute is a scalar, vector, or matrix
  70585. */
  70586. const enum AccessorType {
  70587. /**
  70588. * Scalar
  70589. */
  70590. SCALAR = "SCALAR",
  70591. /**
  70592. * Vector2
  70593. */
  70594. VEC2 = "VEC2",
  70595. /**
  70596. * Vector3
  70597. */
  70598. VEC3 = "VEC3",
  70599. /**
  70600. * Vector4
  70601. */
  70602. VEC4 = "VEC4",
  70603. /**
  70604. * Matrix2x2
  70605. */
  70606. MAT2 = "MAT2",
  70607. /**
  70608. * Matrix3x3
  70609. */
  70610. MAT3 = "MAT3",
  70611. /**
  70612. * Matrix4x4
  70613. */
  70614. MAT4 = "MAT4",
  70615. }
  70616. /**
  70617. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70618. */
  70619. const enum AnimationChannelTargetPath {
  70620. /**
  70621. * Translation
  70622. */
  70623. TRANSLATION = "translation",
  70624. /**
  70625. * Rotation
  70626. */
  70627. ROTATION = "rotation",
  70628. /**
  70629. * Scale
  70630. */
  70631. SCALE = "scale",
  70632. /**
  70633. * Weights
  70634. */
  70635. WEIGHTS = "weights",
  70636. }
  70637. /**
  70638. * Interpolation algorithm
  70639. */
  70640. const enum AnimationSamplerInterpolation {
  70641. /**
  70642. * The animated values are linearly interpolated between keyframes
  70643. */
  70644. LINEAR = "LINEAR",
  70645. /**
  70646. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  70647. */
  70648. STEP = "STEP",
  70649. /**
  70650. * The animation's interpolation is computed using a cubic spline with specified tangents
  70651. */
  70652. CUBICSPLINE = "CUBICSPLINE",
  70653. }
  70654. /**
  70655. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70656. */
  70657. const enum CameraType {
  70658. /**
  70659. * A perspective camera containing properties to create a perspective projection matrix
  70660. */
  70661. PERSPECTIVE = "perspective",
  70662. /**
  70663. * An orthographic camera containing properties to create an orthographic projection matrix
  70664. */
  70665. ORTHOGRAPHIC = "orthographic",
  70666. }
  70667. /**
  70668. * The mime-type of the image
  70669. */
  70670. const enum ImageMimeType {
  70671. /**
  70672. * JPEG Mime-type
  70673. */
  70674. JPEG = "image/jpeg",
  70675. /**
  70676. * PNG Mime-type
  70677. */
  70678. PNG = "image/png",
  70679. }
  70680. /**
  70681. * The alpha rendering mode of the material
  70682. */
  70683. const enum MaterialAlphaMode {
  70684. /**
  70685. * The alpha value is ignored and the rendered output is fully opaque
  70686. */
  70687. OPAQUE = "OPAQUE",
  70688. /**
  70689. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  70690. */
  70691. MASK = "MASK",
  70692. /**
  70693. * 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)
  70694. */
  70695. BLEND = "BLEND",
  70696. }
  70697. /**
  70698. * The type of the primitives to render
  70699. */
  70700. const enum MeshPrimitiveMode {
  70701. /**
  70702. * Points
  70703. */
  70704. POINTS = 0,
  70705. /**
  70706. * Lines
  70707. */
  70708. LINES = 1,
  70709. /**
  70710. * Line Loop
  70711. */
  70712. LINE_LOOP = 2,
  70713. /**
  70714. * Line Strip
  70715. */
  70716. LINE_STRIP = 3,
  70717. /**
  70718. * Triangles
  70719. */
  70720. TRIANGLES = 4,
  70721. /**
  70722. * Triangle Strip
  70723. */
  70724. TRIANGLE_STRIP = 5,
  70725. /**
  70726. * Triangle Fan
  70727. */
  70728. TRIANGLE_FAN = 6,
  70729. }
  70730. /**
  70731. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70732. */
  70733. const enum TextureMagFilter {
  70734. /**
  70735. * Nearest
  70736. */
  70737. NEAREST = 9728,
  70738. /**
  70739. * Linear
  70740. */
  70741. LINEAR = 9729,
  70742. }
  70743. /**
  70744. * Minification filter. All valid values correspond to WebGL enums
  70745. */
  70746. const enum TextureMinFilter {
  70747. /**
  70748. * Nearest
  70749. */
  70750. NEAREST = 9728,
  70751. /**
  70752. * Linear
  70753. */
  70754. LINEAR = 9729,
  70755. /**
  70756. * Nearest Mip-Map Nearest
  70757. */
  70758. NEAREST_MIPMAP_NEAREST = 9984,
  70759. /**
  70760. * Linear Mipmap Nearest
  70761. */
  70762. LINEAR_MIPMAP_NEAREST = 9985,
  70763. /**
  70764. * Nearest Mipmap Linear
  70765. */
  70766. NEAREST_MIPMAP_LINEAR = 9986,
  70767. /**
  70768. * Linear Mipmap Linear
  70769. */
  70770. LINEAR_MIPMAP_LINEAR = 9987,
  70771. }
  70772. /**
  70773. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70774. */
  70775. const enum TextureWrapMode {
  70776. /**
  70777. * Clamp to Edge
  70778. */
  70779. CLAMP_TO_EDGE = 33071,
  70780. /**
  70781. * Mirrored Repeat
  70782. */
  70783. MIRRORED_REPEAT = 33648,
  70784. /**
  70785. * Repeat
  70786. */
  70787. REPEAT = 10497,
  70788. }
  70789. /**
  70790. * glTF Property
  70791. */
  70792. interface IProperty {
  70793. /**
  70794. * Dictionary object with extension-specific objects
  70795. */
  70796. extensions?: {
  70797. [key: string]: any;
  70798. };
  70799. /**
  70800. * Application-Specific data
  70801. */
  70802. extras?: any;
  70803. }
  70804. /**
  70805. * glTF Child of Root Property
  70806. */
  70807. interface IChildRootProperty extends IProperty {
  70808. /**
  70809. * The user-defined name of this object
  70810. */
  70811. name?: string;
  70812. }
  70813. /**
  70814. * Indices of those attributes that deviate from their initialization value
  70815. */
  70816. interface IAccessorSparseIndices extends IProperty {
  70817. /**
  70818. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70819. */
  70820. bufferView: number;
  70821. /**
  70822. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70823. */
  70824. byteOffset?: number;
  70825. /**
  70826. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  70827. */
  70828. componentType: AccessorComponentType;
  70829. }
  70830. /**
  70831. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  70832. */
  70833. interface IAccessorSparseValues extends IProperty {
  70834. /**
  70835. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70836. */
  70837. bufferView: number;
  70838. /**
  70839. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70840. */
  70841. byteOffset?: number;
  70842. }
  70843. /**
  70844. * Sparse storage of attributes that deviate from their initialization value
  70845. */
  70846. interface IAccessorSparse extends IProperty {
  70847. /**
  70848. * The number of attributes encoded in this sparse accessor
  70849. */
  70850. count: number;
  70851. /**
  70852. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  70853. */
  70854. indices: IAccessorSparseIndices;
  70855. /**
  70856. * 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
  70857. */
  70858. values: IAccessorSparseValues;
  70859. }
  70860. /**
  70861. * 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
  70862. */
  70863. interface IAccessor extends IChildRootProperty {
  70864. /**
  70865. * The index of the bufferview
  70866. */
  70867. bufferView?: number;
  70868. /**
  70869. * The offset relative to the start of the bufferView in bytes
  70870. */
  70871. byteOffset?: number;
  70872. /**
  70873. * The datatype of components in the attribute
  70874. */
  70875. componentType: AccessorComponentType;
  70876. /**
  70877. * Specifies whether integer data values should be normalized
  70878. */
  70879. normalized?: boolean;
  70880. /**
  70881. * The number of attributes referenced by this accessor
  70882. */
  70883. count: number;
  70884. /**
  70885. * Specifies if the attribute is a scalar, vector, or matrix
  70886. */
  70887. type: AccessorType;
  70888. /**
  70889. * Maximum value of each component in this attribute
  70890. */
  70891. max?: number[];
  70892. /**
  70893. * Minimum value of each component in this attribute
  70894. */
  70895. min?: number[];
  70896. /**
  70897. * Sparse storage of attributes that deviate from their initialization value
  70898. */
  70899. sparse?: IAccessorSparse;
  70900. }
  70901. /**
  70902. * Targets an animation's sampler at a node's property
  70903. */
  70904. interface IAnimationChannel extends IProperty {
  70905. /**
  70906. * The index of a sampler in this animation used to compute the value for the target
  70907. */
  70908. sampler: number;
  70909. /**
  70910. * The index of the node and TRS property to target
  70911. */
  70912. target: IAnimationChannelTarget;
  70913. }
  70914. /**
  70915. * The index of the node and TRS property that an animation channel targets
  70916. */
  70917. interface IAnimationChannelTarget extends IProperty {
  70918. /**
  70919. * The index of the node to target
  70920. */
  70921. node: number;
  70922. /**
  70923. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70924. */
  70925. path: AnimationChannelTargetPath;
  70926. }
  70927. /**
  70928. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70929. */
  70930. interface IAnimationSampler extends IProperty {
  70931. /**
  70932. * The index of an accessor containing keyframe input values, e.g., time
  70933. */
  70934. input: number;
  70935. /**
  70936. * Interpolation algorithm
  70937. */
  70938. interpolation?: AnimationSamplerInterpolation;
  70939. /**
  70940. * The index of an accessor, containing keyframe output values
  70941. */
  70942. output: number;
  70943. }
  70944. /**
  70945. * A keyframe animation
  70946. */
  70947. interface IAnimation extends IChildRootProperty {
  70948. /**
  70949. * An array of channels, each of which targets an animation's sampler at a node's property
  70950. */
  70951. channels: IAnimationChannel[];
  70952. /**
  70953. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70954. */
  70955. samplers: IAnimationSampler[];
  70956. }
  70957. /**
  70958. * Metadata about the glTF asset
  70959. */
  70960. interface IAsset extends IChildRootProperty {
  70961. /**
  70962. * A copyright message suitable for display to credit the content creator
  70963. */
  70964. copyright?: string;
  70965. /**
  70966. * Tool that generated this glTF model. Useful for debugging
  70967. */
  70968. generator?: string;
  70969. /**
  70970. * The glTF version that this asset targets
  70971. */
  70972. version: string;
  70973. /**
  70974. * The minimum glTF version that this asset targets
  70975. */
  70976. minVersion?: string;
  70977. }
  70978. /**
  70979. * A buffer points to binary geometry, animation, or skins
  70980. */
  70981. interface IBuffer extends IChildRootProperty {
  70982. /**
  70983. * 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
  70984. */
  70985. uri?: string;
  70986. /**
  70987. * The length of the buffer in bytes
  70988. */
  70989. byteLength: number;
  70990. }
  70991. /**
  70992. * A view into a buffer generally representing a subset of the buffer
  70993. */
  70994. interface IBufferView extends IChildRootProperty {
  70995. /**
  70996. * The index of the buffer
  70997. */
  70998. buffer: number;
  70999. /**
  71000. * The offset into the buffer in bytes
  71001. */
  71002. byteOffset?: number;
  71003. /**
  71004. * The lenth of the bufferView in bytes
  71005. */
  71006. byteLength: number;
  71007. /**
  71008. * The stride, in bytes
  71009. */
  71010. byteStride?: number;
  71011. }
  71012. /**
  71013. * An orthographic camera containing properties to create an orthographic projection matrix
  71014. */
  71015. interface ICameraOrthographic extends IProperty {
  71016. /**
  71017. * The floating-point horizontal magnification of the view. Must not be zero
  71018. */
  71019. xmag: number;
  71020. /**
  71021. * The floating-point vertical magnification of the view. Must not be zero
  71022. */
  71023. ymag: number;
  71024. /**
  71025. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  71026. */
  71027. zfar: number;
  71028. /**
  71029. * The floating-point distance to the near clipping plane
  71030. */
  71031. znear: number;
  71032. }
  71033. /**
  71034. * A perspective camera containing properties to create a perspective projection matrix
  71035. */
  71036. interface ICameraPerspective extends IProperty {
  71037. /**
  71038. * The floating-point aspect ratio of the field of view
  71039. */
  71040. aspectRatio?: number;
  71041. /**
  71042. * The floating-point vertical field of view in radians
  71043. */
  71044. yfov: number;
  71045. /**
  71046. * The floating-point distance to the far clipping plane
  71047. */
  71048. zfar?: number;
  71049. /**
  71050. * The floating-point distance to the near clipping plane
  71051. */
  71052. znear: number;
  71053. }
  71054. /**
  71055. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71056. */
  71057. interface ICamera extends IChildRootProperty {
  71058. /**
  71059. * An orthographic camera containing properties to create an orthographic projection matrix
  71060. */
  71061. orthographic?: ICameraOrthographic;
  71062. /**
  71063. * A perspective camera containing properties to create a perspective projection matrix
  71064. */
  71065. perspective?: ICameraPerspective;
  71066. /**
  71067. * Specifies if the camera uses a perspective or orthographic projection
  71068. */
  71069. type: CameraType;
  71070. }
  71071. /**
  71072. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  71073. */
  71074. interface IImage extends IChildRootProperty {
  71075. /**
  71076. * 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
  71077. */
  71078. uri?: string;
  71079. /**
  71080. * The image's MIME type
  71081. */
  71082. mimeType?: ImageMimeType;
  71083. /**
  71084. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  71085. */
  71086. bufferView?: number;
  71087. }
  71088. /**
  71089. * Material Normal Texture Info
  71090. */
  71091. interface IMaterialNormalTextureInfo extends ITextureInfo {
  71092. /**
  71093. * The scalar multiplier applied to each normal vector of the normal texture
  71094. */
  71095. scale?: number;
  71096. }
  71097. /**
  71098. * Material Occlusion Texture Info
  71099. */
  71100. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  71101. /**
  71102. * A scalar multiplier controlling the amount of occlusion applied
  71103. */
  71104. strength?: number;
  71105. }
  71106. /**
  71107. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  71108. */
  71109. interface IMaterialPbrMetallicRoughness {
  71110. /**
  71111. * The material's base color factor
  71112. */
  71113. baseColorFactor?: number[];
  71114. /**
  71115. * The base color texture
  71116. */
  71117. baseColorTexture?: ITextureInfo;
  71118. /**
  71119. * The metalness of the material
  71120. */
  71121. metallicFactor?: number;
  71122. /**
  71123. * The roughness of the material
  71124. */
  71125. roughnessFactor?: number;
  71126. /**
  71127. * The metallic-roughness texture
  71128. */
  71129. metallicRoughnessTexture?: ITextureInfo;
  71130. }
  71131. /**
  71132. * The material appearance of a primitive
  71133. */
  71134. interface IMaterial extends IChildRootProperty {
  71135. /**
  71136. * 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
  71137. */
  71138. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71139. /**
  71140. * The normal map texture
  71141. */
  71142. normalTexture?: IMaterialNormalTextureInfo;
  71143. /**
  71144. * The occlusion map texture
  71145. */
  71146. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71147. /**
  71148. * The emissive map texture
  71149. */
  71150. emissiveTexture?: ITextureInfo;
  71151. /**
  71152. * 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
  71153. */
  71154. emissiveFactor?: number[];
  71155. /**
  71156. * The alpha rendering mode of the material
  71157. */
  71158. alphaMode?: MaterialAlphaMode;
  71159. /**
  71160. * The alpha cutoff value of the material
  71161. */
  71162. alphaCutoff?: number;
  71163. /**
  71164. * Specifies whether the material is double sided
  71165. */
  71166. doubleSided?: boolean;
  71167. }
  71168. /**
  71169. * Geometry to be rendered with the given material
  71170. */
  71171. interface IMeshPrimitive extends IProperty {
  71172. /**
  71173. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  71174. */
  71175. attributes: {
  71176. [name: string]: number;
  71177. };
  71178. /**
  71179. * The index of the accessor that contains the indices
  71180. */
  71181. indices?: number;
  71182. /**
  71183. * The index of the material to apply to this primitive when rendering
  71184. */
  71185. material?: number;
  71186. /**
  71187. * The type of primitives to render. All valid values correspond to WebGL enums
  71188. */
  71189. mode?: MeshPrimitiveMode;
  71190. /**
  71191. * 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
  71192. */
  71193. targets?: {
  71194. [name: string]: number;
  71195. }[];
  71196. }
  71197. /**
  71198. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  71199. */
  71200. interface IMesh extends IChildRootProperty {
  71201. /**
  71202. * An array of primitives, each defining geometry to be rendered with a material
  71203. */
  71204. primitives: IMeshPrimitive[];
  71205. /**
  71206. * Array of weights to be applied to the Morph Targets
  71207. */
  71208. weights?: number[];
  71209. }
  71210. /**
  71211. * A node in the node hierarchy
  71212. */
  71213. interface INode extends IChildRootProperty {
  71214. /**
  71215. * The index of the camera referenced by this node
  71216. */
  71217. camera?: number;
  71218. /**
  71219. * The indices of this node's children
  71220. */
  71221. children?: number[];
  71222. /**
  71223. * The index of the skin referenced by this node
  71224. */
  71225. skin?: number;
  71226. /**
  71227. * A floating-point 4x4 transformation matrix stored in column-major order
  71228. */
  71229. matrix?: number[];
  71230. /**
  71231. * The index of the mesh in this node
  71232. */
  71233. mesh?: number;
  71234. /**
  71235. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  71236. */
  71237. rotation?: number[];
  71238. /**
  71239. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  71240. */
  71241. scale?: number[];
  71242. /**
  71243. * The node's translation along the x, y, and z axes
  71244. */
  71245. translation?: number[];
  71246. /**
  71247. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  71248. */
  71249. weights?: number[];
  71250. }
  71251. /**
  71252. * Texture sampler properties for filtering and wrapping modes
  71253. */
  71254. interface ISampler extends IChildRootProperty {
  71255. /**
  71256. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71257. */
  71258. magFilter?: TextureMagFilter;
  71259. /**
  71260. * Minification filter. All valid values correspond to WebGL enums
  71261. */
  71262. minFilter?: TextureMinFilter;
  71263. /**
  71264. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71265. */
  71266. wrapS?: TextureWrapMode;
  71267. /**
  71268. * T (V) wrapping mode. All valid values correspond to WebGL enums
  71269. */
  71270. wrapT?: TextureWrapMode;
  71271. }
  71272. /**
  71273. * The root nodes of a scene
  71274. */
  71275. interface IScene extends IChildRootProperty {
  71276. /**
  71277. * The indices of each root node
  71278. */
  71279. nodes: number[];
  71280. }
  71281. /**
  71282. * Joints and matrices defining a skin
  71283. */
  71284. interface ISkin extends IChildRootProperty {
  71285. /**
  71286. * 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
  71287. */
  71288. inverseBindMatrices?: number;
  71289. /**
  71290. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  71291. */
  71292. skeleton?: number;
  71293. /**
  71294. * 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)
  71295. */
  71296. joints: number[];
  71297. }
  71298. /**
  71299. * A texture and its sampler
  71300. */
  71301. interface ITexture extends IChildRootProperty {
  71302. /**
  71303. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  71304. */
  71305. sampler?: number;
  71306. /**
  71307. * The index of the image used by this texture
  71308. */
  71309. source: number;
  71310. }
  71311. /**
  71312. * Reference to a texture
  71313. */
  71314. interface ITextureInfo extends IProperty {
  71315. /**
  71316. * The index of the texture
  71317. */
  71318. index: number;
  71319. /**
  71320. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  71321. */
  71322. texCoord?: number;
  71323. }
  71324. /**
  71325. * The root object for a glTF asset
  71326. */
  71327. interface IGLTF extends IProperty {
  71328. /**
  71329. * An array of accessors. An accessor is a typed view into a bufferView
  71330. */
  71331. accessors?: IAccessor[];
  71332. /**
  71333. * An array of keyframe animations
  71334. */
  71335. animations?: IAnimation[];
  71336. /**
  71337. * Metadata about the glTF asset
  71338. */
  71339. asset: IAsset;
  71340. /**
  71341. * An array of buffers. A buffer points to binary geometry, animation, or skins
  71342. */
  71343. buffers?: IBuffer[];
  71344. /**
  71345. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  71346. */
  71347. bufferViews?: IBufferView[];
  71348. /**
  71349. * An array of cameras
  71350. */
  71351. cameras?: ICamera[];
  71352. /**
  71353. * Names of glTF extensions used somewhere in this asset
  71354. */
  71355. extensionsUsed?: string[];
  71356. /**
  71357. * Names of glTF extensions required to properly load this asset
  71358. */
  71359. extensionsRequired?: string[];
  71360. /**
  71361. * An array of images. An image defines data used to create a texture
  71362. */
  71363. images?: IImage[];
  71364. /**
  71365. * An array of materials. A material defines the appearance of a primitive
  71366. */
  71367. materials?: IMaterial[];
  71368. /**
  71369. * An array of meshes. A mesh is a set of primitives to be rendered
  71370. */
  71371. meshes?: IMesh[];
  71372. /**
  71373. * An array of nodes
  71374. */
  71375. nodes?: INode[];
  71376. /**
  71377. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71378. */
  71379. samplers?: ISampler[];
  71380. /**
  71381. * The index of the default scene
  71382. */
  71383. scene?: number;
  71384. /**
  71385. * An array of scenes
  71386. */
  71387. scenes?: IScene[];
  71388. /**
  71389. * An array of skins. A skin is defined by joints and matrices
  71390. */
  71391. skins?: ISkin[];
  71392. /**
  71393. * An array of textures
  71394. */
  71395. textures?: ITexture[];
  71396. }
  71397. /**
  71398. * The glTF validation results
  71399. * @ignore
  71400. */
  71401. interface IGLTFValidationResults {
  71402. info: {
  71403. generator: string;
  71404. hasAnimations: boolean;
  71405. hasDefaultScene: boolean;
  71406. hasMaterials: boolean;
  71407. hasMorphTargets: boolean;
  71408. hasSkins: boolean;
  71409. hasTextures: boolean;
  71410. maxAttributesUsed: number;
  71411. primitivesCount: number
  71412. };
  71413. issues: {
  71414. messages: Array<string>;
  71415. numErrors: number;
  71416. numHints: number;
  71417. numInfos: number;
  71418. numWarnings: number;
  71419. truncated: boolean
  71420. };
  71421. mimeType: string;
  71422. uri: string;
  71423. validatedAt: string;
  71424. validatorVersion: string;
  71425. }
  71426. /**
  71427. * The glTF validation options
  71428. */
  71429. interface IGLTFValidationOptions {
  71430. /** Uri to use */
  71431. uri?: string;
  71432. /** Function used to load external resources */
  71433. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  71434. /** Boolean indicating that we need to validate accessor data */
  71435. validateAccessorData?: boolean;
  71436. /** max number of issues allowed */
  71437. maxIssues?: number;
  71438. /** Ignored issues */
  71439. ignoredIssues?: Array<string>;
  71440. /** Value to override severy settings */
  71441. severityOverrides?: Object;
  71442. }
  71443. /**
  71444. * The glTF validator object
  71445. * @ignore
  71446. */
  71447. interface IGLTFValidator {
  71448. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71449. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71450. }
  71451. }
  71452. declare module BABYLON {
  71453. /** @hidden */
  71454. export var cellPixelShader: {
  71455. name: string;
  71456. shader: string;
  71457. };
  71458. }
  71459. declare module BABYLON {
  71460. /** @hidden */
  71461. export var cellVertexShader: {
  71462. name: string;
  71463. shader: string;
  71464. };
  71465. }
  71466. declare module BABYLON {
  71467. export class CellMaterial extends BABYLON.PushMaterial {
  71468. private _diffuseTexture;
  71469. diffuseTexture: BABYLON.BaseTexture;
  71470. diffuseColor: BABYLON.Color3;
  71471. _computeHighLevel: boolean;
  71472. computeHighLevel: boolean;
  71473. private _disableLighting;
  71474. disableLighting: boolean;
  71475. private _maxSimultaneousLights;
  71476. maxSimultaneousLights: number;
  71477. private _renderId;
  71478. constructor(name: string, scene: BABYLON.Scene);
  71479. needAlphaBlending(): boolean;
  71480. needAlphaTesting(): boolean;
  71481. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71482. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71483. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71484. getAnimatables(): BABYLON.IAnimatable[];
  71485. getActiveTextures(): BABYLON.BaseTexture[];
  71486. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71487. dispose(forceDisposeEffect?: boolean): void;
  71488. getClassName(): string;
  71489. clone(name: string): CellMaterial;
  71490. serialize(): any;
  71491. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  71492. }
  71493. }
  71494. declare module BABYLON {
  71495. export class CustomShaderStructure {
  71496. FragmentStore: string;
  71497. VertexStore: string;
  71498. constructor();
  71499. }
  71500. export class ShaderSpecialParts {
  71501. constructor();
  71502. Fragment_Begin: string;
  71503. Fragment_Definitions: string;
  71504. Fragment_MainBegin: string;
  71505. Fragment_Custom_Diffuse: string;
  71506. Fragment_Before_Lights: string;
  71507. Fragment_Before_Fog: string;
  71508. Fragment_Custom_Alpha: string;
  71509. Fragment_Before_FragColor: string;
  71510. Vertex_Begin: string;
  71511. Vertex_Definitions: string;
  71512. Vertex_MainBegin: string;
  71513. Vertex_Before_PositionUpdated: string;
  71514. Vertex_Before_NormalUpdated: string;
  71515. Vertex_MainEnd: string;
  71516. }
  71517. export class CustomMaterial extends BABYLON.StandardMaterial {
  71518. static ShaderIndexer: number;
  71519. CustomParts: ShaderSpecialParts;
  71520. _isCreatedShader: boolean;
  71521. _createdShaderName: string;
  71522. _customUniform: string[];
  71523. _newUniforms: string[];
  71524. _newUniformInstances: any[];
  71525. _newSamplerInstances: BABYLON.Texture[];
  71526. FragmentShader: string;
  71527. VertexShader: string;
  71528. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71529. ReviewUniform(name: string, arr: string[]): string[];
  71530. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  71531. constructor(name: string, scene: BABYLON.Scene);
  71532. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  71533. Fragment_Begin(shaderPart: string): CustomMaterial;
  71534. Fragment_Definitions(shaderPart: string): CustomMaterial;
  71535. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  71536. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  71537. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  71538. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  71539. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  71540. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  71541. Vertex_Begin(shaderPart: string): CustomMaterial;
  71542. Vertex_Definitions(shaderPart: string): CustomMaterial;
  71543. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  71544. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  71545. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  71546. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  71547. }
  71548. }
  71549. declare module BABYLON {
  71550. export class ShaderAlebdoParts {
  71551. constructor();
  71552. Fragment_Begin: string;
  71553. Fragment_Definitions: string;
  71554. Fragment_MainBegin: string;
  71555. Fragment_Custom_Albedo: string;
  71556. Fragment_Before_Lights: string;
  71557. Fragment_Custom_MetallicRoughness: string;
  71558. Fragment_Custom_MicroSurface: string;
  71559. Fragment_Before_Fog: string;
  71560. Fragment_Custom_Alpha: string;
  71561. Fragment_Before_FragColor: string;
  71562. Vertex_Begin: string;
  71563. Vertex_Definitions: string;
  71564. Vertex_MainBegin: string;
  71565. Vertex_Before_PositionUpdated: string;
  71566. Vertex_Before_NormalUpdated: string;
  71567. Vertex_MainEnd: string;
  71568. }
  71569. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  71570. static ShaderIndexer: number;
  71571. CustomParts: ShaderAlebdoParts;
  71572. _isCreatedShader: boolean;
  71573. _createdShaderName: string;
  71574. _customUniform: string[];
  71575. _newUniforms: string[];
  71576. _newUniformInstances: any[];
  71577. _newSamplerInstances: BABYLON.Texture[];
  71578. FragmentShader: string;
  71579. VertexShader: string;
  71580. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71581. ReviewUniform(name: string, arr: string[]): string[];
  71582. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  71583. constructor(name: string, scene: BABYLON.Scene);
  71584. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  71585. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  71586. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  71587. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  71588. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  71589. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  71590. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  71591. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  71592. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  71593. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  71594. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  71595. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  71596. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  71597. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  71598. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  71599. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  71600. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  71601. }
  71602. }
  71603. declare module BABYLON {
  71604. /** @hidden */
  71605. export var firePixelShader: {
  71606. name: string;
  71607. shader: string;
  71608. };
  71609. }
  71610. declare module BABYLON {
  71611. /** @hidden */
  71612. export var fireVertexShader: {
  71613. name: string;
  71614. shader: string;
  71615. };
  71616. }
  71617. declare module BABYLON {
  71618. export class FireMaterial extends BABYLON.PushMaterial {
  71619. private _diffuseTexture;
  71620. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71621. private _distortionTexture;
  71622. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71623. private _opacityTexture;
  71624. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71625. diffuseColor: BABYLON.Color3;
  71626. speed: number;
  71627. private _scaledDiffuse;
  71628. private _renderId;
  71629. private _lastTime;
  71630. constructor(name: string, scene: BABYLON.Scene);
  71631. needAlphaBlending(): boolean;
  71632. needAlphaTesting(): boolean;
  71633. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71634. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71635. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71636. getAnimatables(): BABYLON.IAnimatable[];
  71637. getActiveTextures(): BABYLON.BaseTexture[];
  71638. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71639. getClassName(): string;
  71640. dispose(forceDisposeEffect?: boolean): void;
  71641. clone(name: string): FireMaterial;
  71642. serialize(): any;
  71643. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  71644. }
  71645. }
  71646. declare module BABYLON {
  71647. /** @hidden */
  71648. export var furPixelShader: {
  71649. name: string;
  71650. shader: string;
  71651. };
  71652. }
  71653. declare module BABYLON {
  71654. /** @hidden */
  71655. export var furVertexShader: {
  71656. name: string;
  71657. shader: string;
  71658. };
  71659. }
  71660. declare module BABYLON {
  71661. export class FurMaterial extends BABYLON.PushMaterial {
  71662. private _diffuseTexture;
  71663. diffuseTexture: BABYLON.BaseTexture;
  71664. private _heightTexture;
  71665. heightTexture: BABYLON.BaseTexture;
  71666. diffuseColor: BABYLON.Color3;
  71667. furLength: number;
  71668. furAngle: number;
  71669. furColor: BABYLON.Color3;
  71670. furOffset: number;
  71671. furSpacing: number;
  71672. furGravity: BABYLON.Vector3;
  71673. furSpeed: number;
  71674. furDensity: number;
  71675. furOcclusion: number;
  71676. furTexture: BABYLON.DynamicTexture;
  71677. private _disableLighting;
  71678. disableLighting: boolean;
  71679. private _maxSimultaneousLights;
  71680. maxSimultaneousLights: number;
  71681. highLevelFur: boolean;
  71682. _meshes: BABYLON.AbstractMesh[];
  71683. private _renderId;
  71684. private _furTime;
  71685. constructor(name: string, scene: BABYLON.Scene);
  71686. furTime: number;
  71687. needAlphaBlending(): boolean;
  71688. needAlphaTesting(): boolean;
  71689. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71690. updateFur(): void;
  71691. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71692. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71693. getAnimatables(): BABYLON.IAnimatable[];
  71694. getActiveTextures(): BABYLON.BaseTexture[];
  71695. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71696. dispose(forceDisposeEffect?: boolean): void;
  71697. clone(name: string): FurMaterial;
  71698. serialize(): any;
  71699. getClassName(): string;
  71700. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  71701. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  71702. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  71703. }
  71704. }
  71705. declare module BABYLON {
  71706. /** @hidden */
  71707. export var gradientPixelShader: {
  71708. name: string;
  71709. shader: string;
  71710. };
  71711. }
  71712. declare module BABYLON {
  71713. /** @hidden */
  71714. export var gradientVertexShader: {
  71715. name: string;
  71716. shader: string;
  71717. };
  71718. }
  71719. declare module BABYLON {
  71720. export class GradientMaterial extends BABYLON.PushMaterial {
  71721. private _maxSimultaneousLights;
  71722. maxSimultaneousLights: number;
  71723. topColor: BABYLON.Color3;
  71724. topColorAlpha: number;
  71725. bottomColor: BABYLON.Color3;
  71726. bottomColorAlpha: number;
  71727. offset: number;
  71728. scale: number;
  71729. smoothness: number;
  71730. private _disableLighting;
  71731. disableLighting: boolean;
  71732. private _renderId;
  71733. constructor(name: string, scene: BABYLON.Scene);
  71734. needAlphaBlending(): boolean;
  71735. needAlphaTesting(): boolean;
  71736. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71737. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71738. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71739. getAnimatables(): BABYLON.IAnimatable[];
  71740. dispose(forceDisposeEffect?: boolean): void;
  71741. clone(name: string): GradientMaterial;
  71742. serialize(): any;
  71743. getClassName(): string;
  71744. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  71745. }
  71746. }
  71747. declare module BABYLON {
  71748. /** @hidden */
  71749. export var gridPixelShader: {
  71750. name: string;
  71751. shader: string;
  71752. };
  71753. }
  71754. declare module BABYLON {
  71755. /** @hidden */
  71756. export var gridVertexShader: {
  71757. name: string;
  71758. shader: string;
  71759. };
  71760. }
  71761. declare module BABYLON {
  71762. /**
  71763. * The grid materials allows you to wrap any shape with a grid.
  71764. * Colors are customizable.
  71765. */
  71766. export class GridMaterial extends BABYLON.PushMaterial {
  71767. /**
  71768. * Main color of the grid (e.g. between lines)
  71769. */
  71770. mainColor: BABYLON.Color3;
  71771. /**
  71772. * Color of the grid lines.
  71773. */
  71774. lineColor: BABYLON.Color3;
  71775. /**
  71776. * The scale of the grid compared to unit.
  71777. */
  71778. gridRatio: number;
  71779. /**
  71780. * Allows setting an offset for the grid lines.
  71781. */
  71782. gridOffset: BABYLON.Vector3;
  71783. /**
  71784. * The frequency of thicker lines.
  71785. */
  71786. majorUnitFrequency: number;
  71787. /**
  71788. * The visibility of minor units in the grid.
  71789. */
  71790. minorUnitVisibility: number;
  71791. /**
  71792. * The grid opacity outside of the lines.
  71793. */
  71794. opacity: number;
  71795. /**
  71796. * Determine RBG output is premultiplied by alpha value.
  71797. */
  71798. preMultiplyAlpha: boolean;
  71799. private _opacityTexture;
  71800. opacityTexture: BABYLON.BaseTexture;
  71801. private _gridControl;
  71802. private _renderId;
  71803. /**
  71804. * constructor
  71805. * @param name The name given to the material in order to identify it afterwards.
  71806. * @param scene The scene the material is used in.
  71807. */
  71808. constructor(name: string, scene: BABYLON.Scene);
  71809. /**
  71810. * Returns wehter or not the grid requires alpha blending.
  71811. */
  71812. needAlphaBlending(): boolean;
  71813. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71814. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71815. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71816. /**
  71817. * Dispose the material and its associated resources.
  71818. * @param forceDisposeEffect will also dispose the used effect when true
  71819. */
  71820. dispose(forceDisposeEffect?: boolean): void;
  71821. clone(name: string): GridMaterial;
  71822. serialize(): any;
  71823. getClassName(): string;
  71824. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  71825. }
  71826. }
  71827. declare module BABYLON {
  71828. /** @hidden */
  71829. export var lavaPixelShader: {
  71830. name: string;
  71831. shader: string;
  71832. };
  71833. }
  71834. declare module BABYLON {
  71835. /** @hidden */
  71836. export var lavaVertexShader: {
  71837. name: string;
  71838. shader: string;
  71839. };
  71840. }
  71841. declare module BABYLON {
  71842. export class LavaMaterial extends BABYLON.PushMaterial {
  71843. private _diffuseTexture;
  71844. diffuseTexture: BABYLON.BaseTexture;
  71845. noiseTexture: BABYLON.BaseTexture;
  71846. fogColor: BABYLON.Color3;
  71847. speed: number;
  71848. movingSpeed: number;
  71849. lowFrequencySpeed: number;
  71850. fogDensity: number;
  71851. private _lastTime;
  71852. diffuseColor: BABYLON.Color3;
  71853. private _disableLighting;
  71854. disableLighting: boolean;
  71855. private _unlit;
  71856. unlit: boolean;
  71857. private _maxSimultaneousLights;
  71858. maxSimultaneousLights: number;
  71859. private _scaledDiffuse;
  71860. private _renderId;
  71861. constructor(name: string, scene: BABYLON.Scene);
  71862. needAlphaBlending(): boolean;
  71863. needAlphaTesting(): boolean;
  71864. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71865. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71866. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71867. getAnimatables(): BABYLON.IAnimatable[];
  71868. getActiveTextures(): BABYLON.BaseTexture[];
  71869. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71870. dispose(forceDisposeEffect?: boolean): void;
  71871. clone(name: string): LavaMaterial;
  71872. serialize(): any;
  71873. getClassName(): string;
  71874. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  71875. }
  71876. }
  71877. declare module BABYLON {
  71878. /** @hidden */
  71879. export var mixPixelShader: {
  71880. name: string;
  71881. shader: string;
  71882. };
  71883. }
  71884. declare module BABYLON {
  71885. /** @hidden */
  71886. export var mixVertexShader: {
  71887. name: string;
  71888. shader: string;
  71889. };
  71890. }
  71891. declare module BABYLON {
  71892. export class MixMaterial extends BABYLON.PushMaterial {
  71893. /**
  71894. * Mix textures
  71895. */
  71896. private _mixTexture1;
  71897. mixTexture1: BABYLON.BaseTexture;
  71898. private _mixTexture2;
  71899. mixTexture2: BABYLON.BaseTexture;
  71900. /**
  71901. * Diffuse textures
  71902. */
  71903. private _diffuseTexture1;
  71904. diffuseTexture1: BABYLON.Texture;
  71905. private _diffuseTexture2;
  71906. diffuseTexture2: BABYLON.Texture;
  71907. private _diffuseTexture3;
  71908. diffuseTexture3: BABYLON.Texture;
  71909. private _diffuseTexture4;
  71910. diffuseTexture4: BABYLON.Texture;
  71911. private _diffuseTexture5;
  71912. diffuseTexture5: BABYLON.Texture;
  71913. private _diffuseTexture6;
  71914. diffuseTexture6: BABYLON.Texture;
  71915. private _diffuseTexture7;
  71916. diffuseTexture7: BABYLON.Texture;
  71917. private _diffuseTexture8;
  71918. diffuseTexture8: BABYLON.Texture;
  71919. /**
  71920. * Uniforms
  71921. */
  71922. diffuseColor: BABYLON.Color3;
  71923. specularColor: BABYLON.Color3;
  71924. specularPower: number;
  71925. private _disableLighting;
  71926. disableLighting: boolean;
  71927. private _maxSimultaneousLights;
  71928. maxSimultaneousLights: number;
  71929. private _renderId;
  71930. constructor(name: string, scene: BABYLON.Scene);
  71931. needAlphaBlending(): boolean;
  71932. needAlphaTesting(): boolean;
  71933. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71934. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71935. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71936. getAnimatables(): BABYLON.IAnimatable[];
  71937. getActiveTextures(): BABYLON.BaseTexture[];
  71938. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71939. dispose(forceDisposeEffect?: boolean): void;
  71940. clone(name: string): MixMaterial;
  71941. serialize(): any;
  71942. getClassName(): string;
  71943. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  71944. }
  71945. }
  71946. declare module BABYLON {
  71947. /** @hidden */
  71948. export var normalPixelShader: {
  71949. name: string;
  71950. shader: string;
  71951. };
  71952. }
  71953. declare module BABYLON {
  71954. /** @hidden */
  71955. export var normalVertexShader: {
  71956. name: string;
  71957. shader: string;
  71958. };
  71959. }
  71960. declare module BABYLON {
  71961. export class NormalMaterial extends BABYLON.PushMaterial {
  71962. private _diffuseTexture;
  71963. diffuseTexture: BABYLON.BaseTexture;
  71964. diffuseColor: BABYLON.Color3;
  71965. private _disableLighting;
  71966. disableLighting: boolean;
  71967. private _maxSimultaneousLights;
  71968. maxSimultaneousLights: number;
  71969. private _renderId;
  71970. constructor(name: string, scene: BABYLON.Scene);
  71971. needAlphaBlending(): boolean;
  71972. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): 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. clone(name: string): NormalMaterial;
  71982. serialize(): any;
  71983. getClassName(): string;
  71984. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  71985. }
  71986. }
  71987. declare module BABYLON {
  71988. /** @hidden */
  71989. export var shadowOnlyPixelShader: {
  71990. name: string;
  71991. shader: string;
  71992. };
  71993. }
  71994. declare module BABYLON {
  71995. /** @hidden */
  71996. export var shadowOnlyVertexShader: {
  71997. name: string;
  71998. shader: string;
  71999. };
  72000. }
  72001. declare module BABYLON {
  72002. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  72003. private _renderId;
  72004. private _activeLight;
  72005. constructor(name: string, scene: BABYLON.Scene);
  72006. shadowColor: BABYLON.Color3;
  72007. needAlphaBlending(): boolean;
  72008. needAlphaTesting(): boolean;
  72009. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72010. activeLight: BABYLON.IShadowLight;
  72011. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72012. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72013. clone(name: string): ShadowOnlyMaterial;
  72014. serialize(): any;
  72015. getClassName(): string;
  72016. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  72017. }
  72018. }
  72019. declare module BABYLON {
  72020. /** @hidden */
  72021. export var simplePixelShader: {
  72022. name: string;
  72023. shader: string;
  72024. };
  72025. }
  72026. declare module BABYLON {
  72027. /** @hidden */
  72028. export var simpleVertexShader: {
  72029. name: string;
  72030. shader: string;
  72031. };
  72032. }
  72033. declare module BABYLON {
  72034. export class SimpleMaterial extends BABYLON.PushMaterial {
  72035. private _diffuseTexture;
  72036. diffuseTexture: BABYLON.BaseTexture;
  72037. diffuseColor: BABYLON.Color3;
  72038. private _disableLighting;
  72039. disableLighting: boolean;
  72040. private _maxSimultaneousLights;
  72041. maxSimultaneousLights: number;
  72042. private _renderId;
  72043. constructor(name: string, scene: BABYLON.Scene);
  72044. needAlphaBlending(): boolean;
  72045. needAlphaTesting(): boolean;
  72046. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72047. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72048. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72049. getAnimatables(): BABYLON.IAnimatable[];
  72050. getActiveTextures(): BABYLON.BaseTexture[];
  72051. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72052. dispose(forceDisposeEffect?: boolean): void;
  72053. clone(name: string): SimpleMaterial;
  72054. serialize(): any;
  72055. getClassName(): string;
  72056. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  72057. }
  72058. }
  72059. declare module BABYLON {
  72060. /** @hidden */
  72061. export var skyPixelShader: {
  72062. name: string;
  72063. shader: string;
  72064. };
  72065. }
  72066. declare module BABYLON {
  72067. /** @hidden */
  72068. export var skyVertexShader: {
  72069. name: string;
  72070. shader: string;
  72071. };
  72072. }
  72073. declare module BABYLON {
  72074. /**
  72075. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  72076. * @see https://doc.babylonjs.com/extensions/sky
  72077. */
  72078. export class SkyMaterial extends BABYLON.PushMaterial {
  72079. /**
  72080. * Defines the overall luminance of sky in interval ]0, 1[.
  72081. */
  72082. luminance: number;
  72083. /**
  72084. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  72085. */
  72086. turbidity: number;
  72087. /**
  72088. * Defines the sky appearance (light intensity).
  72089. */
  72090. rayleigh: number;
  72091. /**
  72092. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  72093. */
  72094. mieCoefficient: number;
  72095. /**
  72096. * Defines the amount of haze particles following the Mie scattering theory.
  72097. */
  72098. mieDirectionalG: number;
  72099. /**
  72100. * Defines the distance of the sun according to the active scene camera.
  72101. */
  72102. distance: number;
  72103. /**
  72104. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  72105. * "inclined".
  72106. */
  72107. inclination: number;
  72108. /**
  72109. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  72110. * an object direction and a reference direction.
  72111. */
  72112. azimuth: number;
  72113. /**
  72114. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  72115. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  72116. */
  72117. sunPosition: BABYLON.Vector3;
  72118. /**
  72119. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  72120. * .sunPosition property.
  72121. */
  72122. useSunPosition: boolean;
  72123. /**
  72124. * Defines an offset vector used to get a horizon offset.
  72125. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  72126. */
  72127. cameraOffset: BABYLON.Vector3;
  72128. private _cameraPosition;
  72129. private _renderId;
  72130. /**
  72131. * Instantiates a new sky material.
  72132. * This material allows to create dynamic and texture free
  72133. * effects for skyboxes by taking care of the atmosphere state.
  72134. * @see https://doc.babylonjs.com/extensions/sky
  72135. * @param name Define the name of the material in the scene
  72136. * @param scene Define the scene the material belong to
  72137. */
  72138. constructor(name: string, scene: BABYLON.Scene);
  72139. /**
  72140. * Specifies if the material will require alpha blending
  72141. * @returns a boolean specifying if alpha blending is needed
  72142. */
  72143. needAlphaBlending(): boolean;
  72144. /**
  72145. * Specifies if this material should be rendered in alpha test mode
  72146. * @returns false as the sky material doesn't need alpha testing.
  72147. */
  72148. needAlphaTesting(): boolean;
  72149. /**
  72150. * Get the texture used for alpha test purpose.
  72151. * @returns null as the sky material has no texture.
  72152. */
  72153. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72154. /**
  72155. * Get if the submesh is ready to be used and all its information available.
  72156. * Child classes can use it to update shaders
  72157. * @param mesh defines the mesh to check
  72158. * @param subMesh defines which submesh to check
  72159. * @param useInstances specifies that instances should be used
  72160. * @returns a boolean indicating that the submesh is ready or not
  72161. */
  72162. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72163. /**
  72164. * Binds the submesh to this material by preparing the effect and shader to draw
  72165. * @param world defines the world transformation matrix
  72166. * @param mesh defines the mesh containing the submesh
  72167. * @param subMesh defines the submesh to bind the material to
  72168. */
  72169. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72170. /**
  72171. * Get the list of animatables in the material.
  72172. * @returns the list of animatables object used in the material
  72173. */
  72174. getAnimatables(): BABYLON.IAnimatable[];
  72175. /**
  72176. * Disposes the material
  72177. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  72178. */
  72179. dispose(forceDisposeEffect?: boolean): void;
  72180. /**
  72181. * Makes a duplicate of the material, and gives it a new name
  72182. * @param name defines the new name for the duplicated material
  72183. * @returns the cloned material
  72184. */
  72185. clone(name: string): SkyMaterial;
  72186. /**
  72187. * Serializes this material in a JSON representation
  72188. * @returns the serialized material object
  72189. */
  72190. serialize(): any;
  72191. /**
  72192. * Gets the current class name of the material e.g. "SkyMaterial"
  72193. * Mainly use in serialization.
  72194. * @returns the class name
  72195. */
  72196. getClassName(): string;
  72197. /**
  72198. * Creates a sky material from parsed material data
  72199. * @param source defines the JSON representation of the material
  72200. * @param scene defines the hosting scene
  72201. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72202. * @returns a new sky material
  72203. */
  72204. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  72205. }
  72206. }
  72207. declare module BABYLON {
  72208. /** @hidden */
  72209. export var terrainPixelShader: {
  72210. name: string;
  72211. shader: string;
  72212. };
  72213. }
  72214. declare module BABYLON {
  72215. /** @hidden */
  72216. export var terrainVertexShader: {
  72217. name: string;
  72218. shader: string;
  72219. };
  72220. }
  72221. declare module BABYLON {
  72222. export class TerrainMaterial extends BABYLON.PushMaterial {
  72223. private _mixTexture;
  72224. mixTexture: BABYLON.BaseTexture;
  72225. private _diffuseTexture1;
  72226. diffuseTexture1: BABYLON.Texture;
  72227. private _diffuseTexture2;
  72228. diffuseTexture2: BABYLON.Texture;
  72229. private _diffuseTexture3;
  72230. diffuseTexture3: BABYLON.Texture;
  72231. private _bumpTexture1;
  72232. bumpTexture1: BABYLON.Texture;
  72233. private _bumpTexture2;
  72234. bumpTexture2: BABYLON.Texture;
  72235. private _bumpTexture3;
  72236. bumpTexture3: BABYLON.Texture;
  72237. diffuseColor: BABYLON.Color3;
  72238. specularColor: BABYLON.Color3;
  72239. specularPower: number;
  72240. private _disableLighting;
  72241. disableLighting: boolean;
  72242. private _maxSimultaneousLights;
  72243. maxSimultaneousLights: number;
  72244. private _renderId;
  72245. constructor(name: string, scene: BABYLON.Scene);
  72246. needAlphaBlending(): boolean;
  72247. needAlphaTesting(): boolean;
  72248. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72249. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72250. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72251. getAnimatables(): BABYLON.IAnimatable[];
  72252. getActiveTextures(): BABYLON.BaseTexture[];
  72253. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72254. dispose(forceDisposeEffect?: boolean): void;
  72255. clone(name: string): TerrainMaterial;
  72256. serialize(): any;
  72257. getClassName(): string;
  72258. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  72259. }
  72260. }
  72261. declare module BABYLON {
  72262. /** @hidden */
  72263. export var triplanarPixelShader: {
  72264. name: string;
  72265. shader: string;
  72266. };
  72267. }
  72268. declare module BABYLON {
  72269. /** @hidden */
  72270. export var triplanarVertexShader: {
  72271. name: string;
  72272. shader: string;
  72273. };
  72274. }
  72275. declare module BABYLON {
  72276. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  72277. mixTexture: BABYLON.BaseTexture;
  72278. private _diffuseTextureX;
  72279. diffuseTextureX: BABYLON.BaseTexture;
  72280. private _diffuseTextureY;
  72281. diffuseTextureY: BABYLON.BaseTexture;
  72282. private _diffuseTextureZ;
  72283. diffuseTextureZ: BABYLON.BaseTexture;
  72284. private _normalTextureX;
  72285. normalTextureX: BABYLON.BaseTexture;
  72286. private _normalTextureY;
  72287. normalTextureY: BABYLON.BaseTexture;
  72288. private _normalTextureZ;
  72289. normalTextureZ: BABYLON.BaseTexture;
  72290. tileSize: number;
  72291. diffuseColor: BABYLON.Color3;
  72292. specularColor: BABYLON.Color3;
  72293. specularPower: number;
  72294. private _disableLighting;
  72295. disableLighting: boolean;
  72296. private _maxSimultaneousLights;
  72297. maxSimultaneousLights: number;
  72298. private _renderId;
  72299. constructor(name: string, scene: BABYLON.Scene);
  72300. needAlphaBlending(): boolean;
  72301. needAlphaTesting(): boolean;
  72302. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72303. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72304. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72305. getAnimatables(): BABYLON.IAnimatable[];
  72306. getActiveTextures(): BABYLON.BaseTexture[];
  72307. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72308. dispose(forceDisposeEffect?: boolean): void;
  72309. clone(name: string): TriPlanarMaterial;
  72310. serialize(): any;
  72311. getClassName(): string;
  72312. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  72313. }
  72314. }
  72315. declare module BABYLON {
  72316. /** @hidden */
  72317. export var waterPixelShader: {
  72318. name: string;
  72319. shader: string;
  72320. };
  72321. }
  72322. declare module BABYLON {
  72323. /** @hidden */
  72324. export var waterVertexShader: {
  72325. name: string;
  72326. shader: string;
  72327. };
  72328. }
  72329. declare module BABYLON {
  72330. export class WaterMaterial extends BABYLON.PushMaterial {
  72331. renderTargetSize: BABYLON.Vector2;
  72332. private _bumpTexture;
  72333. bumpTexture: BABYLON.BaseTexture;
  72334. diffuseColor: BABYLON.Color3;
  72335. specularColor: BABYLON.Color3;
  72336. specularPower: number;
  72337. private _disableLighting;
  72338. disableLighting: boolean;
  72339. private _maxSimultaneousLights;
  72340. maxSimultaneousLights: number;
  72341. /**
  72342. * @param {number}: Represents the wind force
  72343. */
  72344. windForce: number;
  72345. /**
  72346. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  72347. */
  72348. windDirection: BABYLON.Vector2;
  72349. /**
  72350. * @param {number}: Wave height, represents the height of the waves
  72351. */
  72352. waveHeight: number;
  72353. /**
  72354. * @param {number}: Bump height, represents the bump height related to the bump map
  72355. */
  72356. bumpHeight: number;
  72357. /**
  72358. * @param {boolean}: Add a smaller moving bump to less steady waves.
  72359. */
  72360. private _bumpSuperimpose;
  72361. bumpSuperimpose: boolean;
  72362. /**
  72363. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  72364. */
  72365. private _fresnelSeparate;
  72366. fresnelSeparate: boolean;
  72367. /**
  72368. * @param {boolean}: bump Waves modify the reflection.
  72369. */
  72370. private _bumpAffectsReflection;
  72371. bumpAffectsReflection: boolean;
  72372. /**
  72373. * @param {number}: The water color blended with the refraction (near)
  72374. */
  72375. waterColor: BABYLON.Color3;
  72376. /**
  72377. * @param {number}: The blend factor related to the water color
  72378. */
  72379. colorBlendFactor: number;
  72380. /**
  72381. * @param {number}: The water color blended with the reflection (far)
  72382. */
  72383. waterColor2: BABYLON.Color3;
  72384. /**
  72385. * @param {number}: The blend factor related to the water color (reflection, far)
  72386. */
  72387. colorBlendFactor2: number;
  72388. /**
  72389. * @param {number}: Represents the maximum length of a wave
  72390. */
  72391. waveLength: number;
  72392. /**
  72393. * @param {number}: Defines the waves speed
  72394. */
  72395. waveSpeed: number;
  72396. /**
  72397. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72398. * will avoid calculating useless pixels in the pixel shader of the water material.
  72399. */
  72400. disableClipPlane: boolean;
  72401. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72402. private _mesh;
  72403. private _refractionRTT;
  72404. private _reflectionRTT;
  72405. private _reflectionTransform;
  72406. private _lastTime;
  72407. private _lastDeltaTime;
  72408. private _renderId;
  72409. private _useLogarithmicDepth;
  72410. private _waitingRenderList;
  72411. private _imageProcessingConfiguration;
  72412. private _imageProcessingObserver;
  72413. /**
  72414. * Gets a boolean indicating that current material needs to register RTT
  72415. */
  72416. readonly hasRenderTargetTextures: boolean;
  72417. /**
  72418. * Constructor
  72419. */
  72420. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72421. useLogarithmicDepth: boolean;
  72422. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72423. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72424. addToRenderList(node: any): void;
  72425. enableRenderTargets(enable: boolean): void;
  72426. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  72427. readonly renderTargetsEnabled: boolean;
  72428. needAlphaBlending(): boolean;
  72429. needAlphaTesting(): boolean;
  72430. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72431. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72432. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72433. private _createRenderTargets;
  72434. getAnimatables(): BABYLON.IAnimatable[];
  72435. getActiveTextures(): BABYLON.BaseTexture[];
  72436. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72437. dispose(forceDisposeEffect?: boolean): void;
  72438. clone(name: string): WaterMaterial;
  72439. serialize(): any;
  72440. getClassName(): string;
  72441. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  72442. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  72443. }
  72444. }
  72445. declare module BABYLON {
  72446. /** @hidden */
  72447. export var asciiartPixelShader: {
  72448. name: string;
  72449. shader: string;
  72450. };
  72451. }
  72452. declare module BABYLON {
  72453. /**
  72454. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  72455. *
  72456. * It basically takes care rendering the font front the given font size to a texture.
  72457. * This is used later on in the postprocess.
  72458. */
  72459. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  72460. private _font;
  72461. private _text;
  72462. private _charSize;
  72463. /**
  72464. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72465. */
  72466. readonly charSize: number;
  72467. /**
  72468. * Create a new instance of the Ascii Art FontTexture class
  72469. * @param name the name of the texture
  72470. * @param font the font to use, use the W3C CSS notation
  72471. * @param text the caracter set to use in the rendering.
  72472. * @param scene the scene that owns the texture
  72473. */
  72474. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72475. /**
  72476. * Gets the max char width of a font.
  72477. * @param font the font to use, use the W3C CSS notation
  72478. * @return the max char width
  72479. */
  72480. private getFontWidth;
  72481. /**
  72482. * Gets the max char height of a font.
  72483. * @param font the font to use, use the W3C CSS notation
  72484. * @return the max char height
  72485. */
  72486. private getFontHeight;
  72487. /**
  72488. * Clones the current AsciiArtTexture.
  72489. * @return the clone of the texture.
  72490. */
  72491. clone(): AsciiArtFontTexture;
  72492. /**
  72493. * Parses a json object representing the texture and returns an instance of it.
  72494. * @param source the source JSON representation
  72495. * @param scene the scene to create the texture for
  72496. * @return the parsed texture
  72497. */
  72498. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  72499. }
  72500. /**
  72501. * Option available in the Ascii Art Post Process.
  72502. */
  72503. export interface IAsciiArtPostProcessOptions {
  72504. /**
  72505. * The font to use following the w3c font definition.
  72506. */
  72507. font?: string;
  72508. /**
  72509. * The character set to use in the postprocess.
  72510. */
  72511. characterSet?: string;
  72512. /**
  72513. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72514. * This number is defined between 0 and 1;
  72515. */
  72516. mixToTile?: number;
  72517. /**
  72518. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72519. * This number is defined between 0 and 1;
  72520. */
  72521. mixToNormal?: number;
  72522. }
  72523. /**
  72524. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  72525. *
  72526. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72527. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  72528. */
  72529. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  72530. /**
  72531. * The font texture used to render the char in the post process.
  72532. */
  72533. private _asciiArtFontTexture;
  72534. /**
  72535. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72536. * This number is defined between 0 and 1;
  72537. */
  72538. mixToTile: number;
  72539. /**
  72540. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72541. * This number is defined between 0 and 1;
  72542. */
  72543. mixToNormal: number;
  72544. /**
  72545. * Instantiates a new Ascii Art Post Process.
  72546. * @param name the name to give to the postprocess
  72547. * @camera the camera to apply the post process to.
  72548. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  72549. */
  72550. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  72551. }
  72552. }
  72553. declare module BABYLON {
  72554. /** @hidden */
  72555. export var digitalrainPixelShader: {
  72556. name: string;
  72557. shader: string;
  72558. };
  72559. }
  72560. declare module BABYLON {
  72561. /**
  72562. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  72563. *
  72564. * It basically takes care rendering the font front the given font size to a texture.
  72565. * This is used later on in the postprocess.
  72566. */
  72567. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  72568. private _font;
  72569. private _text;
  72570. private _charSize;
  72571. /**
  72572. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72573. */
  72574. readonly charSize: number;
  72575. /**
  72576. * Create a new instance of the Digital Rain FontTexture class
  72577. * @param name the name of the texture
  72578. * @param font the font to use, use the W3C CSS notation
  72579. * @param text the caracter set to use in the rendering.
  72580. * @param scene the scene that owns the texture
  72581. */
  72582. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72583. /**
  72584. * Gets the max char width of a font.
  72585. * @param font the font to use, use the W3C CSS notation
  72586. * @return the max char width
  72587. */
  72588. private getFontWidth;
  72589. /**
  72590. * Gets the max char height of a font.
  72591. * @param font the font to use, use the W3C CSS notation
  72592. * @return the max char height
  72593. */
  72594. private getFontHeight;
  72595. /**
  72596. * Clones the current DigitalRainFontTexture.
  72597. * @return the clone of the texture.
  72598. */
  72599. clone(): DigitalRainFontTexture;
  72600. /**
  72601. * Parses a json object representing the texture and returns an instance of it.
  72602. * @param source the source JSON representation
  72603. * @param scene the scene to create the texture for
  72604. * @return the parsed texture
  72605. */
  72606. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  72607. }
  72608. /**
  72609. * Option available in the Digital Rain Post Process.
  72610. */
  72611. export interface IDigitalRainPostProcessOptions {
  72612. /**
  72613. * The font to use following the w3c font definition.
  72614. */
  72615. font?: string;
  72616. /**
  72617. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72618. * This number is defined between 0 and 1;
  72619. */
  72620. mixToTile?: number;
  72621. /**
  72622. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72623. * This number is defined between 0 and 1;
  72624. */
  72625. mixToNormal?: number;
  72626. }
  72627. /**
  72628. * DigitalRainPostProcess helps rendering everithing in digital rain.
  72629. *
  72630. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72631. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  72632. */
  72633. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  72634. /**
  72635. * The font texture used to render the char in the post process.
  72636. */
  72637. private _digitalRainFontTexture;
  72638. /**
  72639. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72640. * This number is defined between 0 and 1;
  72641. */
  72642. mixToTile: number;
  72643. /**
  72644. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72645. * This number is defined between 0 and 1;
  72646. */
  72647. mixToNormal: number;
  72648. /**
  72649. * Instantiates a new Digital Rain Post Process.
  72650. * @param name the name to give to the postprocess
  72651. * @camera the camera to apply the post process to.
  72652. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  72653. */
  72654. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  72655. }
  72656. }
  72657. declare module BABYLON {
  72658. /** @hidden */
  72659. export var oceanPostProcessPixelShader: {
  72660. name: string;
  72661. shader: string;
  72662. };
  72663. }
  72664. declare module BABYLON {
  72665. /**
  72666. * Option available in the Ocean Post Process.
  72667. */
  72668. export interface IOceanPostProcessOptions {
  72669. /**
  72670. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72671. */
  72672. reflectionSize?: number | {
  72673. width: number;
  72674. height: number;
  72675. } | {
  72676. ratio: number;
  72677. };
  72678. /**
  72679. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72680. */
  72681. refractionSize?: number | {
  72682. width: number;
  72683. height: number;
  72684. } | {
  72685. ratio: number;
  72686. };
  72687. }
  72688. /**
  72689. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  72690. *
  72691. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72692. * Example usage:
  72693. * var pp = new OceanPostProcess("myOcean", camera);
  72694. * pp.reflectionEnabled = true;
  72695. * pp.refractionEnabled = true;
  72696. */
  72697. export class OceanPostProcess extends BABYLON.PostProcess {
  72698. /**
  72699. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  72700. */
  72701. /**
  72702. * Sets weither or not the real-time reflection is enabled on the ocean.
  72703. * Is set to true, the reflection mirror texture will be used as reflection texture.
  72704. */
  72705. reflectionEnabled: boolean;
  72706. /**
  72707. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  72708. */
  72709. /**
  72710. * Sets weither or not the real-time refraction is enabled on the ocean.
  72711. * Is set to true, the refraction render target texture will be used as refraction texture.
  72712. */
  72713. refractionEnabled: boolean;
  72714. /**
  72715. * Gets wether or not the post-processes is supported by the running hardware.
  72716. * This requires draw buffer supports.
  72717. */
  72718. readonly isSupported: boolean;
  72719. /**
  72720. * This is the reflection mirror texture used to display reflections on the ocean.
  72721. * By default, render list is empty.
  72722. */
  72723. reflectionTexture: BABYLON.MirrorTexture;
  72724. /**
  72725. * This is the refraction render target texture used to display refraction on the ocean.
  72726. * By default, render list is empty.
  72727. */
  72728. refractionTexture: BABYLON.RenderTargetTexture;
  72729. private _time;
  72730. private _cameraRotation;
  72731. private _cameraViewMatrix;
  72732. private _reflectionEnabled;
  72733. private _refractionEnabled;
  72734. private _geometryRenderer;
  72735. /**
  72736. * Instantiates a new Ocean Post Process.
  72737. * @param name the name to give to the postprocess.
  72738. * @camera the camera to apply the post process to.
  72739. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  72740. */
  72741. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  72742. /**
  72743. * Returns the appropriate defines according to the current configuration.
  72744. */
  72745. private _getDefines;
  72746. /**
  72747. * Computes the current camera rotation as the shader requires a camera rotation.
  72748. */
  72749. private _computeCameraRotation;
  72750. }
  72751. }
  72752. declare module BABYLON {
  72753. /** @hidden */
  72754. export var brickProceduralTexturePixelShader: {
  72755. name: string;
  72756. shader: string;
  72757. };
  72758. }
  72759. declare module BABYLON {
  72760. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  72761. private _numberOfBricksHeight;
  72762. private _numberOfBricksWidth;
  72763. private _jointColor;
  72764. private _brickColor;
  72765. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72766. updateShaderUniforms(): void;
  72767. numberOfBricksHeight: number;
  72768. numberOfBricksWidth: number;
  72769. jointColor: BABYLON.Color3;
  72770. brickColor: BABYLON.Color3;
  72771. /**
  72772. * Serializes this brick procedural texture
  72773. * @returns a serialized brick procedural texture object
  72774. */
  72775. serialize(): any;
  72776. /**
  72777. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  72778. * @param parsedTexture defines parsed texture data
  72779. * @param scene defines the current scene
  72780. * @param rootUrl defines the root URL containing brick procedural texture information
  72781. * @returns a parsed Brick Procedural BABYLON.Texture
  72782. */
  72783. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  72784. }
  72785. }
  72786. declare module BABYLON {
  72787. /** @hidden */
  72788. export var cloudProceduralTexturePixelShader: {
  72789. name: string;
  72790. shader: string;
  72791. };
  72792. }
  72793. declare module BABYLON {
  72794. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  72795. private _skyColor;
  72796. private _cloudColor;
  72797. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72798. updateShaderUniforms(): void;
  72799. skyColor: BABYLON.Color4;
  72800. cloudColor: BABYLON.Color4;
  72801. /**
  72802. * Serializes this cloud procedural texture
  72803. * @returns a serialized cloud procedural texture object
  72804. */
  72805. serialize(): any;
  72806. /**
  72807. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  72808. * @param parsedTexture defines parsed texture data
  72809. * @param scene defines the current scene
  72810. * @param rootUrl defines the root URL containing cloud procedural texture information
  72811. * @returns a parsed Cloud Procedural BABYLON.Texture
  72812. */
  72813. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  72814. }
  72815. }
  72816. declare module BABYLON {
  72817. /** @hidden */
  72818. export var fireProceduralTexturePixelShader: {
  72819. name: string;
  72820. shader: string;
  72821. };
  72822. }
  72823. declare module BABYLON {
  72824. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  72825. private _time;
  72826. private _speed;
  72827. private _autoGenerateTime;
  72828. private _fireColors;
  72829. private _alphaThreshold;
  72830. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72831. updateShaderUniforms(): void;
  72832. render(useCameraPostProcess?: boolean): void;
  72833. static readonly PurpleFireColors: BABYLON.Color3[];
  72834. static readonly GreenFireColors: BABYLON.Color3[];
  72835. static readonly RedFireColors: BABYLON.Color3[];
  72836. static readonly BlueFireColors: BABYLON.Color3[];
  72837. autoGenerateTime: boolean;
  72838. fireColors: BABYLON.Color3[];
  72839. time: number;
  72840. speed: BABYLON.Vector2;
  72841. alphaThreshold: number;
  72842. /**
  72843. * Serializes this fire procedural texture
  72844. * @returns a serialized fire procedural texture object
  72845. */
  72846. serialize(): any;
  72847. /**
  72848. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  72849. * @param parsedTexture defines parsed texture data
  72850. * @param scene defines the current scene
  72851. * @param rootUrl defines the root URL containing fire procedural texture information
  72852. * @returns a parsed Fire Procedural BABYLON.Texture
  72853. */
  72854. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  72855. }
  72856. }
  72857. declare module BABYLON {
  72858. /** @hidden */
  72859. export var grassProceduralTexturePixelShader: {
  72860. name: string;
  72861. shader: string;
  72862. };
  72863. }
  72864. declare module BABYLON {
  72865. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  72866. private _grassColors;
  72867. private _groundColor;
  72868. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72869. updateShaderUniforms(): void;
  72870. grassColors: BABYLON.Color3[];
  72871. groundColor: BABYLON.Color3;
  72872. /**
  72873. * Serializes this grass procedural texture
  72874. * @returns a serialized grass procedural texture object
  72875. */
  72876. serialize(): any;
  72877. /**
  72878. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  72879. * @param parsedTexture defines parsed texture data
  72880. * @param scene defines the current scene
  72881. * @param rootUrl defines the root URL containing grass procedural texture information
  72882. * @returns a parsed Grass Procedural BABYLON.Texture
  72883. */
  72884. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  72885. }
  72886. }
  72887. declare module BABYLON {
  72888. /** @hidden */
  72889. export var marbleProceduralTexturePixelShader: {
  72890. name: string;
  72891. shader: string;
  72892. };
  72893. }
  72894. declare module BABYLON {
  72895. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  72896. private _numberOfTilesHeight;
  72897. private _numberOfTilesWidth;
  72898. private _amplitude;
  72899. private _jointColor;
  72900. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72901. updateShaderUniforms(): void;
  72902. numberOfTilesHeight: number;
  72903. amplitude: number;
  72904. numberOfTilesWidth: number;
  72905. jointColor: BABYLON.Color3;
  72906. /**
  72907. * Serializes this marble procedural texture
  72908. * @returns a serialized marble procedural texture object
  72909. */
  72910. serialize(): any;
  72911. /**
  72912. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  72913. * @param parsedTexture defines parsed texture data
  72914. * @param scene defines the current scene
  72915. * @param rootUrl defines the root URL containing marble procedural texture information
  72916. * @returns a parsed Marble Procedural BABYLON.Texture
  72917. */
  72918. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  72919. }
  72920. }
  72921. declare module BABYLON {
  72922. /** @hidden */
  72923. export var normalMapProceduralTexturePixelShader: {
  72924. name: string;
  72925. shader: string;
  72926. };
  72927. }
  72928. declare module BABYLON {
  72929. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  72930. private _baseTexture;
  72931. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72932. updateShaderUniforms(): void;
  72933. render(useCameraPostProcess?: boolean): void;
  72934. resize(size: any, generateMipMaps: any): void;
  72935. baseTexture: BABYLON.Texture;
  72936. /**
  72937. * Serializes this normal map procedural texture
  72938. * @returns a serialized normal map procedural texture object
  72939. */
  72940. serialize(): any;
  72941. /**
  72942. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  72943. * @param parsedTexture defines parsed texture data
  72944. * @param scene defines the current scene
  72945. * @param rootUrl defines the root URL containing normal map procedural texture information
  72946. * @returns a parsed Normal Map Procedural BABYLON.Texture
  72947. */
  72948. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  72949. }
  72950. }
  72951. declare module BABYLON {
  72952. /** @hidden */
  72953. export var perlinNoiseProceduralTexturePixelShader: {
  72954. name: string;
  72955. shader: string;
  72956. };
  72957. }
  72958. declare module BABYLON {
  72959. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  72960. time: number;
  72961. timeScale: number;
  72962. translationSpeed: number;
  72963. private _currentTranslation;
  72964. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72965. updateShaderUniforms(): void;
  72966. render(useCameraPostProcess?: boolean): void;
  72967. resize(size: any, generateMipMaps: any): void;
  72968. /**
  72969. * Serializes this perlin noise procedural texture
  72970. * @returns a serialized perlin noise procedural texture object
  72971. */
  72972. serialize(): any;
  72973. /**
  72974. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  72975. * @param parsedTexture defines parsed texture data
  72976. * @param scene defines the current scene
  72977. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  72978. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  72979. */
  72980. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  72981. }
  72982. }
  72983. declare module BABYLON {
  72984. /** @hidden */
  72985. export var roadProceduralTexturePixelShader: {
  72986. name: string;
  72987. shader: string;
  72988. };
  72989. }
  72990. declare module BABYLON {
  72991. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  72992. private _roadColor;
  72993. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72994. updateShaderUniforms(): void;
  72995. roadColor: BABYLON.Color3;
  72996. /**
  72997. * Serializes this road procedural texture
  72998. * @returns a serialized road procedural texture object
  72999. */
  73000. serialize(): any;
  73001. /**
  73002. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  73003. * @param parsedTexture defines parsed texture data
  73004. * @param scene defines the current scene
  73005. * @param rootUrl defines the root URL containing road procedural texture information
  73006. * @returns a parsed Road Procedural BABYLON.Texture
  73007. */
  73008. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  73009. }
  73010. }
  73011. declare module BABYLON {
  73012. /** @hidden */
  73013. export var starfieldProceduralTexturePixelShader: {
  73014. name: string;
  73015. shader: string;
  73016. };
  73017. }
  73018. declare module BABYLON {
  73019. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  73020. private _time;
  73021. private _alpha;
  73022. private _beta;
  73023. private _zoom;
  73024. private _formuparam;
  73025. private _stepsize;
  73026. private _tile;
  73027. private _brightness;
  73028. private _darkmatter;
  73029. private _distfading;
  73030. private _saturation;
  73031. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73032. updateShaderUniforms(): void;
  73033. time: number;
  73034. alpha: number;
  73035. beta: number;
  73036. formuparam: number;
  73037. stepsize: number;
  73038. zoom: number;
  73039. tile: number;
  73040. brightness: number;
  73041. darkmatter: number;
  73042. distfading: number;
  73043. saturation: number;
  73044. /**
  73045. * Serializes this starfield procedural texture
  73046. * @returns a serialized starfield procedural texture object
  73047. */
  73048. serialize(): any;
  73049. /**
  73050. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  73051. * @param parsedTexture defines parsed texture data
  73052. * @param scene defines the current scene
  73053. * @param rootUrl defines the root URL containing startfield procedural texture information
  73054. * @returns a parsed Starfield Procedural BABYLON.Texture
  73055. */
  73056. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  73057. }
  73058. }
  73059. declare module BABYLON {
  73060. /** @hidden */
  73061. export var woodProceduralTexturePixelShader: {
  73062. name: string;
  73063. shader: string;
  73064. };
  73065. }
  73066. declare module BABYLON {
  73067. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  73068. private _ampScale;
  73069. private _woodColor;
  73070. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73071. updateShaderUniforms(): void;
  73072. ampScale: number;
  73073. woodColor: BABYLON.Color3;
  73074. /**
  73075. * Serializes this wood procedural texture
  73076. * @returns a serialized wood procedural texture object
  73077. */
  73078. serialize(): any;
  73079. /**
  73080. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  73081. * @param parsedTexture defines parsed texture data
  73082. * @param scene defines the current scene
  73083. * @param rootUrl defines the root URL containing wood procedural texture information
  73084. * @returns a parsed Wood Procedural BABYLON.Texture
  73085. */
  73086. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  73087. }
  73088. }